Localizer.Tools 1.2.6

Suggested Alternatives

Persilsoft.Localizer

Additional Details

You can use Persilsoft.Localizer

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Localizer.Tools --version 1.2.6
NuGet\Install-Package Localizer.Tools -Version 1.2.6
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="Localizer.Tools" Version="1.2.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Localizer.Tools --version 1.2.6
#r "nuget: Localizer.Tools, 1.2.6"
#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.
// Install Localizer.Tools as a Cake Addin
#addin nuget:?package=Localizer.Tools&version=1.2.6

// Install Localizer.Tools as a Cake Tool
#tool nuget:?package=Localizer.Tools&version=1.2.6

Localizer.Tools

A simple tool for Localization of projects


First, you need to create resource files. The name of each resource file must be follow the format:
{Extractor}.{Culture}.{resx}
Where:
Extractor: The name class to used to interact with the resource files, for example: Messages
Culture: The culture identifier, for example: en-US, es-PE
resx: This is the file extension for resource files

The following are some examples of resource file names:

  • Messages.en-US.resx (English for USA)
  • Messages.es-PE.resx (Spanish for Peru)

In each resource file create an entry with the same key but with the value according to the corresponding language, for example:

  • Name: Message Value=Hello World!
  • Name: Message Value=¡Hola Mundo!

Now, you need to create a class to access each key in the resource file. In the example, we are creating the class called Messages

public class Messages
{
    public static string Hello =>
        LocalizationUtils<Messages>.GetValue(nameof(Hello));
}

Now you can use it.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
Console.WriteLine(Messages.Hello);

Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-PE");
Console.WriteLine(Messages.Hello);

Global usings

global using Localizer.Tools;
global using System.Globalization;

In the case of AspNet Core application, you need to configure the Localization Middleware:

builder.Services.Configure<RequestLocalizationOptions>(options =>
{
    var SupportedCultures = new[] { "en-US", "es-PE" };
    var NeutralCulture = SupportedCultures[0];

    options.SetDefaultCulture(NeutralCulture)
    .AddSupportedCultures(SupportedCultures)
    .AddSupportedUICultures(SupportedCultures);
});

Then add the Localization pipeline:

app.UseRequestLocalization();

Finally, you can use it.

app.MapGet("/localizer/message", () =>
{
    return Results.Ok(Messages.Hello);
})
.WithName("Localizer");
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Localizer.Tools:

Package Downloads
ExceptionHandler.Blazor

Exception Handler Blazor

PushNotifications.BusinessObjects

PushNotifications BusinessObjects

Mail.BusinessObjects

Mail BusinessObjects

Sms.BusinessObjects

Sms BusinessObjects

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated