Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FallbackLocales doesn't work #17

Open
fffilimonov opened this issue Sep 28, 2018 · 0 comments
Open

FallbackLocales doesn't work #17

fffilimonov opened this issue Sep 28, 2018 · 0 comments

Comments

@fffilimonov
Copy link

Example:

locales/en-US.yml
en-US:
  demo:
    hi: "hello"
locales/ru-RU.yml
ru-RU:
  demo:
    hi: "привет"
main.go
package main

import (
	"fmt"
	"github.com/qor/i18n"
	"github.com/qor/i18n/backends/yaml"
)

func main() {
	I18n := i18n.New(yaml.New("locales"))

	I18n.FallbackLocales = map[string][]string{"ru-RU": []string{"fr-FR", "de-DE", "zh-CN"}}

	fmt.Printf("%v\n", I18n.T("en-US", "demo.hi"))
	fmt.Printf("%v\n", I18n.T("ru-RU", "demo.hi"))
	fmt.Printf("%v\n", I18n.T("zh-CN", "demo.hi"))
}

Output:

 go run main.go
hello
привет
hello

According to documentation i should see in the last line translation from locales/ru-RU.yml but I see from default locales/en-US.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant