Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sherry Ann Hernandez 320 posts 344 karma points
    Jan 27, 2011 @ 13:20
    Sherry Ann Hernandez
    0

    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?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 27, 2011 @ 23:42
    Jan Skovgaard
    0

    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

  • Sherry Ann Hernandez 320 posts 344 karma points
    Jan 29, 2011 @ 06:48
    Sherry Ann Hernandez
    0

    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?

  • kerio sp 12 posts 33 karma points
    Jan 29, 2011 @ 11:53
    kerio sp
    0

    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

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 08:01
    Sherry Ann Hernandez
    0

    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?

  • Rik Helsen 670 posts 873 karma points
    Feb 03, 2011 @ 09:44
    Rik Helsen
    0

    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

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 09:58
    Sherry Ann Hernandez
    0

    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;

    using

    using

    using

    using

    using

    using

    using

    using

    using

    namespace FloraHospitalityGlobal

     

    {

     

    public class Global : umbraco.Global

    {

     

     

    protected override void Application_BeginRequest(object sender, EventArgs e)

    {

     

     

    base.Application_BeginRequest(sender, e);

     

    if (Request.QueryString["lang"] != null)

    {

     

    String lang = Request.QueryString["lang"];"lang"] = lang; Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang); Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);

    Session[

     

     

    }

    }

    }

    }

    umbraco;
    System.Globalization;
    System.Threading;
    System.Web.SessionState;
    System.Web.Security;
    System.Web;
    System.Linq;System.Collections.Generic;

    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.

     

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 03, 2011 @ 10:21
    Michael Latouche
    0

    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.

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 11:07
    Sherry Ann Hernandez
    0

    @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.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 03, 2011 @ 11:18
    Michael Latouche
    0

    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.

     

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 11:48
    Sherry Ann Hernandez
    0

    i'm passing it exactly. question is does the dictionary object of umbraco follows the cultureinfo when set?

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 13:15
    Sherry Ann Hernandez
    0

    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?

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 03, 2011 @ 13:24
    Michael Latouche
    0

    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.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 03, 2011 @ 13:25
    Michael Latouche
    0

    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);
    }   

    Hope this helps.

    Cheers,

    Michael.

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 03, 2011 @ 13:58
    Sherry Ann Hernandez
    0

    I've tried that but I think session variable is not permitted in global.asax.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Feb 03, 2011 @ 14:06
    Michael Latouche
    1

    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.

  • kerio sp 12 posts 33 karma points
    Feb 03, 2011 @ 18:20
    kerio sp
    1

    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.

     

  • Sherry Ann Hernandez 320 posts 344 karma points
    Feb 05, 2011 @ 09:07
    Sherry Ann Hernandez
    0

    @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?

  • kerio sp 12 posts 33 karma points
    Feb 05, 2011 @ 11:42
    kerio sp
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft