zewa666 / aurelia-i18next

An Aurelia-Wrapper for the i18next library
MIT License
17 stars 15 forks source link

error related to relativeTime default translations #25

Closed atsu85 closed 9 years ago

atsu85 commented 9 years ago

I've got a question for You regarding this line: https://github.com/zewa666/aurelia-i18next/blob/master/src/relativeTime.js#L9 that currently tries to find translations from this file https://github.com/zewa666/aurelia-i18next/blob/master/src/defaultTranslations/relative.time.js with locale "default" that is currently missing and therefore results an error at https://github.com/zewa666/aurelia-i18next/blob/master/src/relativeTime.js#L9

Shouldn't the default translations (translations.default from that line) be detected based on plugin configuration:

.plugin('aurelia-i18next', (instance) => {
  instance.setup({
    lng : 'et', // <------- custom language not present in defaultTranslations/relative.time.js
    ...
  });
})

If so, I would use i18n.i18next.options.lng instead of default there.

Or maybe i have misconfigured smth or maybe line is never supposed to be executed as users are supposed to provide all the relativeTime translations in the main translations file?

Anyway it would make sense to provide better error message (with some instructions) than

Unhandled promise rejection Error: Error instantiating RelativeTime. Check the inner error for details. inner error: TypeError: Cannot convert undefined or null to object

zewa666 commented 9 years ago

Default here is no translation but the wrapping object containing all the translations. This is caused by the way how es6-module-loaders works I guess.

If you provide your own translation during setup it will take it if it exists. Otherwise it will look for the fallbackLng. So I wasn't able to reproduce your error :( Could you maybe create a unit test depicting the problem?

atsu85 commented 9 years ago

oh, it may be related to the fact, that my application won't have a two languages in foreseeable future - i'm using it to externalize texts/messages, so they can later be managed/changed from one place.

Maybe you can produce it by setting fallback language to the same value as default.

zewa666 commented 9 years ago

@atsu85 any update on this one?