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

t function doesn't work with keyPrefix and array of keys #1604

Closed
AlexKrupko opened this issue Jan 8, 2023 · 2 comments
Closed

t function doesn't work with keyPrefix and array of keys #1604

AlexKrupko opened this issue Jan 8, 2023 · 2 comments

Comments

@AlexKrupko
Copy link

AlexKrupko commented Jan 8, 2023

馃悰 Bug Report

t function doesn't work if keyPrefix is specified and array of keys provided. It fails with missingKey error.
As far as I understood, this line of code is a reason of that error - https://github.com/i18next/i18next/blob/5bd9ac037867edbb45fcdf9976e3b5ea48f164d5/src/i18next.js#L396

i18next.use(initReactI18next).init({
  // ... 
  resources: {
    en: {
      translation: {
        group: {
          key1: "Translation 1",
          key2: "Translation 2"
        }
      }
    }
  }
});

export default function App() {
  const { t } = useTranslation("translation", { keyPrefix: "group" });

  return t(["key1", "key2"]); // Doesn't work
}

To Reproduce

A codesandbox example

Expected behavior

Translation for key1 value should be returned

@adrai
Copy link
Member

adrai commented Jan 8, 2023

i18next v22.4.9 should address this

@adrai
Copy link
Member

adrai commented Jan 8, 2023

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