X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fplugins.js;h=0bbe53f6b7a6b85e1a41dfcbc9059794d867e387;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=70d6cce1fcf3cb39760a968ac4b3ccfd15940feb;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d;p=ckeditor.git diff --git a/_source/core/plugins.js b/_source/core/plugins.js index 70d6cce..0bbe53f 100644 --- a/_source/core/plugins.js +++ b/_source/core/plugins.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -76,8 +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 ); - plugin.lang[ languageCode ] = languageEntries; + var plugin = this.get( pluginName ), + pluginLangEntries = plugin.langEntries || ( plugin.langEntries = {} ), + pluginLang = plugin.lang || ( plugin.lang = [] ); + + if ( CKEDITOR.tools.indexOf( pluginLang, languageCode ) == -1 ) + pluginLang.push( languageCode ); + + pluginLangEntries[ languageCode ] = languageEntries; };