Skip to content

Commit

Permalink
Add explaination of how to allow user to translate via admin UI
Browse files Browse the repository at this point in the history
  • Loading branch information
raven-chen committed Jun 1, 2021
1 parent f7206d2 commit 0f75814
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func main() {

I18n.T("en-US", "demo.greeting") // Not exist at first
I18n.T("en-US", "demo.hello") // Exists in the yml file

i18n.Default = "zh-CN" // change the default locale. the original value is "en-US"
}
```

Expand All @@ -51,7 +53,16 @@ I18n has a built-in web interface for translations which is integrated with [QOR
Admin.AddResource(I18n)
```

Then a page like this will be added to [QOR Admin](http://github.com/qor/admin) interface
To let users able to translate between locales in the admin interface, your "User" need to implement these interfaces.
```go
func (user User) EditableLocales() []string {
return []string{"en-US", "zh-CN"}
}

func (user User) ViewableLocales() []string {
return []string{"en-US", "zh-CN"}
}
```

Refer the [online demo](http://demo.getqor.com/admin/translations).

Expand Down Expand Up @@ -163,6 +174,8 @@ inline_edit.FuncMap(I18n, "en-US", true) // => map[string]interface{}{
// }
```



## License

Released under the [MIT License](http://opensource.org/licenses/MIT).

0 comments on commit 0f75814

Please sign in to comment.