Skip to content

All languages become the same #223

@bbesseling

Description

@bbesseling

If the first load of language strings is the following:

        var version = {
            "qi18n-appversion": "1.21.4.170",
        };
        $.i18n().load({
            "en": version,
            "nl": version,
        });

then it appears that the single "version" JavaScript object will be used to store additional strings for each language.
If you then load:

         $.i18n().load({
             "en": { "qi18n-foo": "foo" },
             "nl": { "qi18n-foo": "bar" }
         });

all translations of all languages "en" and "nl" of "qi18n-foo" end up coming out as "bar".
If you reverse the order of the two loads everything works fine, because the strings from "version" are then instead merged into each unique internal object for each language.
Ideally, the load function of the library should always create new empty internal objects for each new language internally and then merge any newly loaded strings into them from parameters, possibly from single "versions"-like objects.
Not terribly important except that it cost me a day to figure out why all my strings were always the "nl" version, no matter what locale I set. Reversing the order of the language strings in the loads made them all come out the "en" translation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions