Copied to clipboard

Flag this post as spam?

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


  • Sulakhan Bungre 5 posts 25 karma points
    Aug 16, 2013 @ 16:46
    Sulakhan Bungre
    0

    Upgrade Polyglot from 1.4 to 1.5 for language cultures

    We are using Umbraco 4.11.3 and Polyglot 1.4 to host a web site where the main lanuage is English (en) and secondary site is Welsh (cy). The Welsh translation folders and content have been created as 'cy'. We are using our own control to switch between English & Welsh.

    We now have a requirement to support language cultures, i.e. additional English cultures. We therefore plan to upgrade Polyglot to version 1.5.2, and switch on the language cultures, i.e. en-GB, cy-GB, etc., where en-GB becomes the default language.

    Can you please confirm the best approach/steps to achieve this upgrade, and the implications on existing culture unaware default (en) and 'cy' translation pages and folders.

    Also, we would like to use a non-ISO standard English culture, e.g. en-NI (Northern Ireland). How could we achieve this?

    Thanks in advance.

    Sula

  • dimi309 245 posts 579 karma points
    Aug 16, 2013 @ 17:22
    dimi309
    0

    Hi Sula,

    Thanks for using Polyglot :)

    As far as switching from not using cultures to using them is concerned, it is not difficult, but it is true that I have not covered the matter in the documentation. I will update the instructions.

    The non-standard cultures are indeed an interesting feature that I have never been asked about before. I will implement it in a beta version so that you can try it out and see if it works for you. The only limitation there is that the .NET framework itself might not support your system very well (e.g. if you are using the Umbraco dictionary), but I need to test things to be sure that that will even be a problem.

    I'll have both of these items ready by Monday.

    Best regards,

    Dimitri

  • Sulakhan Bungre 5 posts 25 karma points
    Aug 16, 2013 @ 17:28
    Sulakhan Bungre
    0

    Dimitri

    Thanks for the prompt response. I look forward to the updated documentation.

    Thanks,

    Sula

  • dimi309 245 posts 579 karma points
    Aug 18, 2013 @ 13:40
    dimi309
    0

    Hi Sula,

    I have now released version 1.6 of the package, which supports non-standard cultures, as discussed. In the documentation of this version, I also describe how to migrate to a Polyglot configuration in which cultures are used (e.g. en-US, en-GB, etc). 

    I have tested everything with various versions of Umbraco, including v4.11.3. Nevertheless, I would strongly recommend performing the migration steps in a test environment first, and also making a backup of the live system before migrating, just in case.

    Please let me know how it went, or if you have any questions.

    Best regards,

    Dimitri

  • Sulakhan Bungre 5 posts 25 karma points
    Aug 19, 2013 @ 11:31
    Sulakhan Bungre
    0

    Dimitri

    Thanks for this. I will be try 1.6 out and provide feedback. I assume the migration allows from a culture insensitive installation to the culture aware version, e.g. en to en-GB, cy to cy-GB, etc.

    Thanks,

    Sula

  • dimi309 245 posts 579 karma points
    Aug 19, 2013 @ 12:16
    dimi309
    0

    Sula,

    You're welcome!

    Indeed, I have added a section in the v1.6 documentation about how to do that: "Migrating to Using Cultures"

    Basically there are a couple of scripts that need to be executed on the database and a few other changes. It's always a good idea to try such procedures in a test environment first of course.

    Best regards,

    Dimitri

  • Sulakhan Bungre 5 posts 25 karma points
    Aug 19, 2013 @ 18:14
    Sulakhan Bungre
    0

    Dimitri

    Thanks for that. I did the upgrade and ran the SQL migration scripts, which went well, and enabled language cultures. I added a non-standard language to the Polyglot.config file. I now need to migrate the existing templates, script files, etc., which make reference to languages. I had a few additional queries.

    1. I assume the Settings->Languages are standard Umbraco and will only allow standard languages as I cannot add the non-standard language to this setting
    2. When I add a translation to an existing page, I can see the non-standard language in the list and was able to add the translation page
    3. Some of the code makes reference to the Translation Node Id, e.g. var cyTranslationNode = uQuery.GetNode(1187); How do I know the NodeId of the non-standard language?

    Thanks,

    Sula

  • dimi309 245 posts 579 karma points
    Aug 19, 2013 @ 19:05
    dimi309
    0

    Hi Sula,

    Great! I'm happy the migration went well!

    About the questions:

    1. I assume the Settings->Languages are standard Umbraco and will only allow standard languages as I cannot add the non-standard language to this setting

    To my knowledge that is correct. This is why Polyglot circumvents the standard languages limitation by maintaining its own list of non-standard languages in config/Polyglot.config

    2. When I add a translation to an existing page, I can see the non-standard language in the list and was able to add the translation page

    Yes, this seemed to work well during my tests as well.

    3. Some of the code makes reference to the Translation Node Id, e.g. var cyTranslationNode = uQuery.GetNode(1187);

       How do I know the NodeId of the non-standard language?

    For this, perhaps you can have a look at the source code of the Property Translation script of Polyglot:

    https://bitbucket.org/dimitrikourk/polyglot/src/69e95db4d8565980812ae45e52ad4ac796395f20/Dimi.Polyglot/UmbracoRazorScripts/PropertyTranslation.cshtml?at=default

    At line 23, starting from the main language node, it retrieves and displays the translation of a property in the selected language, if the translation exists. You might need a much simpler version of the code of course, which you can write based on this example. If you need any more help with this, please don't hesitate to write back.

    Best regards,

    Dimitri

  • Sulakhan Bungre 5 posts 25 karma points
    Aug 22, 2013 @ 13:18
    Sulakhan Bungre
    0

    Dimitri

    The site is working well with the non-standard culture as well. I had an additional query about calling a script file from within another script file. I tried to call the PropertyTranslation.cshtml from my cshtlm script file as follows:

    @*

    HomePageLinks.cshtml
    

    *@

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using umbraco.MacroEngines;

    @{

    string howToHomePageHeadingText = RenderPage("PropertyTranslation.cshtml", "howtoHomepageHeadingText").ToString().Trim();
    
    <h2>
        @howToHomePageHeadingText
    </h2>
    

    }

    but a blank value is being returned. Is this correct syntax?

    Thanks

    Sula

  • dimi309 245 posts 579 karma points
    Aug 22, 2013 @ 15:35
    dimi309
    0

    Hi Sula,

    First of all, just in case, I have noticed that the variable is named "howToHomepageHeadingText", whereas the alias passed as parameter is "howtoHomepageHeadingText". I am mentioning this, just in case there is a problem with the capitalisation of the alias.

    Anyway, I am afraid that the PropertyTranslation.cshtml script expects to receive its parameter through the corresponding macro, so the code you have mentioned will probably not work.

    I would suggest the following:

    var selectedLanguage = RenderPage("SelectedLanguage.cshtml").ToString().Trim(); 
    var howToHomePageHeadingText = RenderPage("PropertyReferenceTranslation.cshtml", Model.Id, "howtoHomepageHeadingText", selectedLanguage).ToString();

    I could make the PropertyTranslation script work both ways (as a macro and as a script with parameters), but I am trying to keep it performant so I do not want to add too much code to it.

    Another thing you might be interested in, may be the Razor Components package. It allows you to render macros within macro scripts. I have not used it extensively, but it seemed to work well when I tried it once. Using that, you might be able to use code that looks more like what you have listed above, only slightly modified.

    Best regards,

    Dimitri

     

     

Please Sign in or register to post replies

Write your reply to:

Draft