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

Using square brackets in identifier does not work #117

Open
djtsov opened this issue Oct 23, 2019 · 2 comments
Open

Using square brackets in identifier does not work #117

djtsov opened this issue Oct 23, 2019 · 2 comments

Comments

@djtsov
Copy link

djtsov commented Oct 23, 2019

I want to use the square brackets for parameters in translation strings, for example, 'This is my [project]'.
And for that aim I add the {identifier: ['[',']']} as the config parameter for initialize vuex-i18n. But unfortunately when I try to get a translation by this.$i18n.translate('mykey', {'project': 'test' }) , I get 'This is my [project]' instead 'This is my test'.
But when I replace the square brackets to braces (e.g. 'This is my {project}') then all works as expected.
P.S. When I use the square brackets(!) then the this.$i18n.translate('mykey', {'project': 'test' }) stops to work for strings used the braces 'This is my {project}', i.e. the identifier was changed for another symbol.

@djtsov
Copy link
Author

djtsov commented Oct 23, 2019

As I understood, for using the the square brackets in regular expressions, it's needed to use follow identifier: ["\\[","\\]"].
But then this line works wrong:
var key = placeholder.replace(identifiers[0], '').replace(identifiers[1], '');
because translate string contains the single brackets, but identifier[0] is '[' and identifier[1] is ']'.

@tikiatua
Copy link
Member

Hi @djtsov

Thank you for your feedback. I will look into this. The syntax of the identifiers is probably not correct yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants