Replies: 1 comment
-
Hey @supemeko! The The problem is that Here are two better ways to handle this. 1. The Easy Way: Nested
|
Beta Was this translation helpful? Give feedback.
-
Hey @supemeko! The The problem is that Here are two better ways to handle this. 1. The Easy Way: Nested
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How to Dynamically Reference Translation Keys in vue-i18n
I'm having trouble with
vue-i18n
when using the@:{key}
syntax for dynamic translation key references. Here's the issue:Issue
My translation dictionary is:
When calling
$t('HealthAlarm', { reason: 'breeding_wound', name: 'Cow#01' })
, I expect:But the actual output is:
I want to know the best approach for this.
Current Workaround
I'm using a dictionary structure like:
or:
This approach is not elegant enough
Note.1: I don’t assume that only 'reason' needs to be translated twice. The key requiring double translation could be another key, or there could be multiple keys.
Note.2: I don't expect to use a dedicated key to indicate that it will be translated twice, example '{'twice': { 'reason': 'breeding_wound' } }', Although doing so seems better than the existing solutions
Question
What is the best practice for handling dynamic translation key references in
vue-i18n
when the backend provides a dictionary name and JSON data? Specifically:vue-i18n
dictionary to avoid hardcoding keys likeHealthAlarm.breeding_wound
for better scalability?vue-i18n
translations?Please provide code examples or recommendations for optimizing.
Beta Was this translation helpful? Give feedback.
All reactions