add TranslateString() utility function

This commit is contained in:
nytpu
2021-05-11 12:32:41 -06:00
parent 5aa80302af
commit 9bbbc4557c
+8
View File
@@ -121,3 +121,11 @@ func (d *FullData) WriteJSON(dataPath string) error {
err = os.Rename(path, filepath.Join(dataPath, "comitium.json"))
return err
}
// TranslateString takes a template string, a localizer tag, and a localizer
// replacement set and will get the localized string from the localizer tag,
// replace everything using the localizer replacements, and then substitute that
// string into the template string.
func TranslateString(template, localizerTag string, replacements *localizations.Replacements) string {
return fmt.Sprintf(template, Localizer.Get(localizerTag, replacements))
}