Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/Strings.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Strings.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Strings.js b/frontend/gamma/js/Clipperz/PM/Strings.js index a051365..7e855ff 100644 --- a/frontend/gamma/js/Clipperz/PM/Strings.js +++ b/frontend/gamma/js/Clipperz/PM/Strings.js | |||
@@ -1,70 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Strings) == 'undefined') { Clipperz.PM.Strings = {}; } | 26 | if (typeof(Clipperz.PM.Strings) == 'undefined') { Clipperz.PM.Strings = {}; } |
29 | if (typeof(Clipperz.PM.Strings.Languages) == 'undefined') { Clipperz.PM.Strings.Languages = {}; } | 27 | if (typeof(Clipperz.PM.Strings.Languages) == 'undefined') { Clipperz.PM.Strings.Languages = {}; } |
30 | 28 | ||
31 | //----------------------------------------------------------------------------- | 29 | //----------------------------------------------------------------------------- |
32 | /* | 30 | /* |
33 | Clipperz.PM.Strings.standardStrings = { | 31 | Clipperz.PM.Strings.standardStrings = { |
34 | 'loginPanelSwitchLanguageSelectOptions':[ | 32 | 'loginPanelSwitchLanguageSelectOptions':[ |
35 | / * | 33 | / * |
36 | {tag:'option', html:"Arabic (Oman) (العربية)", value:'ar-OM', disabled:true}, | 34 | {tag:'option', html:"Arabic (Oman) (العربية)", value:'ar-OM', disabled:true}, |
37 | {tag:'option', html:"Arabic (Syria) (العربية)", value:'ar-SY', disabled:true}, | 35 | {tag:'option', html:"Arabic (Syria) (العربية)", value:'ar-SY', disabled:true}, |
38 | {tag:'option', html:"Bahasa Indonesia", value:'id-ID', disabled:true}, | 36 | {tag:'option', html:"Bahasa Indonesia", value:'id-ID', disabled:true}, |
39 | {tag:'option', html:"Bulgarian (Български)", value:'bg-BG', disabled:true}, | 37 | {tag:'option', html:"Bulgarian (Български)", value:'bg-BG', disabled:true}, |
40 | {tag:'option', html:"Català", value:'ca-ES', disabled:true}, | 38 | {tag:'option', html:"Català", value:'ca-ES', disabled:true}, |
41 | {tag:'option', html:"Chinese (Simplified) (简体中文)", value:'zh-CN', disabled:true}, | 39 | {tag:'option', html:"Chinese (Simplified) (简体中文)", value:'zh-CN', disabled:true}, |
42 | {tag:'option', html:"Chinese (Traditional) (正體中文)", value:'zh-TW', disabled:true}, | 40 | {tag:'option', html:"Chinese (Traditional) (正體中文)", value:'zh-TW', disabled:true}, |
43 | {tag:'option', html:"Czech (Česky)", value:'cs-CZ', disabled:true}, | 41 | {tag:'option', html:"Czech (Česky)", value:'cs-CZ', disabled:true}, |
44 | {tag:'option', html:"Dansk", value:'da-DK', disabled:true}, | 42 | {tag:'option', html:"Dansk", value:'da-DK', disabled:true}, |
45 | {tag:'option', html:"Deutsch", value:'de-DE'/ *, disabled:true* /}, | 43 | {tag:'option', html:"Deutsch", value:'de-DE'/ *, disabled:true* /}, |
46 | {tag:'option', html:"English (American)", value:'en-US'/ *, disabled:true* /}, | 44 | {tag:'option', html:"English (American)", value:'en-US'/ *, disabled:true* /}, |
47 | {tag:'option', html:"English (British)", value:'en-GB'/ *, disabled:true* /}, | 45 | {tag:'option', html:"English (British)", value:'en-GB'/ *, disabled:true* /}, |
48 | {tag:'option', html:"English (Canadian)", value:'en-CA'/ *, disabled:true* /}, | 46 | {tag:'option', html:"English (Canadian)", value:'en-CA'/ *, disabled:true* /}, |
49 | {tag:'option', html:"Español", value:'es-ES', disabled:true}, | 47 | {tag:'option', html:"Español", value:'es-ES', disabled:true}, |
50 | {tag:'option', html:"Eesti", value:'et-EE', disabled:true}, | 48 | {tag:'option', html:"Eesti", value:'et-EE', disabled:true}, |
51 | {tag:'option', html:"Français", value:'fr-FR', disabled:true}, | 49 | {tag:'option', html:"Français", value:'fr-FR', disabled:true}, |
52 | {tag:'option', html:"Galego", value:'gl-ES', disabled:true}, | 50 | {tag:'option', html:"Galego", value:'gl-ES', disabled:true}, |
53 | {tag:'option', html:"Greek (Ελληνικά)", value:'el-GR', disabled:true}, | 51 | {tag:'option', html:"Greek (Ελληνικά)", value:'el-GR', disabled:true}, |
54 | {tag:'option', html:"Íslenska", value:'is-IS', disabled:true}, | 52 | {tag:'option', html:"Íslenska", value:'is-IS', disabled:true}, |
55 | {tag:'option', html:"Italiano", value:'it-IT'/ *, disabled:true* /}, | 53 | {tag:'option', html:"Italiano", value:'it-IT'/ *, disabled:true* /}, |
56 | {tag:'option', html:"Japanese (日本語)", value:'ja-JP', disabled:true}, | 54 | {tag:'option', html:"Japanese (日本語)", value:'ja-JP', disabled:true}, |
57 | {tag:'option', html:"Korean (한국어)", value:'ko-KR', disabled:true}, | 55 | {tag:'option', html:"Korean (한국어)", value:'ko-KR', disabled:true}, |
58 | {tag:'option', html:"Latviešu", value:'lv-LV', disabled:true}, | 56 | {tag:'option', html:"Latviešu", value:'lv-LV', disabled:true}, |
59 | {tag:'option', html:"Lietuvių", value:'lt-LT', disabled:true}, | 57 | {tag:'option', html:"Lietuvių", value:'lt-LT', disabled:true}, |
60 | {tag:'option', html:"Macedonian (Македонски)", value:'mk-MK', disabled:true}, | 58 | {tag:'option', html:"Macedonian (Македонски)", value:'mk-MK', disabled:true}, |
61 | {tag:'option', html:"Magyar", value:'hu-HU', disabled:true}, | 59 | {tag:'option', html:"Magyar", value:'hu-HU', disabled:true}, |
62 | {tag:'option', html:"Nederlands", value:'nl-NL', disabled:true}, | 60 | {tag:'option', html:"Nederlands", value:'nl-NL', disabled:true}, |
63 | {tag:'option', html:"Norsk bokmål", value:'nb-NO', disabled:true}, | 61 | {tag:'option', html:"Norsk bokmål", value:'nb-NO', disabled:true}, |
64 | {tag:'option', html:"Norsk nynorsk", value:'nn-NO', disabled:true}, | 62 | {tag:'option', html:"Norsk nynorsk", value:'nn-NO', disabled:true}, |
65 | {tag:'option', html:"Persian (Western) (فارسى)", value:'fa-IR', disabled:true}, | 63 | {tag:'option', html:"Persian (Western) (فارسى)", value:'fa-IR', disabled:true}, |
66 | {tag:'option', html:"Polski", value:'pl-PL', disabled:true}, | 64 | {tag:'option', html:"Polski", value:'pl-PL', disabled:true}, |
67 | {tag:'option', html:"Português", value:'pt-PT'/ *, disabled:true* /}, | 65 | {tag:'option', html:"Português", value:'pt-PT'/ *, disabled:true* /}, |
68 | {tag:'option', html:"Português Brasileiro", value:'pt-BR'/ *, disabled:true* /}, | 66 | {tag:'option', html:"Português Brasileiro", value:'pt-BR'/ *, disabled:true* /}, |
69 | {tag:'option', html:"Românä", value:'ro-RO', disabled:true}, | 67 | {tag:'option', html:"Românä", value:'ro-RO', disabled:true}, |
70 | {tag:'option', html:"Russian (Русский)", value:'ru-RU', disabled:true}, | 68 | {tag:'option', html:"Russian (Русский)", value:'ru-RU', disabled:true}, |
@@ -196,97 +194,92 @@ Clipperz.PM.Strings.Languages.setSelectedLanguage = function(aLanguage) { | |||
196 | language = (aLanguage || Clipperz.PM.Strings.preferredLanguage || 'default').toLowerCase(); | 194 | language = (aLanguage || Clipperz.PM.Strings.preferredLanguage || 'default').toLowerCase(); |
197 | if (typeof(Clipperz.PM.Strings.defaultLanguages[language]) != 'undefined') { | 195 | if (typeof(Clipperz.PM.Strings.defaultLanguages[language]) != 'undefined') { |
198 | language = Clipperz.PM.Strings.defaultLanguages[language]; | 196 | language = Clipperz.PM.Strings.defaultLanguages[language]; |
199 | } | 197 | } |
200 | 198 | ||
201 | if (typeof(Clipperz.PM.Strings.Languages[language]) != 'undefined') { | 199 | if (typeof(Clipperz.PM.Strings.Languages[language]) != 'undefined') { |
202 | selectedLanguage = language; | 200 | selectedLanguage = language; |
203 | } else if (typeof(Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]) != 'undefined') { | 201 | } else if (typeof(Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]) != 'undefined') { |
204 | selectedLanguage = Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]; | 202 | selectedLanguage = Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]; |
205 | } else { | 203 | } else { |
206 | selectedLanguage = Clipperz.PM.Strings.defaultLanguages['default']; | 204 | selectedLanguage = Clipperz.PM.Strings.defaultLanguages['default']; |
207 | } | 205 | } |
208 | 206 | ||
209 | if (selectedLanguage != Clipperz.PM.Strings.selectedLanguage) { | 207 | if (selectedLanguage != Clipperz.PM.Strings.selectedLanguage) { |
210 | vartranslations; | 208 | vartranslations; |
211 | 209 | ||
212 | Clipperz.PM.Strings.selectedLanguage = selectedLanguage; | 210 | Clipperz.PM.Strings.selectedLanguage = selectedLanguage; |
213 | 211 | ||
214 | translations = {}; | 212 | translations = {}; |
215 | // MochiKit.Base.update(translations, Clipperz.PM.Strings.standardStrings) | 213 | // MochiKit.Base.update(translations, Clipperz.PM.Strings.standardStrings) |
216 | 214 | ||
217 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages['defaults']); | 215 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages['defaults']); |
218 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings['defaults']); | 216 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings['defaults']); |
219 | 217 | ||
220 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[Clipperz.PM.Strings.defaultLanguages['default']]); | 218 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[Clipperz.PM.Strings.defaultLanguages['default']]); |
221 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[Clipperz.PM.Strings.defaultLanguages['default']]); | 219 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[Clipperz.PM.Strings.defaultLanguages['default']]); |
222 | 220 | ||
223 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[selectedLanguage]); | 221 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[selectedLanguage]); |
224 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[selectedLanguage]); | 222 | MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[selectedLanguage]); |
225 | 223 | ||
226 | Clipperz.PM.Strings.stringsObjectStore = new Clipperz.KeyValueObjectStore(/*{'name':'String.stringsObjectStore [1]'}*/); | 224 | Clipperz.PM.Strings.stringsObjectStore = new Clipperz.KeyValueObjectStore(/*{'name':'String.stringsObjectStore [1]'}*/); |
227 | Clipperz.PM.Strings.stringsObjectStore.initWithValues(translations); | 225 | Clipperz.PM.Strings.stringsObjectStore.initWithValues(translations); |
228 | 226 | ||
229 | if (typeof(bookmarklet) != 'undefined') { | 227 | if (typeof(bookmarklet) != 'undefined') { |
230 | Clipperz.PM.Strings.stringsObjectStore.setValue('bookmarklet', Clipperz.PM.Strings.translateBookmarklet(bookmarklet)); | 228 | Clipperz.PM.Strings.stringsObjectStore.setValue('bookmarklet', Clipperz.PM.Strings.translateBookmarklet(bookmarklet)); |
231 | } | 229 | } |
232 | 230 | ||
233 | MochiKit.Signal.signal(Clipperz.PM.Strings.Languages, 'switchLanguage', selectedLanguage); | 231 | MochiKit.Signal.signal(Clipperz.PM.Strings.Languages, 'switchLanguage', selectedLanguage); |
234 | } | 232 | } |
235 | } | 233 | } |
236 | 234 | ||
237 | //----------------------------------------------------------------------------- | 235 | //----------------------------------------------------------------------------- |
238 | 236 | ||
239 | Clipperz.PM.Strings.getValue = function (aKeyPath, someKeyValues) { | 237 | Clipperz.PM.Strings.getValue = function (aKeyPath, someKeyValues) { |
240 | varresult; | 238 | varresult; |
241 | 239 | ||
242 | result = Clipperz.PM.Strings.stringsObjectStore.getValue(aKeyPath); | 240 | result = Clipperz.PM.Strings.stringsObjectStore.getValue(aKeyPath); |
243 | 241 | ||
244 | //try { | ||
245 | if (typeof(result) == 'string') { | 242 | if (typeof(result) == 'string') { |
246 | if (typeof (someKeyValues) != 'undefined') { | 243 | if (typeof (someKeyValues) != 'undefined') { |
247 | varkey; | 244 | varkey; |
248 | 245 | ||
249 | for (key in someKeyValues) { | 246 | for (key in someKeyValues) { |
250 | result = result.replace( new RegExp(key), someKeyValues[key]); | 247 | result = result.replace( new RegExp(key), someKeyValues[key]); |
251 | // result.replace(, ''); | ||
252 | } | 248 | } |
253 | } | 249 | } |
254 | 250 | ||
255 | result = result.replace(new RegExp('\n'), '<br>'); | 251 | result = result.replace(new RegExp('\n'), '<br>'); |
256 | } | 252 | } |
257 | //} catch (exception) { | ||
258 | //console.log("####", result, aKeyPath, someKeyValues, exception); | ||
259 | //} | ||
260 | 253 | ||
261 | return result; | 254 | return result; |
262 | } | 255 | } |
263 | 256 | ||
264 | Clipperz.PM.Strings.errorDescriptionForException = function (anException) { | 257 | Clipperz.PM.Strings.errorDescriptionForException = function (anException) { |
265 | var result; | 258 | var result; |
266 | 259 | ||
267 | result = Clipperz.PM.Strings.getValue('exceptionsMessages' + '.' + anException.name); | 260 | result = Clipperz.PM.Strings.getValue('exceptionsMessages' + '.' + anException.name); |
268 | 261 | ||
269 | if (result == null) { | 262 | if (result == null) { |
270 | result = anException.message; | 263 | result = anException.message; |
271 | } | 264 | } |
272 | 265 | ||
273 | return result; | 266 | return result; |
274 | }, | 267 | }, |
275 | 268 | ||
276 | //----------------------------------------------------------------------------- | 269 | //----------------------------------------------------------------------------- |
277 | 270 | ||
278 | Clipperz.PM.Strings.Languages.initSetup = function() { | 271 | Clipperz.PM.Strings.Languages.initSetup = function() { |
279 | varlanguage; | 272 | varlanguage; |
280 | varlanguageParser; | 273 | varlanguageParser; |
281 | 274 | ||
282 | language = navigator.language || navigator.userLanguage; //en, en-US, .... "de", "nb-no" | 275 | language = navigator.language || navigator.userLanguage; //en, en-US, .... "de", "nb-no" |
283 | languageParser = new RegExp("language=([a-z]{2}(?:\-[a-z]{2})?)(\&|$)", "i"); | 276 | languageParser = new RegExp("language=([a-z]{2}(?:\-[a-z]{2})?)(\&|$)", "i"); |
284 | if (languageParser.test(window.location.search)) { | 277 | if (languageParser.test(window.location.search)) { |
285 | language = RegExp.$1; | 278 | language = RegExp.$1; |
286 | } | 279 | } |
287 | 280 | ||
288 | Clipperz.PM.Strings.preferredLanguage = language.toLowerCase(); | 281 | Clipperz.PM.Strings.preferredLanguage = language.toLowerCase(); |
289 | Clipperz.PM.Strings.Languages.setSelectedLanguage(Clipperz.PM.Strings.preferredLanguage); | 282 | Clipperz.PM.Strings.Languages.setSelectedLanguage(Clipperz.PM.Strings.preferredLanguage); |
290 | } | 283 | } |
291 | 284 | ||
292 | //----------------------------------------------------------------------------- | 285 | //----------------------------------------------------------------------------- |