Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Language chosen as "ga" when AcceptLang only has English #16

Open
fnetX opened this issue Dec 9, 2022 · 0 comments
Open

[BUG] Language chosen as "ga" when AcceptLang only has English #16

fnetX opened this issue Dec 9, 2022 · 0 comments
Assignees

Comments

@fnetX
Copy link

fnetX commented Dec 9, 2022

Describe the bug

Automatic language detection recently got broken in my project.

To Reproduce
Steps to reproduce the behavior:

  1. Browser sends Accept-Language: en-GB,en;q=0.5
  2. i18n chooses to display ga

Expected behavior
Since both en-GB and en are supplied, and en is available as a folder (and not missing any translations), en should be chosen in my eyes.
ga is missing some strings, so English is used for them instead.

Desktop (please complete the following information):

  • OS: Debian GNU/Linux 11
  • Go version: go1.19.3

Additional context
Add any other context about the problem here.

file structure of locales
locales/
locales/nl
locales/nl/base.yaml
locales/da
locales/da/base.yaml
locales/en
locales/en/other-component.yaml
locales/en/base.yaml
locales/ga
locales/ga/base.yaml
locales/pl
locales/pl/base.yaml
locales/fr
locales/fr/base.yaml
locales/de
locales/de/other-component.yaml
locales/de/base.yaml
Further notes
  • I cannot find any other indicators for languages. There is no "lang" cookie. There is no request GET parameter. Hostname is "localhost".
  • code excerpt (registering API method, I did no further interaction with your library AFAICS)
    locale := i18n.GetLocale(r)
    templateData["tr"] = locale.GetMessage

It works in another browser where I send Accept-Language: de,en-US;q=0.7,en;q=0.3 (de is chosen / displayed).

Appreciate your help :) Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants