How to Localize
The *i18n.Localizer
returned by the bot.SettingsProvider
we created on the previous page is now available in the *plugin.Context
.
Using the Localizer
Localizer
Localized text is generated using *i18n.Config
s. Usually, these are placed in a terms.go
file in your package. If you have many configs, it might also be advisable to group terms into foo_terms.go
, bar_terms.go
etc.
In your command's Invoke
method, you can then use those *i18n.Configs
to generate messages.
Working with Localizer
s
Localizer
sAs you might have already noticed, there are a lot of utilities for working with localized text. Structs typically come in two versions X
and LocalizedX
to provide localization support. If they are constructor-based, they might also use constructors like NewX
, NewXl
, and NewXlt
where NewX
creates an unlocalized version, NexXl
uses a *i18n.Config
, and NewXlt
uses a i18n.Term
.
The same also applies to other functions. For example plugin.Context
provides Reply
, Replyl
and Replylt
.
Last updated
Was this helpful?