Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization on _Layout.cshtml

I'm trying to apply localization on _Layout.cshtml

_Layout.cshtml

@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Localization
@using Microsoft.AspNetCore.Mvc.Localization

@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
@inject IViewLocalizer LayoutLocalizer


<!DOCTYPE html>
<html>
<head>

</head>
    <body>
        <div style="margin:38px;margin-top:56px;" class="hidden-sm-down">
            <h2>@LayoutLocalizer["WelcomeHeader"] <b class="text_border_darkblue">MyTitle</b></h2>
            <div style="text-align:center;margin-top:42px;">
                @LayoutLocalizer["WelcomeSub"]
            </div>
        </div>
    </body>
</html>

The resource files are named named: Views.Shared._Layout.no.resx (I've tried renaming to views.shared.Layout.no.resx without any luck)

like image 491
SteinTheRuler Avatar asked Apr 22 '17 21:04

SteinTheRuler


People also ask

What is localization in. net core?

App localization involves the following: Make the app's content localizable. Provide localized resources for the languages and cultures you support. Implement a strategy to select the language/culture for each request.

What is localization in asp net?

Localization is the process of customizing the globalized web application to a specific locale and culture. Various resources such as images and text for the specific locale are created. The resource file in localization is scoped to a particular page in an application.


1 Answers

You must create a _Layout.no.resx file within the same path of the views but as a root the "Resources" folder. See sample image:

enter image description here

There is a video clarifying the use of Location see here

like image 73
Cesar Alvarado Diaz Avatar answered Nov 15 '22 22:11

Cesar Alvarado Diaz