EddyVerbruggen / EddyVerbruggen/nativescript-localize

Translation with parameters won't work

Open
#91 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
80
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Hello, I'm trying to get a translation with a parameter and it won't work.
I'm using nativescript-vue@2.6.0 and nativescript/core@6.5.1.

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the i18n folder, en.default.json, and the Vue component filter shown in the report. Compare nested keys such as Test.Word %s with the flat Test.Word %s form, then trace parameter lookup and verify that both forms return Word a when the fix is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
internationalization, localization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.