• 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

Inlined Strings

Inlining is a way to write langauge string values right into the code. See Inlining for more instructions.

ILine key = LineRoot.Global.Section("Section").Key("Key")
    .Text("Success")
    .Inline("fi", "Onnistui")
    .Inline("sv", "Det funkar");

Tool can also scan IStringLocalizer texts and convert them to localization files.

IStringLocalizer<Example> myLocalizer = null;
string str = myLocalizer["Hello World"];

Inlined language strings can be converted to localization files, which can then be used as templates for translations to other languages, and then loaded into the application or class library as implementation for one of the abstractions.

Command-Line Arguments

The lever -s searches for inlined strings from **.dll and **.exe files.

Lexical.Localization.Tool -s

Lever -s:<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 -s:**/bin/release/*.dll

Lever -S:<glob pattern> adds exclude file pattern.

Lexical.Localization.Tool -s:**/bin/release/*.dll -S:**/exclude this dir/**

The tool automatically opens package types .zip, .7z, .rar, .tar, .gz, .bzip2, .z, .dll.

Lexical.Localization.Tool -s:**.zip/**.dll

This is sometimes unwanted behaviour. Exclude pattern -S can be used to not open specific file formats.

Lexical.Localization.Tool -s -S:**.zip/**

Some times inline scanner cannot infere the key completely. Such keys are dropped, unless lever -p is used, which sets option to add partially resolved keys to the result. These keys use section "_UNKNOWN_".

Lexical.Localization.Tool -p -s:**.dll

Configuration File

Scan can be configured from files as well.

Lexical.Localization.Tool -le scanconfig.json

Under section "ConvertJobs" there is "InlineScans" array, which that defines sections for jobs that scan inlined strings from .dll files (full configuration example). Example with all properties:

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


InlineScans Parameters:

Parameter Description Example Value
PackageExtensions Extensions to open dll exe zip bzip2 z tar 7z gzip gz rar
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).

  • json
  • xml
  • ini
"InlineScans": [
  {
    "PackageExtensions": "dll exe zip bzip2 z tar 7z gzip gz rar",
    "GlobPattern": "**.dll/**.resources"
    }
  ],
<InlineScans name="0">
  <PackageExtensions>dll, exe, zip, bzip2, z, tar, 7z, gzip, gz, rar</PackageExtensions>
  <GlobPattern>**.dll/**.resources</GlobPattern>
</Inputs>
[ConvertJobs:0:InlineScans:0]
PackageExtensions = dll exe zip bzip2 z tar 7z gzip gz rar
GlobPattern = **.dll/**.resources
Back to top Copyright © 2015-2020 Toni Kalajainen