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.

Support for custom namespace match/separator

See original GitHub issue

Is your feature related to a specific framework or general for this extension

General, next-translate

Is your feature request related to a problem? Please describe.

I’m trying to use this together with next-translate It uses the following pattern t('namespace:key.nested'), which I can’t seem to setup with the custom framework yaml

Describe the solution you’d like

If I could add {namespace} to usageMatchRegex, and use that to pick locale file, another solution would be to have namespaceKeySeparator setting, default to ., I could then set it to : to get the same result.

Additional context

.vscode/settings.json

{
  "i18n-ally.localesPaths": ["./public/static/locales", "public/static/locales"],
  "i18n-ally.namespace": true,
  "i18n-ally.pathMatcher": "{locale}/{namespace}.json",
  "i18n-ally.sourceLanguage": "sv",
  "i18n-ally.keystyle": "nested",
  "i18n-ally.enabledFrameworks": ["custom"]
}

.vscode/i18n-ally-custom-framework.yml

languageIds:
  - javascript
  - typescript
  - javascriptreact
  - typescriptreact

usageMatchRegex:
  - "[^\\w\\d]t\\(['\"`]({namespace})\\:({key})['\"`]"

monopoly: true

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
leonbloycommented, Oct 22, 2020

Is this supposed to work “out of the box”? I’m using 2.3.20 and I cannot make this work

I’m using i18next with two namespaces and ‘:’ as separator

From my i18next config:

  ns: ['common', 'k'],
  defaultNS: 'common',
  nsSeparator: ':',

In my i18-a11y setting I have

"i18n-ally.localesPaths": "src/translations",
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/translation-{namespace}.json",
"i18n-ally.keystyle": "nested",
`

Some examples I tried:


1         t('common.Required')  
2         t('k.legal') 
3         t('common:Required') 
4         t('k:legal') 
5         t('Required') 

Only the first two are recognized by the extension. The others are not found. When I try to add them via the extension, it asks which file to use.

Additionally, it seems to be no way to set a default namespace (example 5) ?

Perhaps anecdotically: In example 5, not only the key is not found, but when I try to add them via the extension, it crops part of the key (eg: “Required val” is saved as “d val” - seems to crop an non-existent common: prefix)

1reaction
antfucommented, May 12, 2020

Supported in v2.1.6. It should work out of the box. All you need would be

{
  "i18n-ally.localesPaths": ["public/static/locales"],
  "i18n-ally.sourceLanguage": "sv",
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for custom namespace match/separator · Issue #295
If I could add {namespace} to usageMatchRegex , and use that to pick locale file, another solution would be to have namespaceKeySeparator ......
Read more >
Manual:Using custom namespaces
Custom namespaces are simple to manage using the $wgExtraNamespaces configuration directive. It is also possible to define alias names for ...
Read more >
Installing IBM Cloud Pak foundational services in a custom ...
Important: You can install foundational services in a custom namespace only if you are installing them for the first time in your cluster....
Read more >
Help:Custom namespaces - semantic-mediawiki.org
Missing data on custom namespaces - troubleshooting on missing semantic data on a custom namespace; $smwgNamespacesWithSemanticLinks - help page ...
Read more >
Namespaces | Airbyte Documentation
Custom Format - Create a "Custom Format" to rename the namespace that your data will be replicated into. If both your desired source...
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