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:
Randy Morgan 2012-12-11 10:48:19 +09:00
parent 667722c663
commit e4fb6c1fee
4 changed files with 7 additions and 13 deletions

View File

@ -41,6 +41,7 @@
Travis.storage.removeItem('travis.user')
Travis.storage.removeItem('travis.token')
Travis.sessionStorage.clear()
Travis.setLocale Travis.default_locale
@setData()
trySignIn: ->
@ -65,6 +66,7 @@
@afterSignIn(data.user) if data?.user
afterSignIn: (user) ->
Travis.setLocale user.locale || Travis.default_locale
Travis.trigger('user:signed_in', user)
@get('app.router').send('afterSignIn', @readAfterSignInPath())

View File

@ -19,7 +19,7 @@ require 'travis/model'
Ember.run.next this, ->
transaction = @get('store').transaction()
transaction.add this
urlGithub: (->
"https://github.com/#{@get('login')}"
).property()
@ -32,9 +32,7 @@ require 'travis/model'
).property()
updateLocale: (locale) ->
Travis.updateLocale(locale)
@setWithSession('locale', locale)
transaction = @get('transaction')
transaction.commit()
@ -46,6 +44,7 @@ require 'travis/model'
transaction.add self
@addObserver 'isSaving', observer
Travis.setLocale(locale)
type: (->
'user'

View File

@ -12,13 +12,6 @@
# popup: (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) ->
# TODO: this solves the case of closing menus and popups,
# but I would like to rewrite it later, not sure how

View File

@ -75,7 +75,7 @@ Storage = Em.Object.extend
storage
)()
default_locale: 'en'
sessionStorage: (->
storage = null
try
@ -93,7 +93,7 @@ Storage = Em.Object.extend
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
I18n.fallbacks = true
Travis.set 'locale', 'en'
Travis.setLocale 'locale', @defualt_locale
Ember.run.next this, ->
app = Travis.App.create(attrs || {})