X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fplugins.js;h=9a55980a5691035bdff152811888aa8bd541a112;hb=1056598c95187351dc58f4991d331e2258d038b5;hp=c9bba7b512a89d2e177ecf47bacde30aff4ffcd5;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/core/plugins.js b/_source/core/plugins.js index c9bba7b..9a55980 100644 --- a/_source/core/plugins.js +++ b/_source/core/plugins.js @@ -76,10 +76,28 @@ CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function }; }); +/** + * Loads a specific language file, or auto detect it. A callback is + * then called when the file gets loaded. + * @param {String} pluginName The name of the plugin to which the provided translation + * should be attached. + * @param {String} languageCode The code of the language translation provided. + * @param {Object} languageEntries An object that contains pairs of label and + * the respective translation. + * @example + * CKEDITOR.plugins.setLang( 'myPlugin', 'en', { + * title : 'My plugin', + * selectOption : 'Please select an option' + * } ); + */ CKEDITOR.plugins.setLang = function( pluginName, languageCode, languageEntries ) { var plugin = this.get( pluginName ), - pluginLang = plugin.lang || ( plugin.lang = {} ); + pluginLangEntries = plugin.langEntries || ( plugin.langEntries = {} ), + pluginLang = plugin.lang || ( plugin.lang = [] ); + + if ( CKEDITOR.tools.indexOf( pluginLang, languageCode ) == -1 ) + pluginLang.push( languageCode ); - pluginLang[ languageCode ] = languageEntries; + pluginLangEntries[ languageCode ] = languageEntries; };