Package i18n provides internationalization and localization for your Go applications.

Overview

i18n

GitHub Workflow Status codecov GoDoc Sourcegraph

Package i18n provides internationalization and localization for your Go applications.

Installation

The minimum requirement of Go is 1.16.

go get github.com/go-i18n/i18n

Getting started

# locale_en-US.ini
[plurals]
file.one = file
file.other = files

dog.one = dog
dog.other = dogs

[messages]
test1 = This patch has %[1]d changed ${file, 1} and deleted %[2]d ${file, 2}
test2 = I have %[1]d ${dog, 1}
# locale_zh-CN.ini
[plurals]
file.other = 文件

[messages]
test1 = 该补丁变更了 %[1]d 个${file, 1}并删除了 %[2]d 个${file, 2}
"This patch has 1 changed file and deleted 2 files" fmt.Println(l2.Translate("messages::test1", 1, 2)) // => "该补丁变更了 1 个文件并删除了 2 个文件" fmt.Println(l2.TranslateWithFallback(l1, "messages::test2", 1)) // => "I have 1 dog" } ">
package main

import (
	"fmt"

	"github.com/go-i18n/i18n"
)

func main() {
	s := i18n.NewStore()
	l1, err := s.AddLocale("en-US", "English", "locale_en-US.ini")
	// ... handler error

	l2, err := s.AddLocale("zh-CN", "简体中文", "locale_zh-CN.ini")
	// ... handler error

	fmt.Println(l1.Translate("messages::test1", 1, 2))
	// => "This patch has 1 changed file and deleted 2 files"

	fmt.Println(l2.Translate("messages::test1", 1, 2))
	// => "该补丁变更了 1 个文件并删除了 2 个文件"

	fmt.Println(l2.TranslateWithFallback(l1, "messages::test2", 1))
	// => "I have 1 dog"
}

License

This project is under the MIT License. See the LICENSE file for the full license text.

Issues
  • Possible to use in gin,is there a demo to refer to?

    Possible to use in gin,is there a demo to refer to?

    What needs to be improved? Please describe

    Possible to use in gin,is there a demo to refer to?

    Why do you think it is important?

    Possible to use in gin,is there a demo to refer to?

    Code of Conduct

    • [X] I agree to follow this project's Code of Conduct
    documentation 
    opened by passerbyo 0
Releases(v1.0.1)
Owner
Internationalization and localization for your Go applications
null
Go-i18n - i18n for Golang

I18n for Go Installation go get -u github.com/fitv/go-i18n Usage YAML files ├──

null 4 Jul 27, 2022
i18n-pseudo - Pseudolocalization is an incredibly useful tool for localizing your apps.

i18n-pseudo Pseudolocalization is an incredibly useful tool for localizing your apps. This module makes it easy to apply pseudo to any given string. I

Fetch Rewards 2 Mar 21, 2022
i18n of golang

i18n i18n of golang 使用方法 下载i18n go get https://github.com/itmisx/i18n 定义 code 语言包 var langPack1 = map[string]map[interface{}]interface{}{ "zh-cn": {

xiaolei 1 Dec 11, 2021
A Go package for n-gram based text categorization, with support for utf-8 and raw text

A Go package for n-gram based text categorization, with support for utf-8 and raw text. To do: write documentation make it faster Keywords: text categ

Peter Kleiweg 67 Feb 13, 2022
[UNMANTEINED] Extract values from strings and fill your structs with nlp.

nlp nlp is a general purpose any-lang Natural Language Processor that parses the data inside a text and returns a filled model Supported types int in

Juan Alvarez 379 Jul 28, 2022
Natural language detection package in pure Go

getlang getlang provides fast natural language detection in Go. Features Offline -- no internet connection required Supports 29 languages Provides ISO

Rylan 138 Jul 28, 2022
The shamoji (杓文字) is a word filtering package

shamoji About The shamoji (杓文字) is word filtering package. Install $ go get -u github.com/osamingo/shamoji Usage package main import ( "fmt" "sync

Osamu TONOMORI 12 May 4, 2022
Translate your Go program into multiple languages.

go-i18n go-i18n is a Go package and a command that helps you translate Go programs into multiple languages. Supports pluralized strings for all 200+ l

Nick Snyder 2.1k Aug 9, 2022
📖 Tutorial: An easy way to translate your Golang application

?? Tutorial: An easy way to translate your Golang application ?? The full article is published on April 13, 2021, on Dev.to: https://dev.to/koddr/an-e

Vic Shóstak 6 Feb 9, 2022
Translate your Go program into multiple languages with similar fmt.Sprintf format syntax.

Loafer-i18n Loafer-i18n is a Go package and a command that helps you translate Go programs into multiple languages. Supports pluralized strings with =

EasyGram 0 Dec 22, 2021
Go efficient text segmentation and NLP; support english, chinese, japanese and other. Go 语言高性能分词

gse Go efficient text segmentation; support english, chinese, japanese and other. 简体中文 Dictionary with double array trie (Double-Array Trie) to achiev

ego 2k Aug 9, 2022
Utilities for working with discrete probability distributions and other tools useful for doing NLP work

GNLP A few structures for doing NLP analysis / experiments. Basics counter.Counter A map-like data structure for representing discrete probability dis

Matt Jones 90 May 31, 2022
Read and use word2vec vectors in Go

Introduction This is a package for reading word2vec vectors in Go and finding similar words and analogies. Installation This package can be installed

Daniël de Kok 47 Jul 3, 2022
Selected Machine Learning algorithms for natural language processing and semantic analysis in Golang

Natural Language Processing Implementations of selected machine learning algorithms for natural language processing in golang. The primary focus for t

James Bowman 370 Jul 27, 2022
A Golang library for text processing, including tokenization, part-of-speech tagging, and named-entity extraction.

prose is a natural language processing library (English only, at the moment) in pure Go. It supports tokenization, segmentation, part-of-speech tagging, and named-entity extraction.

Joseph Kato 2.9k Aug 7, 2022
Self-contained Machine Learning and Natural Language Processing library in Go

If you like the project, please ★ star this repository to show your support! ?? A Machine Learning library written in pure Go designed to support rele

NLP Odyssey 1.2k Aug 1, 2022
Stemmer packages for Go programming language. Includes English, German and Dutch stemmers.

Stemmer package for Go Stemmer package provides an interface for stemmers and includes English, German and Dutch stemmers as sub-packages: porter2 sub

Dmitry Chestnykh 51 Jan 23, 2022
A go library for reading and creating ISO9660 images

iso9660 A package for reading and creating ISO9660 Joliet and Rock Ridge extensions are not supported. Examples Extracting an ISO package main import

Kamil Domański 212 Aug 3, 2022
Gopher-translator - A HTTP API that accepts english word or sentences and translates them to Gopher language

Gopher Translator Service An interview assignment project. To see the full assig

Teodor Draganov 0 Jan 25, 2022