Fix shift-L for toggling language

This commit is contained in:
Vincent Fiduccia 2017-04-24 17:25:05 -07:00
parent 5a5424f5e7
commit fd2f55f60b
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
3 changed files with 16 additions and 10 deletions

View File

@ -145,7 +145,7 @@ export default Ember.Component.extend(NewOrEdit, SelectTab, {
}); });
return out; return out;
}.property('service.name','service.secondaryLaunchConfigs.@each.name','intl._locale'), }.property('service.name','service.secondaryLaunchConfigs.@each.name','intl.locale'),
noLaunchConfigsEnabled: function() { noLaunchConfigsEnabled: function() {
return this.get('launchConfigChoices').filterBy('enabled',true).get('length') === 0; return this.get('launchConfigChoices').filterBy('enabled',true).get('length') === 0;

View File

@ -21,6 +21,7 @@ export default Ember.Component.extend(HoverDropdown, {
currentPath : null, currentPath : null,
// Injections // Injections
intl : Ember.inject.service(),
projects : Ember.inject.service(), projects : Ember.inject.service(),
project : Ember.computed.alias('projects.current'), project : Ember.computed.alias('projects.current'),
projectId : Ember.computed.alias(`tab-session.${C.TABSESSION.PROJECT}`), projectId : Ember.computed.alias(`tab-session.${C.TABSESSION.PROJECT}`),
@ -53,6 +54,7 @@ export default Ember.Component.extend(HoverDropdown, {
init() { init() {
this._super(...arguments); this._super(...arguments);
this.get('intl.locale');
this.set('stacks', this.get('store').all('stack')); this.set('stacks', this.get('store').all('stack'));
this.set('hosts', this.get('store').all('host')); this.set('hosts', this.get('store').all('host'));
this.set('stackSchema', this.get('store').getById('schema','stack')); this.set('stackSchema', this.get('store').getById('schema','stack'));
@ -114,7 +116,8 @@ export default Ember.Component.extend(HoverDropdown, {
'stacks.@each.group', 'stacks.@each.group',
`prefs.${C.PREFS.ACCESS_WARNING}`, `prefs.${C.PREFS.ACCESS_WARNING}`,
'access.enabled', 'access.enabled',
'isAdmin' 'isAdmin',
'intl.locale'
), ),
// Utilities you can use in the condition() function to decide if an item is shown or hidden, // Utilities you can use in the condition() function to decide if an item is shown or hidden,

View File

@ -3,23 +3,26 @@ import missingMessage from 'ui/utils/intl/missing-message';
const { get, makeArray } = Ember; const { get, makeArray } = Ember;
export function initialize(instance) { export function initialize(instance) {
var intl = instance.lookup('service:intl'); let intl = instance.lookup('service:intl');
let adapter = intl.get('adapter');
intl.reopen({ adapter.reopen({
// calling findTranslationByKey with a null key explodes, make it return something _lookup: adapter.lookup,
_findTranslationByKey: intl.findTranslationByKey, lookup(locales, key) {
findTranslationByKey(key, locales) { locales = makeArray(locales || get(this, 'locale'));
locales = makeArray(locales || get(this, '_locale'));
if (locales[0] === 'none') { if (locales[0] === 'none') {
return missingMessage(key, locales); return missingMessage(key, locales);
} else if ( key ) { } else if ( key ) {
return this._findTranslationByKey(...arguments); return this._lookup(locales, key);
}else { }else {
return this._findTranslationByKey('generic.missing', locales); return this._lookup(locales, 'generic.missing');
} }
}, },
});
// @TODO use regular t with htmlSafe instead
intl.reopen({
tHtml(key, ...args) { tHtml(key, ...args) {
const [ options ] = args; const [ options ] = args;
const translation = this.findTranslationByKey(key, options && options.locale); const translation = this.findTranslationByKey(key, options && options.locale);