widget-i18n-debug.js revision d57e8af4277d928d616e3b91b4b26693d18903e1
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * @attribute locale
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * @description
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * The default locale for the widget. NOTE: Using get/set on the "strings" attribute will
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * return/set strings for this locale.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * @default "en"
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * @type String
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * Sets strings for a particular locale, merging with any existing
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence * strings which may already be defined for the locale.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @method _setStrings
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * @protected
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @param {Object} strings The hash of string key/values to set
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @param {Object} locale The locale for the string values being set
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * Returns the strings key/value hash for a paricular locale, without locale lookup applied.
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * @method _getStrings
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * @protected
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * @param {Object} locale
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence * Gets the entire strings hash for a particular locale, performing locale lookup.
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence * If no values of the key are defined for a particular locale the value for the
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence * default locale (in initial locale set for the class) is returned.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @method getStrings
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence * @param {String} locale (optional) The locale for which the string value is required. Defaults to the current locale, if not provided.
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt // TODO: Optimize/Cache. Clear cache on _setStrings call.
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews locale = (locale || this.get(LOCALE)).toLowerCase();
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews Y.log("getStrings: For " + locale, "info", "widget");
f5cfcbf2f7906fb59c2b8b9b8fc9c7a75ac44dabMark Andrews var defLocale = this.getDefaultLocale().toLowerCase(),
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence // If locale is different than the default, or needs lookup support
2d9bd38ec3fbbfe920757b8972d94f664a9b354bMark Andrews if (locale !== defLocale || localeSegments.length > 1) {
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence for (i = 0, l = localeSegments.length; i < l; ++i) {
8319af16557b81eba3277ee67215285f0823b587Mark Andrews Y.log("getStrings: Merging in strings from: " + lookup, "info", "widget");
c3e6fbe4b7471d843d015e3f1737b7edb9d0c547Mark Andrews * Gets the string for a particular key, for a particular locale, performing locale lookup.
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence * If no values if defined for the key, for the given locale, the value for the
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence * default locale (in initial locale set for the class) is returned.
a04588e781b513ae3b30e061ac98035802b5e8e8Mark Andrews * @method getString
5e47b4200ed81b8e18e165fe3a626d9992003db4Mark Andrews * @param {String} key The key.
5e47b4200ed81b8e18e165fe3a626d9992003db4Mark Andrews * @param {String} locale (optional) The locale for which the string value is required. Defaults to the current locale, if not provided.
2320f230995995595438a9d9301d84931fd266ceMark Andrews locale = (locale || this.get(LOCALE)).toLowerCase();
620a452ebe92fff63e85c5930a6e6dc8d9455918Mark Andrews Y.log("getString: For " + locale, "info", "widget");
6dcb47e37f9f0cdb94bdabc3fa157ff07983c590Mark Andrews var defLocale = (this.getDefaultLocale()).toLowerCase(),
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley // If locale is different than the default, or needs lookup support
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt Y.log("getString: Performing lookup for: " + locale, "info", "widget");
0014d6342b0d50ae37126ac16d5bf821d02ffff7David Lawrence // Chop of last locale segment
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * Returns the default locale for the widget (the locale value defined by the
af9dbf1ccdd53933aaae9300d13ce0965d39b067Evan Hunt * widget class, or provided by the user during construction).
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @method getDefaultLocale
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley * @return {String} The default locale for the widget