Hi Allan Lazaro,
Thank you for getting back to me.
I probably did not clarify the questions well enough. Since Sitefinity is an ASP.NET CMS it uses ASP.NET's methods for localizing pages and user controls. With that being said you can take a look at ASP.NET Globalization and Localization
topic in MSDN Knowledge Base. You can use the Telerik.Localization API to set the current culture. That means that you do not need to go to the extent to persist cookies in order to know which language to use.
I could not understand what type of problems you have when localizing custom user controls. The method is the same as described in the KB article I pointed you in my previous reply. I have attached a sample of custom user control (.ascx) that is localized both for English and French. If you take a look at the archive, you just need to create App_LocalResources directory in the folder of your control and then create local resource files with the name of this control for each culture. Please take a look at the attached archive.
Now as you see, shenever you want some labels, or text localized, yuo just have to use this:
|<asp:Literal ID="LocalizableLiteral" runat="server" Text="<%$Resources:LocalizableLiteral%>" /> |
and then define the text in your resources for the controls. Furthermore, if you want to create your custom module, and controls that will use content form that module, you should take a look at the sample Products Module
. It is a custom generic content based module, that is localizable.
Now lets move to your user part. You can create a custom HTTP module, that will check if the current culture name is equal to the preferred language set in the profile of the logged in user.
So here is a suggestion what you can do. You can have your public pages (accessible to non autheticated users) use templates that have the language bar control in them. Then the members only pages can use templates that do not have the language bar on them.
Here is a sample how to achieve this. First off as described in the webinar I pointed you to, you should add custom fields to users' profiles like this:
|<profile defaultProvider="Sitefinity"> |
| <providers> |
| <clear/> |
| <add name="Sitefinity" connectionStringName="DefaultConnection" applicationName="/" type="Telerik.DataAccess.AspnetProviders.TelerikProfileProvider, Telerik.DataAccess"/> |
| </providers> |
| <properties> |
| ... |
| <add name="PreferredLanguage"/> |
| ... |
| </properties> |
Then you can add fields in your controls for registering users, and managing their profiles. You can do it like this:
|<asp:Label ID="lblLanguage" Text="Preferred Language" runat="server" /> |
|<asp:DropDownList ID="PreferredLanguage" runat="server"> |
| <asp:ListItem Text="English" Value="en" Selected="True" /> |
| <asp:ListItem Text="French" Value="fr" /> |
Now lets move to the custom HTTP module. I have prepared a sample one for you. You can find it attached. Here its what it does - it inherits from Sitefinity's CmsHttpModule, and overrides the method that checks if a user is authenticated. If true, then define the culture for the UI to the preferred one set in user's profile. To try this module out extract it to ~/App_Code/
directory in your project solution. Then open the web.config and find the following line:
| ... |
| <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/> |
| ... |
And substitute it with the following:
|<add name="Cms" type="Telerik.Samples.CustomCmsHttpModule.CustomCmsHttpModule, App_Code"/> |
This should do what you desire. If you have more questions, please feel free to contact us.
the Telerik team