Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the translation variable delimiters be configured? #330

Closed
josephfarina opened this issue Nov 18, 2020 · 6 comments
Closed

Can the translation variable delimiters be configured? #330

josephfarina opened this issue Nov 18, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@josephfarina
Copy link
Contributor

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

@josephfarina
Copy link
Contributor Author

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

@aralroca
Copy link
Owner

@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!

@aralroca aralroca added the enhancement New feature or request label Nov 25, 2020
@josephfarina
Copy link
Contributor Author

josephfarina commented Dec 3, 2020

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: %{ }

@aralroca
Copy link
Owner

aralroca commented Dec 3, 2020

@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

@josephfarina
Copy link
Contributor Author

Thanks @aralroca that made it really easy

@aralroca
Copy link
Owner

aralroca commented Dec 4, 2020

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

@aralroca aralroca closed this as completed Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants