i18n

package
v1.0.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package i18n 多国语言.

包括 Load, GetPrinter.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrinter

func GetPrinter(tags ...language.Tag) *message.Printer

func GetTag

func GetTag(langs []string, tags ...language.Tag) language.Tag

func Load

func Load(locales embed.FS) error
Example
package main

import (
	"embed"

	"github.com/xuender/oils/i18n"
)

//go:embed locales
var locales embed.FS

func main() {
	_ = i18n.Load(locales)
	tag, _ := i18n.Tag("zh_CN")
	printer := i18n.GetPrinter(tag)

	printer.Printf("hellohometown")

}
Output:

你好家乡!

func LoadDir

func LoadDir(locales embed.FS, dir string) error

func LoadFile

func LoadFile(locales embed.FS, paths ...string) error

func SetString

func SetString(tag language.Tag, data map[string]string) error

func Tag

func Tag(paths ...string) (language.Tag, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL