summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-05-11 12:32:41 -0600
committernytpu <alex@nytpu.com>2021-05-11 12:32:41 -0600
commit9bbbc4557c84c1574ac98690ed91c748f7c37613 (patch)
tree5b127863511f0beb1129f0af7e1fd8bce0934df7
parent5aa80302af2aa31b63c51f5e020b8464ab635ff2 (diff)
add TranslateString() utility function
-rw-r--r--core/core.go8
1 files changed, 8 insertions, 0 deletions
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))
+}