https://github.com/hyperscale-stack/translation
The Hyperscale translation library provides a simple translation manager over x/text package.
https://github.com/hyperscale-stack/translation
go go-module golang gomodule i18n internationalization localization localize module translation translations
Last synced: 14 days ago
JSON representation
The Hyperscale translation library provides a simple translation manager over x/text package.
- Host: GitHub
- URL: https://github.com/hyperscale-stack/translation
- Owner: hyperscale-stack
- License: mit
- Created: 2022-02-24T21:36:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2026-05-11T05:29:20.000Z (about 1 month ago)
- Last Synced: 2026-05-11T07:25:10.374Z (about 1 month ago)
- Topics: go, go-module, golang, gomodule, i18n, internationalization, localization, localize, module, translation, translations
- Language: Go
- Homepage:
- Size: 88.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Hyperscale Translation [](https://github.com/hyperscale-stack/translation/releases/latest) [](https://godoc.org/github.com/hyperscale-stack/translation)
[](https://goreportcard.com/report/github.com/hyperscale-stack/translation)
| Branch | Status | Coverage |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| master | [](https://github.com/hyperscale-stack/translation/actions?query=workflow%3AGo) | [](https://coveralls.io/github/hyperscale-stack/translation?branch=master) |
The Hyperscale translation library provides a simple translation manager over `x/text` package.
## Example
```go
package main
import (
"fmt"
"github.com/hyperscale-stack/locale"
"github.com/hyperscale-stack/translation"
"golang.org/x/text/language"
"golang.org/x/text/message/catalog"
)
func main() {
// plase use golang.org/x/text/cmd/gotext for build catalog
c := catalog.NewBuilder(catalog.Fallback(language.English))
c.SetString(language.English, "Hello World", "Hello World")
c.SetString(language.French, "Hello World", "Bonjour le monde")
// the default language is always language.English, for override use translation.WithDefaultLocale()
trans := translation.New(
[]language.Tag{
language.English,
language.French,
},
translation.WithCatalog(c),
)
ctx := context.Background()
ctx = locale.ToContext(ctx, language.French)
trans.Translate(ctx, "Hello World") // return Bonjour le monde
}
```
## License
Hyperscale Translation is licensed under [the MIT license](LICENSE.md).