MIT License

项目介绍

go-playground/universal-translator 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 MIT License 许可证,目前获得 429 个 Star、55 次 Fork。

仓库全名
go-playground/universal-translator
开源许可证
MIT License
Star 数
429
Fork 数
55
未关闭 Issue
11

README 摘要

universal-translator Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules Why another i18n library? Because none of the plural rules seem to be correct out there, including the previous implementation of this package, so I took it upon myself to create locales for everyone to use; this package is a thin wrapper around locales in order to store and translate text for use in…

完整内容见 GitHub 原始 README 或本页 。

常见问题

universal-translator 用什么语言开发?

主要使用 Go 编写,采用 MIT License 许可证,目前有 429 个 Star。

universal-translator 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 universal-translator 的源码?

可以直接克隆仓库:git clone https://github.com/go-playground/universal-translator.git,默认分支为 master;安装与运行步骤见仓库 README。

universal-translator 最近还在维护吗?

仓库最近一次更新为 9月21日,当前有 11 个未关闭 Issue;Star 数为 429,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

:speech_balloon: i18n Translator for Go/Golang using CLDR data + pluralization rules

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
548
价值分
274
活跃状态
活跃

语言占比

Go
Go Template
Makefile

Release

README

universal-translator

Project status Coverage Status Go Report Card GoDoc License

Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules

Why another i18n library?

Because none of the plural rules seem to be correct out there, including the previous implementation of this package, so I took it upon myself to create locales for everyone to use; this package is a thin wrapper around locales in order to store and translate text for use in your applications.

Features

  • Rules generated from the CLDR data, v36.0.1
  • Contains Cardinal, Ordinal and Range Plural Rules
  • Contains Month, Weekday and Timezone translations built in
  • Contains Date & Time formatting functions
  • Contains Number, Currency, Accounting and Percent formatting functions
  • Supports the “Gregorian” calendar only ( my time isn’t unlimited, had to draw the line somewhere )
  • Support loading translations from files
  • Exporting translations to file(s), mainly for getting them professionally translated
  • Code Generation for translation files -> Go code… i.e. after it has been professionally translated
  • Tests for all languages, I need help with this, please see here

Installation

Use go get

go get github.com/go-playground/universal-translator

Usage & Documentation

Please see https://godoc.org/github.com/go-playground/universal-translator for usage docs

Examples:

File formatting

All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained within the same file(s); they are only separated for easy viewing.

Examples:
Basic Makeup

NOTE: not all fields are needed for all translation types, see examples

{
    "locale": "en",
    "key": "days-left",
    "trans": "You have {0} day left.",
    "type": "Cardinal",
    "rule": "One",
    "override": false
}
Field Description
locale The locale for which the translation is for.
key The translation key that will be used to store and lookup each translation; normally it is a string or integer.
trans The actual translation text.
type The type of translation Cardinal, Ordinal, Range or “” for a plain substitution(not required to be defined if plain used)
rule The plural rule for which the translation is for eg. One, Two, Few, Many or Other.(not required to be defined if plain used)
override If you wish to override an existing translation that has already been registered, set this to ‘true’. 99% of the time there is no need to define it.

Help With Tests

To anyone interesting in helping or contributing, I sure could use some help creating tests for each language. Please see issue here for details.

Supported Go Versions

This package is aligned with the Go release policy in that support is guaranteed for the two most recent major versions.

This does not mean the package will not work with older versions of Go, only that we reserve the right to increase the MSGV(Minimum Supported Go Version) when the need arises to address Security issues/patches, OS issues & support or newly introduced functionality that would greatly benefit the maintenance and/or usage of this package.

If and when the MSGV is increased it will be done so in a minimum of a Minor release bump.

License

Distributed under MIT License, please see license file in code for more details.

评论

暂无评论