Documentation ¶
Index ¶
- Variables
- func ParseLocalizations(rawData [][]RawCell, platform Platform, formats Formats, tabName string, ...) (loc Localizations, formatArgs LocalizationFormatArgs, warnings []error, ...)
- func Run(source Source, platform Platform, resDir string, keyColumn string, ...) error
- func WriteLocalizations(platform Platform, dir ResDir, localizations Localizations, ...) (error error)
- type Cell
- type FallbackStringWriter
- type FooterArgs
- type FormatKey
- type FormatStringArgs
- type Formats
- type HeaderArgs
- type Key
- type Lang
- type LocalizationFormatArgs
- type Localizations
- type LocalizedStringArgs
- type Platform
- type PostprocessArgs
- type Postprocessor
- type PreprocessArgs
- type Preprocessor
- type RawCell
- type ResDir
- type Source
Constants ¶
This section is empty.
Variables ¶
var DefaultEmptyLocRegexp, _ = regexp.Compile("^$")
Functions ¶
func ParseLocalizations ¶
func ParseLocalizations( rawData [][]RawCell, platform Platform, formats Formats, tabName string, keyColumn string, errorIfMissing bool, emptyLocalizationRegexp *regexp.Regexp, ) (loc Localizations, formatArgs LocalizationFormatArgs, warnings []error, error error)
ParseLocalizations parses formats given the raw table data and returns, if successful, mappings for each localized string in different languages.
func Run ¶
func Run( source Source, platform Platform, resDir string, keyColumn string, formatNameColumn string, defaultLocalization string, defaultLocalizationPath string, stopOnMissing bool, reportMissingLocalizations bool, defFormatName string, emptyLocalizationMatch *regexp.Regexp, ) error
Run launches the actual process of fetching, parsing and writing the localization files.
func WriteLocalizations ¶
func WriteLocalizations( platform Platform, dir ResDir, localizations Localizations, formatArgs LocalizationFormatArgs, defLocLang Lang, defLocPath string, ) (error error)
WriteLocalizations writes localization files into platform-defined directories.
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell represents a table cell.
type FallbackStringWriter ¶
type FallbackStringWriter interface {
FallbackString(args *LocalizedStringArgs) string
}
type FooterArgs ¶
type FooterArgs struct {
}FooterArgs encapsulates arguments to a function that returns a localization file footer for a given platform.
type FormatKey ¶
type FormatKey = string
FormatKey represents a name of the format.
func FormatArgs ¶
type FormatStringArgs ¶
FormatStringArgs encapsulates arguments to a function that returns the actual format specification for a given platform.
type Formats ¶
Formats represents a mapping between format names and platform-specific format descriptions.
func ParseFormats ¶
func ParseFormats( rawData [][]RawCell, platform Platform, formatsTabName string, formatColumnTitle string, defFormatName string, ) (Formats, error)
ParseFormats parses formats given the raw table data and returns, if successful, mappings to the actual platform format for each format name.
type HeaderArgs ¶
HeaderArgs encapsulates arguments to a function that returns a localization file header for a given platform.
type LocalizationFormatArgs ¶
LocalizationFormatArgs represents a mapping between a localized string key and its format arguments.
type Localizations ¶
Localizations represents a mapping between a localized string key and it's values for different languages.
func (Localizations) Count ¶
func (loc Localizations) Count() map[Lang]int
func (Localizations) Locales ¶
func (loc Localizations) Locales() (locales []string)
func (Localizations) SortedKeys ¶
func (loc Localizations) SortedKeys() (sortedKeys []Key)
type LocalizedStringArgs ¶
type LocalizedStringArgs struct { Index int IsLast bool Lang Lang Key Key Value string FormatArgs []string }
LocalizedStringArgs encapsulates arguments to a function that returns the actual localized string for a given platform.
type Platform ¶
type Platform interface { // Returns platform names that can be used to identify it in the sheet. Names() []string // Returns a full relative path to localization file for a given language. LocalizationFilePath(lang Lang, resDir ResDir) string // Returns header text. Returned string can be empty. Newlines must be included here if localization format requires them. Header(args *HeaderArgs) string // Returns actual localization binding for a given language. Newlines must be included here if localization format requires them. LocalizedString(args *LocalizedStringArgs) string Footer(args *FooterArgs) string // Returns nil if format is valid and non-nil error otherwise ValidateFormat(format string) error // Returns an actual format string taking the argument position into consideration. // Example 1: format strings on Android are positional (with position starting from 1). In this case invocation of IndexedFormatString(0, "s") would return "%1$s". // Example 2: format strings on iOS aren't positional. In this case invocation of IndexedFormatString(0, "@") would return "%@". FormatString(args *FormatStringArgs) string // Returns replacement characters for any special character that needs to be guarded in the platform resources. ReplacementChars() map[string]string }
Platform represents an object responsible for specifying a format of the resulting localization file.
type PostprocessArgs ¶
type PostprocessArgs struct { Localizations Localizations Formats Formats FormatArgs LocalizationFormatArgs ResDir ResDir DefaultLocalization Lang }
PostprocessArgs encapsulates arguments for a postprocess function
type Postprocessor ¶
type Postprocessor interface {
Postprocess(args PostprocessArgs) error
}
type PreprocessArgs ¶
type PreprocessArgs struct { Localizations Localizations Formats Formats FormatArgs LocalizationFormatArgs ResDir ResDir DefaultLocalization Lang }
PreprocessArgs encapsulates arguments for a preprocess function
type Preprocessor ¶
type Preprocessor interface {
Preprocess(args PreprocessArgs) error
}