Created
July 17, 2019 14:04
-
-
Save SeppPenner/4e3d909a16a53cfab8e701d293344356 to your computer and use it in GitHub Desktop.
Blazor localization test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/" | |
@namespace TestApplication | |
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>TestApplicationl</title> | |
<base href="~/" /> | |
<environment include="Development"> | |
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> | |
</environment> | |
<environment exclude="Development"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | |
asp-fallback-href="css/bootstrap/bootstrap.min.css" | |
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" | |
crossorigin="anonymous" | |
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"/> | |
</environment> | |
<link href="css/site.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<app>@(await Html.RenderComponentAsync<App>())</app> | |
<script src="_framework/blazor.server.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Example.Application | |
{ | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Mvc.Razor; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
this.Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<ApplicationDbContext>(options => | |
options.UseSqlServer(this.Configuration.GetConnectionString("SqlServerConnection"))); | |
services.AddDefaultIdentity<IdentityUser>() | |
.AddEntityFrameworkStores<ApplicationDbContext>(); | |
services.AddRazorPages(); | |
services.AddServerSideBlazor(); | |
services.AddLocalization(options => options.ResourcesPath = "Translations"); | |
services.AddSignalR(); | |
//services.AddMvc(options => options.EnableEndpointRouting = false).AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix).AddDataAnnotationsLocalization(); | |
} | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseDatabaseErrorPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Home/Error"); | |
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
app.UseStaticFiles(); | |
app.UseRouting(); | |
app.UseAuthentication(); | |
app.UseAuthorization(); | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllers(); | |
endpoints.MapBlazorHub(); | |
endpoints.MapFallbackToPage("/_Host"); | |
}); | |
//app.UseMvc(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Microsoft.AspNetCore.Mvc.Localization | |
@inject IViewLocalizer Localizer | |
<table class="table"> | |
<thead> | |
<tr> | |
<th scope="col">@Localizer["Date"]</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>a</td> | |
<td>b</td> | |
</tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment