Skip to content

add the bower configuration #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "jquery-localize",
"version": "0.1.2",
"license": "MIT",
"description": "A jQuery plugin that makes it easy to i18n your static web site.",
"keywords": [
"jquery",
"localize",
"i18n"
],
"homepage": "https://github.com/Haixing-Hu/jquery-localize",
"authors": [
{
"name": "coderifous",
"email": "[email protected]"
}
],
"repository": {
"type": "git",
"url": "[email protected]:Haixing-Hu/jquery-localize.git"
},
"main": [
"dist/jquery.localize.js"
],
"dependencies": {
"jquery": ">=1.9.0"
},
"devDependencies": {
"qunit":">=1.11.0"
},
"ignore": [
"test",
"libs"
]
}

3 changes: 3 additions & 0 deletions dist/jquery.localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ http://keith-wood.name/localisation.html
return loadLanguage(pkg, lang, level + 1);
};
errorFunc = function() {
if (level < 3) {
loadLanguage(pkg, lang, level + 1);
}
if (options.fallback && options.fallback !== lang) {
return loadLanguage(pkg, options.fallback);
}
Expand Down
6 changes: 3 additions & 3 deletions dist/jquery.localize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions examples/language_country_code_directly.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Localize Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<h1>Test localization...</h1>
<p data-localize="message">It failed :(</p>
<script type="text/javascript" charset="utf-8">
$(function(){
var opts = { language: "zh-CN", pathPrefix: "../test/lang"};
$("[data-localize]").localize("test", opts)
})
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion localize.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jquery.localize",
"title": "Localize",
"description": "A jQuery plugin that makes it easy to i18n your static web site.",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/coderifous/jquery-localize",
"author": {
"name": "coderifous",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-localize",
"version": "0.0.0-ignored",
"version": "0.1.1",
"engines": {
"node": ">= 0.8.0"
},
Expand Down
3 changes: 3 additions & 0 deletions src/jquery.localize.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ do ($ = jQuery) ->
notifyDelegateLanguageLoaded(intermediateLangData)
loadLanguage(pkg, lang, level + 1)
errorFunc = ->
# by Haixing Hu: load the next level even if the higher level failed.
if level < 3
loadLanguage(pkg, lang, level + 1)
if options.fallback && options.fallback != lang
loadLanguage(pkg, options.fallback)
ajaxOptions =
Expand Down
3 changes: 3 additions & 0 deletions test/lang/test-zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"message": "language-country code success"
}
6 changes: 6 additions & 0 deletions test/localize_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ do ($ = jQuery) ->
t.localize("test", opts)
equal t.text(), "country code success"

test "load language-country code json file directly", ->
opts = language: "zh-CN", pathPrefix: "lang"
t = localizableTagWithRel("p", "message", text: "language-country code fail")
t.localize("test", opts)
equal t.text(), "language-country code success"

module "Language optimization"

test "skipping language using string match", ->
Expand Down
12 changes: 12 additions & 0 deletions test/localize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@
t.localize("test", opts);
return equal(t.text(), "country code success");
});
test("load language-country code json file directly", function() {
var opts, t;
opts = {
language: "zh-CN",
pathPrefix: "lang"
};
t = localizableTagWithRel("p", "message", {
text: "language-country code fail"
});
t.localize("test", opts);
return equal(t.text(), "language-country code success");
});
module("Language optimization");
test("skipping language using string match", function() {
var opts, t;
Expand Down