diff --git a/.github/workflows/test-go.yml b/.github/workflows/test-go.yml index 3d88ab58..554fe896 100644 --- a/.github/workflows/test-go.yml +++ b/.github/workflows/test-go.yml @@ -14,8 +14,8 @@ jobs: run: | npm install npm run generate.go - cd ./clients/go/test - go test + cd ./clients/go + go test ./... -v - name: License check uses: phrase/actions/lawa-ci@v1 with: diff --git a/clients/go/config.go b/clients/go/config.go index 5588abc3..eed298b1 100644 --- a/clients/go/config.go +++ b/clients/go/config.go @@ -34,6 +34,8 @@ type Config struct { Pull []byte Push []byte + LocaleMapping map[string]string + UserAgent string } @@ -132,17 +134,19 @@ func configPath() (string, error) { func (cfg *Config) UnmarshalYAML(unmarshal func(i interface{}) error) error { m := map[string]interface{}{} + localeMapping := map[string]interface{}{} err := ParseYAMLToMap(unmarshal, map[string]interface{}{ - "access_token": &cfg.Credentials.Token, - "host": &cfg.Credentials.Host, - "debug": &cfg.Debug, - "page": &cfg.Page, - "per_page": &cfg.PerPage, - "project_id": &cfg.DefaultProjectID, - "file_format": &cfg.DefaultFileFormat, - "push": &cfg.Push, - "pull": &cfg.Pull, - "defaults": &m, + "access_token": &cfg.Credentials.Token, + "host": &cfg.Credentials.Host, + "debug": &cfg.Debug, + "page": &cfg.Page, + "per_page": &cfg.PerPage, + "project_id": &cfg.DefaultProjectID, + "file_format": &cfg.DefaultFileFormat, + "push": &cfg.Push, + "pull": &cfg.Pull, + "locale_mapping": &localeMapping, + "defaults": &m, }) if err != nil { return err @@ -156,6 +160,13 @@ func (cfg *Config) UnmarshalYAML(unmarshal func(i interface{}) error) error { } } + if len(localeMapping) > 0 { + cfg.LocaleMapping, err = ConvertToStringMap(localeMapping) + if err != nil { + return err + } + } + return nil } diff --git a/clients/go/config_test.go b/clients/go/config_test.go index ee6febc6..375b6a2b 100644 --- a/clients/go/config_test.go +++ b/clients/go/config_test.go @@ -372,6 +372,11 @@ func TestParseConfig(t *testing.T) { if config.Token != "123" { t.Errorf("Got %s, expected %s", config.Token, "123") } + + if config.LocaleMapping["en"] != "English" { + t.Errorf("Got %s, expected %s", config.LocaleMapping["en"], "English") + } + } func TestParseConfig_fromPath(t *testing.T) { diff --git a/clients/go/testdata/config_files/.phrase.yml b/clients/go/testdata/config_files/.phrase.yml index c4b80a41..dc3819f3 100644 --- a/clients/go/testdata/config_files/.phrase.yml +++ b/clients/go/testdata/config_files/.phrase.yml @@ -1,5 +1,7 @@ phrase: access_token: "123" + locale_mapping: + en: English push: sources: - file: "./config/locales/.yml"