Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
Keep the same Ruby's API.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed May 10, 2012
1 parent c3d6377 commit 7d58f50
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ You can set default values for missing scopes:
// with interpolation
I18n.t("noun", {defaultValue: "I'm a {{noun}}", noun: "Mac"});

Translation fallback can be enabled by enabling the `I18n.fallback` option:
Translation fallback can be enabled by enabling the `I18n.fallbacks` option:

<script type="text/javascript">
I18n.fallback = true;
I18n.fallbacks = true;
</script>

By default missing translations will first be looked for in less
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Set if engine should fallback to the default locale when a translation
// is missing.
this.fallback = false;
this.fallbacks = false;

// Set the default translation object.
this.translations = {};
Expand Down Expand Up @@ -89,7 +89,7 @@
}

// Add the default locale if fallback strategy is enabled.
if (I18n.fallback && I18n.defaultLocale) {
if (I18n.fallbacks && I18n.defaultLocale) {
locales.push(I18n.defaultLocale);
}

Expand All @@ -103,7 +103,7 @@
list.push(locale);
}

if (I18n.fallback && countryCode && countryCode !== locale && !~list.indexOf(countryCode)) {
if (I18n.fallbacks && countryCode && countryCode !== locale && !~list.indexOf(countryCode)) {
list.push(countryCode);
}
});
Expand Down
2 changes: 1 addition & 1 deletion spec/js/defaults.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ describe("Defaults", function(){
});

it("sets fallback", function(){
expect(I18n.fallback).toEqual(false);
expect(I18n.fallbacks).toEqual(false);
});
});
14 changes: 7 additions & 7 deletions spec/js/translate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ describe("Translate", function(){
expect(I18n.t("hello", {locale: "pt-BR"})).toEqual("Olá Mundo!");
});

it("fallbacks to the default locale when I18n.fallbacks is enabled", function(){
it("fallbacks to the default locale when I18n.fallbackss is enabled", function(){
I18n.locale = "pt-BR";
I18n.fallback = true;
I18n.fallbacks = true;
expect(I18n.t("greetings.stranger")).toEqual("Hello stranger!");
});

it("fallbacks to default locale when providing an unknown locale", function(){
I18n.locale = "fr";
I18n.fallback = true;
I18n.fallbacks = true;
expect(I18n.t("greetings.stranger")).toEqual("Hello stranger!");
});

it("fallbacks to less specific locale", function(){
I18n.locale = "de-DE";
I18n.fallback = true;
I18n.fallbacks = true;
expect(I18n.t("hello")).toEqual("Hallo Welt!");
});

it("fallbacks using custom rules (function)", function(){
I18n.locale = "no";
I18n.fallback = true;
I18n.fallbacks = true;
I18n.locales["no"] = function() {
return ["nb"];
};
Expand All @@ -68,15 +68,15 @@ describe("Translate", function(){

it("fallbacks using custom rules (array)", function() {
I18n.locale = "no";
I18n.fallback = true;
I18n.fallbacks = true;
I18n.locales["no"] = ["no", "nb"];

expect(I18n.t("hello")).toEqual("Hei Verden!");
});

it("fallbacks using custom rules (string)", function() {
I18n.locale = "no";
I18n.fallback = true;
I18n.fallbacks = true;
I18n.locales["no"] = "nb";

expect(I18n.t("hello")).toEqual("Hei Verden!");
Expand Down

0 comments on commit 7d58f50

Please sign in to comment.