Skip to content

Commit

Permalink
refactored #57 a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mashpie committed Apr 28, 2013
1 parent 26066d7 commit 865325e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ i18n.overrideLocaleFromQuery = function (req) {
// ===================
// = private methods =
// ===================

/**
* registers all public API methods to a given response object when not already declared
*/
Expand Down Expand Up @@ -299,14 +298,16 @@ function translate(locale, singular, plural) {
locale = defaultLocale;
}

// attempt to read when defined as valid locale
if (!locales[locale]) {
read(locale);
if (!locales[locale]) {
if (debug) {
console.warn("WARN: Locale " + locale + " couldn't be read - check the context of the call to $__. Using " + defaultLocale + " (set by request) as current locale");
}
locale = defaultLocale;
}
}

// fallback to default when missed
if (!locales[locale]) {
logWarn("WARN: Locale " + locale + " couldn't be read - check the context of the call to $__. Using " + defaultLocale + " (default) as current locale");
locale = defaultLocale;
read(locale);
}

if (plural) {
Expand Down

0 comments on commit 865325e

Please sign in to comment.