diff --git a/core/core.go b/core/core.go index b5acf46..5f1e86e 100644 --- a/core/core.go +++ b/core/core.go @@ -100,6 +100,7 @@ func Init(dataPath string, localizer *localizations.Localizer) error { return nil } +// WriteJSON writes a FullData to disk func (d *FullData) WriteJSON(dataPath string) error { // use .new so if there's a corruption when writing the old file is intact path := filepath.Join(dataPath, "comitium.json.new") @@ -125,5 +126,14 @@ func (d *FullData) WriteJSON(dataPath string) error { // 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)) + return TranslateStringLocalizer(Localizer, template, localizerTag, replacements) +} + +// TranslateStringLocalizer takes a localizations.Localizer, 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. +// Should not be used once core.Init() is called, instead use TranslateString(). +func TranslateStringLocalizer(localizer *localizations.Localizer, template, localizerTag string, replacements *localizations.Replacements) string { + return fmt.Sprintf(template, localizer.Get(localizerTag, replacements)) }