diff --git a/public/language/en/register.json b/public/language/en/register.json new file mode 100644 index 0000000000..6b8a26f282 --- /dev/null +++ b/public/language/en/register.json @@ -0,0 +1,16 @@ +{ + "register": "Register", + "help.email": "By default, your email will be hidden from the public.", + "help.username_restrictions": "A unique username between %1 and %2 characters. Others can mention you with @username.", + "help.minimum_password_length": "Your password's length must be at least %1 characters.", + "email_address": "Email Address", + "email_address_placeholder": "Enter Email Address", + "username": "Username", + "username_placeholder": "Enter Username", + "password": "Password", + "password_placeholder": "Enter Password", + "confirm_password": "Confirm Password", + "confirm_password_placeholder": "Confirm Password", + "register_now_button": "Register Now", + "alternative_registration": "Alternative Registration" +} \ No newline at end of file diff --git a/public/src/translator.js b/public/src/translator.js index 8ee16f398a..a1ebc017a8 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -47,24 +47,36 @@ translator.translate = function (data, callback) { var keys = data.match(/\[\[.*?\]\]/g), loading = 0; + + function insertLanguage(text, key, value, variables) { + for (var i = 1, ii = variables.length; i < ii; i++) { + var variable = variables[i].replace(']]', ''); + value = value.replace('%' + i, variable); + } + + text = text.replace(key, value); + + return text; + } for (var key in keys) { if (keys.hasOwnProperty(key)) { //check for additional variables then keys[key].split(/[,][?\s+]/); + var variables = keys[key].split(/[,][?\s+]/); var parsedKey = keys[key].replace('[[', '').replace(']]', '').split(':'), languageFile = parsedKey[0]; - parsedKey = parsedKey[1]; + parsedKey = parsedKey[1].split(',')[0]; if (files.loaded[languageFile]) { - data = data.replace(keys[key], files.loaded[languageFile][parsedKey]); + data = insertLanguage(data, keys[key], files.loaded[languageFile][parsedKey], variables); } else { loading++; (function (languageKey, parsedKey) { translator.load(languageFile, function (languageData) { - data = data.replace(languageKey, languageData[parsedKey]); + data = insertLanguage(data, languageKey, languageData[parsedKey], variables); loading--; checkComplete(); }); diff --git a/public/templates/register.tpl b/public/templates/register.tpl index 7cb72b39d3..6003d203f9 100644 --- a/public/templates/register.tpl +++ b/public/templates/register.tpl @@ -1,9 +1,9 @@ @@ -12,46 +12,46 @@
- +
- +
- By default, your email will be hidden from the public. + [[register:help.email]]
- +
- +
- A unique username. {minimumUsernameLength}-{maximumUsernameLength} characters. Others can mention you with @username. + [[register:help.username_restrictions, {minimumUsernameLength}, {maximumUsernameLength}]]
- +
- +
- Your password's length must be at least {minimumPasswordLength} characters. + [[register:help.minimum_password_length, {minimumPasswordLength}]]
- +
- + @@ -61,7 +61,7 @@

- +
@@ -70,7 +70,7 @@
-

Alternative Registration

+

[[register:alternative_registration]]