You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File that loads localization from server, at initialization MyEventHandler.ts
async myInternationalization() {
const myTranslations = (await this.api.call({
href: '/internationalization',
method: 'GET',
} as Link)) as MessageSchema
this.handleInternationalization(myTranslations)
}
handleInternationalization(messageSchema: MessageSchema) {
for (const locale in messageSchema) {
i18n.global.setLocaleMessage(locale, messageSchema[locale])
}
}
All of the above work so that when I call $t or t in a component, the label is translated. All the labels are printed if I console.log i18n.global.messages.value
However, when I try to interpolate parameters in a ts file, it's not working
This method receives a pair of {label, string[] } arguments. However, the string that results from calling t does not interpolate the given parameters.
For example, if my definition for the translation is:
my.message=The planet {0} that you are looking for is unknown
And I pass the parameter
{
args: ['Venuz']
message:"my.message"
}
I will obtain a string with value: The planet {0} that you are looking for is unknown
Instead of The planet Venuz that you are looking for is unknown
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was going to open a bug report for this, but I'm not sure if it's a bug, or if I'm missing something.
My application has the following setup:
First, create i18n
File
internationalization.ts
Load i18n in app
File
main.ts
File that loads localization from server, at initialization
MyEventHandler.ts
All of the above work so that when I call
$t
ort
in a component, the label is translated. All the labels are printed if I console.log i18n.global.messages.valueHowever, when I try to interpolate parameters in a ts file, it's not working
File
passAMessage.ts
This method receives a pair of
{label, string[] }
arguments. However, the string that results from callingt
does not interpolate the given parameters.For example, if my definition for the translation is:
my.message=The planet {0} that you are looking for is unknown
And I pass the parameter
I will obtain a string with value:
The planet {0} that you are looking for is unknown
Instead of
The planet Venuz that you are looking for is unknown
I appreciate any guidance you might have.
Beta Was this translation helpful? Give feedback.
All reactions