• Lexical
Show / Hide Table of Contents
  • Lexical.FileSystem
    • Introduction
    • Abstractions
      • IFileSystem
        • IFileSystem
        • IFileSystemBrowse
        • IFileSystemCreateDirectory
        • IFileSystemDelete
        • IFileSystemFileAttribute
        • IFileSystemMount
        • IFileSystemMove
        • IFileSystemObserve
        • IFileSystemOpen
      • IEvent
      • IEntry
      • IOption
      • IToken
    • FileSystem
    • VirtualFileSystem
    • MemoryFileSystem
    • EmbeddedFileSystem
    • HttpFileSystem
    • Decoration
    • IFileProvider
    • Utility
      • DisposeList
      • FileScanner
      • VisitTree
      • File Operation
  • Lexical.FileProvider
    • Introduction
    • Package
    • Package.Abstractions
    • Root
    • Zip
    • Dll
    • SharpCompress
    • SharpZipLib
    • FileScanner
    • Utils
  • Lexical.Localization
    • Introduction
    • Tutorial
    • Asset
      • IAsset
      • IStringAsset
    • Line
      • ILine
      • ILineFactory
      • ILineRoot
      • ILineFormat
      • ILineLogger
      • LineComparer
    • File
      • ILineReader
      • ILineWriter
      • Ini
      • Json
      • Xml
      • Resx
      • Resources
    • Miscellaneous
      • Plurality
      • ICulturePolicy
      • IStringFormat
      • Dependency Injection
    • Practices
      • Class Library
      • Class Library DI
      • Class Library DI opt.
  • Lexical.Utilities
    • Introduction
    • UnicodeString
    • FileScanner
    • Permutation
    • Tuples
    • StructList

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:

  • json
  • xml
  • ini
"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}"
    }
  ],
<Inputs name="0">
  <PackageExtensions>dll, exe, zip, bzip2, z, tar, 7z, gzip, gz, rar</PackageExtensions>
  <GlobPattern>**.dll/**.resources</GlobPattern>
  <GlobPatterns name="0"></GlobPatterns>
  <WildCardPattern></WildCardPattern>
  <WildCardPatterns name="0"></WildCardPatterns>
  <FileName></FileName>
  <FileNames name="0"></FileNames>
  <Exclude></Exclude>
  <Excludes name="0"></Excludes>
  <KeyPattern>{anysection_0/}{anysection_1/}{anysection_2/}{key_0}{/key_1}</KeyPattern>
</Inputs>
[ConvertJobs:0:Inputs:0]
PackageExtensions = dll exe zip bzip2 z tar 7z gzip gz rar
GlobPattern = **.dll/**.resources
GlobPatterns:0 = 
WildCardPattern = 
WildCardPatterns:0 = 
FileName = 
FileNames:0 = 
Exclude = 
Excludes:0 = 
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".


  • json
  • xml
  • ini
"Inputs": [
  {
    "PackageExtensions": "dll exe zip bzip2 z tar 7z gzip gz rar",
    "GlobPattern": "**.dll/**.resources"
  }
],
<Inputs name="0">
  <PackageExtensions>dll, exe, zip, bzip2, z, tar, 7z, gzip, gz, rar</PackageExtensions>
  <GlobPattern>**.dll/**.resources</GlobPattern>
</Inputs>
[ConvertJobs:0:Inputs:0]
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.

  • json
  • xml
  • ini
"Inputs": [
  {
    "PackageExtensions": "",
    "GlobPattern": "**{.Culture}.dll/**.resources",
    "KeyPattern": "{Type.}[Key]"
  }
],
<Inputs name="0">
  <PackageExtensions>dll, exe, zip, bzip2, z, tar, 7z, gzip, gz, rar</PackageExtensions>
  <GlobPattern>**{.Culture}.dll/**.resources</GlobPattern>
  <KeyPattern>{Type.}[Key]</KeyPattern>
</Inputs>
[ConvertJobs:0:Inputs:0]
PackageExtensions = dll exe zip bzip2 z tar 7z gzip gz rar
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.

  • json
  • xml
  • ini
"Inputs": [
  {
    "ReaderClass": "ExampleNamespace.ExtFileFormat,ExtLibrary"
  }
],
<Inputs name="0">
  <ReaderClass>ExampleNamespace.ExtFileFormat,ExtLibrary</ReaderClass>
</Inputs>
[ConvertJobs:0:Inputs:0]
ReaderClass = ExampleNamespace.ExtFileFormat,ExtLibrary


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
Back to top Copyright © 2015-2020 Toni Kalajainen