add a locale var to all translations

This commit is contained in:
Negue 2015-01-30 20:11:29 +01:00
parent f2a1160c48
commit e1983203c9
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