Lunaris.Gettext 1.3.1

dotnet add package Lunaris.Gettext --version 1.3.1
                    
NuGet\Install-Package Lunaris.Gettext -Version 1.3.1
                    
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="Lunaris.Gettext" Version="1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lunaris.Gettext" Version="1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="Lunaris.Gettext" />
                    
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 Lunaris.Gettext --version 1.3.1
                    
#r "nuget: Lunaris.Gettext, 1.3.1"
                    
#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 Lunaris.Gettext@1.3.1
                    
#: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=Lunaris.Gettext&version=1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=Lunaris.Gettext&version=1.3.1
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.3.1 0 11/15/2026
1.3.0 117 11/8/2026
1.2.0 94 11/8/2026
1.1.0 131 10/25/2026
1.0.0 129 10/22/2026