Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow locale per-instance + local override in i18n

  • Loading branch information...
commit 4486e49c519c56662b8fe404b6c944effb1291f6 1 parent a15bd5e
@mde authored
Showing with 16 additions and 3 deletions.
  1. +16 −3 lib/i18n.js
View
19 lib/i18n.js
@@ -18,8 +18,10 @@
var core = require('./core')
, i18n;
+var DEFAULT_LOCALE = 'en-us';
+
i18n = new (function () {
- var _defaultLocale = 'en-us'
+ var _defaultLocale = DEFAULT_LOCALE
, _strings = {};
this.getText = function (key, opts, locale) {
@@ -50,8 +52,19 @@ i18n = new (function () {
})();
i18n.I18n = function (locale) {
- this.getText = function (key, opts) {
- return i18n.getText(key, opts || {}, locale);
+ var _locale = locale || DEFAULT_LOCALE;
+
+ this.getLocale = function (locale) {
+ return _locale;
+ };
+
+ this.setLocale = function (locale) {
+ _locale = locale;
+ };
+
+ this.getText = function (key, opts, locale) {
+ return i18n.getText(key,
+ opts || {}, locale || _locale);
};
this.t = this.getText;
};
Please sign in to comment.
Something went wrong with that request. Please try again.