This project demonstrates how to create a localized widget. The Localized widget renders its content in the default language or in German, depending on which language version of the page is requested. The project is based on the start template sample. For more information, see Sample: Starter template.
When the Renderer attempts to render a page, the culture for that page is passed along as information to the Renderer. The Renderer uses this culture to set the CultureInfo.CurrentUICulture and CultureInfo.CurrentCulture properties to match the value of the Sitefinity page.
CultureInfo
.CurrentUICulture
CultureInfo.CurrentCulture
The API for localized strings is based on the out-of-the-box API for developing ASP.NET Core applications. For more information, see Globalization and localization in ASP.NET Core.
NOTE: The instructions in this sample use Visual Studio 2022 and a Sitefinity renderer project named Renderer.
Under your Renderer project, you must create the following folders:
ViewComponents
Views
Shared
Components
Localized
You must register the custom scripts or styles in the _Layout.cshtml file. You must then use this custom base layout for every page where the Localized widget is placed
_Layout.cshtml
Perform the following:
Views/Shared
NOTE: If you have any custom scripts or styles, place them in folders wwwroot/scripts/scripts.js and wwwroot/styles/styles.css.
wwwroot/scripts/scripts.js
wwwroot/styles/styles.css
In Visual Studio, open the Renderer application.
Renderer
ViewComponent
View
Views/Shared/Components/Localized
Build your solution.
When you open your Renderer application and open the New editor, you will see the Localized widget in the widget selector. When you add the widget on your page and click the Custom empty text link, you can enter a text string that will be displayed on the frontend.
This sample is available in Sitefinity’s GitHub repository. You can run and play with it. To do this, perform the following:
sitefinity-aspnetcore-mvc-samples-master/src/localization
localization.sln
appsettings.json
“Sitefinity”
“Url”
localization
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important