Skip to content

Commit

Permalink
chore: add sample code for using "go:embed"
Browse files Browse the repository at this point in the history
  • Loading branch information
misitebao committed Jun 29, 2022
1 parent faa7b93 commit eef6ef6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/README.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eef6ef6

Please sign in to comment.