Skip to content

Commit bdb443b

Browse files
author
Olivier Tilloy
committed
Do not limit language codes to 2 letters.
Fixes: #50.
1 parent 89fbac0 commit bdb443b

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

dist/jquery.localize.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,11 @@ http://keith-wood.name/localisation.html
4141
}
4242
break;
4343
case 2:
44-
if (lang.length >= 2) {
45-
file = "" + pkg + "-" + (lang.substring(0, 2)) + "." + fileExtension;
46-
return jsonCall(file, pkg, lang, level);
47-
}
48-
break;
44+
file = "" + pkg + "-" + (lang.split('-')[0]) + "." + fileExtension;
45+
return jsonCall(file, pkg, lang, level);
4946
case 3:
50-
if (lang.length >= 5) {
51-
file = "" + pkg + "-" + (lang.substring(0, 5)) + "." + fileExtension;
52-
return jsonCall(file, pkg, lang, level);
53-
}
47+
file = "" + pkg + "-" + (lang.split('-').slice(0, 2).join('-')) + "." + fileExtension;
48+
return jsonCall(file, pkg, lang, level);
5449
}
5550
};
5651
jsonCall = function(file, pkg, lang, level) {

src/jquery.localize.coffee

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ do ($ = jQuery) ->
3434
else
3535
loadLanguage(pkg, lang, 2)
3636
when 2
37-
if lang.length >= 2
38-
file = "#{pkg}-#{lang.substring(0, 2)}.#{fileExtension}"
39-
jsonCall(file, pkg, lang, level)
37+
file = "#{pkg}-#{lang.split('-')[0]}.#{fileExtension}"
38+
jsonCall(file, pkg, lang, level)
4039
when 3
41-
if lang.length >= 5
42-
file = "#{pkg}-#{lang.substring(0, 5)}.#{fileExtension}"
43-
jsonCall(file, pkg, lang, level)
40+
file = "#{pkg}-#{lang.split('-').slice(0,2).join('-')}.#{fileExtension}"
41+
jsonCall(file, pkg, lang, level)
4442

4543
jsonCall = (file, pkg, lang, level) ->
4644
file = "#{options.pathPrefix}/#{file}" if options.pathPrefix?

0 commit comments

Comments
 (0)