Merge pull request #460 from negue/fullTranslation

add a locale var to all translations
This commit is contained in:
Matteo Pagliazzi 2015-02-06 18:47:17 +01:00
commit 419b6bf611
2 changed files with 6 additions and 3 deletions

View file

@ -72,7 +72,7 @@
"questEggTRexText": "Tyrannosaur",
"questEggTRexAdjective": "tiny-armed",
"eggNotes": "Find a hatching potion to pour on this egg, and it will hatch into a <%= eggAdjective() %> <%= eggText() %>.",
"eggNotes": "Find a hatching potion to pour on this egg, and it will hatch into a <%= eggAdjective(locale) %> <%= eggText(locale) %>.",
"hatchingPotionBase": "Base",
"hatchingPotionWhite": "White",
@ -85,7 +85,7 @@
"hatchingPotionCottonCandyBlue": "Cotton Candy Blue",
"hatchingPotionGolden": "Golden",
"hatchingPotionNotes": "Pour this on an egg, and it will hatch as a <%= potText() %> pet.",
"hatchingPotionNotes": "Pour this on an egg, and it will hatch as a <%= potText(locale) %> pet.",
"foodMeat": "Meat",
"foodMilk": "Milk",

View file

@ -15,10 +15,13 @@ module.exports =
locale = 'en' if (!locale? or (!module.exports.strings and !module.exports.translations[locale]))
string = if (!module.exports.strings) then module.exports.translations[locale][stringName] else module.exports.strings[stringName]
clonedVars = _.clone(vars) or {};
clonedVars.locale = locale;
if string
try
_.template(string, (vars or {}))
_.template(string, (clonedVars))
catch e
'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'
else