User macro displayed content depending on language



  • Avatar
    Roman Serazhiev

    Hi Volker.

    Technically translations created with Scroll Translations are all stored on the same page; each translation is wrapped in a special macro (SV translations macro). If the macro can't be found on a page, Scroll Translations marks this page to not be translated.

    You need to put the output of your macro into a sv-translation macro for the current language. Unfortunately, there is no way to get the current language within the user macro, so you have to have a sv-translataion macro for each language in the space, like the following (where you need to change the languageKey, and the content to be displayed):

    <ac:structured-macro ac:name="sv-translation" ac:schema-version="1"><ac:parameter ac:name="language">{languageKey}</ac:parameter><ac:rich-text-body>
    {content to be displayed}

    The best would probably be to have a copy the user macro for spaces with Scroll Translations, in which a sv-translation macro is added for each language you are using.

    Here is an example of a user macro that prints "Content in English" when added in English (United States) and "Content in French" when added to French (France):

    ## @noparams
    <ac:structured-macro ac:name="sv-translation" ac:schema-version="1"><ac:parameter ac:name="language">en_US</ac:parameter><ac:rich-text-body>
    Content in English
    <ac:structured-macro ac:name="sv-translation" ac:schema-version="1"><ac:parameter ac:name="language">fr_FR</ac:parameter><ac:rich-text-body>
    Content in French

    Hope this helps.


    Comment actions Permalink
  • Avatar
    Volker Weinreich

    Hi Roman,

    thanks, that actually helped me a lot. I knew the structure of the translated pages, but I didn't realized, that I could use it in a user macro.


    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk