go-html/translator_clone_default.go
Virgil 2a5e2ee5a3
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
fix(html): preserve locale on cloned translators
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 02:07:05 +00:00

28 lines
538 B
Go

//go:build !js
// SPDX-Licence-Identifier: EUPL-1.2
package html
import i18n "dappco.re/go/core/i18n"
func cloneTranslator(svc Translator, locale string) Translator {
if svc == nil {
return nil
}
if cloner, ok := svc.(translatorCloner); ok && cloner != nil {
if clone := cloner.Clone(); clone != nil {
applyLocaleToService(clone, locale)
return clone
}
}
if current, ok := svc.(*i18n.Service); ok && current != nil {
clone := &i18n.Service{}
applyLocaleToService(clone, locale)
return clone
}
return svc
}