go-html/translator_clone_js.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

25 lines
460 B
Go

//go:build js
// SPDX-Licence-Identifier: EUPL-1.2
package html
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.(*defaultTranslator); ok && current != nil {
clone := *current
return &clone
}
return svc
}