Internationalize ULS
* internationalize ULS when jquery.i18n is present. Otherwise use the fallback English interface * Example with and without i18n * Message files for few languages
This commit is contained in:
1 parent
2ce74db801
commit
0781f022dd
18 files changed
+201
-31
No files matched your search
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uls-example-title": "Universal Language Selector"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uls-example-title": "ആഗോള ഭാഷാ സഹായി"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/*! jquery.i18n - v0.1.0 - 2012-09-21
|
||||
* https://github.com/wikimedia/jquery.i18n
|
||||
* Copyright (c) 2012 Santhosh Thottingal; Licensed GPL, MIT */
|
||||
function pluralRuleParser(a,b){function q(){}function r(a){return function(){for(var b=0;b<a.length;b++){var c=a[b]();if(c!==null)return c}return null}}function s(a){var b=c,d=[];for(var e=0;e<a.length;e++){var f=a[e]();if(f===null)return c=b,null;d.push(f)}return d}function t(a,b){return function(){var d=c,e=[],f=b();while(f!==null)e.push(f),f=b();return e.length<a?(c=d,null):e}}function u(b){var d=b.length;return function(){var e=null;return a.substr(c,d)===b&&(e=b,c+=d),e}}function v(b){return function(){var d=a.substr(c).match(b);return d===null?null:(c+=d[0].length,d[0])}}function w(){var a=f();return a===null?(q(" -- failed n"),a):(a=parseInt(b,10),q(" -- passed n ",a),a)}function y(){var a=s([w,d,h,d,e]);return a===null?(q(" -- failed mod"),null):(q(" -- passed mod"),parseInt(a[0],10)%parseInt(a[4],10))}function z(){var a=s([d,j]);return a===null?(q(" -- failed not"),null):a[1]}function A(){var a=s([x,d,g,t(0,z),d,e]);return a!==null?(q(" -- passed is"),a[3][0]==="not"?a[0]!==parseInt(a[5],10):a[0]===parseInt(a[5],10)):(q(" -- failed is"),null)}function B(){var a=s([r([D,e]),t(0,C)]),b=[];return a!==null?(b=b.concat(a[0],a[1][0]),b):(q(" -- failed rangeList"),null)}function C(){var a=s([n,B]);return a!==null?a[1]:(q(" -- failed rangeTail"),null)}function D(){var a=s([e,m,e]);if(a!==null){q(" -- passed range");var b=[],c=parseInt(a[0],10),d=parseInt(a[2],10);for(i=c;i<=d;i++)b.push(i);return b}return q(" -- failed range"),null}function E(){var a=s([x,t(0,z),d,k,d,B]);if(a!==null){q(" -- passed _in");var b=a[5];for(var c=0;c<b.length;c++)if(parseInt(b[c],10)===a[0])return a[1][0]!=="not";return a[1][0]==="not"}return q(" -- failed _in "),null}function F(){var a=s([x,d,l,d,B]);if(a!==null){q(" -- passed within ");var b=a[4];return parseInt(b[0],10)<=a[0]&&a[0]<=parseInt(b[1],10)}return q(" -- failed within "),null}function H(){var a=s([G,d,p,d,J]);return a?(q(" -- passed and"),a[0]&&a[4]):(q(" -- failed and"),null)}function I(){var a=s([G,d,o,d,J]);return a?(q(" -- passed or"),a[0]||a[4]):(q(" -- failed or"),null)}function K(a){return parseFloat(a)%1===0}function L(){if(!K(b))return!1;var a=J();return a}var c=0,d=v(/^\s+/),e=v(/^\d+/),f=u("n"),g=u("is"),h=u("mod"),j=u("not"),k=u("in"),l=u("within"),m=u(".."),n=u(","),o=u("or"),p=u("and");q("pluralRuleParser",a,b);var x=r([y,w]),G=r([A,E,F]),J=r([H,I,G]),M=L();return M!==null&&c===a.length,M}(function(a,b,c){"use strict";var d=function(b){this.options=a.extend({},a.i18n.defaults,b),this.parser=this.options.parser,this.messageStore=this.options.messageStore,this.languages={},this.locale=this.options.locale,this.init()};d.prototype={init:function(){var b=this;this.messageStore.init(this.locale),String.prototype.toLocaleString=function(){var c=this.valueOf(),d=b.locale,e=0;while(d){var f=d.toLowerCase().split("-"),g=f.length;do{var h=f.slice(0,g).join("-");!b.messageStore.messages[h]&&b.options.messageLocationResolver&&b.messageStore.load(b.options.messageLocationResolver(h),h);var i=b.messageStore.get(h,c);if(i)return i;g--}while(g);if(d==="en")break;d=a.i18n.fallbacks[b.locale]&&a.i18n.fallbacks[b.locale][e]||b.options.fallbackLocale,b.log("Trying fallback locale for "+b.locale+": "+d),e++}return c},String.locale=this.locale},destroy:function(){a("body").data("i18n",null)},load:function(a,b){this.messageStore.load(a,b)},log:function(){var d=b.console!==c;d&&a.i18n.debug&&b.console.log.apply(b.console,arguments)},parse:function(b,c){var d=b.toLocaleString();return this.parser.language=a.i18n.languages[a.i18n().locale]||a.i18n.languages["default"],this.parser.parse(d,c)}},String.locale=String.locale||a("html").attr("lang");if(!String.locale)if(typeof b.navigator!==c){var e=b.navigator;String.locale=e.language||e.userLanguage||""}else String.locale="";a.i18n=function(b,e){var f=[],g=a("body").data("i18n"),h=typeof b=="object"&&b;return h&&h.locale&&g&&g.locale!==h.locale&&(String.locale=g.locale=h.locale),g||(a("body").data("i18n",g=new d(h)),a("[data-i18n]").each(function(b){var c=a(this);if(c.data("i18n")){var d=c.data("i18n"),e=a.i18n(d);e!==d&&c.text(e)}})),b?(e!==c&&(f=a.makeArray(arguments),f.shift()),typeof b=="string"?g.parse(b,f):g):g},a.fn.i18n=function(b){return this.each(function(){var b=a(this);if(b.data("i18n")){var c=b.data("i18n"),d=a.i18n(c);d!==c&&b.text(d)}else b.find("[data-i18n]").i18n()})};var f={parse:function(a,b){return a.replace(/\$(\d+)/g,function(a,d){var e=parseInt(d,10)-1;return b[e]!==c?b[e]:"$"+d})}};a.i18n.languages={},a.i18n.messageStore=a.i18n.messageStore||{},a.i18n.parser=f,a.i18n.parser.emitter={},a.i18n.debug=!1,a.i18n.defaults={locale:String.locale,fallbackLocale:"en",parser:a.i18n.parser,messageStore:a.i18n.messageStore,messageLocationResolver:null},a.i18n.Constructor=d,b._=b._||a.i18n})(jQuery,window),function(a,b,c){"use strict";var d=function(){this.messages={},this.sources={},this.locale=String.locale};d.prototype={init:function(b){this.locale=b;var c=this,d=a("link"),e=d.length;this.log("initializing for "+b);whLine truncated
|
||||
Reference in new issue
Block a user