question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't figure out how to use translation variables

See original GitHub issue

I tried:

{$t("foot", { default: 'hello', count: 1 })}

The default works, but using the example, the count isn’t working. What am I missing?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cibernoxcommented, Jun 6, 2021

I copied the API from svelte-i18n. Values must be passed inside a values key. In your example it should be {$t("foot", { default: 'hello', values: { count: 1 } })}. I personally don’t like that too much, I find it a bit verbose, but since svelte-i18n is the most popular i18n library for svelte by a lot I thought it was wise to just use the exact same API to make transitioning to this library dead simple.

0reactions
cibernoxcommented, Jun 18, 2021

Great to hear, closing this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I add variables to my translations? - Help Center
Click on it to access the panel: You should now see the information panel of the translation you've selected. Click on the "Variables"...
Read more >
Variables as args in translation function - WordPress.org
You can add variables to translated strings by using sprintf() , but you can't translate those variables. In your example, you have this...
Read more >
How to Automatically Translate Text Variables into Other ...
Select the text variable to be translated in the Data Sets tree. From the object inspector, go to Properties > TRANSFORMATIONS > Translate...
Read more >
Translating variables into english [closed]
I have recently came across some code where the variable names are in french, I could not use google translate because only part...
Read more >
Top Tips for Translations - Engineering @ Binti
Many translation libraries will allow the translator to change the order of variables, which is effective if you can be precise with your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found