• 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

T4 Text Templating Script

T4 Template script automatically updates the localization files as code evolves.


Download Lexical.Localization.Tool.exe and add it into the C# project folder.


Create new text template file "scanner.tt" into the C# project.

Add .ini.tt

Paste the following snippet into the .tt file.


"output extensions" determines file format. Supported formats are .json, .resx, .xml, .resources, .ini.

<#@ output extension=".ini"#>



Click on the "scanner.tt" and select "Run custom tool."

run .tt



If everything went as expected, two new files are added into the project scanner.ini and scanner.ini.log.

after run



The generated file now contains the inlined strings that are read from the code. These generated language strings can now be passed to translators and then added back to the project.

For the example the output would be:

Section:Key = Success

[Culture:fi]
Section:Key = Onnistui

[Culture:sv]
Section:Key = Det funkar



If there was an issue with the T4, the script can be debugged. debug .tt

Back to top Copyright © 2015-2020 Toni Kalajainen