i18n-ally
i18n-ally copied to clipboard
Support custom namespace delimiters
Is your feature related to a specific framework or general for this extension
i18next, but I think it is general
Is your feature request related to a problem? Please describe.
I am using this extension in multiple projects with i18next.
In i18next, developer can specify a nsSeparator
, like ":" or "|". But this extension always give me "." as suggestions.
which will not work in project.
Projects using :
as delimiter can be parsed correctly in this extension, but those using |
or other delimiters don't.
Describe the solution you'd like
I'd like to have a setting to change default namespace delimiters from .
to :
.
Or, I found this setting i18n-ally.regex.usageMatchAppend
but I don't know how to make it correct.
In one of my porject we use $t('namespace:key.subKey')
for translations. But \\$t\\(\\s*[\\'\"`]({namespace})\\:({key})[\\'\"`]
cannot make the extension parse my code correctly.
Additional context
Related to #295
Looking forward to this.
I also open an issue on the react-i18next that might solve the problem by customizing the nsSeprator
on the typescript side: https://github.com/i18next/react-i18next/issues/1467
We also use i18next with options
{
defaultNS: 'myDefaultNS',
fallbackNS: ['myDefaultNS', 'myNS'],
nsSeparator: '|',
keySeparator: '.',
}
so we have the same issue that given myNS|someParent.someFinalKey
effectively the key get prefixed with e.g. myNS|
and I thought I could make it work at least for default namespaces which means someParent.someFinalKey
.
And I tried setting a global default namespace using defaultNamespace
which works. I realized we have also added NS despite it wasn't necessary, so I tried setting usageMatchRegex
such that it skips the myNS|
part. I had luck with
"[^\\w\\d]t\\(['\"
](?:[\w]\|)?(.)['"]"
but since I knew this is all very suboptimal, I tried to find a regex so it could match |
with .
which seems to be not possible. And I wouldn't be able to configure multiple default namespaces anyways.
The conclusion
I think it would be enough to allow configuring multiple key separators/delimiters or specify a regex for rather than a single character
Same goes for default namespaces or rather fallback namespaces. This project doesn't differentiate between namespaces and keys like i18next does even though it does and I see how those are very similar.
Sorry, if this was a lil tedious, I failed to structure this well but wanted to share my thoughts, TLDR is we need this too :)
I could not find any information on this particular issue elsewhere then this issue and this: https://github.com/lokalise/i18n-ally/issues/443 issue. The issue I'm facing is with the namespace delimiter in the auto completion. This issue is still opened, so I'm asking if there are any plans on this, or if I just have something wrong, and the suggestions should be displayed corrently, when using the "i18next" framework. Thanks!
Also interested in this being fixed!