Skip to content

Consider more than the primary subtag for useBrowserDefault #85

@danielhjacobs

Description

@danielhjacobs

https://www.npmjs.com/package/next-export-i18n#usebrowserdefault notes "Remember that next-export-i18n considers only the primary subtag, e.g., en-US from the will be read as en.

But this doesn't have to be the behavior, right? It would be nice for one website to support both Traditional and Simplified Chinese using this package, even though they both start with zh (zh-cn and zh-tw).

My idea is adjusting this function to get the language without the split if such translations exist, or otherwise use the split if those translations exist:

browserLang = (
(window.navigator.languages && window.navigator.languages[0]) ||
window.navigator.language
)
.split("-")[0]
.toLowerCase();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions