registration.tpl; translator variable system

v1.18.x
psychobunny 12 years ago
parent 1a1fea535b
commit b8037845d6

@ -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 @<span id='yourUsername'>username</span>.",
"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"
}

@ -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();
});

@ -1,9 +1,9 @@
<ol class="breadcrumb">
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/" itemprop="url"><span itemprop="title">Home</span></a>
<a href="/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
</li>
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">Register</span>
<span itemprop="title">[[register:register]]</span>
</li>
</ol>
@ -12,46 +12,46 @@
<div class="well well-lg">
<form class="form-horizontal" role="form" action="{relative_path}/register" method="post">
<div class="form-group">
<label for="email" class="col-lg-4 control-label">Email Address</label>
<label for="email" class="col-lg-4 control-label">[[register:email_address]]</label>
<div class="col-lg-8">
<div class="input-group">
<input class="form-control" type="text" placeholder="Enter Email Address" name="email" id="email" />
<input class="form-control" type="text" placeholder="[[register:email_address_placeholder]]" name="email" id="email" />
<span class="input-group-addon">
<span id="email-notify"><i class="icon icon-circle-blank"></i></span>
</span>
</div>
<span class="help-block">By default, your email will be hidden from the public.</span>
<span class="help-block">[[register:help.email]]</span>
</div>
</div>
<div class="form-group">
<label for="username" class="col-lg-4 control-label">Username</label>
<label for="username" class="col-lg-4 control-label">[[register:username]]</label>
<div class="col-lg-8">
<div class="input-group">
<input class="form-control" type="text" placeholder="Enter Username" name="username" id="username" />
<input class="form-control" type="text" placeholder="[[register:username_placeholder]]" name="username" id="username" />
<span class="input-group-addon">
<span id="username-notify"><i class="icon icon-circle-blank"></i></span>
</span>
</div>
<span class="help-block">A unique username. {minimumUsernameLength}-{maximumUsernameLength} characters. Others can mention you with @<span id="yourUsername">username</span>.</span>
<span class="help-block">[[register:help.username_restrictions, {minimumUsernameLength}, {maximumUsernameLength}]]</span>
</div>
</div>
<div class="form-group">
<label for="password" class="col-lg-4 control-label">Password</label>
<label for="password" class="col-lg-4 control-label">[[register:password]]</label>
<div class="col-lg-8">
<div class="input-group">
<input class="form-control" type="password" placeholder="Enter Password" name="password" id="password" />
<input class="form-control" type="password" placeholder="[[register:password_placeholder]]" name="password" id="password" />
<span class="input-group-addon">
<span id="password-notify"><i class="icon icon-circle-blank"></i></span>
</span>
</div>
<span class="help-block">Your password's length must be at least {minimumPasswordLength} characters.</span>
<span class="help-block">[[register:help.minimum_password_length, {minimumPasswordLength}]]</span>
</div>
</div>
<div class="form-group">
<label for="password-confirm" class="col-lg-4 control-label">Confirm Password</label>
<label for="password-confirm" class="col-lg-4 control-label">[[register:confirm_password]]</label>
<div class="col-lg-8">
<div class="input-group">
<input class="form-control" type="password" placeholder="Confirm Password" name="password-confirm" id="password-confirm" />
<input class="form-control" type="password" placeholder="[[register:confirm_password_placeholder]]" name="password-confirm" id="password-confirm" />
<span class="input-group-addon">
<span id="password-confirm-notify"><i class="icon icon-circle-blank"></i></span>
</span>
@ -61,7 +61,7 @@
<div class="form-group">
<div class="col-lg-offset-4 col-lg-8">
<hr />
<button class="btn btn-primary btn-lg btn-block" id="register" type="submit">Register Now</button>
<button class="btn btn-primary btn-lg btn-block" id="register" type="submit">[[register:register_now_button]]</button>
</div>
</div>
<input type="hidden" name="_csrf" value="{token}" />
@ -70,7 +70,7 @@
</div>
<div class="col-md-6 {alternate_logins:display}">
<div class="well well-lg">
<h4>Alternative Registration</h4>
<h4>[[register:alternative_registration]]</h4>
<ul class="alt-logins">
<li data-url="/auth/twitter" class="twitter {twitter:display}"><i class="icon-twitter-sign icon-3x"></i></li>
<li data-url="/auth/google" class="google {google:display}"><i class="icon-google-plus-sign icon-3x"></i></li>

Loading…
Cancel
Save