forked from nikitaeverywhere/LightPivotTable
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ae8d97
commit 8f98041
Showing
6 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Light pivot localization. | ||
* | ||
* @scope {pivotLocale} - Sets the pivotLocale scope variable. | ||
* @param {string} [locale] - Two-letter language code. | ||
* @constructor | ||
*/ | ||
var PivotLocale = function (locale) { | ||
|
||
this.LOCALE = ""; | ||
|
||
this.setLocale(locale || navigator.language); | ||
|
||
}; | ||
|
||
/** | ||
* Editable locales. | ||
* | ||
* @type {{ru: string, en: string, de: string}[]} | ||
*/ | ||
PivotLocale.prototype.LOCALES = [ | ||
{ "ru": "Всего", "en": "Total", "de": "Summe" } | ||
]; | ||
|
||
/** | ||
* @param {string} locale - Two-letter code locale. | ||
*/ | ||
PivotLocale.prototype.setLocale = function (locale) { | ||
|
||
var i, locales = []; | ||
|
||
locale = locale.toLowerCase(); | ||
|
||
if (this.LOCALES[0].hasOwnProperty(locale)) { | ||
this.LOCALE = locale; | ||
} else { | ||
for (i in this.LOCALES[0]) { locales.push(i); } | ||
console.warn( | ||
"LightPivot: locale " + locale + " is not supported. Currently localized: " | ||
+ locales.join(", ") + "." | ||
); | ||
this.LOCALE = "en"; | ||
} | ||
|
||
}; | ||
|
||
/** | ||
* Get the localized phrase. | ||
* | ||
* @param {number} index - Index of phrase. | ||
* @returns {string} - Localized string. | ||
*/ | ||
PivotLocale.prototype.get = function (index) { | ||
|
||
return (this.LOCALES[index] || {})[this.LOCALE] || "{not localized}"; | ||
|
||
}; | ||
|
||
var pivotLocale = new PivotLocale(); |