Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
@@ -0,0 +1,32 @@
package l10n
import (
"embed"
"github.com/qsfera/server/pkg/l10n"
)
var (
//go:embed locale
_localeFS embed.FS
)
const (
// subfolder where the translation files are stored
_localeSubPath = "locale"
// domain of the graph service (transifex)
_domain = "graph"
)
// Translate translates a string based on the locale and default locale
func Translate(content, locale, defaultLocale, translationPath string) string {
t := l10n.NewTranslatorFromCommonConfig(defaultLocale, _domain, translationPath, _localeFS, _localeSubPath)
return t.Translate(content, locale)
}
// TranslateEntity returns a function that translates a struct or slice based on the locale
func TranslateEntity(locale, defaultLocale string, entity any, opts ...l10n.TranslateOption) error {
t := l10n.NewTranslatorFromCommonConfig(defaultLocale, _domain, "", _localeFS, _localeSubPath)
return t.TranslateEntity(locale, entity, opts...)
}