Devhub.Localization 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Devhub.Localization --version 1.0.0                
NuGet\Install-Package Devhub.Localization -Version 1.0.0                
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="Devhub.Localization" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Devhub.Localization --version 1.0.0                
#r "nuget: Devhub.Localization, 1.0.0"                
#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 Devhub.Localization as a Cake Addin
#addin nuget:?package=Devhub.Localization&version=1.0.0

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

Как использовать?

  1. Создайте новое приложение с именем {ProjectName}.Localization

  2. Добавьте файл ресурса с расширенеим .resx в папку Resources отдельной для каждой языковой культуры. Например: Resources\Resource.uz.resx

  3. Добавьте пустой класс с названием Resource.cs в корневую папку приложения. Используется для поиска пути ресерсов

  4. Установите пакет Devhub.Localization

  5. Наконец зарегистрируйте сервис локализации

пример:

public static IServiceCollection AddCustomLocalization(this IServiceCollection services, IConfiguration config)
{
    services
        .AddLocalization(options =>
        {
            options.ResourcesPath = "Resources";
        })
        .AddDevhubLocalization(options =>
        {
            options.SupportedLanguages = config.GetSection("SupportedCultures").Get<string[]>();
            options.ResosurceSource = typeof(Resource);
        });

    return services;
}

public static IApplicationBuilder UseCustomLocalization(this IApplicationBuilder app)
{
    app.UseDevhubLocalization();

    return app;
}

Пример файловой структуры приложения:

MyProject.Localization
    Resources                   - Папка для хранения ресурсов
        Resource.en.resx
        Resource.uz.resx
        Resource.ru.resx
    Resource.cs                 - Пустой класс
    ConfigurationExtensions     - Вспомогетельный класс для регистрации сервиса локализации
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Devhub.Localization:

Package Downloads
Meddata.Localization

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 390 3/26/2024
1.0.0 753 8/1/2023

changed culture