iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
600 stars 210 forks source link

Documentation Issue: Insert variable into localized strings #7106

Closed arome closed 3 weeks ago

arome commented 3 weeks ago

Is there an option available in the Localization interface that allows us to insert variable into a localized string? i.e.: I want to translate everything in this sentence except for the fileName that I'll be providing.

The file ${fileName} already exists. Do you want to replace it or keep both files?)

Found on page https://www.itwinjs.org/reference/core-common/localization/localization

arome commented 3 weeks ago

I found that its possible to be done by putting a double curly braces {{ variable }}.

williamkbentley commented 3 weeks ago

correct. the options in getLocalizedString come from i18next. you can use their interpolation and other functions, such as plurals and formatting