2018-12-29 01:27:37 +01:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { readOnly } from '@ember/object/computed';
|
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
2016-06-20 19:28:10 +02:00
|
|
|
import localesMeta from 'croodle/locales/meta';
|
2015-11-20 02:18:19 +01:00
|
|
|
|
2016-08-02 01:55:48 +02:00
|
|
|
export default Component.extend({
|
2015-11-20 02:18:19 +01:00
|
|
|
tagName: 'select',
|
|
|
|
classNames: [ 'language-select' ],
|
2018-12-29 01:27:37 +01:00
|
|
|
i18n: service(),
|
|
|
|
moment: service(),
|
|
|
|
current: readOnly('i18n.locale'),
|
2015-11-20 02:18:19 +01:00
|
|
|
|
2016-08-02 01:55:48 +02:00
|
|
|
locales: computed('i18n.locales', function() {
|
2016-01-19 05:46:52 +01:00
|
|
|
let currentLocale = this.get('i18n.locale');
|
2015-12-07 22:21:38 +01:00
|
|
|
|
2016-01-19 05:46:52 +01:00
|
|
|
return this.get('i18n.locales').map(function(locale) {
|
2015-12-07 22:21:38 +01:00
|
|
|
return {
|
|
|
|
id: locale,
|
|
|
|
selected: locale === currentLocale,
|
2016-06-20 19:28:10 +02:00
|
|
|
text: localesMeta[locale]
|
2015-12-07 22:21:38 +01:00
|
|
|
};
|
2015-11-20 02:18:19 +01:00
|
|
|
});
|
|
|
|
}),
|
|
|
|
|
|
|
|
change() {
|
2016-01-19 05:46:52 +01:00
|
|
|
let locale = this.$().val();
|
2015-11-23 13:32:40 +01:00
|
|
|
this.get('i18n').set('locale', locale);
|
2015-11-20 02:18:19 +01:00
|
|
|
}
|
|
|
|
});
|