Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gobuffalo/mw-i18n
Buffalo i18n Middleware
https://github.com/gobuffalo/mw-i18n
go gobuffalo golang i18n internationalization middleware translation
Last synced: 3 days ago
JSON representation
Buffalo i18n Middleware
- Host: GitHub
- URL: https://github.com/gobuffalo/mw-i18n
- Owner: gobuffalo
- License: mit
- Created: 2018-07-30T11:41:37.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T15:39:54.000Z (almost 2 years ago)
- Last Synced: 2024-06-19T22:16:51.913Z (5 months ago)
- Topics: go, gobuffalo, golang, i18n, internationalization, middleware, translation
- Language: Go
- Size: 345 KB
- Stars: 6
- Watchers: 8
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# i18n middleware
NOTE: v2.0.3 will be the last version of this module and it will be deprecated.
Use instead.This Buffalo middleware enables i18n features in your app:
* User language detection from configurable sources
* Translation helper using locales bundles from github.com/nicksnyder/go-i18n
* Localized views## Installation
This middleware is setup by default on a new Buffalo app:
### actions/app.go
```go
var app *buffalo.App// T is used to provide translations
var T *i18n.Translator// App is where all routes and middleware for buffalo
// should be defined. This is the nerve center of your
// application.
func App() *buffalo.App {
if app == nil {
// [...]// Setup and use translations:
var err error
if T, err = i18n.New(os.DirFS("locales"), "en"); err != nil {
app.Stop(err)
}
app.Use(T.Middleware())
}
return app
}
```Use `i18n.New` to create a new instance of the translation module, then add the middleware (`T.Middleware()`) to the app to enable its features.
See for further info about Buffalo translation features and configuration.