![]() In practice, translations will be automatically injected from a translator-supplied data source. In order to use catalogs, we need to populate them with translations. Think of it as a set of per-language dictionaries with translations for a set of keys. Now in order to print translated messages, we need to add them to the message catalog so that the Printer can find them for the right language tag.Ī Catalog defines collections of translated format strings. ![]() If you run this program you will get: ➜ go run main.go P.Printf("There are %v flowers in our garden.\n", 1500) P := message.NewPrinter(language.BritishEnglish) The library will take care any localized formatting variants for you: package main If you want to learn more about the language API see this doc here.Ĭoming back to our messages we can assign a new printer using a different language and print the formatted strings.
0 Comments
Leave a Reply. |