Zonit.Extensions.Cultures
0.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Zonit.Extensions.Cultures --version 0.1.1
NuGet\Install-Package Zonit.Extensions.Cultures -Version 0.1.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="Zonit.Extensions.Cultures" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zonit.Extensions.Cultures --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Zonit.Extensions.Cultures, 0.1.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 Zonit.Extensions.Cultures as a Cake Addin #addin nuget:?package=Zonit.Extensions.Cultures&version=0.1.1 // Install Zonit.Extensions.Cultures as a Cake Tool #tool nuget:?package=Zonit.Extensions.Cultures&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Supporting language culture
Advanced language support for Blazor.
Nuget Package Abstraction
Install-Package Zonit.Extensions.Cultures.Abstractions
Nuget Package Extensions
Install-Package Zonit.Extensions.Cultures
Install
Add this in Routes.razor
@using Zonit.Extensions
<ZonitCulturesExtension />
Services in Program.cs
builder.Services.AddCulturesExtension();
App in Program.cs
app.UseCulturesExtension();
Example usage:
@page "/culture"
@using Zonit.Extensions.Cultures
@implements IDisposable
@inject ICultureProvider Culture
@Culture.Translate("Hello {0}", "user")
@code{
protected override void OnInitialized()
{
Culture.OnChange += StateHasChanged;
}
public void Dispose()
{
Culture.OnChange -= StateHasChanged;
}
}
API:
public interface ICultureProvider
{
/// <summary>
/// Returns the current culture in use in the BCP 47 standard
/// </summary>
public string GetCulture { get; }
/// <summary>
/// Returns the translation in the current language used
/// </summary>
/// <param name="content">Search string, example: �Hello {0}�</param>
/// <param name="args">Additional arguments, example: �User�</param>
/// <returns></returns>
public string Translate(string content, params object?[] args);
/// <summary>
/// Default time zone for the user
/// </summary>
/// <param name="utcDateTime"></param>
/// <returns></returns>
public DateTime ClientTimeZone(DateTime utcDateTime);
/// <summary>
/// Event that is triggered when the language is changed
/// </summary>
public event Action? OnChange;
/// <summary>
/// Date and time format
/// </summary>
public DateTimeFormatModel DateTimeFormat { get; }
}
public interface ICultureManager
{
/// <summary>
/// Get the current culture in use in the BCP 47 standard
/// </summary>
public string GetCulture { get; }
/// <summary>
/// Get the current time zone in use in the IANA standard
/// </summary>
public string GetTimeZone { get; }
/// <summary>
/// Get list of supported cultures
/// </summary>
public LanguageModel[] SupportedCultures { get; }
/// <summary>
/// Changing the default language
/// </summary>
/// <param name="culture">Language parameter in BCP 47 standard</param>
public void SetCulture(string culture);
/// <summary>
/// Changing the default time zone
/// </summary>
/// <param name="timeZone"></param>
public void SetTimeZone(string timeZone);
/// <summary>
/// Event that is triggered when the language is changed
/// </summary>
public event Action? OnChange;
}
public interface ITranslationManager
{
/// <summary>
/// Add one translation
/// </summary>
/// <param name="item"></param>
public void Add(Variable item);
/// <summary>
/// Add multiple translations
/// </summary>
/// <param name="items"></param>
public void AddRange(List<Variable> items);
}
Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Zonit.Extensions.Cultures.Abstractions (>= 0.1.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Zonit.Extensions.Cultures:
Package | Downloads |
---|---|
Zonit.Services.Manager
Package Description |
|
Zonit.Services.Dashboard
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.