Next-translate: Can the translation variable delimiters be configured?

Created on 18 Nov 2020  Â·  6Comments  Â·  Source: vinissimus/next-translate

It seems like translation variables are currently wrapped in {{variable}}. Is this configurable to something like %{variable}?

enhancement

All 6 comments

I'd be happy to make a PR to support this — if it is not already.

@josephfarina for now the interpolation prefix and suffix are limited to only {{ and }}, here's the code:

I think it's good to give the opportunity to be configurable. So, if you want to go ahead with your PR, you are welcome to do so. Thank you very much!

Hey again @aralroca, do you have any suggestion of how to access the i18n.js config file here?

https://github.com/vinissimus/next-translate/blob/5f27c864189455382a5c98f20debc23208acd798/src/I18nProvider.js#L44-L45

IMO this option should be supported similar to how i18next does it with an interpolation.prefix and interpolation.suffix option in the config file:

https://www.i18next.com/translation-function/interpolation#additional-options

This is also a necessity for Smartling btw. They require the delim to be: %{ }

@josephfarina You have made me realize that it is a bit cumbersome to use the settings inside I18nProvider. I've done a PR to fix this, so now you can consume the configuration:

https://github.com/vinissimus/next-translate/pull/369/files#diff-ea0a179cd243269347b1b4d033a6bfd270e19e2a319af583c8c318b1040d3bcaR112

Thanks @aralroca that made it really easy

Nice! @josephfarina I prereleased 1.0.0-canary.4 with this change

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dimaip picture dimaip  Â·  4Comments

shunkakinoki picture shunkakinoki  Â·  4Comments

roy1210 picture roy1210  Â·  7Comments

SpicyPete picture SpicyPete  Â·  4Comments

aralroca picture aralroca  Â·  3Comments