Completed dynamic I18n intetegration.
travis-web starts in English. When the user logs in, it switches to their locale, when they logout, it goes back to english.
This commit is contained in:
parent
667722c663
commit
e4fb6c1fee
|
@ -41,6 +41,7 @@
|
||||||
Travis.storage.removeItem('travis.user')
|
Travis.storage.removeItem('travis.user')
|
||||||
Travis.storage.removeItem('travis.token')
|
Travis.storage.removeItem('travis.token')
|
||||||
Travis.sessionStorage.clear()
|
Travis.sessionStorage.clear()
|
||||||
|
Travis.setLocale Travis.default_locale
|
||||||
@setData()
|
@setData()
|
||||||
|
|
||||||
trySignIn: ->
|
trySignIn: ->
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
@afterSignIn(data.user) if data?.user
|
@afterSignIn(data.user) if data?.user
|
||||||
|
|
||||||
afterSignIn: (user) ->
|
afterSignIn: (user) ->
|
||||||
|
Travis.setLocale user.locale || Travis.default_locale
|
||||||
Travis.trigger('user:signed_in', user)
|
Travis.trigger('user:signed_in', user)
|
||||||
@get('app.router').send('afterSignIn', @readAfterSignInPath())
|
@get('app.router').send('afterSignIn', @readAfterSignInPath())
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ require 'travis/model'
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
updateLocale: (locale) ->
|
updateLocale: (locale) ->
|
||||||
Travis.updateLocale(locale)
|
|
||||||
@setWithSession('locale', locale)
|
|
||||||
|
|
||||||
transaction = @get('transaction')
|
transaction = @get('transaction')
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
|
@ -46,6 +44,7 @@ require 'travis/model'
|
||||||
transaction.add self
|
transaction.add self
|
||||||
|
|
||||||
@addObserver 'isSaving', observer
|
@addObserver 'isSaving', observer
|
||||||
|
Travis.setLocale(locale)
|
||||||
|
|
||||||
type: (->
|
type: (->
|
||||||
'user'
|
'user'
|
||||||
|
|
|
@ -12,13 +12,6 @@
|
||||||
# popup: (event) ->
|
# popup: (event) ->
|
||||||
# console.log event
|
# console.log event
|
||||||
|
|
||||||
localeDidChange: (->
|
|
||||||
if locale = Travis.app.get('auth.user.locale')
|
|
||||||
if Travis.needsLocaleChange(locale)
|
|
||||||
Travis.setLocale(locale)
|
|
||||||
Travis.app.get('router').reload()
|
|
||||||
).observes('Travis.app.auth.user.locale')
|
|
||||||
|
|
||||||
click: (event) ->
|
click: (event) ->
|
||||||
# TODO: this solves the case of closing menus and popups,
|
# TODO: this solves the case of closing menus and popups,
|
||||||
# but I would like to rewrite it later, not sure how
|
# but I would like to rewrite it later, not sure how
|
||||||
|
|
|
@ -75,7 +75,7 @@ Storage = Em.Object.extend
|
||||||
|
|
||||||
storage
|
storage
|
||||||
)()
|
)()
|
||||||
|
default_locale: 'en'
|
||||||
sessionStorage: (->
|
sessionStorage: (->
|
||||||
storage = null
|
storage = null
|
||||||
try
|
try
|
||||||
|
@ -93,7 +93,7 @@ Storage = Em.Object.extend
|
||||||
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
|
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
|
||||||
|
|
||||||
I18n.fallbacks = true
|
I18n.fallbacks = true
|
||||||
Travis.set 'locale', 'en'
|
Travis.setLocale 'locale', @defualt_locale
|
||||||
|
|
||||||
Ember.run.next this, ->
|
Ember.run.next this, ->
|
||||||
app = Travis.App.create(attrs || {})
|
app = Travis.App.create(attrs || {})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user