Cacx.LanguageManager 1.1.2

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

πŸ“– Resource Manager πŸ“–

This Manager was originally created to manage languages in my WPF applications. <br> It also works on other kind of resources tho.

πŸ“š Lets go through a step by step tutorial on how to setup and use this library.

πŸ“‹ Setup

Open the project terminal and type in dotnet add package Cacx.LanguageManager --version 1.1.1

πŸ’» Usage

Optional: <br>

Register the LocalizationService via DI <br> You can also implement your own LocalizationService and register it via the Interface

public App()
{
    AppHost = Host.CreateDefaultBuilder().ConfigureServices((context, services) =>
    {
         _ = services.AddSingleton<ILocalizationService, LocalizationService>((_) =>
         {
             return new LocalizationService(basePath: "Some path...");
         });
    }.Build();

    _ = AppHost.Services.GetRequiredService<ILocalizationService>(); //This call is needed! Just disregard the service
}

Step 1

➑️ Get the ILocalizationService implementation

There a two ways to achieve this. <br>

Either get it from your DI Container

public ExampleCtor(ILocalizationService service)
{
  
}

or instanciate an ILocalizationService one time...

//Call this at the start of your application
public void Method()
{
  _ = new LocalizationService("some random path...") //You dont have to use the instance instantly you can disregrad it for now
}

and use this property afterwards to get it...

public void SomeOtherMethod()
{
  ILocalizationService service = LocalizationProvider.Service;
}

Step 2

🌐 Set the Language

This will be CultureInfo.CurrentUICulture by default

public void Example()
{
  CultureInfo language = new CultureInfo("en-US");
  service.SetLanguage(language);
}

Step 3

πŸ”Update/Set the Context

Imagine you have this folder structure (which is recommended)

///   MyApp(Project)
///    ->Resources(Folder)
///        ->Login(Folder)
///            Login.resx
///            Login.de-DE.resx
///        ->CreateAccount(Folder)
///            CreateAccount.resx
///            CreateAccount.de-DE.resx

➑️ Imagine you wanna access the Login resource
public void Example()
{
  string basePath = "MyApp.Resources.Login.Login"; //"{ProjectName}.{Folder}.{Folder}.{Filename}"
  service.UpdateContext(basePath);
}

You have to do this context switch to access the resources of another file!

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.2 191 12/20/2025
1.1.1 234 12/7/2025
1.1.0 157 12/6/2025
1.0.0 225 12/3/2025