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
type
Cached type reference for XmlLocalisationInterchangeFileFormat.
public static Type type
Field Value
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
targetstringTarget text for the translation unit.
pascalstringPascal case identifier used as the trans-unit ID.
dataXlfDataXLF 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
sourcestringSource text for the translation unit.
targetstringTarget text for the translation unit.
pascalstringPascal case identifier used as the trans-unit ID.
fnstringPath to the XLF file to append to.
Returns
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
fnstringPath to the XLF file.
pXlfPartsWhich part of the trans-unit to check (Id or Target).
saveToClipboardboolReserved for clipboard functionality.
Returns
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
fnstringPath to the XLF file.
saveAllLastLetterToClipboardboolWhether to save distinct last letters to clipboard.
Returns
GetFilesCs(ILogger, string?)
Gets all .cs files from the given path recursively.
public static List<string> GetFilesCs(ILogger logger, string? path = null)
Parameters
Returns
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
xlfPathstringPath to the XLF file.
Returns
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
keystringReference parameter for the current key being processed.
contentstringC# file content to search.
filestringOptional file path for debugging purposes.
Returns
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
keystringReference parameter for the current key being processed.
contentstringC# file content to search.
Returns
GetLastLetter(XElement)
Gets the last character from a trans-unit's target value.
public static char? GetLastLetter(XElement item)
Parameters
itemXElementTrans-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
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
GetTarget(XElement)
Gets the target XML element from a trans-unit.
public static XElement GetTarget(XElement item)
Parameters
itemXElementTrans-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
fnstringPath to the XLF file to parse.
Returns
Id(XElement)
Gets the id attribute value from an XElement.
public static string Id(XElement element)
Parameters
elementXElementXML 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
keystringKey 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
countstringText 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
xlfPathstringPath to the XLF file to deduplicate.
Returns
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
Returns
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
fnstringPath to the XLF file.
idsEndingEndList<string>List of IDs or target values to remove.
pXlfPartsWhich part to match against (Id or Target).
Returns
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
fnstringPath to the XLF file to process.
xpXlfPartsWhich XLF part (Source or Target) to check for empty values.
aRemoveFromXlfWhichHaveEmptyTargetOrSourceArgsOptions controlling removal behavior (defaults to Default if null).
Returns
RemoveSessI18nIfLineContains(string)
Removes SessI18n references from lines that contain any of the predefined identifiers.
public static string RemoveSessI18nIfLineContains(string count)
Parameters
countstringText 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
countstringSource text content to process.
lineContIList<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
Returns
ReplaceInXlfSolutions(ILogger, string)
Is calling in XlfManager.WhichStartEndWithNonDigitNumber
public static Task ReplaceInXlfSolutions(ILogger logger, string pairsReplace)
Parameters
Returns
ReplaceRlDataToSessionI18n(string)
Replaces RLData resource calls with SessionI18n calls using default parameters.
public static string ReplaceRlDataToSessionI18n(string text)
Parameters
textstringSource 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
contentstringSource content to transform.
fromstringOriginal resource accessor prefix to replace.
tostringNew 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
Returns
ReplaceStringKeysWithXlfKeys(string)
Replaces string keys with XLF keys in all C# files under the given path.
public static Task ReplaceStringKeysWithXlfKeys(string path)
Parameters
pathstringRoot directory to scan for C# files.
Returns
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
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
countstringSource 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
Returns
ReturnEndingOn(string, List<string>)
public static Task<OutRefDC<string, List<string>>> ReturnEndingOn(string fn, List<string> list)
Parameters
Returns
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
fnstringPath to the XLF file to trim.