po

package
v0.0.0-...-f974105 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const NOTUSED = "not-used, archived.  Not currently needed for translation."

Variables

This section is empty.

Functions

func Friendly

func Friendly(code string) string

func PoQuote

func PoQuote(w *bytes.Buffer, label string, content string)

Types

type File

type File struct {
	ByID              MapStringRecord
	InOrder           []string
	Headers           MapHeaders
	Language          string
	Locale            string
	Translated        int
	OutOf             int
	PercentTranslated string
	// contains filtered or unexported fields
}

File contains the map of strings for this translation.

func Load

func Load(fn string) (*File, error)

Load a .PO file into memory.

func (*File) Add

func (f *File) Add(input string, context string, escapequotes bool)

Translate takes a given input text, and returns back either the translated text, or the original text again.

func (*File) GetLang

func (f *File) GetLang() string

GetLang returns the lowercase name string; ie en or pt

func (*File) GetLangName

func (f *File) GetLangName() string

GetLang returns the lowercase name string; ie en or pt

func (*File) GetLangPercentTranslated

func (f *File) GetLangPercentTranslated() string

GetLangPercentTranslated returns what percentage of the translation is done

func (*File) GetLangUC

func (f *File) GetLangUC() string

GetLangUC returns the uppercase name string; ie EN or PT

func (*File) GetLocale

func (f *File) GetLocale() string

GetLocale simply returns the locale name; ie en_US or pt_BR

func (*File) Save

func (f *File) Save(fn string) error

Load a .PO file into memory.

func (*File) Translate

func (f *File) Translate(input string, escapequotes bool) string

Translate takes a given input text, and returns back either the translated text, or the original text again.

type Files

type Files struct {
	Pot        *File
	ByLanguage MapStringFile
}

Files a collection of loaded translation files, plus the .pot file

func LoadAll

func LoadAll(potfn string, root string) (*Files, error)

LoadAll loads a .pot file, and a directory of .po files. The .pot file is mostly used for statistics.

func (*Files) ApacheAddLanguage

func (f *Files) ApacheAddLanguage() string

ApacheAddLanguage Generates the Apache "AddLanguage" text

func (*Files) Languages

func (combined *Files) Languages() []string

Languages returns the list of locales loaded in the combined *Files object

type MapHeaders

type MapHeaders map[string]string

MapHeaders contains a list of headers from the "" element (first element).

type MapStringFile

type MapStringFile map[string]*File

MapStringFile is a map of loaded translation files

type MapStringRecord

type MapStringRecord map[string]*Record

MapStringRecord maps original strings to Records

type Record

type Record struct {
	Comment string
	MsgID   string
	MsgStr  string
}

Record is a single text translated

Jump to

Keyboard shortcuts

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