Documentation
¶
Index ¶
- func IsFuzzyToken(token string) bool
- func LoadMessages(r io.Reader) (<-chan Message, <-chan error)
- func LoadMessagesMap(tmReader io.Reader) (messages map[string]Message, err error)
- func LoadMessagesMapFromFile(filename string) (messages map[string]Message, err error)
- func NewReaderUTF16(fileReader io.Reader) io.Reader
- func NewWriterUTF16(fileWriter io.Writer) io.Writer
- func SaveMessages(srcChan <-chan Message, dstWriter io.Writer) (n int)
- func Split() bufio.SplitFunc
- func StringsEscape(s string) string
- func StringsUnescape(s string) (t string, err error)
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFuzzyToken ¶
IsFuzzyToken will return true for tokens that match the text "fuzzy". The match is case insensitive.
func LoadMessages ¶
LoadMessages reads the data provided by io.Reader and outputs messages on a channel it returns. This function will run asynchronously and return before the whole stream has been processed.
func LoadMessagesMap ¶
LoadMessagesMap will read all the entries from the messages file. If it encounters an error it will return with the error instead of continuing. The function returns a map with the messages once all messages have been read.
func LoadMessagesMapFromFile ¶
LoadMessagesMapFromFile uses the given filename to open the messages file and reads all messages from it. The function returns a map with the messages once all messages have been read.
func NewReaderUTF16 ¶
NewReaderUTF16 will create a reader that expects data in UTF16 LittleEndian mode and it will also expect the matching BOM.
func NewWriterUTF16 ¶
NewWriterUTF16 will create a writer that will stream out text in UTF16 LittleEndian mode with a BOM.
func SaveMessages ¶
SaveMessages will take a channel with messages and stream them to character stream dstWriter. The function will return when all messages have been sent. The goroutine feeding srcChan should close the channel once it has finished. The closing of the channel indicates to SaveMessages that it can finish too. The function returns the number of messages it has written to the dstWriter.
func Split ¶
Split will split the file into (fuzzy, context, id, string) tuples.
TODO count processed runes so we can point to a location when there is an error.
func StringsEscape ¶
func StringsUnescape ¶
Types ¶
type Message ¶
type Message struct { // Fuzzy is true when the source Str is different from the target Ctx value or // when the source ID is missing completely from the target file. // Set in messages loaded from a strings file that are preceeded with a // comment that contains the word "fuzzy". Fuzzy bool // Missing is true when the ID was not found in the target file. When true both // the target Ctx and Str will contain the source Str. // Set in messages emited by the TranslateMessages function. Missing bool Ctx string ID string Str string }
Message contains the information of a single .strings file entry.
" Ctx " "ID" = "Str";
There are 2 types of strings files; "source" and "target" strings files. The source type contains the original language of the translation project and there is supposed to be only 1 source. A target strings file contains a specific translation to another language.
For a source .strings file the Ctx contains a note for the translator. For a target .strings file the every Ctx contains the matching Str from the source .strings file. This is done so that by comparing source.Str with target.Ctx a change in the original translation string can be determined.