dotstrings

package
v0.0.0-...-8f05a37 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFuzzyToken

func IsFuzzyToken(token string) bool

IsFuzzyToken will return true for tokens that match the text "fuzzy". The match is case insensitive.

func LoadMessages

func LoadMessages(r io.Reader) (<-chan Message, <-chan error)

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

func LoadMessagesMap(tmReader io.Reader) (messages map[string]Message, err error)

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

func LoadMessagesMapFromFile(filename string) (messages map[string]Message, err error)

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

func NewReaderUTF16(fileReader io.Reader) io.Reader

NewReaderUTF16 will create a reader that expects data in UTF16 LittleEndian mode and it will also expect the matching BOM.

func NewWriterUTF16

func NewWriterUTF16(fileWriter io.Writer) io.Writer

NewWriterUTF16 will create a writer that will stream out text in UTF16 LittleEndian mode with a BOM.

func SaveMessages

func SaveMessages(srcChan <-chan Message, dstWriter io.Writer) (n int)

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

func Split() bufio.SplitFunc

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 StringsEscape(s string) string

func StringsUnescape

func StringsUnescape(s string) (t string, err error)

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.

Jump to

Keyboard shortcuts

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