diff --git a/build/jquery.localize.js b/build/jquery.localize.js index 439c6e2..57f4f25 100644 --- a/build/jquery.localize.js +++ b/build/jquery.localize.js @@ -1,12 +1,13 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.3 (function() { var $, normaliseLang; $ = jQuery; normaliseLang = function(lang) { - lang = lang.replace(/_/, '-').toLowerCase(); - if (lang.length > 3) { + lang = lang.replace(/_/, '-'); + lang = lang.substring(0, 2).toLowerCase() + lang.substring(2); + if (lang.length === 5) { lang = lang.substring(0, 3) + lang.substring(3).toUpperCase(); } return lang; @@ -45,7 +46,7 @@ break; case 3: if (lang.length >= 5) { - file = "" + pkg + "-" + (lang.substring(0, 5)) + "." + fileExtension; + file = "" + pkg + "-" + lang + "." + fileExtension; return jsonCall(file, pkg, lang, level); } } diff --git a/src/jquery.localize.coffee b/src/jquery.localize.coffee index 7eb5cdf..b101653 100644 --- a/src/jquery.localize.coffee +++ b/src/jquery.localize.coffee @@ -7,10 +7,12 @@ $ = jQuery -# Ensures language code is in the format aa-AA. +# Ensures language code is in the format aa-AA, or if longer, +# keep capitalization (zh-Hans) of second part. normaliseLang = (lang) -> - lang = lang.replace(/_/, '-').toLowerCase() - if lang.length > 3 + lang = lang.replace(/_/, '-') + lang = lang.substring(0, 2).toLowerCase() + lang.substring(2) + if lang.length == 5 lang = lang.substring(0, 3) + lang.substring(3).toUpperCase() lang @@ -37,7 +39,7 @@ $.localize = (pkg, options = {}) -> jsonCall(file, pkg, lang, level) when 3 if lang.length >= 5 - file = "#{pkg}-#{lang.substring(0, 5)}.#{fileExtension}" + file = "#{pkg}-#{lang}.#{fileExtension}" jsonCall(file, pkg, lang, level) jsonCall = (file, pkg, lang, level) ->