i18nPlugin icon indicating copy to clipboard operation
i18nPlugin copied to clipboard

Warning on object returns despite enabling `returnObjects`

Open ChlodAlejandro opened this issue 4 years ago • 1 comments

In my initialization function, I enabled returnObjects so that I can pull objects from the localization files.

await i18next.use(LanguageDetector).init({
    fallbackLng: this.fallbackLanguage,
    debug: true,
    returnObjects: true,
});

My files look like this (ui.json):

{
    "okCancel": {
        "ok": "OK",
        "cancel": "Cancel"
    }
}

For some reason, even with returnObjects initialized, when running i18next.t("ui:okCancel"), I'm notified of a Reference to object. The same issue occurs when running i18next.t("ui:okCancel", {returnObjects: true}). I'm led to believe this is something wrong with the plugin, since i18next supports returning objects. I've added a few screenshots below for reference. Hope this can get resolved soon. Thanks!

Screenshots

Initialization

initialization

Localization file

localization

Usage in code, with reported problem

usage in code

ChlodAlejandro avatar Dec 28 '20 11:12 ChlodAlejandro

Hi!

You're right, the plugin does not respond to init function params. This feature is to be done in future releases. There is no init function parsing (this feature is still experimental). So for now, I would implement additional setting "Enable return objects". I think I'll do it in the next release.

Regards

nyavro avatar Dec 28 '20 11:12 nyavro