From eef6ef6aa172392861826bc2bd8ae0bb4506f241 Mon Sep 17 00:00:00 2001 From: misitebao Date: Wed, 29 Jun 2022 22:45:31 +0800 Subject: [PATCH] chore: add sample code for using "go:embed" --- .github/README.zh-Hans.md | 8 ++++++++ README.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/README.zh-Hans.md b/.github/README.zh-Hans.md index 1be45ce1..ae593afb 100644 --- a/.github/README.zh-Hans.md +++ b/.github/README.zh-Hans.md @@ -38,6 +38,14 @@ bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) bundle.LoadMessageFile("es.toml") ``` +```go +// 如果使用 go:embed +//go:embed locale.*.json +var LocaleFS embed.FS + +bundle.LoadMessageFileFS(LocaleFS, "locale.sv.json") +``` + 创建一个 Localizer 以用于一组语言首选项。 ```go diff --git a/README.md b/README.md index 0856dc8d..f3cc20d4 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) bundle.LoadMessageFile("es.toml") ``` +```go +// If use go:embed +//go:embed locale.*.json +var LocaleFS embed.FS + +bundle.LoadMessageFileFS(LocaleFS, "locale.sv.json") +``` + Create a Localizer to use for a set of language preferences. ```go