Command-Line Arguments
The lever -i searches for known file types **.ini, **.xml, **.json, **.resources, **.resx in current directory.
Lexical.Localization.Tool -i
Lever -i:<glob pattern> searches for files with a glob pattern; ? denotes one character, * any name under one directory, ** any filename and subdirectory. Pattern is matched against full rooted file paths. For matching purposes folder separator is converted to '/' in Windows.
Lexical.Localization.Tool -i:**/localization.ini
Some times file name carries information about the localization keys. Parameter information can extracted from file names by formulating key name pattern into the search pattern. This information is used later in the outputting phase of the tool.
Lexical.Localization.Tool -i:{culture/}[Assembly].dll/**.resources
Lexical.Localization.Tool -i:{culture/}*.dll/[Assembly.][Type.]{Culture.}resources
File formats .resx and .resources do not contain the semantics on how each line is formulated. For these cases the key pattern should be specified after comma -i:<glob pattern>,<key pattern>.
Lexical.Localization.Tool -i:**/localization{.Culture}.resx,[Type:][Key]
Lever -I:<glob pattern> adds exclude file pattern.
Lexical.Localization.Tool -i:**/localization.ini -I:**/exclude this dir/**
The tool automatically opens package types .zip, .7z, .rar, .tar, .gz, .bzip2, .z, .dll.
Lexical.Localization.Tool -i:**.zip/**.json
This is, however, sometimes unwanted behaviour. Exclude pattern -I: can be used to not open specific file formats.
Lexical.Localization.Tool -i -I:**.zip/** -I:**.dll/**
To read with custom ReaderClass, set class name as Assembly qualified type name to third parameter. See more.
Lexical.Localization.Tool.exe -i:include/**.tmp,,Lexical.Localization.LocalizationXmlReader
Configuration File
An alternative way to configure inputs is by configuration files.
Lexical.Localization.Tool -le inputconfig.json
Under section "ConvertJobs" there is "Inputs" array, which that defines sections for jobs that read localization files (full configuration example). Example with all properties:
"Inputs": [
{
"PackageExtensions": "dll exe zip bzip2 z tar 7z gzip gz rar",
"GlobPattern": "**.dll/**.resources",
"GlobPatterns": [],
"WildCardPattern": "",
"WildCardPatterns": [],
"FileName": "",
"FileNames": [],
"Exclude": "",
"Excludes": [],
"KeyPattern": "{anysection_0/}{anysection_1/}{anysection_2/}{key_0}{/key_1}"
}
],
Input Parameters:
Parameter | Description | Example Value |
---|---|---|
PackageExtensions | Extensions to open | dll exe zip bzip2 z tar 7z gzip gz rar |
KeyPattern | The format of each line. | [Type.][Key]{.Key_n} |
FileName | Single file to scan | filename.ext |
FileNames | List of files to scan | filename1.ext, filename2.ext |
WildcardPattern | Pattern of files to scan | *.dll |
WildcardPatterns | Multiple patterns of files to scan | *.dll, *.exe |
GlobPattern | Glob pattern of files to scan | **.dll/**.resources |
GlobPatterns | Multiple glob patterns to scan | |
Exclude | One glob pattern of files to exclude | **.zip/** |
Excludes | Multiple glob patterns of files to exclude |
File Pattern
Atleast one file pattern parameter is needed (out of GlobPattern, GlobPatterns, WildCardPattern, WildCardPatterns, FileName, FileNames).
*WildCardPattern is uses "?" to refer to one character, and "*" to any characters across multiple directories.
GlobPattern is uses "?" to refer to one character, "*" to refer any characters file within one directory, and "**" any characters across multiple directories.
PackageExtensions is a list of file formats to look inside of. The supported package formats are: dll exe zip bzip2 z tar 7z gzip gz rar. When PackageExtension is enabled, then file pattern can refer into a package file, e.g. "**.zip/**.xml".
"Inputs": [
{
"PackageExtensions": "dll exe zip bzip2 z tar 7z gzip gz rar",
"GlobPattern": "**.dll/**.resources"
}
],
File pattern can contain parameters, these patterns are extracted and added to the imported keys.
FileName = Localization{-Culture}.ini
Key Pattern
File formats .resx and .resources need information about how the key string is formulated. KeyPattern describes this with ILinePattern notation.
"Inputs": [
{
"PackageExtensions": "",
"GlobPattern": "**{.Culture}.dll/**.resources",
"KeyPattern": "{Type.}[Key]"
}
],
Context free file formats (.xml .json .ini) are self sufficient and do not need KeyPattern.
Reader Class
To use custom file format a ReaderClass can be provided.
Class name is written in Assembly qualified type name, and can refer to external .dll file.
External .dll is searched from 1. the directory where the tool is installed, 2. the working directory where the tool is ran.
This class must implement ILocalizationReader.
Custom reader class is needed if the file format cannot be inferred from the file extension.
"Inputs": [
{
"FileName": "myfile.xml.tmp",
"ReaderClass": "Lexical.Localization.LocalizationXmlReader"
}
],
Existing reader classes:
Class name | Description |
---|---|
Lexical.Localization.IniLinesWriter | .ini |
Lexical.Localization.JsonLinesReader | .json |
Lexical.Localization.LocalizationXmlReader | .xml |
Lexical.Localization.LocalizationResxReader | .resx |
Lexical.Localization.BinarysLineReader | .resources |