Lunaris.Gettext
1.3.1
dotnet add package Lunaris.Gettext --version 1.3.1
NuGet\Install-Package Lunaris.Gettext -Version 1.3.1
<PackageReference Include="Lunaris.Gettext" Version="1.3.1" />
<PackageVersion Include="Lunaris.Gettext" Version="1.3.1" />
<PackageReference Include="Lunaris.Gettext" />
paket add Lunaris.Gettext --version 1.3.1
#r "nuget: Lunaris.Gettext, 1.3.1"
#:package Lunaris.Gettext@1.3.1
#addin nuget:?package=Lunaris.Gettext&version=1.3.1
#tool nuget:?package=Lunaris.Gettext&version=1.3.1
Warning Lunaris.Gettext is not unmaintained, it currently is feature complete with near-exact parity with gettext, and is therefore in maintenance mode, which means new releases will only feature bug fixes.
Lunaris.Gettext
A C# library that directly interfaces with the native gettext library.
The syntax is meant to be near-exact with how you would utilize gettext via C, including shorthands, with the exception of certain function design changes for standard C# conventions.
String concatenation works the same as string.Format ({0}, {1}, etc.).
Dependencies
gettext is the only runtime dependency. If you are on Linux, it comes pre-installed. On macOS, it can be installed via Homebrew, and there are packages available for gettext on winget. Git Bash being installed is enough, as it also pulls in gettext as a runtime dependency.
Example
global using static Lunaris.Gettext;
BindTextDomain("ExampleApp", "/usr/share/locale");
TextDomain("ExampleApp");
BindTextDomainCodeset("ExampleApp", "UTF-8");
Console.WriteLine(GetString("Hello, world!"));
// -> Saluton, mondo!
// Plural forms
Console.WriteLine(
GetPluralString(
"I have {0} apple.", // Singular form
"I have {0} apples.", // Plural form
2 // Count
)
); // -> Mi havas 2 pomoj
Usage with xgettext
To use Lunaris.Gettext with xgettext, use these flags:
xgettext \
--output ExampleApp.pot \
--from-code UTF-8 \
--keyword \
--keyword=GetString \
--keyword=GetPluralString:1,2 \
--keyword=__ \
--keyword=__N:1,2 \
Program.cs
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.