i18n

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package i18n provides internationalization support for lokit itself.

It wraps the gotext library to provide simple T() and N() functions for translating lokit's user-facing strings. Translations are embedded in the binary via //go:embed and loaded at startup via Init().

Usage:

import "github.com/minios-linux/lokit/i18n"

func main() {
    i18n.Init("")  // auto-detect from LANGUAGE/LC_ALL/LC_MESSAGES/LANG
    fmt.Println(i18n.T("Hello, world!"))
    fmt.Println(i18n.N("Found %d file", "Found %d files", count))
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(lang string)

Init initializes the i18n system. If lang is empty, it auto-detects from the environment variables LANGUAGE, LC_ALL, LC_MESSAGES, LANG (in that order, matching GNU gettext behavior).

Init should be called once at program startup, before any T() or N() calls.

func N

func N(singular, plural string, n int) string

N translates a string with plural forms. The singular form is used when n == 1, the plural form otherwise (exact rules depend on the target language's plural formula).

func T

func T(msgid string) string

T translates a string. If no translation is available, returns the original string unchanged (standard gettext passthrough behavior).

Types

This section is empty.

Jump to

Keyboard shortcuts

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