From e1983203c97654cadb92f407f6b115bab0a6e0b8 Mon Sep 17 00:00:00 2001 From: Negue Date: Fri, 30 Jan 2015 20:11:29 +0100 Subject: [PATCH] add a locale var to all translations --- locales/en/content.json | 4 ++-- script/i18n.coffee | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/locales/en/content.json b/locales/en/content.json index be79d23c42..a2ee7b3d20 100644 --- a/locales/en/content.json +++ b/locales/en/content.json @@ -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", diff --git a/script/i18n.coffee b/script/i18n.coffee index ea735c9892..8b99175f5f 100644 --- a/script/i18n.coffee +++ b/script/i18n.coffee @@ -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