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

Sexy Web Design

Sexy Web Design

Elliot Stocks / SitePoint / 2009-03-28 / $39.95

Description A guide to building usable, aesthetically pleasing interfaces for web sites and web applications by applying timeless principles of user-centered design. This book focuses on practical ......一起来看看 《Sexy Web Design》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

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

HEX CMYK 互转工具

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

HEX HSV 互换工具