Localize taxonomies and taxa

To localize taxonomies or their taxa using the Sitefinity CMS you must set a desired value in the culture you want for the properties that are localizable. These properties are of type Lstring, which enables you to persist different value for different culture, and Sitefinity CMS will automatically resolve the correct value based on the current culture in the context where the taxonomy or taxa is used.

Create a taxonomy in a specified language

By default, when using the Sitefinity CMS API to create items, they are created in the current culture of the thread your request is executed in. If you are not running your code on a page where you are explicitly selecting a different language, the current culture of the thread is usually the default culture of your Sitefinity CMS website.

To create a taxonomy in a specific culture, you need to set the desired culture to be the current thread culture. Once you take care of that, you proceed by using the API to create the item. The following example demonstrates creating a taxonomy in a specified culture:

Add a translation of a taxon in a specified language

You can use the Sitefinity CMS API to add a translation to a taxon, that already exists. You must get the taxon and set the desired values for the taxon properties in the desired language. This is done via the SetString method  of the Lstring class, which enables you to pass a string value and a culture, for which that value should be persisted. The following sample demonstrates using the SetString method to add a translation to an existing taxon properties:

Notice that some of the taxon properties are not localizable, for example Name. When adding a translation to an existing taxon you can choose whether to skip setting values to the non-localizable properties, since this will override the value in all languages.

Additionally, when the Urls for localizable content are generated, you must take care of setting the CurrentThread culture to be the desired one. This way the Sitefinity CMS API that is responsible for URL generation will persist the Url in the correct language. Don't forget to set back the original culture once you are done saving your changes. Omitting this might affect any code that runs afterwards in the same thread.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

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.

Web Security for Sitefinity Administrators

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.

Foundations of Sitefinity ASP.NET Core Development

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.

Was this article helpful?

Next article

Query localized items