One requirement of our client is to provide multilingual content. But the problem is he doesn't like how umbraco is handling it which is creating another folder for each language.
Now what he wants me to do is to create a dropdown selection for the language.
If I select spanish on the dropdown then all the content will be populated with spanish content only.
Is there a way for me to do it in the back office? I was thinking of creating a dropdown control and put it inline with the logout button. Now when I select a language I should be able to set the appropriate resource file.
I don't know if it possible to do it using a dropdown..,
Do you know why your client does not like it when multiple folders are created? Is it because he get's confused when there is more than one site i the content section? If so I'm thinking it should be possible to work around setting up three user accounts. One for each language, which only shows the language that is connected with the login (if that makes sense).
Another possibility is a bit more cumbersome and I'm not sure if there are any SEO issues / and what the workarounds could be. But you could create three tabs on each of your document types. One for each language where you add language prefixed properties on each tab. The downside is off course that you need to duplicate the properties etc. Once there was a great section about this on umbraco.org's books section but it seems like it has been lost during the launch of the new site. But maybe there is something to gain from this slideshare presentation: http://www.slideshare.net/mardenpb1/multi-lingual-websites-in-umbraco
When we create multiple folders for multiple language. Example in our case, we plan to make it available in 40 languages because it is travel/hotel portal. It will be very difficult for us, especially the content writer to manage it. I can't also make different tabs for each document type because of the same issue that we have on translating it to 40 languages.
In both scenario, it is still cubersome for the user.
So I was thinking for now is to create a simplified admin ui using the umbraco API to present the content to our user. I will use different folder in the main umbraco admininistration site to handle multilingual but then I will present the content in a simplified way to the custom admin UI I will develop.
Do you think it's possible?
I was thinking of how to do the publish function using the API. Do you have any idea how to it?
Hi Kerio is it possible using your sample to set the resource file for the content. We don't want automatic translation for the content that's why I was thinking of putting it in a resource file.
Additional question is how did you extend the global.asax file?
Just convince him that it is a requirement, because otherwise he won't be able to optimise the url's of each language, and his hotel won't appear in the search results at all just because the search terms don't match the url...
Hotels & holidays are excessively competitive, and he can be sure this is an issue. other hotel websites will outperform his.
40 languages ? isn't that a bit over-the-top for a hotel site ? :p
But when I try to compile it and put in the bin folder. It seems that it is not working because my navigation where I defined the dictionary objects for the language is not changing.
Are your sure your querystring parameter name is called "lang"? How do you go from your dropdown to the "new language page"? Do you set the new language page url as value of your dropdown items? Or do you use a server dropdown control and just post your current page on dropdown selected index changed?
In the second case, chances are big that 1/ You need to check Request.Form["lang"] instead of Request.Querystring["lang"] 2/ Even if the server-side ID name of your dropdown is "lang", the client side ID, and therefore the form parameter name, will be something else (the "ClientID" value of your dropdown).
Don't forget you have to set the culture at every call, so if sometimes the querystring value is not available, you have to set the culture from your Session variable, otherwize you are back to the default culture
Also, you migh try calling the base.Application_BeginRequest at the end of your method, once you have set the culture (but I'm not sure).
Maybe this is a casing issue? I'm not 100% sure anymore, but I kind of remember having some issues because the CultureInfo constructor is case sensitive => if you come with a parameter value of "EN", I think it will not work and you have to lower-case it to "en". Same if you come with values like "en-EN", they have to be properly cased.
Fix it. Though my problem is setting the session variable. Because whenever I try to go to other pages, the culture info is reverted back to default. Any suggestion how to call the culture info on every request without passing the parameters?
You have indeed to set the culture on every page request. Since you are setting the Session["lang"] variable when getting the language via the querystring, I think the only thing you need to do is implement an "else" clause if you don't have the querystring parameter, and then set the CultureInfo based on the value saved in your Session variable (with a default value in case it is not set yet).
That way, the CultureInfo will be set on every page, regardless of querystring.
Somehow my entry was duplicated, so just removed my text and put a suggestion for the code insead:
if (Request.QueryString["lang"] != null)
Session["lang"] = Request.QueryString["lang"];
String lang = Session["lang"];
if (!string.IsNullorEmpty(lang)) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang); Thread.CurrentThread.CurrentCulture = new CultureInfo(lang); }
Strange, because then you would get an exception when trying to access it... Is your site Session-enabled? I guess you are not running on load-balanced web servers for your tests?
Otherwize, you can use a cookie like in the example of Kerio. This is actually "safer" than session + it allows you to retrieve the user language the next time he connects to your site, while storing in Session will oblige him to select the language every time he visits your site again.
Hi again, well if it can help you in my case i use global resource files, because i put content in masterpages and this is the reason for the trick to usea global.asax to set language and culture setting. You can read more about this solution in http://www.codeproject.com/KB/aspnet/masterpageglobalization.aspx
And to use the global.asax file i just delete/rename the one from umbraco in umbraco/bin folder to for example App_global.asax.dll and put mine in umbraco root folder.
I make use of asp.net global resources files (filename.langcode.resx) created with visual studio, and put them in App_GlobalResources folder (and copied to umbraco root installation folder) .Then where I want to put content from resources files i use an user control/macro .ascx with code to get content from resources file, for example,
and macro/user control is called from masterpage or regular pages inside umbraco.
In my case i did this way because i just want taste how multilanguages worked in umbraco and how use recources files, i've yet resources files with all the contents before. But maybe it's not the best approach for a big portal with 40 languages, besides the reasons already commented (about bad indexing with search engines), it could happen that you have a very different layout in pages with content in different languages (maybe some language are read right to left, or use different charset), so maybe the best solution is like you've yet commented, use different folder for every languages, and build different website for each one. hope this help
Multilingual content in one site
Hello,
One requirement of our client is to provide multilingual content. But the problem is he doesn't like how umbraco is handling it which is creating another folder for each language.
Now what he wants me to do is to create a dropdown selection for the language.
If I select spanish on the dropdown then all the content will be populated with spanish content only.
Is there a way for me to do it in the back office? I was thinking of creating a dropdown control and put it inline with the logout button. Now when I select a language I should be able to set the appropriate resource file.
Do you think it is possible?
Hi Sherry
I don't know if it possible to do it using a dropdown..,
Do you know why your client does not like it when multiple folders are created? Is it because he get's confused when there is more than one site i the content section? If so I'm thinking it should be possible to work around setting up three user accounts. One for each language, which only shows the language that is connected with the login (if that makes sense).
Another possibility is a bit more cumbersome and I'm not sure if there are any SEO issues / and what the workarounds could be. But you could create three tabs on each of your document types. One for each language where you add language prefixed properties on each tab. The downside is off course that you need to duplicate the properties etc. Once there was a great section about this on umbraco.org's books section but it seems like it has been lost during the launch of the new site. But maybe there is something to gain from this slideshare presentation: http://www.slideshare.net/mardenpb1/multi-lingual-websites-in-umbraco
I hope these inputs are useful.
/Jan
Hi Jan,
When we create multiple folders for multiple language. Example in our case, we plan to make it available in 40 languages because it is travel/hotel portal. It will be very difficult for us, especially the content writer to manage it. I can't also make different tabs for each document type because of the same issue that we have on translating it to 40 languages.
In both scenario, it is still cubersome for the user.
So I was thinking for now is to create a simplified admin ui using the umbraco API to present the content to our user. I will use different folder in the main umbraco admininistration site to handle multilingual but then I will present the content in a simplified way to the custom admin UI I will develop.
Do you think it's possible?
I was thinking of how to do the publish function using the API. Do you have any idea how to it?
Hello, yes for example i did that in my personal website that run with umbraco 4.5.1. http://www.campdeturiaonline.com.es
In my case i use querystring, but it's possible with dropdown, just put code in Application_BeginRequest event inside global.asax file.
if (Request.QueryString["lang"] != null)
{
String lang = Request.QueryString["lang"];
// HttpCookie cookie = Request.Cookies["CultureInfo"];
// if (cookie != null && cookie.Value != null)
//{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
these lines just to setup cultute and cultureUI from value get from querystring or dropdown.
Hope this helps
Hi Kerio is it possible using your sample to set the resource file for the content. We don't want automatic translation for the content that's why I was thinking of putting it in a resource file.
Additional question is how did you extend the global.asax file?
Just convince him that it is a requirement, because otherwise he won't be able to optimise the url's of each language, and his hotel won't appear in the search results at all just because the search terms don't match the url...
Hotels & holidays are excessively competitive, and he can be sure this is an issue. other hotel websites will outperform his.
40 languages ? isn't that a bit over-the-top for a hotel site ? :p
I've already tell him that but he is determined to simplify the backoffice. My client is a sort of innovator. He wanted to try and test everything.
It is a group of hotels so somehow in the future it will be fine.
Anyway, I try to use kerio's approach but i'm having a problem with it. This is my code for the global.asax.System;
But when I try to compile it and put in the bin folder. It seems that it is not working because my navigation where I defined the dictionary objects for the language is not changing.
Hello,
Are your sure your querystring parameter name is called "lang"? How do you go from your dropdown to the "new language page"? Do you set the new language page url as value of your dropdown items? Or do you use a server dropdown control and just post your current page on dropdown selected index changed?
In the second case, chances are big that
1/ You need to check Request.Form["lang"] instead of Request.Querystring["lang"]
2/ Even if the server-side ID name of your dropdown is "lang", the client side ID, and therefore the form parameter name, will be something else (the "ClientID" value of your dropdown).
Don't forget you have to set the culture at every call, so if sometimes the querystring value is not available, you have to set the culture from your Session variable, otherwize you are back to the default culture
Also, you migh try calling the base.Application_BeginRequest at the end of your method, once you have set the culture (but I'm not sure).
Hope this helps you solving the issue.
Cheers,
Michael.
@Mike
What I did is to copy the global.asax and global.asax.cs to the root folder of my umbraco installation.
I'm getting the request.querystring value but it seems that it is still not changing the culture info.
Hello,
Maybe this is a casing issue? I'm not 100% sure anymore, but I kind of remember having some issues because the CultureInfo constructor is case sensitive => if you come with a parameter value of "EN", I think it will not work and you have to lower-case it to "en". Same if you come with values like "en-EN", they have to be properly cased.
Cheers,
Michael.
i'm passing it exactly. question is does the dictionary object of umbraco follows the cultureinfo when set?
Fix it. Though my problem is setting the session variable. Because whenever I try to go to other pages, the culture info is reverted back to default. Any suggestion how to call the culture info on every request without passing the parameters?
Hello,
You have indeed to set the culture on every page request. Since you are setting the Session["lang"] variable when getting the language via the querystring, I think the only thing you need to do is implement an "else" clause if you don't have the querystring parameter, and then set the CultureInfo based on the value saved in your Session variable (with a default value in case it is not set yet).
That way, the CultureInfo will be set on every page, regardless of querystring.
Cheers,
Michael.
Somehow my entry was duplicated, so just removed my text and put a suggestion for the code insead:
Hope this helps.
Cheers,
Michael.
I've tried that but I think session variable is not permitted in global.asax.
Strange, because then you would get an exception when trying to access it... Is your site Session-enabled? I guess you are not running on load-balanced web servers for your tests?
Otherwize, you can use a cookie like in the example of Kerio. This is actually "safer" than session + it allows you to retrieve the user language the next time he connects to your site, while storing in Session will oblige him to select the language every time he visits your site again.
Cheers,
Michael.
Hi again, well if it can help you in my case i use global resource files, because i put content in masterpages and this is the reason for the trick to usea global.asax to set language and culture setting. You can read more about this solution in http://www.codeproject.com/KB/aspnet/masterpageglobalization.aspx
And to use the global.asax file i just delete/rename the one from umbraco in umbraco/bin folder to for example App_global.asax.dll and put mine in umbraco root folder.
@Kerio and @Mike - Thanks.
@Kerio - How did you build the resource file for the umbraco content? Will I be using the key use in umbraco.config?
I make use of asp.net global resources files (filename.langcode.resx) created with visual studio, and put them in App_GlobalResources folder (and copied to umbraco root installation folder) .Then where I want to put content from resources files i use an user control/macro .ascx with code to get content from resources file, for example,
<%@ Control Language="C#" ClassName="slides" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Labeldev.Text = (String)GetGlobalResourceObject("resourcefilename", "key");
}
</script>
or if you want directly in asp.control,
<asp:Localize runat="server" ID="ebooks" Text="<%$ Resources:resourcefilename, key %>"/>
<br />
<asp:HyperLink navigateurl="http://www.domain.com/" id="link2" runat="server" Text="<%$ Resources:resourcefilename, key %>">linktext</asp:HyperLink>the
and macro/user control is called from masterpage or regular pages inside umbraco.
In my case i did this way because i just want taste how multilanguages worked in umbraco and how use recources files, i've yet resources files with all the contents before. But maybe it's not the best approach for a big portal with 40 languages, besides the reasons already commented (about bad indexing with search engines), it could happen that you have a very different layout in pages with content in different languages (maybe some language are read right to left, or use different charset), so maybe the best solution is like you've yet commented, use different folder for every languages, and build different website for each one.
hope this help
is working on a reply...