Table of Contents

Class StringCatParser

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

Parser for Apple String Catalog files (.xcstrings). A single .xcstrings file contains translations for all locales in the format: strings → key → localizations → lang → stringUnit → value.

public class StringCatParser : BaseJsonParser
Inheritance
StringCatParser
Inherited Members

Properties

TextProcessingMode

Gets or sets the text processing mode used when recognising placeholder strings.

public static TextFormat TextProcessingMode { get; set; }

Property Value

TextFormat

Methods

CanHandleExtension(string)

Checks whether this parser can handle a translation file with the given extension.

This method is not used for configuration files.

public override bool CanHandleExtension(string fileExtension)

Parameters

fileExtension string

The extension to check.

Returns

bool

true if the extension is supported and false otherwise.

GetTextProcessingMode()

Used for internal needs.

protected override TextFormat GetTextProcessingMode()

Returns

TextFormat

The effective text processing mode.

InternalLoadTranslationEntriesFromJSON(JsonElement, Translation?, string, TextFormat?)

protected override Translation InternalLoadTranslationEntriesFromJSON(JsonElement jsonObj, Translation? translation, string groupName, TextFormat? textProcessingMode)

Parameters

jsonObj JsonElement
translation Translation
groupName string
textProcessingMode TextFormat?

Returns

Translation

InternalLoadTranslationStructure(string, TextFormat?)

Loads the keys from the default translation file and builds a tree of keys.

protected override TranslationTree? InternalLoadTranslationStructure(string content, TextFormat? textProcessingMode)

Parameters

content string

The content to parse.

textProcessingMode TextFormat?

The mode of processing of the text of the default file.

Returns

TranslationTree

The constructed TranslationTree upon success or null otherwise.

Exceptions

TextParseException

Gets thrown when parsing of a default translation file fails.

LoadTranslation(string, CultureInfo?, TextFormat?)

Loads the translation information from the file and returns a translation.

public override Translation? LoadTranslation(string translationText, CultureInfo? culture, TextFormat? textProcessingMode)

Parameters

translationText string

The text of the file to load.

culture CultureInfo

An optional reference to the locale, whose translation is to be loaded. Makes sense for CSV and TSV formats that may contain multiple translations in one file.

textProcessingMode TextFormat?

The mode of processing of the text of the translation file.

Returns

Translation

The loaded translation or null if loading failed.

LoadTranslationWithLocations(string, CultureInfo?, TextFormat?)

Parses the translation using a streaming JSON reader that captures exact key positions. Called when PopulateKeyLocations is true.

protected override Translation? LoadTranslationWithLocations(string translationText, CultureInfo? culture, TextFormat? textProcessingMode)

Parameters

translationText string
culture CultureInfo
textProcessingMode TextFormat?

Returns

Translation

Use()

Initializes the parser class, making it available for use.

public static void Use()