Lugha.Import
0.3.0
dotnet add package Lugha.Import --version 0.3.0
NuGet\Install-Package Lugha.Import -Version 0.3.0
<PackageReference Include="Lugha.Import" Version="0.3.0" />
<PackageVersion Include="Lugha.Import" Version="0.3.0" />
<PackageReference Include="Lugha.Import" />
paket add Lugha.Import --version 0.3.0
#r "nuget: Lugha.Import, 0.3.0"
#:package Lugha.Import@0.3.0
#addin nuget:?package=Lugha.Import&version=0.3.0
#tool nuget:?package=Lugha.Import&version=0.3.0
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 aTranslationSet.
Code emitter
CodeEmitter (static class) - transforms translation sets into C# source.
EmitContracts(TranslationSet reference, string ns)- generatesITextScopeinterfaces 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/TranslationEntrytypes so the emitter is format-agnostic. - Plural support: the emitter resolves CLDR rules via
LanguageRules.Resolve()fromLugha.Commonand emitsPlural.Select<TCardinal>(count, new PluralForms { ... })calls. - Parameter typing: parameters named
"count"receiveinttype; all others receivestring.
Build
Multi-targets netstandard2.0 and net10.0. References Lugha.Common.
dotnet build import/lugha-import
Licence
| Product | Versions 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. |
-
.NETStandard 2.0
- Lugha.Common (>= 0.3.0)
-
net10.0
- Lugha.Common (>= 0.3.0)
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.