Nibble

Introducing Eazy D for Umbraco, Dictionary Items made Easier!

EazyDLogoI’m proud to announce another new Umbraco package Smile 

This one adds a little something to the Umbraco backoffice that should make your life easier when working with multilingual sites in Umbraco (if you aren’t familiar with how to do multilingual sites in Umbraco make sure to check out this chapter on umbraco.tv http://umbraco.tv/videos/implementor/multi-lingual/creating-a-multi-lingual-site/introduction/ )

One of the tasks that you need to perform when working with a multilingual site is to make sure you don’t have any static text in your templates / partial views / macro scripts (that is in a single language) and that is where dictionary items come in place, for each language defined on your site you need to have a corresponding value.

This of course means then when creating these dictionary items you need to move back and forth between your templates/partial views and the dictionary part of the Umbraco backoffice (and that can suck when you have a lot of items to create).

Meet Eazy D

Eazy D will add a new function to your template / view editor that allows you to create dictionary items directly from the editor you are in

image

Simply select the snippet of text you want to replace by a dictionary item and hit the new toolbar button

image

That will open the Eazy D dialog

image

Eazy D will auto generate a Key (making sure it’s one that is available)

You then have the choice to select a parent dictionary item (creating nested items allows you to have some structure in your dictionary items), parent selection will be remembered by the dialog Smile (so you don’t have to selected the same parent each time)

And of course the value is populated with the selected snippet

Hitting ok will create the new dictionary item and replace the selected snippet with the code needed to get the dictionary item value (Umbraco.GetDictionaryValue(“Key”))

image

So as you can see it’s a great little time saver Smile

Customize key generator

So to make it fast and easy to create dictionary items Eazy D will auto generate a dictionary Key based on the selected snipped, it’s also possible to customize this if you have a specific naming convention you want to follow.

That is setup in the config file \App_Plugins\EazyD\EazyD.config

That by default looks like

<?xml version="1.0" encoding="utf-8"?>
<eazyd>
  <settings>
    <setting key="autoGenerateKey" value="True"/>
    <setting key="autoGenerateKeyProvider" value="EazyD.Providers.AutoGenKey, EazyD"/>
  </settings>
</eazyd>
  

So you can disable this auto generate behavior or point it to a custom provider

Just implement a super simple interface (this is how the default one looks) and then change the provider key to your custom type!

    public class AutoGenKey: IAutoGenKey
    {
        public string Generate(string value)
        {
            var val = value.ToCamelCase();
            if (val.Length > 50)
                val = val.Substring(0, 50);
            return Regex.Replace(val, @"[^A-Za-z0-9]+", "");
        }
    }

 

And that’s it, want to learn more about Eazy D and how it was created (dialog is MVC and features some nice little Umbraco tips and tricks) be sure to tune in to tomorrows uHangout http://uhangout.co.uk ( so 27/9/2013 at 1:15 UK time). And will also release the package tomorrow Smile

2 Comments so far

  1. Ismail Mayat on September 27th, 2013

    Tim,

    That is an excellent package will definately be making use of it on all sites not just multilingual. I don’t like the idea of hard coding any kind of template in templates / macros but prefer it in the dictionary this will just make it so much more easier to get stuff into the dictionary in the first place.

    Ismail

  2. Tim Geyssens on September 27th, 2013

    @Ismail, thanks :)

Leave a Reply