Lugha.Import 0.3.0

dotnet add package Lugha.Import --version 0.3.0
                    
NuGet\Install-Package Lugha.Import -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lugha.Import" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lugha.Import" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Lugha.Import" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lugha.Import --version 0.3.0
                    
#r "nuget: Lugha.Import, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lugha.Import@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lugha.Import&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Lugha.Import&version=0.3.0
                    
Install as a Cake Tool

Lugha.Import

Shared import library that converts external translation files into typed Lugha source code. Format-specific parsers produce a common intermediate representation which a single code emitter transforms into ITextScope interfaces and sealed locale classes.

dotnet add package Lugha.Import

Most users consume this indirectly via Lugha.Import.Gettext, Lugha.Import.Resx, or Lugha.Cli. Reference it directly only if you are building a custom import tool or a third-party source generator.

Architecture

External files (.po / .pot / .resx / .resw)
        |
        v
  Format-specific parsers
  (GettextParser / ResxParser)
        |
        v
  TranslationSet              <-- format-neutral IR
  +-- TranslationEntry[]
        |
        v
    CodeEmitter
    |-- EmitContracts()        --> ITextScope interfaces
    +-- EmitImplementations()  --> sealed locale classes
        |
        v
  EmittedFile[]               --> C# source strings

API

Data types

Type Kind Purpose
TranslationEntry sealed record One translated text: Key (dot-delimited scope.member), Value, Parameters (ordered names), PluralForms (CLDR category to text, nullable).
TranslationSet sealed record A complete locale: Language (BCP 47 tag) and Entries (list of TranslationEntry).
EmittedFile sealed record A generated source file: FileName and Content.

Parsers

GettextParser (static class in Lugha.Import.Gettext) - parses .po and .pot files. Handles msgctxt as scope prefix, plural forms via msgid_plural/msgstr[N], and both named ({name}) and positional (%s/%d) placeholders.

  • Parse(string content) - locale file with language header.
  • ParseTemplate(string content) - template file (reference locale).

ResxParser (static class in Lugha.Import.Resx) - parses .resx and .resw XML files. Converts _ to . in resource keys, extracts {0}-style format holes, and reads <comment> elements for named parameter hints.

  • Parse(string content, string language) - returns a TranslationSet.

Code emitter

CodeEmitter (static class) - transforms translation sets into C# source.

  • EmitContracts(TranslationSet reference, string ns) - generates ITextScope interfaces from the reference locale.
  • EmitImplementations(TranslationSet locale, string contractNs, string targetNs) - generates sealed classes implementing the scope interfaces.
  • ToInterfaceName(string scopeName) - converts a scope name to its interface name (e.g. "Connection" to "IConnectionText").
  • ToClassPrefix(string languageTag) - converts a language tag to a class name prefix (e.g. "en-GB" to "EnGb").

Design

  • Two-phase emission: contracts from a reference locale, implementations from each target. A missing translation becomes an unimplemented interface member - a compile error, not a runtime surprise.
  • Format-neutral IR: both parsers produce the same TranslationSet/TranslationEntry types so the emitter is format-agnostic.
  • Plural support: the emitter resolves CLDR rules via LanguageRules.Resolve() from Lugha.Common and emits Plural.Select<TCardinal>(count, new PluralForms { ... }) calls.
  • Parameter typing: parameters named "count" receive int type; all others receive string.

Build

Multi-targets netstandard2.0 and net10.0. References Lugha.Common.

dotnet build import/lugha-import

Licence

Apache License 2.0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Lugha.Import:

Package Downloads
Lugha.Import.Gettext

Gettext (.po/.pot) source generator for Lugha typed localisation.

Lugha.Import.Resx

Resx (.resx/.resw) source generator for Lugha typed localisation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 196 3/21/2026
0.2.2 194 3/6/2026
0.2.1 186 3/6/2026
0.2.0 179 3/6/2026
0.1.0 191 3/5/2026