Translation mechanism fails for language codes with dashes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Wikia Search UI |
New
|
Undecided
|
Unassigned |
Bug Description
When I select language "de-formal" ("Sie-Form"), the translation table can not be loaded because of the following JavaScript error:
Error: invalid assignment left-hand side
Source File: http://
Line: 1, Column: 14
Source Code:
i18n.de-
On the left-hand side of the assignment, the language code ("de-formal") needs to be quoted in order to be used as a lookup key.
In the trunk code, http://
the assignment above is generated on line 23.
There is a set of braces where I don't expect one, but those are apparently PHP syntax.
My suggestion for line 23 is this:
$text = "i18n.['{$lang}']= {$json};";
In the long run, I would prefer it if the MediaWiki extension did not have to know the variable name on the browser side.
Even better would be if the browser did not have to trust the MediaWiki side to issue benign expressions.
MediaWiki should just serve a JSON object. Yeah, I know, it's hard to do because of XSS safeguards.