i18n icon indicating copy to clipboard operation
i18n copied to clipboard

FallbackLocales doesn't work

Open fffilimonov opened this issue 6 years ago • 0 comments

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.

fffilimonov avatar Sep 28 '18 06:09 fffilimonov