Skip to content

Commit 132358e

Browse files
committed
Now loads language json for local file urls (file://...)
* test files no longer require http server to work, so people can run the tests themselves with less fuss. * test/absolute_prefix_path.html still requires http server.
1 parent 87add63 commit 132358e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/jquery.localize.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@
3636
function jsonCall(file, pkg, lang, level) {
3737
if (options.pathPrefix) file = options.pathPrefix + "/" + file;
3838

39-
$.ajax({
39+
var ajaxOptions = {
4040
url: file,
4141
dataType: "json",
4242
async: false,
4343
timeout: (options && options.timeout ? options.timeout : 500),
4444
success: successFunc
45-
});
45+
};
46+
47+
// hack to work with serving from local file system.
48+
// local file:// urls won't work in chrome:
49+
// http://code.google.com/p/chromium/issues/detail?id=40787
50+
if (window.location.protocol == "file:")
51+
ajaxOptions.error = function(xhr){ successFunc($.parseJSON(xhr.responseText)); };
52+
53+
$.ajax(ajaxOptions);
4654

4755
function successFunc(d) {
4856
$.extend(intermediateLangData, d);

0 commit comments

Comments
 (0)