i18n

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package i18n provides internationalization support for PixivFE.

This file contains global functions and variables for setting and retrieving the current locale, as well as functions for translating user-facing errors and formatted strings.

This file loads translation files and looks up translations for given strings.

This file rewrites strings in Jet templates before they are parsed.

Index

Constants

View Source
const BaseLocale = "en"

BaseLocale is the default locale used when no specific locale is set.

View Source
const (
	// CallerSkipFrames is the number of stack frames to skip to reach the calling function
	// that invokes the translation lookup.
	CallerSkipFrames int = 2
)

Variables

View Source
var AvailableLanguages = []language{
	{"en", "English"},
	{"vi-VN", "Vietnamese"},
	{"zh-TW", "Traditional Chinese"},
}

AvailableLanguages lists the languages supported by package i18n.

Functions

func Error

func Error(text string) error

func Errorf

func Errorf(format string, a ...any) error

func GetLocale

func GetLocale() string

func Replacer

func Replacer(locale string, file string) *strings.Replacer

Replacer returns nil when nothing needs to be replaced.

func SetLocale

func SetLocale(locale string)

func Setup

func Setup() error

func Sprintf

func Sprintf(format string, a ...any) string

func SuccintID

func SuccintID(file string, text string) string

func Tag added in v3.0.4

func Tag(tag string) string

Tag returns the English translation for a given tag.

If no translation is found, it returns the original tag.

func Tr

func Tr(text string) string

Tr returns a translation for the provided string.

Types

type TrPairs

type TrPairs = []string

format: old0, new0, old1, new1, ...

Directories

Path Synopsis
Package main is a crawler to find i18n function calls in Go files.
Package main is a crawler to find i18n function calls in Go files.
Package main provides a tool that reads JSON input from stdin, creates a translation map, outputs the result as JSON to stdout.
Package main provides a tool that reads JSON input from stdin, creates a translation map, outputs the result as JSON to stdout.
This file implements a crawler for extracting translatable strings from HTML templates.
This file implements a crawler for extracting translatable strings from HTML templates.

Jump to

Keyboard shortcuts

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