go-localize alternatives and similar packages
Based on the "Natural Language Processing" category.
Alternatively, view go-localize alternatives based on common mentions on social networks and blogs.
-
prose
A library for text processing that supports tokenization, part-of-speech tagging, named-entity extraction, and more. -
gojieba
This is a Go implementation of jieba which a Chinese word splitting algorithm. -
gse
Go efficient text segmentation; support english, chinese, japanese and other. -
go-i18n
A package and an accompanying tool to work with localized text. -
spaGO
Self-contained Machine Learning and Natural Language Processing library in Go. -
whatlanggo
A natural language detection package for Go. Supports 84 languages and 24 scripts (writing systems e.g. Latin, Cyrillic, etc). -
sentences
A sentence tokenizer: converts text into a list of sentences. -
locales
π a set of locales generated from the CLDR Project which can be used independently or within an i18n package; these were built for use with, but not exclusive to https://github.com/go-playground/universal-translator -
universal-translator
π¬ i18n Translator for Go/Golang using CLDR data + pluralization rules -
go-nlp
Utilities for working with discrete probability distributions and other tools useful for doing NLP work. -
RAKE.go
A Go port of the Rapid Automatic Keyword Extraction Algorithm (RAKE) -
gounidecode
Unicode transliterator (also known as unidecode) for Go -
segment
A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29 -
MMSEGO
This is a GO implementation of MMSEG which a Chinese word splitting algorithm. -
textcat
A Go package for n-gram based text categorization, with support for utf-8 and raw text -
stemmer
Stemmer packages for Go programming language. Includes English and German stemmers. -
paicehusk
Golang implementation of the Paice/Husk Stemming Algorithm -
petrovich
Petrovich is the library which inflects Russian names to given grammatical case. -
snowball
Snowball stemmer port (cgo wrapper) for Go. Provides word stem extraction functionality Snowball native. -
golibstemmer
Go bindings for the snowball libstemmer library including porter 2 -
icu
Cgo binding for icu4c C library detection and conversion functions. Guaranteed compatibility with version 50.1. -
libtextcat
Cgo binding for libtextcat C library. Guaranteed compatibility with version 2.2. -
go-tinydate
A tiny date object in Go. Tinydate uses only 4 bytes of memory -
gotokenizer
A tokenizer based on the dictionary and Bigram language models for Golang. (Now only support chinese segmentation) -
porter
This is a fairly straightforward port of Martin Porter's C implementation of the Porter stemming algorithm. -
gosentiwordnet
Sentiment analyzer using sentiwordnet lexicon in Go. -
go-eco
Similarity, dissimilarity and distance matrices; diversity, equitability and inequality measures; species richness estimators; coenocline models. -
detectlanguage
Language Detection API Go Client. Supports batch requests, short phrase or single word language detection.
Scout APM - Leading-edge performance monitoring starting at $39/month
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of go-localize or a related project?
Popular Comparisons
README
go-localize
Simple and easy to use i18n (Internationalization and localization) engine written in Go, used for translating locale strings. Use with go generate or on the CLI. Currently supports JSON, YAML, TOML and CSV translation files
Why another i18n library?
This package aims to be as simple and easy to use as possible. It also takes inspiration from popular localization libraries/packages in other languages - so makes it easier to reason about coming from other languages and frameworks.
Usage
Go generate
The suggested way to use go-localize is to use go generate
. For example, take the following directory structure:
goapp
βββ localizations_src
βββ en
βΒ Β βββ messages.yaml
βββ es
βββ customer
βΒ Β βββ messages.json
βββ messages.json
Example of JSON translation file:
{
"hello": "Hola",
"how_are_you": "ΒΏCΓ³mo estΓ‘s?",
"whats_your_name": "ΒΏCuΓ‘l es tu nombre?",
"hello_my_name_is": "Hola, mi nombre es {{.name}}"
}
Example of YAML translation file:
hello: hello
how_are_you: How are you?
whats_your_name: "What's your name?"
hello_my_name_is: Hello my name is {{.name}}
hello_firstname_lastname: Hello {{.firstname}} {{.lastname}}
Example of CSV translation file:
hello, hello
how_are_you, How are you?
Example of TOML translation file:
hello = "hello"
how_are_you = "How are you?"
To then generate the localization package, add the following to your main.go
or another one of your .go
files:
//go:generate go-localize -input localizations_src -output localizations
Now you'll be able to use the localization like so:
l := localizations.New("en", "es")
println(l.Get("messages.how_are_you")) // How are you?
println(l.GetWithLocale("es", "messages.hello_my_name_is", &localizations.Replacements{"name":"steve"})) // "Hola, mi nombre es steve"
With en
being the locale and es
being the fallback. The localization keys are worked out using folder structure, eg:
en/customer/messages.json
with the contents being:
{
"hello": "hello customer!"
}
You'll be able to access this using the key: customer.messages.hello
.
Suggestions
It is suggested to instead of using hardcoded locale keys i.e. en
to use the language keys included in key, i.e: language.BritishEnglish.String()
which is en-GB
Replacements
Take this replacement string for example:
hello_firstname_lastname: Hello {{.firstname}} {{.lastname}}
To then replace firstname
and the lastname
variable, you can use
something like this:
l := localizations.New("en", "es")
println(l.Get("hello_firstname_lastname", &localizations.Replacements{"firstname": "steve", "lastname": "steve"}))
You can also append numerous replacements if you have them like so:
println(l.Get("hello_firstname_lastname", &localizations.Replacements{"firstname": "steve"}, &localizations.Replacements{"lastname": "steve"}))
Locale defining and localization fallbacks
You can define the locale and fallbacks using:
l := localizations.New("en", "es")
Where en
is the locale and es
is the fallback. If no translation key-value is
found then the key will be returned. For example
println(l.Get("key_doesnt_exist")) //"key_doesnt_exist" will be printed
Translation file support
We currently support JSON and YAML translation files. Please suggest missing file type using issues or pull requests.
CLI
Instead of using go generate you can just generate the localizations manually using go-localize
:
Usage of go-localize:
-input string
input localizations folder
-output string
where to output the generated package