mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-09 21:59:42 -06:00
embed translation on startup
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"strings"
|
||||
"text/template"
|
||||
@@ -19,12 +20,15 @@ import (
|
||||
ehmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/eventhistory/v0"
|
||||
)
|
||||
|
||||
//go:embed l10n/locale
|
||||
var _translationFS embed.FS
|
||||
|
||||
var (
|
||||
_resourceTypeSpace = "storagespace"
|
||||
_resourceTypeShare = "share"
|
||||
|
||||
// TODO: from config
|
||||
_pathToLocales = "/home/jkoberg/ocis/services/userlog/pkg/service/locales"
|
||||
_pathToLocales = "/home/jkoberg/ocis/services/userlog/l10n/locale"
|
||||
_domain = "default"
|
||||
)
|
||||
|
||||
@@ -281,7 +285,7 @@ func composeMessage(nt NotificationTemplate, locale string, vars map[string]inte
|
||||
|
||||
func loadTemplates(nt NotificationTemplate, locale string) (string, string) {
|
||||
// Create Locale with library path and language code and load default domain
|
||||
l := gotext.NewLocale(_pathToLocales, locale)
|
||||
l := gotext.NewLocaleFS("l10n/locale", locale, _translationFS)
|
||||
l.AddDomain(_domain)
|
||||
return l.Get(nt.Subject), l.Get(nt.Message)
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ func getSpace(ctx context.Context, spaceID string, gwc gateway.GatewayAPIClient)
|
||||
}
|
||||
|
||||
if res.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return nil, fmt.Errorf("Unexpected status code while getting space: %v", res.GetStatus().GetCode())
|
||||
return nil, fmt.Errorf("Error while getting space: (%v) %s", res.GetStatus().GetCode(), res.GetStatus().GetMessage())
|
||||
}
|
||||
|
||||
if len(res.StorageSpaces) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user