Once again, I will post a ridiculously short and simple post. In this post I will demonstrate how to enable localization on products module. The idea is, of course, that we can have different versions of products depending on the culture/language end user selected.
NOTE #1: Since this post is a part of the sequential series, at the very least, you should read the introductory post and set up the project as it was explained there.
NOTE #2: Localization feature is not available in the Sitefinity Community version.
Enabling localization on products module
In order to enable localization on products module, we will have to do two things:
- Enable localization for the site itself
- Enable localization for the products module
To enable localization for the site, open your web.config file and navigate to the following element:
and change the persistenceMode to PathPrefix (any value other than none, will turn on the localization). While at the topic, let me segue to the list of possible values for the PersistanceMode property (NOTE: this list applies only to Sitefinity 3.5 and higher):
- None – Localization is disabled.
- PathPrefix - The language code is inserted as folder in the URL right after application root.
- QueryString - The language code is appended in the query string of the request.
- BrowserSettings - Language code is not explicitly persisted and always the first match from browser preferred languages is used. AutoSetClientLanguage property must be true when this mode is selected.
- DomainName - The language is set per domain. This option could be used when you have different language versions and different domain for every language version. For instance the site has English and German versions, two domains could be used: myENsite.com and myGERsite.com.
- DomainExtension - The language code comes from the top level domain, if it is a country domain (.uk, .it, .es...), otherwise the default language is used.
So, the localization element with enabled localization for site, English as default language and English and Croatian as supported languages would look like this:
The, second thing we need to do is to enable localization for our products module. To do so, we will need to set the allowLocalization property to true in products provider. Navigate to
|<localization defaultProvider="Sitefinity" persistenceMode="PathPrefix" defaultCulture="en" cultures="en, hr"> |
element in web.config and make sure that this line has allowLocalization property set to true:
And you are done. You will be able to localize your products from now on.
|<add name="Products" allowLocalization="true" allowWorkflow="true" urlRewriteFormat="[Name].aspx" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" securityProviderName="" allowVersioning="False" applicationName="/Products" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data" /> |
The code for this sample you can download from here.