Skip to content
New issue

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

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

Already on GitHub? # to your account

fix fallback bug #475

Merged
merged 2 commits into from
Oct 26, 2017
Merged
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
4 changes: 2 additions & 2 deletions app/assets/javascripts/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@
var firstFallback = null;
var secondFallback = null;
if (localeParts.length === 3) {
firstFallback = localeParts[0];
secondFallback = [
firstFallback = [
localeParts[0],
localeParts[1]
].join("-");
secondFallback = localeParts[0];
}
else if (localeParts.length === 2) {
firstFallback = localeParts[0];
Expand Down
4 changes: 4 additions & 0 deletions spec/js/translate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ describe("Translate", function(){
it("fallbacks to 1-part locale when 2-part missing requested translation", function(){
expect(I18n.t("dog")).toEqual("狗");
});

it("fallbacks to 2-part for the first time", function(){
expect(I18n.t("dragon")).toEqual("龍");
});
});

it("fallbacks using custom rules (function)", function(){
Expand Down
6 changes: 4 additions & 2 deletions spec/js/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ var DEBUG = false;
};

Translations["zh-Hant"] = {
cat: "貓"
cat: "貓"
, dragon: "龍"
};

Translations["zh"] = {
dog: "狗"
dog: "狗"
, dragon: "龙"
};

return Translations;
Expand Down