Skip to content

Commit f031e4f

Browse files
author
Olivier Tilloy
committed
When a language-country code was requested, do not fail early if the language only file doesn't exist.
Fixes: #47.
1 parent e7c2c64 commit f031e4f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

dist/jquery.localize.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ http://keith-wood.name/localisation.html
5959
return loadLanguage(pkg, lang, level + 1);
6060
};
6161
errorFunc = function() {
62-
if (options.fallback && options.fallback !== lang) {
62+
if (level === 2 && lang.indexOf('-') > -1) {
63+
return loadLanguage(pkg, lang, level + 1);
64+
} else if (options.fallback && options.fallback !== lang) {
6365
return loadLanguage(pkg, options.fallback);
6466
}
6567
};

dist/jquery.localize.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.localize.coffee

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ do ($ = jQuery) ->
4747
notifyDelegateLanguageLoaded(intermediateLangData)
4848
loadLanguage(pkg, lang, level + 1)
4949
errorFunc = ->
50-
if options.fallback && options.fallback != lang
50+
if level == 2 && lang.indexOf('-') > -1
51+
# the language-only file may not exist, try the language-country file next
52+
# (ref: https://github.com/coderifous/jquery-localize/issues/47)
53+
loadLanguage(pkg, lang, level + 1)
54+
else if options.fallback && options.fallback != lang
5155
loadLanguage(pkg, options.fallback)
5256
ajaxOptions =
5357
url: file

0 commit comments

Comments
 (0)