Go 实现的国际化 i18n 库 go-i18n

码农软件 · 软件分类 · 其他开发相关 · 2019-10-16 09:43:43

软件介绍

ii18n - 是一个 Go 的 i18n 库,采用 MIT 开源协议。通过读取翻译映射格式的配置文件来实现多语言翻译。使用起来非常简单方便。

下载安装

go get github.com/syyongx/ii18n

快速开始

import github.com/syyongx/ii18n

func main() {
    config := map[string]Config{
        "app": Config{
            SourceNewFunc: NewJSONSource,
            OriginalLang:  "en-US",
            BasePath:      "./testdata",
            FileMap: map[string]string{
                "app":   "app.json",
                "error": "error.json",
            },
        },
    }
    NewI18N(config)
    message := T("app", "hello", nil, "zh-CN")
}

Apis

NewI18N(config map[string]Config) *I18N
T(category string, message string, params map[string]string, lang string) string

配置文件

参考 testdata 目录。

本文地址:https://www.codercto.com/soft/d/16867.html

软件测试

软件测试

[美]Ron Patton / 张小松、王珏、曹跃 / 机械工业出版社 / 2006-4 / 30.00元

软件测试(原书第2版),ISBN:9787111185260,作者:(美)佩腾(Patton,R.) 著,张小松 等译;张小松译一起来看看 《软件测试》 这本书的介绍吧!

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具