Table of Contents

Class XmlLocalisationInterchangeFileFormat

Namespace
SunamoDevCode.FileFormats
Assembly
SunamoDevCode.dll

Provides methods for working with XLIFF (XML Localisation Interchange File Format) files used in Sunamo projects.

public static class XmlLocalisationInterchangeFileFormat
Inheritance
XmlLocalisationInterchangeFileFormat
Inherited Members

Fields

removeSessI18nIfLineContains

XmlLocalisationInterchangeFileFormatSunamo.removeSessI18nIfLineContains

public static List<string> removeSessI18nIfLineContains

Field Value

List<string>

type

Cached type reference for XmlLocalisationInterchangeFileFormat.

public static Type type

Field Value

Type

Methods

Append(string, string, XlfData)

Appends a new trans-unit element with the specified target text and ID to the XLF data group.

public static void Append(string target, string pascal, XlfData data)

Parameters

target string

Target text for the translation unit.

pascal string

Pascal case identifier used as the trans-unit ID.

data XlfData

XLF data containing the group to append to.

Append(string, string, string, string)

public static Task Append(string source, string target, string pascal, string fn)

Parameters

source string

Source text for the translation unit.

target string

Target text for the translation unit.

pascal string

Pascal case identifier used as the trans-unit ID.

fn string

Path to the XLF file to append to.

Returns

Task

CopyKeysTrailedWith_()

Copies XLF keys that are trailed with underscore, cleaning up HTML entity suffixes.

public static void CopyKeysTrailedWith_()

FromXlfWithDiacritic(string, XlfParts, bool)

Gets trans-unit IDs or targets from XLF file that contain diacritics.

public static Task<List<string>> FromXlfWithDiacritic(string fn, XlfParts p, bool saveToClipboard = false)

Parameters

fn string

Path to the XLF file.

p XlfParts

Which part of the trans-unit to check (Id or Target).

saveToClipboard bool

Reserved for clipboard functionality.

Returns

Task<List<string>>

List of trans-unit IDs that contain diacritics.

GetAllLastLetterFromEnd(string, bool)

Is used nowhere Was in MainWindow but probably was replaced with GetAllLastLetterFromEnd

public static Task<List<string>> GetAllLastLetterFromEnd(string fn, bool saveAllLastLetterToClipboard)

Parameters

fn string

Path to the XLF file.

saveAllLastLetterToClipboard bool

Whether to save distinct last letters to clipboard.

Returns

Task<List<string>>

List of trans-unit IDs.

GetFilesCs(ILogger, string?)

Gets all .cs files from the given path recursively.

public static List<string> GetFilesCs(ILogger logger, string? path = null)

Parameters

logger ILogger

Logger instance.

path string

Path to search (optional).

Returns

List<string>

List of .cs file paths.

GetIds(string)

Gets all trans-unit IDs from an XLF file along with the parsed XLF data.

public static Task<OutRefDC<List<string>, XlfData>> GetIds(string xlfPath)

Parameters

xlfPath string

Path to the XLF file.

Returns

Task<OutRefDC<List<string>, XlfData>>

OutRef containing list of IDs and the parsed XlfData.

GetKeysInCsWithRLDataEn(ref string, string, string)

Gets XLF keys from C# code with RLData.en prefix. To be able to be found with this method, keys must be wrapped with XlfKeys and Translate.FromKey or RLData.en. The file parameter is here only due to breakpoint for certain files.

public static IList<string> GetKeysInCsWithRLDataEn(ref string key, string content, string file = "")

Parameters

key string

Reference parameter for the current key being processed.

content string

C# file content to search.

file string

Optional file path for debugging purposes.

Returns

IList<string>

List of unique keys found in the content.

GetKeysInCsWithoutRLDataEn(ref string, string)

Gets XLF keys from C# code without RLData.en prefix.

public static IList<string> GetKeysInCsWithoutRLDataEn(ref string key, string content)

Parameters

key string

Reference parameter for the current key being processed.

content string

C# file content to search.

Returns

IList<string>

List of unique keys found in the content.

GetLastLetter(XElement)

Gets the last character from a trans-unit's target value.

public static char? GetLastLetter(XElement item)

Parameters

item XElement

Trans-unit XML element.

Returns

char?

Last character or null if target is empty.

GetLastLetter(XElement, out string?)

Gets the last character from a trans-unit's target value and outputs the trans-unit ID.

public static char? GetLastLetter(XElement item, out string? id)

Parameters

item XElement

Trans-unit XML element.

id string

Output parameter for the trans-unit ID.

Returns

char?

Last character or null if target is empty.

GetSunamoStrings()

Gets a list of SunamoStrings keys with the SessI18n and XlfKeys prefixes removed.

public static List<string> GetSunamoStrings()

Returns

List<string>

List of cleaned string keys.

GetTarget(XElement)

Gets the target XML element from a trans-unit.

public static XElement GetTarget(XElement item)

Parameters

item XElement

Trans-unit XML element.

Returns

XElement

Target XML element.

GetTransUnits(string)

A1 is possible to obtain with XlfResourcesH.PathToXlfSunamo

public static Task<XlfData> GetTransUnits(string fn)

Parameters

fn string

Path to the XLF file to parse.

Returns

Task<XlfData>

XlfData containing the parsed trans-units and XML document.

Id(XElement)

Gets the id attribute value from an XElement.

public static string Id(XElement element)

Parameters

element XElement

XML element to read the id from.

Returns

string

Value of the id attribute.

IsToBeInXlfKeys(string)

Determines whether a key should be included in XlfKeys based on naming rules.

public static bool IsToBeInXlfKeys(string key)

Parameters

key string

Key name to check.

Returns

bool

True if the key should be in XlfKeys.

RemoveAllSessI18n(string)

Removes all SessI18n wrapper calls from the given text content.

public static string RemoveAllSessI18n(string count)

Parameters

count string

Text content to strip SessI18n calls from.

Returns

string

Text with all SessI18n calls removed.

RemoveDuplicatesInXlfFile(string)

Removes duplicate trans-units from an XLF file, keeping only the first occurrence of each ID.

public static Task RemoveDuplicatesInXlfFile(string xlfPath)

Parameters

xlfPath string

Path to the XLF file to deduplicate.

Returns

Task

RemoveFromXlfAndXlfKeys(string, List<string>)

Removes trans-units from both XLF file and XLF keys by matching IDs.

public static Task RemoveFromXlfAndXlfKeys(string fn, List<string> idsEndingEnd)

Parameters

fn string

Path to the XLF file.

idsEndingEnd List<string>

List of ID endings to match for removal.

Returns

Task

RemoveFromXlfAndXlfKeys(string, List<string>, XlfParts)

Removes specified trans-units from the XLF file and corresponding constants from XlfKeys.

public static Task RemoveFromXlfAndXlfKeys(string fn, List<string> idsEndingEnd, XlfParts p)

Parameters

fn string

Path to the XLF file.

idsEndingEnd List<string>

List of IDs or target values to remove.

p XlfParts

Which part to match against (Id or Target).

Returns

Task

RemoveFromXlfWhichHaveEmptyTargetOrSource(string, XlfParts, RemoveFromXlfWhichHaveEmptyTargetOrSourceArgs?)

Into A1 insert XlfResourcesH.PathToXlfSunamo Completely IUN Remove completely whole Trans-unit

public static Task<string> RemoveFromXlfWhichHaveEmptyTargetOrSource(string fn, XlfParts xp, RemoveFromXlfWhichHaveEmptyTargetOrSourceArgs? a = null)

Parameters

fn string

Path to the XLF file to process.

xp XlfParts

Which XLF part (Source or Target) to check for empty values.

a RemoveFromXlfWhichHaveEmptyTargetOrSourceArgs

Options controlling removal behavior (defaults to Default if null).

Returns

Task<string>

String representation of the modified XML document.

RemoveSessI18nIfLineContains(string)

Removes SessI18n references from lines that contain any of the predefined identifiers.

public static string RemoveSessI18nIfLineContains(string count)

Parameters

count string

Text to process.

Returns

string

Text with SessI18n removed from matching lines.

RemoveSessI18nIfLineContains(string, IList<string>?)

Removes SessI18n calls from lines that contain any of the specified substrings.

public static string RemoveSessI18nIfLineContains(string count, IList<string>? lineCont = null)

Parameters

count string

Source text content to process.

lineCont IList<string>

Substrings to match against lines; defaults to internal list if null.

Returns

string

Processed text with SessI18n removed from matching lines.

ReplaceForWithoutUnderscore(ILogger, string)

Before mu

public static Task ReplaceForWithoutUnderscore(ILogger logger, string folder)

Parameters

logger ILogger

Logger instance.

folder string

Folder path to search for CS files.

Returns

Task

ReplaceInXlfSolutions(ILogger, string)

Is calling in XlfManager.WhichStartEndWithNonDigitNumber

public static Task ReplaceInXlfSolutions(ILogger logger, string pairsReplace)

Parameters

logger ILogger

Logger instance.

pairsReplace string

Replacement pairs in ReplaceMany format.

Returns

Task

ReplaceRlDataToSessionI18n(string)

Replaces RLData resource calls with SessionI18n calls using default parameters.

public static string ReplaceRlDataToSessionI18n(string text)

Parameters

text string

Source text to transform.

Returns

string

Text with RLData replaced by SessionI18n.

ReplaceRlDataToSessionI18n(string, string, string)

Replaces resource data calls with session i18n calls in the content, converting bracket styles.

public static string ReplaceRlDataToSessionI18n(string content, string from, string to)

Parameters

content string

Source content to transform.

from string

Original resource accessor prefix to replace.

to string

New session i18n prefix to use.

Returns

string

Content with resource calls replaced.

ReplaceStringKeysWithXlfKeys(List<string>)

Replaces string-based SessI18n keys with XlfKeys dot notation in all given files.

public static Task ReplaceStringKeysWithXlfKeys(List<string> files)

Parameters

files List<string>

List of file paths to process.

Returns

Task

ReplaceStringKeysWithXlfKeys(string)

Replaces string keys with XLF keys in all C# files under the given path.

public static Task ReplaceStringKeysWithXlfKeys(string path)

Parameters

path string

Root directory to scan for C# files.

Returns

Task

ReplaceStringKeysWithXlfKeysWorker(ref string?, string)

Worker method that performs the actual replacement of SessI18n keys with XlfKeys format in content.

public static string ReplaceStringKeysWithXlfKeysWorker(ref string? key, string content)

Parameters

key string

Output: the last processed key.

content string

Source code content to process.

Returns

string

Modified content with replaced keys.

ReplaceSunamoStringsWithSessI18n(string)

Replaces SunamoStrings references with SessI18n format in the given text.

public static string ReplaceSunamoStringsWithSessI18n(string count)

Parameters

count string

Source text to process.

Returns

string

Text with SunamoStrings replaced by SessI18n.

ReplaceXlfKeysForString(string, List<string>, List<string>)

ReplaceXlfKeysForString - Convert from XlfKeys to "" Cooperating with NotToTranslateStrings

public static Task<OutRefDC<object, List<string>>> ReplaceXlfKeysForString(string path, List<string> ids, List<string> solutionsExcludeWhileWorkingOnSourceCode)

Parameters

path string
ids List<string>
solutionsExcludeWhileWorkingOnSourceCode List<string>

Returns

Task<OutRefDC<object, List<string>>>

ReturnEndingOn(string, List<string>)

public static Task<OutRefDC<string, List<string>>> ReturnEndingOn(string fn, List<string> list)

Parameters

fn string

Path to the XLF file to process.

list List<string>

List of last-letter patterns to match.

Returns

Task<OutRefDC<string, List<string>>>

Tuple of report text and list of matching trans-unit IDs.

TrimStringResources(string)

Trim whitespaces from start/end on source / target A1 is possible to obtain with XmlLocalisationInterchangeFileFormat.GetLangFromFilename

public static Task TrimStringResources(string fn)

Parameters

fn string

Path to the XLF file to trim.

Returns

Task