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

Translation with parameters won't work #91

Open
seergiue opened this issue Apr 18, 2020 · 2 comments
Open

Translation with parameters won't work #91

seergiue opened this issue Apr 18, 2020 · 2 comments

Comments

@seergiue
Copy link

seergiue commented Apr 18, 2020

Hello, I'm trying to get a translation with a parameter and it won't work.
I'm using [email protected] and nativescript/[email protected].

So the translations work fine without params but not with them.

  • My i18n folder is inside the app folder.
  • I have added a .default.json file.
  • All .json files contain "app.name" key.

My en.default.json:

"Test": {
    "Word %s": "Word %s"
},

Vue component where I use the filter:

<Label :text="'Test.Word %s' | L('a')" />

Instead of returning me Word a it returns Test.Word a. So it includes the param but it's like if it was trying to find Word a instead of Word %s in my translation file.

Any idea?

Thanks!

UPDATE:

If I set the JSON like this:

"Test.Word %s": "Word %s"

Then it works. Its a bit odd because you never know when is looking for the key or accessing key.value.

@emog
Copy link
Contributor

emog commented May 12, 2020

Please view the documentation for Vue.

Add Vue.filter("L", localize); in app.js

"some_common_key": {
"subkey": "Word %s"
}

@seergiue
Copy link
Author

@emog Thanks for answering!

But what happens if I want to add strings as keys for my translations?

Like this:

<Label :text="'Test.Word %s' | L('a')" />

Instead of what you proposed:

<Label :text="'commonKey.subKey' | L('a')" />

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