Devhub.Localization
1.0.0
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
<PackageReference Include="Devhub.Localization" Version="1.0.0" />
paket add Devhub.Localization --version 1.0.0
#r "nuget: Devhub.Localization, 1.0.0"
// 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
Как использовать?
Создайте новое приложение с именем {ProjectName}.Localization
Добавьте файл ресурса с расширенеим .resx в папку Resources отдельной для каждой языковой культуры. Например: Resources\Resource.uz.resx
Добавьте пустой класс с названием Resource.cs в корневую папку приложения. Используется для поиска пути ресерсов
Установите пакет Devhub.Localization
Наконец зарегистрируйте сервис локализации
пример:
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 | Versions 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. |
-
net5.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Localization (>= 2.2.0)
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.
changed culture