Copied to clipboard

Flag this post as spam?

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


  • Bilal Isa 60 posts 76 karma points
    Oct 25, 2010 @ 10:17
    Bilal Isa
    0

    Localization with dictionary

    Can somebody provide a full XSLT example of how to use Dictionaries and dictionary elements to localize a website?
    I tried with something like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:softpilar.library="urn:softpilar.library" xmlns:softpilar.web.localisation="urn:softpilar.web.localisation" xmlns:umbraco.contour="urn:umbraco.contour"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets softpilar.library softpilar.web.localisation umbraco.contour ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="key" select="/macro/key"/>
    <xsl:variable name="currentLanguageCode" select="softpilar.library:GetCurrentLanguage()"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:value-of select="softpilar.web.localisation:translate($key, $currentLanguageCode)"/>
     <!--<xsl:value-of select="$currentLanguageCode" />-->
    </xsl:template>
    </xsl:stylesheet>

    I’m using version 4.5.1 and I’m getting the following error when I save my XSLT with the language in my browser set to English:

    Error occured
    System.ArgumentNullException: Value cannot be null. 
    Parameter name: value
    at System.Web.Caching.CacheEntry..ctor(String key, Object value, CacheDependency dependency, CacheItemRemovedCallback onRemovedHandler, DateTime utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, Boolean isPublic)
    at System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic, String key, Object value, CacheDependency dependencies, DateTime utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace)
    at System.Web.Caching.Cache.Add(String key, Object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback)
    at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
    at umbraco.cms.businesslogic.language.Language.GetByCultureCode(String CultureCode)
    at SoftPilar.Web.Localisation.DictionaryLookUp.translate(String key, String language)

    Thanks in advance.

  • Rich Green 2246 posts 4008 karma points
    Oct 25, 2010 @ 10:33
    Rich Green
    0

    Hi,

    Do you have Umbraco.TV? I you have then the first 2 videos here will answer all your questions 

    http://www.umbraco.tv/help-and-support/video-tutorials/for-site-builders/running-multiple-sites/structure,-domains-and-languages

    I don't know where you got your XSLT from but you're making it way more complicated than it is.

    Can you tell us a little more about the structure of the website, is it a multi-lingual site structured like this:

    Content

    -English Site

    -French Site

    -Spanish Site

    If so then you just need to set the 'hostnames' (right click and select 'manage hostnames') on each node and set a language for each.

    Then, add your values to the Dictionary in the languages section.

    To get them in XSLT you just use

    xsl:value-of select="umbraco.library:GetDictionaryItem('nameOfDictionaryItem)" />

     

    Umbraco will automatically pull out the language item based on the language you specified when you set the host name.

    Rich

     

  • Bilal Isa 60 posts 76 karma points
    Oct 25, 2010 @ 10:50
    Bilal Isa
    0

    Greetings Rich


    I don’t have Umbraco TV and my site is not structured like you outlined. Is it Umbraco best practice?
    Instead I have one root note and I use Current culture based on the language in the browser to pull out the relevant content. I have some global names on the site that I want to translate. Previously I was using Global resource files, but I wanted to use Dictionaries because it seems more natural, but maybe I’m not using them in the way they are intended to be used?

  • Rich Green 2246 posts 4008 karma points
    Oct 25, 2010 @ 11:58
    Rich Green
    0

    Hi,

     The structure I have represented is considered best practice but there are of course situations where it is not appropriate.

    It might be worth subscribing to umbraco.tv for a month if you can and have a look at those videos.

    I'm sure it can work how you describe, but I don't know the XSLT for that I'm afraid but I'm sure it's been done.

    Rich

     

     

  • Rich Green 2246 posts 4008 karma points
    Oct 25, 2010 @ 12:08
    Rich Green
    0

    You could also read this thread which is looking to achieve the same thing.

    http://our.umbraco.org/forum/using/ui-questions/2814-MultiLanguage-same-Domain-?p=0

    Rich

  • Bilal Isa 60 posts 76 karma points
    Oct 25, 2010 @ 12:33
    Bilal Isa
    0

    Hello Rich
    It looks like the person who started the thread to begin with wanted to do the same as me but ended doing multi lingual sites. If multi lingual sites is better for SEO I might consider restructuring the website. Thanks again.

  • Bilal Isa 60 posts 76 karma points
    Nov 01, 2010 @ 10:38
    Bilal Isa
    0

    I will restructure the website in the way outlined by Rich. Thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft