Copied to clipboard

Flag this post as spam?

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


  • Kleber Hucalo 26 posts 165 karma points
    Aug 01, 2014 @ 01:37
    Kleber Hucalo
    0

    Hi there

    I am getting an error on Translation Redirect macro.

    On Razor I am using this:

    @Umbraco.RenderMacro("TranslationRedirect")

    and getting this:

    Error loading MacroEngine script (file: TranslationRedirect.cshtml)

    when debugging it shows:

    {"Object reference not set to an instance of an object."}

    on this line:

    string basicPageUrl = string.Format("{0}?lang={1}", page.Parent.Parent.Url, page.GetPropertyValue("language"));

    Where this property "language" comes from?

    Is there any other setting necessary to use this feature, what is wrong here?

    What I need is: if the user navigate to others page it keeps the selected language. Say on home page the user select to change language, then when user go to home/about-us it displays the content on the selected language, now it reset to the default language.

    Also I would like to say this is the best multilingual package for Umbraco. Great stuff.

  • dimi309 245 posts 579 karma points
    Aug 01, 2014 @ 10:00
    dimi309
    0

    Hi Kleber,

    Many thanks for the nice comment about Polyglot!

    The language property must be declared in your translation document types, as is mentioned in the instructions (Polyglot_v2.0_Documentation.pdf for Umbraco 7, page 5 at the bottom "Most importantly...", or the corresponding part of the instructions Polyglot_v1.6_Documentation.pdf for Umbraco <= 6, both downloadable from the package's page, under Documentation).

    I think that, if you create the property, this problem will be resolved. You may have to recreate your translation documents, because that property is a label and is filled in by Polyglot automatically when the translations are created. If it has not been in place so far, it will be empty in existing translation documents.

    Please let me know if you need further assistance.

    Best regards,

    Dimitri

  • Kleber Hucalo 26 posts 165 karma points
    Aug 04, 2014 @ 00:10
    Kleber Hucalo
    0

    Hi Dimitri

    Thanks for your reply, but I still have no luck.

    I am stuck on it, I forgot to mention that I would like to build it using tabs.

    This is the steps I am doing for create a website with 2 different languages:

    - Created the document types call textpage

    - Created the tabs content and content (pt)

    - Created the properties bodyText and badyTextpt

    - Created the label language inside content (pt) tab.

    On template created the following:

    @Umbraco.RenderMacro("LanguageSelector")
    @Umbraco.RenderMacro("TranslationRedirect")
    @Umbraco.RenderMacro("PropertyTranslation", new{Property="bodyText"})

    If I delete the translation redirect link it works fine, but only for that page, if I navigate to other page it goes back to default language.

    If I keep the translation redirect, it still give the error, that object is null.

    I followed the documentation, however still not figured out how this can work with tabs.

    If you could give me some hint will be appreciated.

  • dimi309 245 posts 579 karma points
    Aug 04, 2014 @ 14:34
    dimi309
    100

    Hi Kleber,

    I think I see what's going on. Indeed, things change a bit if you are using tabs (hence, you are not using the translation document types).

    First of all, you don't need the TranslationRedirect macro at all. You would only need this if you were creating translation nodes, which to my understanding you are not. The purpose of TranslationRedirect, is to redirect a visitor to the site to the foreseen URL for each page, if he were to navigate to a translation node by accident or by guessing its URL and trying to hack the system. The fact that the macro has not been placed on a translation node, which is what it has been developed for, also explains why you get the null object error.

    Now, what you do need to look into, is the TranslatedNavigation macro which is mentioned under "Further Steps" on page 8 of the Polyglod v2 documentation (for developers using Polyglot v2 on Umbraco 7) or page 10 of the Polyglot v1.6 documentation (for developers using Polyglot v1.6 on older versions of Umbraco).

    You see, the default navigation menus provided by example Umbraco configurations are not ready to take Polyglot-style translations into account and the macro TranslatedNavigation provided by Polyglot does. You can either use it directly if it suits you, or adapt it to your site's structure and specific requirements if need be. You can also use its code as an example of how to develop other navigation components that you may need.

    Best regards,

    Dimitri

  • Kleber Hucalo 26 posts 165 karma points
    Aug 05, 2014 @ 00:17
    Kleber Hucalo
    0

    Hi Dimitri

    Its works like charm.

    Thank you very much for your advice, you rock mate!

     

     

  • dimi309 245 posts 579 karma points
    Aug 06, 2014 @ 06:21
    dimi309
    0

    You're welcome Kleber. Good luck with your project!

Please Sign in or register to post replies

Write your reply to:

Draft