More in this section

Forums / Developing with Sitefinity / Assigning correct language code

Assigning correct language code

7 posts, 0 answered
  1. J
    J avatar
    20 posts
    Registered:
    05 Feb 2008
    11 Aug 2008
    Link to this post
    We have a site with multiple languages, so the urls are similar to
    http://domain/en/page.aspx
    http://domain/es/page.aspx

    Now, we have a Generic content in our template with relative links such as-
    news.aspx
    contact.aspx

    But we need these urls to always capture the right language code , so we made them absolute by adding the following in our templates-

    <a href="/<%= System.Threading.Thread.CurrentThread.CurrentUICulture.Name %>/ContactUs.aspx">
                                Contact Us</a>

    But now when we edit a page that uses the template, we get the following-

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

    What is the right way of implementation so that the links have the correct language code?

    Thanks.
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    11 Aug 2008
    Link to this post
    Hi J,

    You can localize Generic Content items as well, therefore there would be no need for dynamically creating links. If you search for allowLocalization properties in web.config, you will notice that you can allow localization for Generic Content, News, Blogs, Events and so on. By doing so you will have a different version of content for each version and therefore you will be able to insert the correct link in each content (in respect to the current culture set by Sitefinity).

    For more information on Module localization, please refer to section Module Localization of the Sitefinity User Manual.

    I hope you will find this information helpful. Let us know if there is anything else we can do for you.

    Sincerely yours,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. J
    J avatar
    20 posts
    Registered:
    05 Feb 2008
    11 Aug 2008
    Link to this post
    Thanks Ivan. When adding the links through the editor and selecting the page to link to, the links don't have anything about the language code in them. i.e. they are standard like-
    <a href="/ContactUs.aspx">Contact Us</a>

    When the pages are rendered, the links shows as /Contact.aspx but when a user clicks on it, it gets redirected to /en/Contact.aspx (the language the user is in ).

    Is this the correct behavior? It seems to work correctly. I am wondering how this affects search engines since the crawlers will see the link as /Contact.aspx and not /en/Contact.aspx

    Let me know if I am missing something. Thanks.
  4. J
    J avatar
    20 posts
    Registered:
    05 Feb 2008
    12 Aug 2008
    Link to this post
    Hi Ivan - Any thoughts on how this effects search engines and their view of the links i.e. seeing them as /en/page.aspx vs /page.aspx. When linking to pages, is it possible to pull the necessary tags so that the links always have the language code in them?

    Thanks.
  5. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    13 Aug 2008
    Link to this post
    Hi J,

    Personally I don't believe this will have negative impact form the SEO perspective, but that is of course only my speculation - and I am no SEO expert. An easy way around this - if you think having the language part in URL would help your causes - is to simply modify the URL once you select it in the LinkManager of the GenericContent editor. When you select a page, you will have the URL in the first box, and all you have to do is insert /de, for example if the page you intend to link is in German.

    I am sorry that we do not offer a more automated way of doing this and that I was not able to help you more at the moment. If you need any further assistance, please do not hesitate to contact us.

    Best wishes,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. J
    J avatar
    20 posts
    Registered:
    05 Feb 2008
    18 Aug 2008
    Link to this post
    Hi Ivan - I thought this was working but unfortunately it doesn't seem like it is. Our site loads by default with-
    http://domain/en/homepage.aspx
    In our template, we have links like /es/homepage.aspx, /fr/homepage.aspx.
    On clicking a link like /es/homepage.aspx, the homepage renders with spanish content but on a clicking any of the other links like /contact.aspx, it ends up going to /en/contact.aspx. I would have thought based on your earlier description, it would go to /es/contact.aspx (which does exist). Is there a cookie or something that sitefinity uses to determine which language version to display? We are not using the language selector control. Our language selector for the end user are flags with links like /es/homepage.aspx, /fr/homepage.aspx.
    Thanks.
  7. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    20 Aug 2008
    Link to this post
    Hello J,

    Yes, when you click on /contact.aspx, it redirects to /en/contact.aspx, because the English is set as default language, i.e. accessing a page without specifying language loads its default language version.
    Actually, the language prefix (en, es, fr, ...) determines the current culture of the requested page. The page itself does not contain any localized content, it just has controls, which, on the other hand, could be localized. The idea is that you may have a multilingual site, without creating a specific language version for each page, e.g. if localization is enabled for your generic content module and you have placed some generic content items on the page, each content will display the content for the current culture.
    If the requested page does not contain a version of the requested language, the default language version is loaded. There is an option to configure the site to throw 404 http error if the requested language version does not exist.


    All the best,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
7 posts, 0 answered