https://github.com/dcb9/i18nc
Generate type safe Go code from english locale content
https://github.com/dcb9/i18nc
Last synced: about 2 months ago
JSON representation
Generate type safe Go code from english locale content
- Host: GitHub
- URL: https://github.com/dcb9/i18nc
- Owner: dcb9
- License: mit
- Created: 2021-09-28T03:27:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-28T08:10:19.000Z (over 3 years ago)
- Last Synced: 2025-01-25T16:09:15.184Z (4 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# i18nc
Generate type safe Go code from english locale content## Usage
### Create i18nc generate.go
```
# file i18nc/generate.gopackage i18nc
//go:generate go run -mod=mod github.com/dcb9/i18nc/cmd/i18nc $GOPACKAGE i18nc_generated.go ../locales/en.json
```### generate Go code
```bash
$ go generate ./i18nc
```### Init i18nc and use
```
package mainimport (
"your_module/i18nc"
"github.com/nicksnyder/go-i18n/v2/i18n"
)func main() {
i18nc.Localizer = initLocalizer()fmt.Println(i18nc.YourMessageID())
}func initLocalizer() *i18n.Localizer {
// FIXME: do your own init procedure
return nil
}
```## Acknowledgements
- [nicksnyder/go-i18n](https://github.com/nicksnyder/go-i18n)
- [gobeam/stringy](https://github.com/gobeam/stringy)## License
Released under the MIT License - see `LICENSE` for details.