Index: branches/jsgrammar/includes/resourceloader/ResourceLoaderLanguageModule.php |
— | — | @@ -36,19 +36,23 @@ |
37 | 37 | } |
38 | 38 | /** |
39 | 39 | * @param $context ResourceLoaderContext |
40 | | - * @return string |
| 40 | + * @return string Javascript code |
41 | 41 | */ |
42 | 42 | public function getScript( ResourceLoaderContext $context ) { |
43 | 43 | global $wgContLang; |
| 44 | + $code = Xml::encodeJsVar( $wgContLang->getCode() ); |
| 45 | + $forms = Xml::encodeJsVar( $this->getSiteLangGrammarForms() ); |
| 46 | + |
44 | 47 | $js = |
45 | | - 'var langCode = ' . FormatJson::encode( $wgContLang->getCode() ) . ', ' . |
46 | | - "langData = mw.language.data;\n" . |
47 | | - "if ( langData[langCode] === undefined ) {\n" . |
48 | | - " langData[langCode] = new mw.Map();\n" . |
49 | | - "}\n" . |
50 | | - Xml::encodeJsCall( 'langData[langCode].set', |
51 | | - array( 'grammarForms', $this->getSiteLangGrammarForms( ) ) |
52 | | - ); |
| 48 | +<<<JAVASCRIPT |
| 49 | +var langCode = $code, |
| 50 | +langData = mw.language.data; |
| 51 | +if ( langData[langCode] === undefined ) { |
| 52 | + langData[langCode] = new mw.Map(); |
| 53 | +} |
| 54 | +langData[langCode].set( "grammarForms", $forms ); |
| 55 | +JAVASCRIPT; |
| 56 | + |
53 | 57 | return $js; |
54 | 58 | } |
55 | 59 | /** |