add basic config and change i18n pkg

This commit is contained in:
Livio Amstutz
2020-03-25 07:58:58 +01:00
parent 96b88f5d8c
commit 5cd9ca506a
21 changed files with 515 additions and 19 deletions

View File

@@ -0,0 +1,34 @@
package grpc
type Config struct {
ServerPort string
GatewayPort string
SearchLimit int
CustomHeaders []string
}
func (c *Config) ToServerConfig() *ServerConfig {
return &ServerConfig{
Port: c.ServerPort,
SearchLimit: c.SearchLimit,
}
}
func (c *Config) ToGatewayConfig() *GatewayConfig {
return &GatewayConfig{
Port: c.GatewayPort,
GRPCEndpoint: c.ServerPort,
CustomHeaders: c.CustomHeaders,
}
}
type ServerConfig struct {
Port string
SearchLimit int
}
type GatewayConfig struct {
Port string
GRPCEndpoint string
CustomHeaders []string
}

View File

@@ -8,9 +8,9 @@ import (
"github.com/BurntSushi/toml"
"github.com/caos/logging"
"github.com/ghodss/yaml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
"gopkg.in/yaml.v2"
"github.com/caos/zitadel/internal/api"
http_util "github.com/caos/zitadel/internal/api/http"
@@ -43,8 +43,9 @@ func NewTranslator(config TranslatorConfig) (*Translator, error) {
func newBundle(i18nDir string, defaultLanguage language.Tag) (*i18n.Bundle, error) {
bundle := i18n.NewBundle(defaultLanguage)
bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal)
bundle.RegisterUnmarshalFunc("yml", yaml.Unmarshal)
yamlUnmarshal := func(data []byte, v interface{}) error { return yaml.Unmarshal(data, v) }
bundle.RegisterUnmarshalFunc("yaml", yamlUnmarshal)
bundle.RegisterUnmarshalFunc("yml", yamlUnmarshal)
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
files, err := ioutil.ReadDir(i18nDir)