intl

package
v0.0.0-...-fd1ce1a Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package intl provides utilties for internationalization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type L10N

type L10N struct {
	// Mapping from source code format strings to format strings
	// for the target locale.
	FmtStrings map[L10NString]L10NString
}

An L10N is a localization; it can be used to translate strings to the target locale. The zero value assumes format strings are already in the target locale, providing no translations.

func (L10N) Fmt

func (l L10N) Fmt(fmt L10NString, args ...string) string

Format a message for the target locale. 'fmt' is a string which may include format specifiers:

%% emits a literal '%'

%0, %1, ... %9 each emit args[i] where i is the number after the %.

If the character after the % is anything else, or if the % is at the end of the string, it is emitted literally.

Before formatting, the format string will first be translated to the target locale. If the string is not known to the receiver, it will be used as-is.

type L10NString

type L10NString string

An L10NString is a string which should be localized. Defined as its own type so that you can't pass a variable of type string as the fmt argument to L10N.Fmt, but you can still pass a string literal.

Jump to

Keyboard shortcuts

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