Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n and Spanish Translation #46

Merged
merged 4 commits into from
Dec 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
_site/
.bundle/
vendor/
*.iml
packages
*.lock
4 changes: 4 additions & 0 deletions client/entry.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ AccountsEntry =
config: (appConfig) ->
@settings = _.extend(@settings, appConfig)

i18n.setDefaultLanguage "en_US"
if appConfig.language
i18n.setLanguage appConfig.language

if appConfig.signUpTemplate
Router.routes = _.reject Router.routes, (e, i) ->
e.name is 'entrySignUp'
Expand Down
3 changes: 3 additions & 0 deletions client/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ Handlebars.registerHelper 'otherLoginServices', ->

Handlebars.registerHelper 'loginServices', ->
Accounts.oauth.serviceNames()

Handlebars.registerHelper 'showSignupCode', ->
AccountsEntry.config.showSignupCode is true
37 changes: 37 additions & 0 deletions client/i18n/english.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
en =
signIn: "Sign In"
signin: "sign in"
signOut: "Sign Out"
signUp: "Sign Up"
OR: "OR"
forgotPassword: "Forgot your Password?"
emailAddress: "Email Address"
emailResetLink: "Email Reset Link"
dontHaveAnAccount: "Don't have an account?"
resetYourPassword: "Reset your Password"
updateYourPassword: "Update your password"
password: "Password"
usernameOrEmail: "Username or email"
email: "Email"
ifYouAlreadyHaveAnAccount: "If you already have an account"
signUpWithYourEmailAddress: "Sign up with your email address"
username: "Username"
optional: "Optional"
signupCode: "Signup Code"
clickAgree: "By clicking Sign up, you agree to our"
privacyPolicy: "Privacy Policy"
terms: "Terms of Use"
sign: "Sign"
with: "with"

error:
minChar: "7 character minimum password."
pwOneLetter: "Password requires 1 letter."
pwOneDigit: "Password must have at least one digit."
uernameRequired: "Username is required"
emailRequired: "Email is required"
signupCodeRequired: "Signup code is required"
signupCodeIncorrect: "Signup code is incorrect"
unknown: "Unknown error"

i18n.map "en", en
36 changes: 36 additions & 0 deletions client/i18n/spanish.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
es =
signIn: "Entrar"
signOut: "Salir"
signUp: "Suscribir"
OR: "O"
forgotPassword: "Contraseña olvidada?"
emailAddress: "Dirección de Email"
emailResetLink: "Reiniciar Email"
dontHaveAnAccount: "No tenés una cuenta?"
resetYourPassword: "Resetear tu contraseña"
updateYourPassword: "Actualizar tu contraseña"
password: "Contraseña"
usernameOrEmail: "Usuario o email"
email: "Email"
ifYouAlreadyHaveAnAccount: "Si ya tenés una cuanta"
signUpWithYourEmailAddress: "Suscribir con tu email"
username: "Usuario"
optional: "Opcional"
signupCode: "Codigo para suscribir"
clickAgree: "Si haces clic en Sucribir estas de acuerdo con la"
privacyPolicy: "Póliza de Privacidad"
terms: "Terminos de Uso"
sign: "Ingresar"
with: "con"

error:
minChar: "7 carácteres minimo."
pwOneLetter: "Minimo una letra."
pwOneDigit: "Minimo un dígito."
uernameRequired: "Usuario es necesario"
emailRequired: "Email es necesario"
signupCodeRequired: "Codigo para suscribir es necesario"
signupCodeIncorrect: "Codigo para suscribir no coincide"
unknown: "Error desconocido"

i18n.map "es", es
6 changes: 3 additions & 3 deletions client/views/accountButtons/accountButtons.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
{{/if}}

{{#if wrapLinks}}<li>{{/if}}
<a href="/sign-out">Sign Out</a>
<a href="/sign-out">{{i18n "signOut"}}</a>
{{#if wrapLinks}}</li>{{/if}}

{{else}}

{{#if wrapLinks}}<li>{{/if}}
<a href="/sign-in">Sign In</a>
<a href="/sign-in">{{i18n "signIn"}}</a>
{{#if wrapLinks}}</li>{{/if}}

{{#unless wrapLinks}}<span>or</span>{{/unless}}

{{#if wrapLinks}}<li>{{/if}}
<a href="/sign-up">Sign Up</a>
<a href="/sign-up">{{i18n "signUp"}}</a>
{{#if wrapLinks}}</li>{{/if}}

{{/if}}
Expand Down
10 changes: 6 additions & 4 deletions client/views/forgotPassword/forgotPassword.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
{{#if error}}
<div class='alert alert-danger'>{{error}}</div>
{{/if}}
<h3>Forgot your Password?</h3>
<h3>{{i18n 'forgotPassword'}}</h3>
<form id='forgotPassword'>
<div class="form-group">
<input type="email" name="forgottenEmail" class="form-control" placeholder="Email address" value=''>
<input type="email" name="forgottenEmail" class="form-control" placeholder="{{i18n 'emailAddress'}}" value=''>
</div>
<button type="submit" class="btn btn-default">Email Reset Link</button>
<button type="submit" class="btn btn-default">{{i18n 'emailResetLink'}}</button>
</form>
<p class="entry-signup-cta">Don't have an account? <a href="/sign-up">Sign up</a></p>
{{#if showSignupCode}}
<p class="entry-signup-cta">{{i18n 'dontHaveAnAccount'}} <a href="/sign-up">{{i18n 'signUp'}}</a></p>
{{/if}}
</div>
</div>
</template>
Expand Down
8 changes: 5 additions & 3 deletions client/views/resetPassword/resetPassword.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
{{#if error}}
<div class='alert alert-danger'>{{error}}</div>
{{/if}}
<h3>Reset your Password</h3>
<h3>{{i18n "resetYourPassword"}}</h3>
<form id='resetPassword'>
<div class="form-group">
<input type="password" name="new-password" class="form-control" value=''>
</div>
<button type="submit" class="btn btn-default">Update your password</button>
<button type="submit" class="btn btn-default">{{i18n "updateYourPassword"}}</button>
</form>
<p class="entry-signup-cta">Don't have an account? <a href="/sign-up">Sign up</a></p>
{{#if showSignupCode}}
<p class="entry-signup-cta">{{i18n 'dontHaveAnAccount'}} <a href="/sign-up">{{i18n 'signUp'}}</a></p>
{{/if}}
</div>
</div>
</template>
4 changes: 2 additions & 2 deletions client/views/signIn/signIn.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Template.entrySignIn.helpers
'USERNAME_AND_EMAIL'
'USERNAME_AND_OPTIONAL_EMAIL'
], fields)
return 'Username or email'
return i18n("usernameOrEmail")

return 'Email'
return i18n("email")

logo: ->
AccountsEntry.settings.logo
Expand Down
14 changes: 8 additions & 6 deletions client/views/signIn/signIn.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@
{{> entrySocial}}
{{/each}}
<div class="email-option">
<strong class="line-thru or-sign-in">OR</strong>
<strong class="line-thru or-sign-in">{{i18n "OR"}}</strong>
</div>
</div>
{{/if}}
{{> entryError}}
{{#unless otherLoginServices}}
<div class="email-option">
<h3>Sign In</h3>
<h3>{{i18n "signIn"}}</h3>
</div>
{{/unless}}
<form class="entry-form" id='signIn'>
<div class="form-group">
<input name="email" type="{{emailInputType}}" class="form-control" value='{{email}}' placeholder="{{emailPlaceholder}}">
</div>
<div class="form-group">
<input name="password" type="password" class="form-control" value='{{password}}' placeholder="Password">
<input name="password" type="password" class="form-control" value='{{password}}' placeholder="{{i18n 'password'}}">
</div>
<p><a href="/forgot-password">Forgot password?</a></p>
<button type="submit" class="submit btn btn-default">Sign in</button>
<p><a href="/forgot-password">{{i18n "forgotPassword"}}</a></p>
<button type="submit" class="submit btn btn-default">{{i18n "signIn"}}</button>
</form>
<p class="entry-signup-cta">Don't have an account? <a href="/sign-up">Sign up</a></p>
{{#if showSignupCode}}
<p class="entry-signup-cta">{{i18n "dontHaveAnAccount"}} <a href="/sign-up">{{i18n "signUp"}}</a></p>
{{/if}}
</div>
</div>
</div>
Expand Down
15 changes: 8 additions & 7 deletions client/views/signUp/signUp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ Template.entrySignUp.events
errMsg = []
msg = false
if password.length < 7
errMsg.push "7 character minimum password."
errMsg.push i18n("error.minChar")
if password.search(/[a-z]/i) < 0
errMsg.push "Password requires 1 letter."
errMsg.push i18n("error.pwOneLetter")
if password.search(/[0-9]/) < 0
errMsg.push "Password must have at least one digit."
errMsg.push i18n("error.pwOneDigit")

if errMsg.length > 0
msg = ""
Expand All @@ -97,17 +97,18 @@ Template.entrySignUp.events
'USERNAME_ONLY'], fields)

if usernameRequired && email.length is 0
Session.set('entryError', 'Username is required')
Session.set('entryError', i18n("error.uernameRequired"))
return

if emailRequired && email.length is 0
Session.set('entryError', 'Email is required')
Session.set('entryError', i18n("error.emailRequired"))
return

if AccountsEntry.settings.showSignupCode && signupCode.length is 0
Session.set('entryError', 'Signup code is required')
Session.set('entryError', i18n("error.signupCodeRequired"))
return


Meteor.call('entryValidateSignupCode', signupCode, (err, valid) ->
if err
console.log err
Expand All @@ -130,7 +131,7 @@ Template.entrySignUp.events
Router.go AccountsEntry.settings.dashboardRoute
)
else
Session.set('entryError', 'Signup code is incorrect')
Session.set('entryError', i18n("error.signupCodeIncorrect"))
return
)

30 changes: 15 additions & 15 deletions client/views/signUp/signUp.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,61 @@
<div class="entry col-md-4 col-md-offset-4">
<h3>Create an Account</h3>
{{#if otherLoginServices}}
<p class="entry-signin-cta">If you already have an account <a href="/sign-in">sign in</a>.</p>
<p class="entry-signin-cta">{{i18n "ifYouAlreadyHaveAnAccount"}} <a href="/sign-in">{{i18n "signin"}}</a>.</p>
<div class="entry-social">
{{#each loginServices}}
{{> entrySocial}}
{{/each}}
<div class="email-option">
<strong class="line-thru">OR</strong>
<a data-toggle="collapse" href="#signUp">
Sign up with your email address
{{i18n "signUpWithYourEmailAddress"}}
</a>
</div>
</div>
{{else}}
<p class="entry-signin-cta">If you already have an account <a href="/sign-in">sign in</a>.</p>
<p class="entry-signin-cta">{{i18n "ifYouAlreadyHaveAnAccount"}}t <a href="/sign-in">{{i18n "signin"}}</a>.</p>
{{/if}}
{{> entryError}}
<form class="entry-form {{signupClass}}" id='signUp'>
{{#if showUsername}}
<div class="form-group">
<label>Username</label>
<label>{{i18n "username"}}</label>
<input name="username" type="string" class="form-control" value=''>
</div>
{{/if}}

{{#if showEmail}}
<div class="form-group">
<label>Email Address</label>
<input type="email" class="form-control" value=''{{#if emailIsOptional}} placeholder="Optional"{{/if}}>
<label>{{i18n "emailAddress"}}</label>
<input type="email" class="form-control" value=''{{#if emailIsOptional}} placeholder="{{i18n 'optional'}}"{{/if}}>
</div>
{{/if}}

<div class="form-group">
<label>Password</label>
<label>{{i18n "password"}}</label>
<input type="password" class="form-control" value=''>
</div>

{{#if showSignupCode}}
<div class="form-group">
<label>Signup Code</label>
<label>{{i18n "signupCode"}}</label>
<input name="signupCode" type="string" class="form-control" value=''>
</div>
{{/if}}

<button type="submit" class="submit btn btn-default">Sign up</button>
<button type="submit" class="submit btn btn-default">{{i18n "signUp"}}</button>
</form>
{{#if both}}
<p class="entry-agreement">By clicking Sign up, you agree to our
<a href="{{privacyUrl}}">Privacy Policy</a> and
<a href="{{termsUrl}}">Terms of Use</a>.
<p class="entry-agreement">{{i18n "clickAgree"}}
<a href="{{privacyUrl}}">{{i18n "privacyPolicy"}}</a> and
<a href="{{termsUrl}}">{{i18n "terms"}}</a>.
</p>
{{else}}
{{#unless neither}}
<p class="entry-agreement">By clicking Sign up, you agree to our
{{#if privacyUrl}}<a href="{{privacyUrl}}">Privacy Policy</a>.{{/if}}
{{#if termsUrl}}<a href="{{termsUrl}}">Terms of Use</a>.{{/if}}
<p class="entry-agreement">{{i18n "clickAgree"}}
{{#if privacyUrl}}<a href="{{privacyUrl}}">{{i18n "privacyPolicy"}}</a>.{{/if}}
{{#if termsUrl}}<a href="{{termsUrl}}">{{i18n "terms"}}</a>.{{/if}}
</p>
{{/unless}}
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion client/views/social/social.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Template.entrySocial.events
loginButtonsSession.configureService(serviceName)
else
# FIX THIS
loginButtonsSession.errorMessage(err.reason || "Unknown error")
loginButtonsSession.errorMessage(err.reason || i18n("error.unknown"))
loginWithService = Meteor["loginWith" + capitalize(serviceName)]
options = {}

Expand Down
4 changes: 2 additions & 2 deletions client/views/social/social.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template name='entrySocial'>
<button class="btn" id="entry-{{this}}" name="{{this}}">
{{#if google}}
<i class="fa fa-{{this}}-plus"></i> Sign {{buttonText}} with {{capitalize this}}</button>
<i class="fa fa-{{this}}-plus"></i> {{i18n "sign"}} {{buttonText}} {{i18n "with"}} {{capitalize this}}</button>
{{else}}
<i class="fa fa-{{this}}"></i> Sign {{buttonText}} with {{capitalize this}}</button>
<i class="fa fa-{{this}}"></i> {{i18n "sign"}} {{buttonText}} {{i18n "with"}} {{capitalize this}}</button>
{{/if}}
</template>
6 changes: 5 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ Package.on_use(function(api) {
'client/views/error/error.html',
'client/views/error/error.coffee',
'client/views/accountButtons/accountButtons.html',
'client/views/accountButtons/accountButtons.coffee'
'client/views/accountButtons/accountButtons.coffee',
'client/i18n/english.coffee',
'client/i18n/spanish.coffee'
], 'client');

// SERVER
Expand All @@ -55,6 +57,8 @@ Package.on_use(function(api) {
api.imply('accounts-base', ['client', 'server']);
api.export('AccountsEntry', ['client', 'server']);
api.use('iron-router', ['client', 'server']);
api.use('just-i18n', ['client']);
api.use('headers', ['client']);
api.add_files(['shared/router.coffee'], ['client', 'server']);

});
3 changes: 2 additions & 1 deletion smart.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"version": "0.4.4",
"git": "https://github.com/BeDifferential/accounts-entry.git",
"packages": {
"iron-router": "0.6.1"
"iron-router": "0.6.1",
"just-i18n": {}
}
}