![]() |
VOOZH | about |
dotnet add package JCTools.I18N --version 2.0.0.2
NuGet\Install-Package JCTools.I18N -Version 2.0.0.2
<PackageReference Include="JCTools.I18N" Version="2.0.0.2" />
<PackageVersion Include="JCTools.I18N" Version="2.0.0.2" />Directory.Packages.props
<PackageReference Include="JCTools.I18N" />Project file
paket add JCTools.I18N --version 2.0.0.2
#r "nuget: JCTools.I18N, 2.0.0.2"
#:package JCTools.I18N@2.0.0.2
#addin nuget:?package=JCTools.I18N&version=2.0.0.2Install as a Cake Addin
#tool nuget:?package=JCTools.I18N&version=2.0.0.2Install as a Cake Tool
A simplification of the configuration of location in .net core
PM> Install-Package JCTools.I18N
For configure the localization and globalization settings follow the next steps:
PM> Install-Package JCTools.I18N
private readonly IHostingEnvironment _enviroment;
public Startup(IHostingEnvironment env)
{
// Store the enviroment instance
_enviroment = env;
...
}
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMvc();
services.AddLocalizationServices(
// The supported cultures
new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("en-US"),
new CultureInfo("es"),
new CultureInfo("es-MX")
},
// the default culture
defaultCulture: "es-MX"
)
.AddSingleLocalizationFile<I18N, Resources.I18N>(_enviroment);
}
app.UseLocalization();
The previous line should will be add before the next code:
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
For access at the localized strings into the Controllers, use:
private readonly SingleLocalizer _localizer;
public HomeController(SingleLocalizer localizer)
{
...
// store the receive argument into our field
_localizer = localizer;
...
}
ViewData["Message"] = _localizer["About_Message"];
For access at the localized string into the views, use:
@inject JCTools.I18N.Services.SingleHtmlLocalizer Localizer
<strong>@Localizer["Support"]:</strong> <a href="mailto:Support@example.com">Support@example.com</a>
For access to the localized strings into the models and viewmodels, use the data annotation of the namespace System.ComponentModel.DataAnnotations, how to shown below
using System.ComponentModel.DataAnnotations;
namespace JCTools.I18N.Test.ViewModels
{
public class ContactViewModel
{
[Display(Name = "ContactViewModel_Email", ResourceType = typeof(Resources.I18N))]
[EmailAddress(ErrorMessageResourceName = "ContactViewModel_EmailError", ErrorMessageResourceType = typeof(Resources.I18N))]
public string Email { get; set; }
[Display(Name = "ContactViewModel_Message", ResourceType = typeof(Resources.I18N))]
public string Message { get; set; }
}
}
For view spanish usage process, visit: JCTools.mx
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp1.1 netcoreapp1.1 is compatible. netcoreapp2.0 netcoreapp2.0 is compatible. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.