Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 24, 2013 @ 11:26
    Fuji Kusaka
    0

    Dictionary Item in VB userControl

    Hi everyone,

    I have a userControl in VB which works perfectly until the client decided to convert the website to a multilingual website. 

    Anyone can explain how do i get to add dictionaryItem to my userControl, i already added the umbraco.dll reference.

    //fuji

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Jan 24, 2013 @ 12:39
    Peter Gregory
    0

    Hmmm VB.NET..  I thought I spoke with you about this when I was in Mauritius. :)  Its pretty late so the following is off the top of my head and I'm not really a VB guy so will tackle it from a C# angle and leave it to you to convert.

    In c# you do it like this to load a dictionary item given you know the culture ID of the current node that you are looking at. So the first thing you need to do is establish what the culture of the domain that you are looking at is.  I cant remember what forum post I got this from but its sound.  The following assumes that you only have one domain assigned to each of your language roots of the site.

    This will retrieve the domains collection for the current node that you are looking at. I break out of the loop early once I find an item you could probably go about it differently if you had multiple domains assigned to a root.

    var domains = umbraco.library.GetCurrentDomains(currentNode.Id);
    if (domains != null) { foreach (var d in domains) {
    //this is the languageId of the current node langId = d.Language.id;
    //this is the culture code eg en-US if you need it for other localization stuff langAlias = d.Language.CultureAlias; break; } }

    Once you know the language ID you can go about retrieving your key from code. The string you pass the DictionaryItem is the name of the key you created in the backoffice.

    var yourTranslation = new umbraco.cms.businesslogic.Dictionary.DictionaryItem("The dictionary key string").Value(langId);

    Again sorry for not having the VB equiv but I am sure you can take this and build a VB version pretty easy.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jan 28, 2013 @ 06:22
    Fuji Kusaka
    100

    Hi Pete,

    Sorry for replying only now. Manage to do it in VB itself. YES you did !!! but since we already implemented it before so why not try to make it happened and use the same usercontrol !!! :)

    Imports System.Web
    Imports System.Net.Mail
    Imports umbraco.cms

          lblPrenom.Text = umbraco.library.GetDictionaryItem("Name")
          lblNom.Text = umbraco.library.GetDictionaryItem("LastName")

     

    I guess its always good to know both!!

    Thanks for the reply

    //Fuji

     

     

Please Sign in or register to post replies

Write your reply to:

Draft