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] translation API is returning undefined when provided locale is undefined or null #501

Open
longdoan7421 opened this issue Oct 2, 2022 · 0 comments · May be fixed by #502
Open

[Bug] translation API is returning undefined when provided locale is undefined or null #501

longdoan7421 opened this issue Oct 2, 2022 · 0 comments · May be fixed by #502

Comments

@longdoan7421
Copy link

Hi, the current API i18n.__ is returning undefined value if the provided locale is undefined or null even when the configuration has retryInDefaultLocale = true.

Steps to reproduce

const i18n = require('i18n');

i18n.configure({
  locales: ['en', 'de'],
  defaultLocale: 'en',
  directory: './locales',
  updateFiles: false,
  retryInDefaultLocale: true,
});

console.log(i18n.__({ phrase: 'Hello', locale: undefined})); // undefined

Environment:

  • NodeJS: v14+
  • i18n-node version: 0.15.1

Actual behavior

Return undefined.

Expected behavior

Return translated string in default locale if retryInDefaultLocale = true and perhaps even in case retryInDefaultLocale = false.

longdoan7421 added a commit to longdoan7421/i18n-node that referenced this issue Oct 2, 2022
longdoan7421 added a commit to longdoan7421/i18n-node that referenced this issue Oct 5, 2022
longdoan7421 added a commit to longdoan7421/i18n-node that referenced this issue Jun 25, 2023
longdoan7421 added a commit to longdoan7421/i18n-node that referenced this issue Jun 25, 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

Successfully merging a pull request may close this issue.

1 participant