question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

Namespaces with slashes not working

See original GitHub issue

Describe the bug

Separating namespaces into subfolders, the namespace match with slashes donโ€™t work. Thereโ€™s a problem to support slashes as a namespace separator.

Locales structure:

locales
โ””โ”€โ”€ en-US
    โ”œโ”€โ”€ common.json
    โ”œโ”€โ”€ models
    โ”‚   โ””โ”€โ”€ model-companies.json
    โ””โ”€โ”€ pages
        โ”œโ”€โ”€ home.json
        โ””โ”€โ”€ login.json

Namespace that i need to match:

t("pages/login:unauthorized.title")

i18n-ally settings:

  "i18n-ally.localesPaths": ["public/locales"],
  "i18n-ally.pathMatcher": "{locale}/{namespaces}.{ext}",
  "i18n-ally.enabledParsers": ["json"],
  "i18n-ally.namespace": true,
  "i18n-ally.keystyle": "nested",
  "i18n-ally.displayLanguage": "pt-BR",
  "i18n-ally.enabledFrameworks": [ "react", "i18next"],

Extension Version i18n Ally v2.3.21

Framework/i18n package you are using next-i18next

Device Infomation

  • OS: macOS Catalina
  • Version: 10.15.6
  • VS Code Version: 1.50.1

Extension Log

๐Ÿ’ผ Workspace root changed to "/Users/daniel/project"
๐ŸŒž Enabled
๐Ÿงฉ Enabled frameworks: React, i18next
๐Ÿงฌ Enabled parsers: json

๐Ÿš€ Initializing loader "/Users/daniel/project"
๐Ÿ“‚ Directory structure: dir
๐Ÿ—ƒ Custom Path Matcher: {locale}/{namespaces}.{ext}
๐Ÿ—ƒ Path Matcher Regex: /^(?<locale>[\w-_]+)\/(?<namespace>.+)\.(?<ext>json|ya?ml|json5)$/

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
antfucommented, Nov 13, 2020

Should be supported in v2.4.4

0reactions
dnbastoscommented, Nov 12, 2020

Hi @antfu, An issue was opened on this subject in the i18next repository https://github.com/i18next/i18next/issues/1404, the maintainers do not mention the use of : for subfolders and the conclusion is that this is a feature for a few case and recommend creating your own customization of the framework to deal with it. https://www.i18next.com/misc/creating-own-plugins

However, I suspect there was a customization like this to work in this case. https://github.com/antfu/i18n-ally/issues/342#issuecomment-657492465 As mentioned by @haggen I also think that using โ€œ:โ€ to separate both namespaces and subfolders can cause problems because if is a namespace or folder separator, it corresponds to different locales.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespaces with slashes not working ยท Issue #425 - GitHub
Describe the bug Separating namespaces into subfolders, the namespace match with slashes don't work. There's a problem to support slashes asย ...
Read more >
In php, namespaces a forward slash? - Stack Overflow
Are there any particular reasons for this? I feel the backslash convention is illogical because unix/linux file systems utilize forward slashes.
Read more >
Naming Files, Paths, and Namespaces - Win32 apps
The backslash divides the file name from the path to it, and one directory name from another directory name in a path. You...
Read more >
FAQ: things you need to know about namespaces - PHP
Class names that do not contain a backslash like name can be resolved in 2 different ways. If there is an import statement...
Read more >
On PHP 5.3's Namespace Backslash Backlash
The problem is, the internals of PHP are that namespaces and classes are in different hashes and the call to either compile to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found