From c27b0281cae529b2f1ad618c6df83e9481dd6d5a Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 25 Aug 2021 22:47:29 +0200 Subject: [PATCH] Support lang extanding for internal translations --- pkg/locale/service.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/locale/service.go b/pkg/locale/service.go index 21e9a534d..4f039c03e 100644 --- a/pkg/locale/service.go +++ b/pkg/locale/service.go @@ -132,6 +132,19 @@ func (svc *service) Reload() error { svc.set[lang.Tag] = lang } + // Do another pass and link all extended languages + for _, lang := range svc.set { + if lang.Extends.IsRoot() { + continue + } + + if svc.set[lang.Extends] == nil { + return fmt.Errorf("could not extend langage %q from an unknown language %q", lang.Tag, lang.Extends) + } + + lang.extends = svc.set[lang.Extends] + } + return nil }