Open ziofat opened 2 years ago
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.
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!
Ping, here's one user also using i18next with nsSeparator: ":"
and the suggestion suggests namespace.nested.key
instead of namespace:nested.key
or even t('nested.key', { ns: namespace })
or what have you.
The current suggestions are just not (flexible) enough.
In this scenario, it should suggest me with the following:
{t('common:remove')}
t('common:remove')
<Trans i18nKey="common:remove"></Trans>
common:remove
i18n.t('common:remove')
or better yet:
{t('remove', { ns: 'common' })}
t('common:remove')
<Trans i18nKey="common:remove" />
common:remove
i18n.t('common:remove')
As a user/developer, I'd rather have all these suggestions editable in a way, that user themselves could define each pattern for the suggestions. For example, I wouldn't most likely ever need other than the first two ({t('remove', { ns: 'common' })}
and t('common:remove')
) or perhaps not more than one.
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
which will not work in project.
nsSeparator
, like ":" or "|". But this extension always give me "." as suggestions.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