add TranslateString() utility function
This commit is contained in:
@@ -121,3 +121,11 @@ func (d *FullData) WriteJSON(dataPath string) error {
|
|||||||
err = os.Rename(path, filepath.Join(dataPath, "comitium.json"))
|
err = os.Rename(path, filepath.Join(dataPath, "comitium.json"))
|
||||||
return err
|
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))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user