Merge pull request #78 from randym/i18n

Updates and Fixes for Profile and UI to properly handle locale switching
This commit is contained in:
Piotr Sarnacki 2012-12-11 07:07:54 -08:00
commit 4657ee351b
21 changed files with 120 additions and 53 deletions

View File

@ -1,3 +1,3 @@
---
:polled_at: 1354548824
:updated_at: 1354548824
:polled_at: 1355195128
:updated_at: 1355195128

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

@ -1,3 +1,4 @@
require 'helpers/handlebars'
require 'helpers/helpers'
require 'helpers/urls'
require 'helpers/i18n_handlebars'

View File

@ -6,9 +6,6 @@ safe = (string) ->
Handlebars.registerHelper 'tipsy', (text, tip) ->
safe '<span class="tool-tip" original-title="' + tip + '">' + text + '</span>'
Handlebars.registerHelper 't', (key) ->
safe I18n.t(key)
Ember.registerBoundHelper 'capitalize', (value, options) ->
if value?
safe $.capitalize(value)

View File

@ -0,0 +1,34 @@
I18nBoundView = Ember.View.extend Ember._Metamorph, {
key: null,
valueDidChange: ->
return if this.morph.isRemoved()
this.morph.html(this.valueForRender())
valueForRender: ->
new Handlebars.SafeString I18n.t(this.key)
init: ->
this._super()
Travis.addObserver('locale', this, 'valueDidChange')
didInsertElement: ->
this.valueDidChange()
destroy: ->
Travis.removeObserver('locale', this, 'valueDidChange')
this._super()
render: (buffer) ->
buffer.push(this.valueForRender())
}
Ember.Handlebars.registerHelper 't', (key, options) ->
view = options.data.view
bindView = view.createChildView(I18nBoundView, { key: key })
view.appendChild(bindView)
# dont write any content from this helper, let the child view
# take care of itself.
false

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,8 +32,7 @@ require 'travis/model'
).property()
updateLocale: (locale) ->
@setWithSession('locale', locale)
transaction = @get('transaction')
transaction.commit()
@ -45,6 +44,7 @@ require 'travis/model'
transaction.add self
@addObserver 'isSaving', observer
Travis.setLocale(locale)
type: (->
'user'

View File

@ -115,6 +115,7 @@ Travis.Router = Ember.Router.extend
router.get('accountsController').set('content', Travis.Account.find())
router.get('applicationController').connectOutlet 'top', 'top'
router.get('applicationController').connectOutlet 'left', 'accounts'
router.get('applicationController').connectOutlet 'flash', 'flash'
index: Ember.Route.extend
route: '/'

View File

@ -25,18 +25,16 @@
{{user.token}}
</dd>
</div>
<div>
<dt>
{{t profiles.show.locale}}:
</dt>
<dd>
{{view Ember.Select id="locale"
contentBinding="view.locales"
valueBinding="Travis.app.currentUser.locale"
optionLabelPath="content.name"
optionValuePath="content.key"}}
</dd>
</div>
</dl>
<form>
{{view Ember.Select id="locale"
contentBinding="view.locales"
valueBinding="Travis.app.currentUser.locale"
optionLabelPath="content.name"
optionValuePath="content.key"}}
<button name="commit" {{action saveLocale target="view"}}>
{{t profiles.show.update_locale}}
</button>
</form>

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

@ -44,26 +44,25 @@
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
).property('user.gravatarId')
# locale: (->
# @get('user.locale')
# ).property('user.locale')
locale: (->
@get('user.locale')
).property('user.locale')
locales: (->
[
{ key: null, name: '' }
{ key: 'en', name: 'English' }
{ key: 'ca', name: 'Catalan' }
{ key: 'cs', name: 'Čeština' }
{ key: 'es', name: 'Español' }
{ key: 'fr', name: 'Français' }
{ key: 'ja', name: '日本語' }
{ key: 'nl', name: 'Nederlands' }
{ key: 'nb', name: 'Norsk Bokmål' }
{ key: 'pl', name: 'Polski' }
{ key: 'pt-BR': name: 'Português brasileiro' }
{ key: 'pt-BR', name: 'Português brasileiro' }
{ key: 'ru', name: 'Русский' }
]
).property()
saveLocale: (event) ->
change: (event) ->
return unless $('#locale').val()
@get('user').updateLocale($('#locale').val())

File diff suppressed because one or more lines are too long

View File

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

View File

@ -19,6 +19,7 @@ en:
sponsored_by: This test series was run on a worker box sponsored by
name: Build
started_at: Started
state: state
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ en:
sponsored_by: This test series was run on a worker box sponsored by
sponsored_by:
started_at: Started
state: state
layouts:
about:
alpha: This stuff is alpha.
@ -82,6 +84,7 @@ en:
job: Job
log: Log
top:
accounts: accounts
admin: Admin
blog: Blog
docs: Docs
@ -89,6 +92,7 @@ en:
home: Home
profile: Profile
sign_out: Sign Out
signing_in: signing_in
stats: Stats
locales:
ca:
@ -106,6 +110,7 @@ en:
show:
email: Email
github: Github
locale: Locale
message:
config: how to configure custom build options
your_repos: ! " Flick the switches below to turn on the Travis service hook for your projects, then push to GitHub.<br />\n To test against multiple rubies, see"
@ -118,6 +123,7 @@ en:
your_repos: Your Repositories
queue: Queue
repositories:
asciidoc: asciidoc
branch: Branch
commit: Commit
duration: Duration
@ -136,7 +142,6 @@ en:
pull_requests: Pull Requests
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Duration
statistics:

View File

@ -19,6 +19,7 @@ es:
sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por
name: Build
started_at: Iniciado
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ es:
sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por
sponsored_by: Patrocinado por
started_at: Iniciado
state:
layouts:
about:
alpha: Esto es alpha.
@ -82,6 +84,7 @@ es:
job: Trabajo
log: Registro
top:
accounts:
admin: Admin
blog: Blog
docs: Documentación
@ -89,6 +92,7 @@ es:
home: Inicio
profile: Perfil
sign_out: Desconectar
signing_in:
stats: Estadísticas
locales:
ca:
@ -106,6 +110,7 @@ es:
show:
email: email
github: Github
locale:
message:
config: como configurar tus propias opciones para el Build
your_repos: ! " Activa los interruptores para inicial el Travis service hook para tus proyectos, y haz un Push en GitHub.<br />\n Para probar varias versiones de ruby, mira"
@ -118,6 +123,7 @@ es:
your_repos: Tus repositorios
queue: Cola
repositories:
asciidoc:
branch: Rama
commit: Commit
duration: Duración
@ -136,7 +142,6 @@ es:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Duración
statistics:

View File

@ -19,6 +19,7 @@ fr:
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
name: Version
started_at: Commencé
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ fr:
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
started_at: Commencé
state:
layouts:
about:
alpha: Ceci est en alpha.
@ -82,6 +84,7 @@ fr:
job: Tâche
log: Journal
top:
accounts:
admin: Admin
blog: Blog
docs: Documentation
@ -89,6 +92,7 @@ fr:
home: Accueil
profile: Profil
sign_out: Déconnexion
signing_in:
stats: Statistiques
locales:
ca:
@ -106,6 +110,7 @@ fr:
show:
email: Courriel
github: Github
locale:
message:
config: comment configurer des options de version personnalisées
your_repos: ! 'Utilisez les boutons ci-dessous pour activer Travis sur vos projets puis déployez sur GitHub.<br />
@ -120,6 +125,7 @@ fr:
your_repos: Vos dépôts
queue: File
repositories:
asciidoc:
branch: Branche
commit: Commit
duration: Durée
@ -138,7 +144,6 @@ fr:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Durée
statistics:

View File

@ -19,6 +19,7 @@ ja:
sponsored_by: このテストは以下のスポンサーの協力で行いました。
name: ビルド
started_at: 開始時刻
state:
datetime:
distance_in_words:
hours_exact:
@ -47,6 +48,7 @@ ja:
sponsored_by: このテストは以下のスポンサーの協力で行いました。
sponsored_by:
started_at: 開始時刻
state:
layouts:
about:
alpha: まだアルファですよ!
@ -76,6 +78,7 @@ ja:
job: ジョブ
log: ログ
top:
accounts:
admin: 管理
blog: ブログ
docs: Travisとは
@ -83,6 +86,7 @@ ja:
home: ホーム
profile: プロフィール
sign_out: ログアウト
signing_in:
stats: 統計
locales:
ca:
@ -100,6 +104,7 @@ ja:
show:
email: メール
github: Github
locale: 言語
message:
config: 詳細設定
your_repos: 以下のスイッチを設定し、Travis-ciを有効にします。Githubへプッシュしたらビルドは自動的に開始します。複数バーションや細かい設定はこちらへ
@ -112,6 +117,7 @@ ja:
your_repos: リポジトリ
queue: キュー
repositories:
asciidoc:
branch: ブランチ
commit: コミット
duration: 処理時間
@ -130,7 +136,6 @@ ja:
pull_requests: プルリクエスト
test:
textile: .textile
asciidoc: .asciidoc
repository:
duration: 時間
statistics:

View File

@ -19,6 +19,7 @@ nb:
sponsored_by: Denne testen ble kjørt på en maskin sponset av
name: Jobb
started_at: Startet
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ nb:
sponsored_by: Denne testserien ble kjørt på en maskin sponset av
sponsored_by:
started_at: Startet
state:
layouts:
about:
alpha: Dette er alfa-greier.
@ -82,6 +84,7 @@ nb:
job: Jobb
log: Logg
top:
accounts:
admin: Administrator
blog: Blogg
docs: Dokumentasjon
@ -89,6 +92,7 @@ nb:
home: Hjem
profile: Profil
sign_out: Logg ut
signing_in:
stats: Statistikk
locales:
ca:
@ -106,6 +110,7 @@ nb:
show:
email: E-post
github: Github
locale:
message:
config: hvordan sette opp egne jobbinnstillinger
your_repos: ! "Slå\x10 på Travis for prosjektene dine ved å dra i bryterne under, og send koden til Github.<br />\nFor å teste mot flere versjoner av ruby, se "
@ -118,6 +123,7 @@ nb:
your_repos: Dine kodelagre
queue:
repositories:
asciidoc:
branch: Gren
commit: Innsender
duration: Varighet
@ -136,7 +142,6 @@ nb:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Varighet
statistics:

View File

@ -19,6 +19,7 @@ nl:
sponsored_by: Deze tests zijn gedraaid op een machine gesponsord door
name: Bouw
started_at: Gestart
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ nl:
sponsored_by: Deze testen zijn uitgevoerd op een machine gesponsord door
sponsored_by:
started_at: Gestart
state:
layouts:
about:
alpha: Dit is in alfa-stadium.
@ -82,6 +84,7 @@ nl:
job: Taak
log: Logboek
top:
accounts:
admin: Administratie
blog: Blog
docs: Documentatie
@ -89,6 +92,7 @@ nl:
home: Home
profile: Profiel
sign_out: Uitloggen
signing_in:
stats: Statistieken
locales:
ca:
@ -106,6 +110,7 @@ nl:
show:
email: Email adres
github: Github
locale:
message:
config: hoe eigen bouw-opties in te stellen
your_repos: ! 'Zet de schakelaars hieronder aan om de Travis hook voor uw projecten te activeren en push daarna naar Github<br />
@ -120,6 +125,7 @@ nl:
your_repos: Uw repositories
queue: Wachtrij
repositories:
asciidoc:
branch: Tak
commit: Commit
duration: Duur
@ -138,7 +144,6 @@ nl:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Duur
statistics:

View File

@ -19,6 +19,7 @@ pl:
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
name: Build
started_at: Rozpoczęto
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ pl:
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
started_at: Rozpoczęto
state:
layouts:
about:
alpha: To wciąż jest wersja alpha.
@ -82,6 +84,7 @@ pl:
job: Zadanie
log: Log
top:
accounts:
admin:
blog: Blog
docs: Dokumentacja
@ -89,6 +92,7 @@ pl:
home: Start
profile: Profil
sign_out: Wyloguj się
signing_in:
stats: Statystki
locales:
ca:
@ -106,6 +110,7 @@ pl:
show:
email: Email
github: Github
locale:
message:
config: jak skonfigurować niestandardowe opcje builda
your_repos: ! " Przesuń suwak poniżej, aby włączyć Travisa, dla twoich projektów, a następnie umieść swój kod na GitHubie.<br />\n Aby testować swój kod przy użyciu wielu wersji Rubiego, zobacz"
@ -118,6 +123,7 @@ pl:
your_repos: Twoje repozytoria
queue: Kolejka
repositories:
asciidoc:
branch: Gałąź
commit: Commit
duration: Czas trwania
@ -136,7 +142,6 @@ pl:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration:
statistics:

View File

@ -19,6 +19,7 @@ pt-BR:
sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por
name: Build
started_at: Iniciou em
state:
datetime:
distance_in_words:
hours_exact:
@ -53,6 +54,7 @@ pt-BR:
sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por
sponsored_by:
started_at: Iniciou em
state:
layouts:
about:
alpha: Isto é um alpha.
@ -82,6 +84,7 @@ pt-BR:
job: Trabalho
log: Log
top:
accounts:
admin: Admin
blog: Blog
docs: Documentação
@ -89,6 +92,7 @@ pt-BR:
home: Home
profile: Perfil
sign_out: Sair
signing_in:
stats: Estatísticas
locales:
ca:
@ -106,6 +110,7 @@ pt-BR:
show:
email: Email
github: Github
locale:
message:
config: como configurar opções de build
your_repos: Use os botões abaixo para ligar ou desligar o hook de serviço do Travis para seus projetos, e então, faça um push para o Github.<br />Para testar com múltiplas versões do Ruby, leia
@ -118,6 +123,7 @@ pt-BR:
your_repos: Seus Repositórios
queue: Fila
repositories:
asciidoc:
branch: Branch
commit: Commit
duration: Duração
@ -136,7 +142,6 @@ pt-BR:
pull_requests:
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Duração
statistics:

View File

@ -19,6 +19,7 @@ ru:
sponsored_by: Эта серия тестов была запущена на машине, спонсируемой
name: Билд
started_at: Начало
state:
datetime:
distance_in_words:
hours_exact:
@ -59,6 +60,7 @@ ru:
sponsored_by: Эта серия тестов была запущена на машине спонсируемой
sponsored_by:
started_at: Начало
state:
layouts:
about:
alpha: Это альфа-версия
@ -88,6 +90,7 @@ ru:
job: Задача
log: Журнал
top:
accounts:
admin: Управление
blog: Блог
docs: Документация
@ -95,6 +98,7 @@ ru:
home: Главная
profile: Профиль
sign_out: Выход
signing_in:
stats: Статистика
locales:
ca:
@ -112,6 +116,7 @@ ru:
show:
email: Электронная почта
github: Github
locale:
message:
config: как настроить специальные опции билда
your_repos: ! 'Используйте переключатели, чтобы включить Travis service hook для вашего проекта, а потом отправьте код на GitHub.<br />
@ -126,6 +131,7 @@ ru:
your_repos: Ваши репозитории
queue: Очередь
repositories:
asciidoc:
branch: Ветка
commit: Коммит
duration: Длительность
@ -144,7 +150,6 @@ ru:
pull_requests: Запросы на Pull
test:
textile: Textile
asciidoc: AsciiDoc
repository:
duration: Длительность
statistics: