2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* Defines the FCKLanguageManager object that is used for language
25
var FCKLanguageManager = FCK.Language =
32
bn : 'Bengali/Bangla',
40
'en-au' : 'English (Australia)',
41
'en-ca' : 'English (Canadian)',
42
'en-uk' : 'English (United Kingdom)',
51
'fr-ca' : 'French (Canada)',
67
nb : 'Norwegian Bokmal',
71
pt : 'Portuguese (Portugal)',
72
'pt-br' : 'Portuguese (Brazil)',
77
sr : 'Serbian (Cyrillic)',
78
'sr-latn' : 'Serbian (Latin)',
84
zh : 'Chinese Traditional',
85
'zh-cn' : 'Chinese Simplified'
88
GetActiveLanguage : function()
90
if ( FCKConfig.AutoDetectLanguage )
94
// IE accepts "navigator.userLanguage" while Gecko "navigator.language".
95
if ( navigator.userLanguage )
96
sUserLang = navigator.userLanguage.toLowerCase() ;
97
else if ( navigator.language )
98
sUserLang = navigator.language.toLowerCase() ;
101
// Firefox 1.0 PR has a bug: it doens't support the "language" property.
102
return FCKConfig.DefaultLanguage ;
105
// Some language codes are set in 5 characters,
106
// like "pt-br" for Brazilian Portuguese.
107
if ( sUserLang.length >= 5 )
109
sUserLang = sUserLang.substr(0,5) ;
110
if ( this.AvailableLanguages[sUserLang] ) return sUserLang ;
113
// If the user's browser is set to, for example, "pt-br" but only the
114
// "pt" language file is available then get that file.
115
if ( sUserLang.length >= 2 )
117
sUserLang = sUserLang.substr(0,2) ;
118
if ( this.AvailableLanguages[sUserLang] ) return sUserLang ;
122
return this.DefaultLanguage ;
125
TranslateElements : function( targetDocument, tag, propertyToSet, encode )
127
var e = targetDocument.getElementsByTagName(tag) ;
129
for ( var i = 0 ; i < e.length ; i++ )
131
// The extra () is to avoid a warning with strict error checking. This is ok.
132
if ( (sKey = e[i].getAttribute( 'fckLang' )) )
134
// The extra () is to avoid a warning with strict error checking. This is ok.
135
if ( (s = FCKLang[ sKey ]) )
138
s = FCKTools.HTMLEncode( s ) ;
139
e[i][ propertyToSet ] = s ;
145
TranslatePage : function( targetDocument )
147
this.TranslateElements( targetDocument, 'INPUT', 'value' ) ;
148
this.TranslateElements( targetDocument, 'SPAN', 'innerHTML' ) ;
149
this.TranslateElements( targetDocument, 'LABEL', 'innerHTML' ) ;
150
this.TranslateElements( targetDocument, 'OPTION', 'innerHTML', true ) ;
151
this.TranslateElements( targetDocument, 'LEGEND', 'innerHTML' ) ;
154
Initialize : function()
156
if ( this.AvailableLanguages[ FCKConfig.DefaultLanguage ] )
157
this.DefaultLanguage = FCKConfig.DefaultLanguage ;
159
this.DefaultLanguage = 'en' ;
161
this.ActiveLanguage = new Object() ;
162
this.ActiveLanguage.Code = this.GetActiveLanguage() ;
163
this.ActiveLanguage.Name = this.AvailableLanguages[ this.ActiveLanguage.Code ] ;