lang

package
v0.0.0-...-d417536 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Overview

Internationalization support.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Available languages.
	Langs = []string{
		"en", "ru", "de",
	}

	// Some UI constants.
	Months = []string{
		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
	}
	Days = []string{
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
	}
)

Functions

func DefaultFromReq

func DefaultFromReq(r *http.Request) string

Try to guess appropriate default language based on request's IP.

func FromReq

func FromReq(r *http.Request) string

Get request's language.

func Get

func Get(langID, str string) string

Translate given string. Will panic on invalid langID, must be checked by caller.

func GetN

func GetN(langID, str, plural string, n int) string

Translate plural form. Will panic on invalid langID, must be checked by caller.

func Load

func Load() (err error)

Preload all available translations.

Types

This section is empty.

Jump to

Keyboard shortcuts

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