Documentation ¶
Overview ¶
Package execute contains the functions called by the main command line interface
Index ¶
- Constants
- Variables
- type ProcessSettings
- func (settings *ProcessSettings) Directory() (ProcessedFileList, error)
- func (settings *ProcessSettings) File(languageIdentifier string) (loadedLanguages ProcessedFileList, err error)
- func (settings *ProcessSettings) FileCompileOnly(languageIdentifier string) error
- func (settings *ProcessSettings) FileNoReturn(languageIdentifier string) error
- type ProcessedFile
- type ProcessedFileFlag
- type ProcessedFileFlagName
- type ProcessedFileList
Constants ¶
const ( SettingsFileName = "settings-gol10n.json" VarDictionaryFileBase = "variables" YAML_Extension = "yaml" JSON_Extension = "json" )
const ( DictionaryFileBase = "dictionary" GTR_Extension_Compressed = ".gtr.gz" GTR_Extension_Uncompressed = ".gtr" )
Variables ¶
var ProcessedFileFlagNames = []ProcessedFileFlagName{ createPFFN(1, "UNUSED", " "), createPFFN(PFF_Language_SuccessfullyLoaded, "Language_SuccessfullyLoaded", "SuLD"), createPFFN(PFF_Language_SuccessNoFallbackSet, "Language_SuccessNoFallbackSet", "SuNF"), createPFFN(PFF_Language_IsDefault, "Language_IsDefault", "Defa"), createPFFN(PFF_Load_NotAttempted, "Load_NotAttempted", "LoNA"), createPFFN(PFF_Load_NotFound, "Load_NotFound", "LoNF"), createPFFN(PFF_Load_YAML, "Load_YAML", "LoYA"), createPFFN(PFF_Load_JSON, "Load_JSON", "LoJS"), createPFFN(PFF_Load_Compiled, "Load_Compiled", "LoCo"), createPFFN(PFF_Error_DuringProcessing, "Error_DuringProcessing", "Er "), createPFFN(PFF_OutputSuccess_CompiledLanguage, "OutputSuccess_CompiledLanguage", "OuCL"), createPFFN(PFF_OutputSuccess_CompiledDictionary, "OutputSuccess_CompiledDictionary", "OuCD"), createPFFN(PFF_OutputSuccess_GoDictionaries, "OutputSuccess_GoDictionaries", "OuGD"), }
ProcessedFileFlagNames is named information about the ProcessedFileFlags
Functions ¶
This section is empty.
Types ¶
type ProcessSettings ¶
type ProcessSettings struct { //The settings from $SettingsFileName DefaultLanguage string //The identifier for the default language InputPath string //The directory with the translation text files GoOutputPath string //The directory to output the generated Go files to. Each namespace gets its own directory and file in the format “$NamespaceName/translationIDs.go” CompiledOutputPath string //The directory to output the compiled binary translation files to. Each language gets its own .gtr or .gtr.gz (gzip compressed) file GoDictHeader string //Extra code included just above the const in generated go dictionaries CompressCompiled bool //Whether the compiled binary translation files are saved as .gtr or .gtr.gz (gzip compressed) AllowBigStrings bool //If the translation strings can be larger than 64KB. If true, and a large translation string is found, then compiled binary translation files will become larger AllowJSONTrailingComma bool //If JSON files can have trailing commas. If true, a sanitization process is ran over the JSON that changes the regular expression “,\s*\n\s*}” to just “}” //Extra settings added by [command line] flags OutputGoDictionary bool `json:"-"` //Whether to output go dictionary files OutputCompiled bool `json:"-"` //Whether to output compiled .gtr files IgnoreTimestamps bool `json:"-"` //Whether to force outputting all files, ignoring timestamps }
ProcessSettings are taken from $SettingsFileName and are used to automatically read translation text files, compiled translation files, and go dictionary files.
Compiled files are read from (and not written to) if their modification timestamps are newer than their translation text files, unless IgnoreTimestamps=true.
Updating the default language may force all other languages to be updated.
func (*ProcessSettings) Directory ¶
func (settings *ProcessSettings) Directory() (ProcessedFileList, error)
Directory processes all files in the InputPath directory. It also returns the resultant languages.
No ProcessedFiles are returned if any of the following errors occur: Directory error, language identity used more than once, default language not found
func (*ProcessSettings) File ¶
func (settings *ProcessSettings) File(languageIdentifier string) (loadedLanguages ProcessedFileList, err error)
File processes a single language and its fallbacks (and default). It returns the resultant languages (fallbacks, default, self).
The languages in the fallback chain and the default language are also processed for the returned Language objects.
func (*ProcessSettings) FileCompileOnly ¶
func (settings *ProcessSettings) FileCompileOnly(languageIdentifier string) error
FileCompileOnly processes a single translation text file. It does not attempt to look at fallbacks, default languages, or already-compiled files.
This will only work if a compiled dictionary already exists.
func (*ProcessSettings) FileNoReturn ¶
func (settings *ProcessSettings) FileNoReturn(languageIdentifier string) error
FileNoReturn processes a single language.
The default language will also need to be processed for the dictionary, but will only have the dictionary written out for it if it needs updating.
The languages in the fallback chain will not be processed. Because of this, there will be no Language objects returned.
type ProcessedFile ¶
type ProcessedFile struct { LangIdentifier string InputFileName string Warnings []string Err error Flags ProcessedFileFlag Lang *translate.Language //Only filled if Flags.PFF_Language_Success* }
ProcessedFile is an item in the list of processed files and what was done to/with them.
type ProcessedFileFlag ¶
type ProcessedFileFlag uint
const ( //Language object info PFF_Language_SuccessfullyLoaded ProcessedFileFlag //If the Language object was successfully loaded and filled into ProcessedFiles and the fallback was set PFF_Language_SuccessNoFallbackSet //If the Language object was loaded and filled into ProcessedFiles, but the fallback was not set PFF_Language_IsDefault //If this is the default language //Loading state (mutually exclusive) PFF_Load_NotAttempted //File loading was not attempted because other errors occurred first PFF_Load_NotFound //File was not loaded because its translation text file was not found PFF_Load_YAML //If this was loaded from a YAML translation text file PFF_Load_JSON //If this was loaded from a JSON translation text file PFF_Load_Compiled //If this was loaded from a .gtr file (compression state is assumed from ProcessSettings.CompressCompiled) //Error information PFF_Error_DuringProcessing //If errors occurred during processing //File output success flags PFF_OutputSuccess_CompiledLanguage //If a .gtr file was successfully output (only when ProcessSettings.OutputCompiled, compression state is assumed from ProcessSettings.CompressCompiled) PFF_OutputSuccess_CompiledDictionary //If a .gtr dictionary file was successfully output (only when ProcessSettings.OutputCompiled and PFF_Language_IsDefault, compression state is assumed from ProcessSettings.CompressCompiled) PFF_OutputSuccess_GoDictionaries //If one or more go dictionary files was successfully output (only when ProcessSettings.OutputGoDictionary and PFF_Language_IsDefault) )
type ProcessedFileFlagName ¶
type ProcessedFileFlagName struct { Flag ProcessedFileFlag Name string ShortName [4]byte //All shortname strings must be 4 bytes }
ProcessedFileFlagName : See ProcessedFileFlagNames
type ProcessedFileList ¶
type ProcessedFileList map[string]*ProcessedFile
ProcessedFileList is a list of ProcessedFiles keyed to their language identifier
func (ProcessedFileList) CreateFlagTable ¶
func (list ProcessedFileList) CreateFlagTable() []string
CreateFlagTable creates an aligned ascii table that shows which flags are set on which ProcessedFiles. The row headers are the ProcessedFileFlagNames.ShortName and the column headers are the ProcessedFile.LangIdentifier.
Format: 1 row per language. 1 column per flag. 4 letter flag names are split over 2 columns
Symbols: | column separator, * values