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

Extracted message not namespaced when using next-intl #136

Open
oscar-b opened this issue Jan 2, 2025 · 2 comments
Open

Extracted message not namespaced when using next-intl #136

oscar-b opened this issue Jan 2, 2025 · 2 comments

Comments

@oscar-b
Copy link

oscar-b commented Jan 2, 2025

When extracting a string in a project with next-intl, it isn't saved to the file with the namespace nesting which is defined in the source file:

const t = await getTranslations('RootLayout');
t("new-message")

Instead of ending up in as:

{
  "RootLayout": {
    "new-message": "123"
  }
}

it ends up as:

{
  "new-message": "123"
}

Is there any special configuration that's needed to get this behavior?

After extracting, the plugin reports:

ERROR: 'RootLayout.new-message' not found in source with language tag 'en'

If I manually move the new message to the correct namespace in the JSON, the plugin detects this properly and displays it as it should, it's just the extraction that doesn't work.

Copy link
Member

Yeah tricky. Sherlock has no concept of a namespace.

The implementation of matching a message like RootLayout.new-message happens via the next-intl plugin. Extending the next-intl plugin to report a namespace for a given file as well as adding an onExtract callback to Sherlock could be a solution.

In the meantime, either not using namespaces or manually fixing the key is the way to go. Sherlock has a feature freeze till lix 1.0 and the inlang sdk 2.0 are out, see https://opral.substack.com/p/focus-shift-from-inlang-to-lix

@oscar-b
Copy link
Author

oscar-b commented Jan 3, 2025

@samuelstroschein All right, was mostly confused since parts of the plugin handled namespaced strings and the other part didn't :)

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