Comments (7)
Can you show the relevant translations? Do you have multiple locales? What version are you using?
Given 'prototypes.defaultNewPrototypeName', {count: 3}
, ember-i18n doesn't know whether you have translations like
prototypes:
defaultNewPrototypeName: 'something with {{count}}'
or like
prototypes:
defaultNewPrototypeName:
one: 'one new default property name'
other: '{{count}} new default property names'
So it first looks for prototypes.defaultNewPropertyName.other
, then falls back to prototypes.defaultNewPropertyName
.
We'll need more of your setup to be able to replicate the failure.
from ember-i18n.
As you said, I think it's related to my setup.
I play a bit with a twiddle and it seems to be ok: https://ember-twiddle.com/#/910eefc652a09838b15674ffe8e39cd3
I will reopen the issue if I find an error I can't explain.
from ember-i18n.
Thanks!
from ember-i18n.
Sorry, now I was able to reproduce the issue.
https://ember-twiddle.com/910eefc652a09838b15674ffe8e39cd3
console.log(this.get('i18n').t('plural', {count: 1}).toString()); // Missing translation: plural
console.log(this.get('i18n').t('plural', {count: 0}).toString()); // Zero plural
console.log(this.get('i18n').t('plural', {count: 1}).toString()); // Zero plural
This is strange to me, I would expect that t('plural', {count: 1})
always returns the same string.
from ember-i18n.
I won't be able to look into this in the near future, but I hope that this excellent reproduction will make it easy for the community to solve :)
from ember-i18n.
The problem is that both _defineMissingTranslationTemplate
and _compileTemplate
set this.translations[key] = something;
and they do not take into account inflection
generated by pluralForm
, I think :)
I believe the two functions should receive the full key path, including the inflection, if count was set.
I am doing something like this:
Edit: I updated the code
findTranslation(fallbackChain, count) {
if (this.translations === undefined) { this._init(); }
let inflection;
if (count != null) {
inflection = this.pluralForm(+count);
}
let result;
let i;
for (i = 0; i < fallbackChain.length; i++) {
let key = fallbackChain[i];
if (count != null) {
result = this.translations[`${key}.${inflection}`];
// If result is null, fallback
if(result == null) {
result = this.translations[key]
}
// Always use key with inflection
key = `${key}.${inflection}`;
} else {
result = this.translations[key]
}
if (result) {
return {
key: key,
result: result
};
}
}
return {
key: count == null ? fallbackChain[0] : `${fallbackChain[0]}.${inflection}`,
result: result
};
},
from ember-i18n.
jamesarosen/ember-i18n has been deprecated in favor of ember-intl.
from ember-i18n.
Related Issues (20)
- Adding a `scope` option HOT 3
- Compatibility with fastboot?
- helper creates Ember.Object.extend().create() HOT 3
- emberGetownerPolyfill issue in i18n service HOT 4
- Refactor test helpers
- Passing in multiple translation keys (perhaps to Safely concat them together?) HOT 11
- Setting locale as described fails HOT 2
- switching language locally, not globally HOT 2
- require in get-locales clashes with other locally defined requires HOT 10
- Quest: intent to deprecate HOT 18
- Issue using ember-i18n in qunit 4.2.1 and ember-cli version 2.18.2 HOT 12
- Call a translation key dynamically HOT 2
- Getting a language value from locale in a template HOT 4
- Dynamic update of <html lang="en"> with FastBoot support HOT 2
- Interpolating quotes HOT 2
- ;import Service from "ember-i18n/service"; HOT 2
- Babel error HOT 1
- undefined is not an object (evaluating 'this.get('i18n').t') HOT 1
- _locale Computed property is not called more than once HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-i18n.