From 9bbbc4557c84c1574ac98690ed91c748f7c37613 Mon Sep 17 00:00:00 2001 From: nytpu Date: Tue, 11 May 2021 12:32:41 -0600 Subject: [PATCH] add TranslateString() utility function --- core/core.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/core.go b/core/core.go index d35f9bf..feeaf9c 100644 --- a/core/core.go +++ b/core/core.go @@ -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)) +}