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

Support Nested Property Namespace Functions in namespaceFunctions Lexer Option #1103

Open
gobzila opened this issue Jan 3, 2025 · 0 comments

Comments

@gobzila
Copy link

gobzila commented Jan 3, 2025

🐛 Bug Report

Currently, the namespaceFunctions option in the lexers does not support recognizing wrapped functions defined as namespace properties, such as i18n.useTranslate. For example:

const { t } = i18n.useTranslate('common');
const message = t('welcome_message');

The parser fails to recognize i18n.useTranslate as a valid namespace function, and as a result, it does not extract the common namespace or the associated keys. The current implementation of namespaceFunctions only supports simple function names like useTranslate, which limits the parser's flexibility for projects that use wrapped functions defined within namespaces.

Expected behavior

Extend the namespaceFunctions option in the lexers to support namespace property functions (e.g., i18n.useTranslate) in the same way that functions and componentFunctions were enhanced in Issue #912 and PR #913. This enhancement will allow the parser to extract namespaces and keys from nested property functions seamlessly.

Why It's Important

This enhancement would improve the flexibility of the parser, making it compatible with projects that use namespaced or wrapped translation functions. It would also bring consistency across functions, componentFunctions, and namespaceFunctions, enabling developers to extract translations without requiring additional preprocessing or workarounds.

Your Environment

  • runtime version: node v20.11.1
  • i18next version: 23.15.1
  • os: Mac
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

1 participant