| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 var loadedLangs = {}; 9 10 CKEDITOR.lang = 11 { 12 /** 13 * The list of languages available in the editor core. 14 * @type Object 15 * @example 16 * alert( CKEDITOR.lang.en ); // "true" 17 */ 18 languages : 19 { 20 'af' : 1, 21 'ar' : 1, 22 'bg' : 1, 23 'bn' : 1, 24 'bs' : 1, 25 'ca' : 1, 26 'cs' : 1, 27 'cy' : 1, 28 'da' : 1, 29 'de' : 1, 30 'el' : 1, 31 'en-au' : 1, 32 'en-ca' : 1, 33 'en-gb' : 1, 34 'en' : 1, 35 'eo' : 1, 36 'es' : 1, 37 'et' : 1, 38 'eu' : 1, 39 'fa' : 1, 40 'fi' : 1, 41 'fo' : 1, 42 'fr-ca' : 1, 43 'fr' : 1, 44 'gl' : 1, 45 'gu' : 1, 46 'he' : 1, 47 'hi' : 1, 48 'hr' : 1, 49 'hu' : 1, 50 'is' : 1, 51 'it' : 1, 52 'ja' : 1, 53 'km' : 1, 54 'ko' : 1, 55 'lt' : 1, 56 'lv' : 1, 57 'mn' : 1, 58 'ms' : 1, 59 'nb' : 1, 60 'nl' : 1, 61 'no' : 1, 62 'pl' : 1, 63 'pt-br' : 1, 64 'pt' : 1, 65 'ro' : 1, 66 'ru' : 1, 67 'sk' : 1, 68 'sl' : 1, 69 'sr-latn' : 1, 70 'sr' : 1, 71 'sv' : 1, 72 'th' : 1, 73 'tr' : 1, 74 'uk' : 1, 75 'vi' : 1, 76 'zh-cn' : 1, 77 'zh' : 1 78 }, 79 80 /** 81 * Loads a specific language file, or auto detect it. A callback is 82 * then called when the file gets loaded. 83 * @param {String} languageCode The code of the language file to be 84 * loaded. If "autoDetect" is set to true, this language will be 85 * used as the default one, if the detect language is not 86 * available in the core. 87 * @param {Boolean} autoDetect Indicates that the function must try to 88 * detect the user language and load it instead. 89 * @param {Function} callback The function to be called once the 90 * language file is loaded. Two parameters are passed to this 91 * function: the language code and the loaded language entries. 92 * @example 93 */ 94 load : function( languageCode, defaultLanguage, callback ) 95 { 96 // If no languageCode - fallback to browser or default. 97 // If languageCode - fallback to no-localized version or default. 98 if ( !languageCode || !CKEDITOR.lang.languages[ languageCode ] ) 99 languageCode = this.detect( defaultLanguage, languageCode ); 100 101 if ( !this[ languageCode ] ) 102 { 103 CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( 104 '_source/' + // @Packager.RemoveLine 105 'lang/' + languageCode + '.js' ), 106 function() 107 { 108 callback( languageCode, this[ languageCode ] ); 109 } 110 , this ); 111 } 112 else 113 callback( languageCode, this[ languageCode ] ); 114 }, 115 116 /** 117 * Returns the language that best fit the user language. For example, 118 * suppose that the user language is "pt-br". If this language is 119 * supported by the editor, it is returned. Otherwise, if only "pt" is 120 * supported, it is returned instead. If none of the previous are 121 * supported, a default language is then returned. 122 * @param {String} defaultLanguage The default language to be returned 123 * if the user language is not supported. 124 * @returns {String} The detected language code. 125 * @example 126 * alert( CKEDITOR.lang.detect( 'en' ) ); // e.g., in a German browser: "de" 127 */ 128 detect : function( defaultLanguage, probeLanguage ) 129 { 130 var languages = this.languages; 131 probeLanguage = probeLanguage || navigator.userLanguage || navigator.language; 132 133 var parts = probeLanguage 134 .toLowerCase() 135 .match( /([a-z]+)(?:-([a-z]+))?/ ), 136 lang = parts[1], 137 locale = parts[2]; 138 139 if ( languages[ lang + '-' + locale ] ) 140 lang = lang + '-' + locale; 141 else if ( !languages[ lang ] ) 142 lang = null; 143 144 CKEDITOR.lang.detect = lang ? 145 function() { return lang; } : 146 function( defaultLanguage ) { return defaultLanguage; }; 147 148 return lang || defaultLanguage; 149 } 150 }; 151 152 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |