Flowsy.Localization 2.0.1

dotnet add package Flowsy.Localization --version 2.0.1                
NuGet\Install-Package Flowsy.Localization -Version 2.0.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="Flowsy.Localization" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Flowsy.Localization --version 2.0.1                
#r "nuget: Flowsy.Localization, 2.0.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.
// Install Flowsy.Localization as a Cake Addin
#addin nuget:?package=Flowsy.Localization&version=2.0.1

// Install Flowsy.Localization as a Cake Tool
#tool nuget:?package=Flowsy.Localization&version=2.0.1                

Flowsy Localization

Basic functionality for multi-lingual support.

Requirements

In order to offer multi-lingual support, applications must provide resource files with translations for every supported culture.

To load translations we need to specify an assembly and its resource file base name.

The resource file base name is built taking its path from the root of our project, using dots instead of directory separators and excluding the culture name and extension.

Load Translations Using an Extension Method

// Given the resource files for en-US and es-MX:
// /path/to/the/project/Resources/Shared.en-us.resx
// /path/to/the/project/Resources/Shared.es-mx.resx

// Load translation specifying and assembly and the resource file base name.
var localizedString1 = "StringId".Localize(typeof(SomeClass).Assembly, "Resources.Shared");

// Load translation specifying only the assembly containing the resource files.
// If we don't specify a resource file base name, the default is "Resources.Shared".
var localizedString2 = "StringId".Localize(typeof(SomeClass).Assembly);

// Load translation from the assembly calling Localize using the default base name for resource files. 
var localizedString3 = "StringId".Localize();

Load Translations Using IStringLocalizer

Another convenient way of loading translations is to stick to the rules defined for resource file naming, so we can inject instances of IStringLocalizer and get a translated string value directly by doing:

[ApiController]
[Route("/api/[controller]")
public class ExampleController : ControllerBase
{
    private readonly IStringLocalizer<ExampleController> _stringLocalizer;
    
    public ExampleController(IStringLocalizer<ExampleController> stringLocalizer)
    {
        _stringLocalizer = stringLocalizer;
    }
    
    [HttpGet]
    public string Get()
    {
        return _stringLocalizer["ExampleMessage"];
    }
}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Flowsy.Localization:

Package Downloads
Flowsy.Repository.Sql

Repository implementation for SQL databases.

Flowsy.Web.Api

Foundation components for Web APIs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 8,506 11/6/2022
2.0.0 1,976 10/25/2022
1.0.0 384 10/17/2022