Merge pull request #3276 from vincent99/master

Cache translated states
This commit is contained in:
Vincent Fiduccia 2019-08-19 17:19:56 -07:00 committed by GitHub
commit 6ab0bd2315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 17 deletions

View File

@ -1,9 +1,5 @@
{{#if hasBlock}} {{#if hasBlock}}
{{yield}} {{yield}}
{{else}} {{else}}
{{#if model.localizedState}} {{model.displayState}}
{{t model.localizedState}} {{/if}}
{{else}}
{{model.displayState}}
{{/if}}
{{/if}}

View File

@ -465,23 +465,20 @@ export default Mixin.create({
// This is like this so you can override the displayed state calculation // This is like this so you can override the displayed state calculation
displayState: alias('_displayState'), displayState: alias('_displayState'),
_displayState: computed('relevantState', function() { _displayState: computed('relevantState', 'intl.locale', function() {
var state = get(this, 'relevantState') || ''; const intl = get(this, 'intl');
const state = get(this, 'relevantState') || '';
const key = `resourceState.${ (state || 'unknown').toLowerCase() }`;
if ( intl.locale && intl.exists(key) ) {
return intl.t(key);
}
return state.split(/-/).map((word) => { return state.split(/-/).map((word) => {
return ucFirst(word); return ucFirst(word);
}).join('-'); }).join('-');
}), }),
localizedState: computed('relevantState', function() {
const intl = get(this, 'intl');
const key = `resourceState.${ (get(this, 'relevantState') || 'unknown').toLowerCase() }`;
if ( intl.exists(key) ) {
return key;
}
}),
showTransitioningMessage: computed('transitioning', 'transitioningMessage', 'displayState', function() { showTransitioningMessage: computed('transitioning', 'transitioningMessage', 'displayState', function() {
var trans = get(this, 'transitioning'); var trans = get(this, 'transitioning');