Rework the language switcher for current language support

This commit is contained in:
2015-02-21 15:47:07 +01:00
parent c8109c8ad6
commit f082bdf191
8 changed files with 27 additions and 1 deletions
@@ -1,7 +1,9 @@
App.LanguageSwitcherComponent = Ember.Component.extend
classNames: ['language-switcher-container']
locales: (-> ['en', 'nl']).property()
current_locale: (-> Qstorage.getItem('locale') ).property()
actions:
switchTo: (locale)->
setLocale locale
@set 'current_locale', locale
@get('targetObject.store').all("page").invoke 'reload'
@@ -0,0 +1,5 @@
Ember.Handlebars.helper 'isCurrentLocale', (locale, options)->
if locale is 'nl'
options.fn @
else
options.inverse @
@@ -1,2 +1,2 @@
each locale in locales
a.language-switch-button{ action "switchTo" locale}= flag locale
view language-switcher-button locale=locale
@@ -0,0 +1,8 @@
App.LanguageSwitcherButtonView = Ember.View.extend
tagName: 'a'
templateName: 'components/language-switcher-button'
classNameBindings: ['isCurrent:current']
classNames: ['language-switch-button']
isCurrent: Ember.computed 'locale', 'controller.current_locale', ->
@get('locale') is @get('controller.current_locale')
click: -> @get('controller').send 'switchTo', @get('locale')