Command-Line Arguments
The lever -o writes the collected localization lines into console. This is same as -o:stdout.ini.
Lexical.Localization.Tool.exe -o
The lever -o:<filename.ext> writes the localization lines to filename in format ext. The file format ext must be one of the supported formats: ini, xml, json, resx, resources. (More)
Lexical.Localization.Tool.exe -o:localization.ini
As a special case, if filename is stdout then the content is written to standard-out pipe, and if the filename is stderr then to standard-error pipe.
Lexical.Localization.Tool.exe -o:stdout.ini
Parameters be placed into the file name pattern.
Lexical.Localization.Tool.exe -o:{Culture/}{Type}.ini
Lexical.Localization.Tool.exe -o:localization{-Culture}.json
The key pattern is can be formulated after comma -o:<filename.ext>,<key pattern> (More).
Lexical.Localization.Tool.exe -o:{Culture/}{Type}.ini,{anysection_n/}[Key]{/Key_n}
Lexical.Localization.Tool.exe -o:stdout.ini,{Culture}/
The lever -k extends all keys to all detected cultures in case values are missing.
Lexical.Localization.Tool.exe -vle -i:include/**.ini -ok
For instance, if following keys were read from input sources.
en:MyClass:Success = Success
de:MyClass:Error = Fehler
The output with -k would extend all the keys to all the cultures with empty values.
en:MyClass:Success = Success
en:MyClass:Error =
de:MyClass:Success =
de:MyClass:Error = Fehler
The -c:<cultures> lever adds more cultures to be included. Use it with -k.
Lexical.Localization.Tool.exe -vle -i:include/**.ini -okc:fi,sv
The previous example would look like this.
en:MyClass:Success = Success
en:MyClass:Error =
de:MyClass:Success =
de:MyClass:Error = Fehler
fi:MyClass:Success =
fi:MyClass:Error =
sv:MyClass:Success =
sv:MyClass:Error =
The -C:<cultures> lever adds cultures to be excluded.
Lexical.Localization.Tool.exe -vle -i:include/**.ini -ok -c:fi,sv -C:en,de
Looks like this. The keys get copied as templates to other cultures.
fi:MyClass:Success =
fi:MyClass:Error =
sv:MyClass:Success =
sv:MyClass:Error =
To write with custom WriterClass, set class name as Assembly qualified type name to third parameter. Custom writer class is needed if the file format cannot be inferred from the file extension. See more.
Lexical.Localization.Tool.exe -vle -i:include/**.ini -o:myfile.tmp,,Lexical.Localization.XmlLocalizationWriter
Instead of overwriting previous files, they can be updated with -u flag instead of -o. This attempts to preserve whitespace and file structure.
Lexical.Localization.Tool.exe vle -i:include/**.ini -u:localization.ini
An alternative is -U which matches lines by their effective key.
Lexical.Localization.Tool.exe vle -i:include/**.ini -U:localization.ini
Configuration File
Outputting can be configured from files as well.
Lexical.Localization.Tool -le outputconfig.json
Under section "ConvertJobs" there is "Outputs" array, which that defines sections for output configurations (full configuration example). Example with all properties:
"Outputs": [
{
"FilePattern": "localization{-Culture}.ini",
"FilePatterns": [],
"KeyPattern": "{Culture}/{Location_n}{Assembly}{Resource_n}/{Type}{Section_n/}/{Key_n}",
"Cultures": "en-UK,en-US,es-ES,fi-FI,de-DE",
"ExcludeCultures": "fi-FI",
"KeyExtend": "True",
"WriterClass": "",
"WriteFlags": ""
}
]
Outputs Parameters:
Parameter | Description | Example Value |
---|---|---|
FileName | File name pattern | filename.ext |
FileNames | Array of file name patterns | filename1.ext, filename2.ext |
KeyPattern | Line format | {anysection_n.}[Key]{.Key_n} |
KeyExtend | Whether to extends all keys to all cultures when values are missing. | True/False |
Cultures | Culture to include. Use with KeyExtend=true | en-UK,en-US,es-ES,fi-FI,de-DE |
ExcludeCultures | Cultures to exclude. | fi-FI,de-DE |
WriterClass | Assembly qualified type name for writer class. | ExampleNamespace.ExtFileFormat,ExtLibrary |
WriteFlags | Write flags | Add,Overwrite |
File Pattern
Atleast one FilePattern parameter is needed (out of FilePattern, FilePatterns).
File pattern determines the output file to write to.
Parameters can be embedded into it. For example "localization{-Culture}.ini" splits the content into different files depending on cultures of the keys.
Key Pattern
The optional KeyPattern determines how each line is written out. The effect of the pattern depends on the file format.
For context dependent file formats (.resx, .resources), the KeyPattern defines the exact formulation of the key. For example KeyPattern = {Type.}[Key] appends "Type" and then "Key".
<data name="MyClass.Error">
<value>Error (Code=0x{0:X8})</value>
</data>
For tree based files and context free file formats (.xml, json, .ini) KeyPattern determines how keys are grouped into tree levels. The character "/" determines separation between levels.
For instance KeyPattern = {Culture}/{Location_n}{Assembly}{Resource_n}/{Type}{Section_n}/{Key_n} puts keys into four levels, or less if key lacks parameters.
<Culture:en>
<Type:ConsoleApp1.MyController>
<Key:Success>Success</Key:Success>
<Key:Error>Error (Code=0x{0:X8})</Key:Error>
</Type:ConsoleApp1.MyController>
</Culture:en>
If separator is inside a pattern "{Section_n/}", then each "Section" opens a new level. For example KeyPattern = {anysection_n/}{Key_n} can formulate following levels.
<Section:Classes>
<Type:MyController>
<Section:Errors>
<Key:Error>Error (Code=0x{0:X8})</Key:Error>
</Section:Errors>
</Type:MyController>
</Section:Classes>
.ini files have maximum of two levels. The first level determines the [section], and second the key value pairs. For instance KeyPattern = {Culture}{Type}{Assembly}/{Location_n}{Resource_n}{Section_n}{Key_n} puts keys into two levels.
[Culture:en:Type:MyClass]
Key:Success = Ok
If parameter is not in the KeyPattern then the rest added to the last level. For instance KeyPattern = {Culture}/ separates by culture and then by other parameters.
[Culture:en]
Type:MyClass:Key:Success = Ok
Cultures
The parameter value KeyExtend=true extends every detected key to every detected culture. It can be further extended with Cultures parameter which adds extra cultures.
Parameter ExcludeCultures excludes cultures from the input result.
These parameters can be used for copying keys from one culture to others as template.
Writer Class
Custom writer class can be used with WriterClass parameter.
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 ILineWriter.
WriterClass is needed if file format cannot be inferred from the extension in FilePattern.
"Outputs": [
{
"FilePattern": "myfile.xml.tmp",
"WriterClass": "Lexical.Localization.XmlLocalizationWriter"
}
],
Writer classes built in to the localization tool.
Class name | Description |
---|---|
Lexical.Localization.IniLocalizationWriter | .ini |
Lexical.Localization.JsonLocalizationWriter | .json |
Lexical.Localization.XmlLocalizationWriter | .xml |
Lexical.Localization.ResXLocalizationWriter | .resx |
Lexical.Localization.BinarysLocalizationWriter | .resources |
Write Flags
WriteFlags determine how file is written. Flags are separated by comma, for example "Add,Remove,Modify,EffectiveKeyMatching". The default value is "Add,Overwrite".
Flag | Description |
---|---|
Add | Permission to add new entries to the container. |
Remove | Permission to remove nodes that no longer exist. |
RemoveCautious | Permission to remove nodes if node is free from unknown elements. |
Modify | Permission to modify values of existing entries. |
Overwrite | Overwrite contents of previous file. The flag "Add" must also be set with this. |
EffectiveKeyMatching | Matches lines by effective key. |