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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

lng does not work if is after a # #256

Closed
totszwai opened this issue Mar 23, 2022 · 2 comments
Closed

lng does not work if is after a # #256

totszwai opened this issue Mar 23, 2022 · 2 comments

Comments

@totszwai
Copy link

totszwai commented Mar 23, 2022

馃悰 Bug Report

The following URLs does not work:

http://localhost:8080/#/something?lng=fr
http://localhost:8080/#/something/?lng=fr

Only works if the query string is before a #.

http://localhost:8080/?lng=fr#/something

To Reproduce

  const languageDetector = new LanguageDetector(null, {
    // order and from where user language should be detected
    order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag', 'path', 'subdomain'],

    // keys or params to lookup language from
    lookupQuerystring: 'lng',
    lookupCookie: 'i18next',
    lookupLocalStorage: 'i18nextLng',
    lookupSessionStorage: 'i18nextLng',
    lookupFromPathIndex: 0,
    lookupFromSubdomainIndex: 0,

    // cache user language on
    caches: ['localStorage', 'cookie'],
    excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)

    // optional htmlTag with lang attribute, the default is:
    htmlTag: document.documentElement,

    // optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
    cookieOptions: { path: '/', sameSite: 'strict' }
  });

  if (!i18n.isInitialized) {
    i18n
      .use(languageDetector)

Expected behavior

Expect the lng in the querystring to work regardless of position

Your Environment

node v14
i18next-browser-language 6.1.2

@adrai
Copy link
Member

adrai commented Mar 23, 2022

In theory this is not part of the querystring, because of the # fragment delimiter....
but I just provided a fallback with v6.1.4... can you try?

@adrai adrai closed this as completed Mar 23, 2022
@totszwai
Copy link
Author

totszwai commented Mar 23, 2022

@adrai Confirmed that it work, thanks a lot for providing a fallback and publishing it so quickly! 馃憤

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