Skip to content

Expose the detected locale part #4

@sebastien-p

Description

@sebastien-p

Let's say I want to write a requirejs plugin which would be based on i18n but including some more features like :

  • Dynamic generation of an array of all supported languages for a given bundle ([{ code: "en", name: "English", root: true, current: false }, { code: "fr", name: "Français", current: true }, ...])
  • ...

Why ? Mainly in order to help providing a language picker (select menu, flags or whatever) in my applications.

Generating the array is easy but knowing which locale part has been detected by the i18n plugin is not currently possible because the value isn't exposed somehow.

In addition to making my life easier, I think appending that functionality to the official i18n requirejs plugin could be useful to other plugin developers too.

Adding something like value._currentLocale = needed.slice(-1)[0] just before onLoad(value) (line 175) does the trick but I'm pretty sure one can find a better solution.

Hopefully my english wasn't too bad and you get the point of this "issue". Thanks.

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