We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37582
    • 65 Posts
    Hey there,

    I am using Babel for my website and my aim is to have a navigation, that works in every context. This is surely possible with wayfinder, but I can't use wayfinder for several reasons.

    Currently, I am wrapping my head round this:

    If I use just this:

    <a href="[[~6]]">foo</a>


    It'll always lead me to the same resource and disregard the set language.

    However, there is a snippet in Babel called BabelTranslation which returns the id of a document in the language I choose. So if 6 is a document in english and I want the resource id of the matching german document I just do this:

    [[BabelTranslation? &resourceId=`6` &contextKey=`de`]]


    Alright, just one step away from the solution:

    Now I don't want to set the contextKey (language) manually like in the example above. Instead, I want to read it from the setting cultureKey. My final result is a set of nested chunks, which does not work however.

    <a href="[[~[[BabelTranslation? &resourceId=`6` &contextKey=`[[++cultureKey]]`]]]]">foo</a>


    Is this a syntax error or more an error of my understanding? Should I write my own Snippet for that instead?

    Cheers
    Chris
      • 33968
      • 863 Posts
      If I remember correctly contextKey should default to the current context, so you could just leave that out?
        • 37582
        • 65 Posts
        Hey Lucas,

        thanks for your reply. Unfortunately contextKey isn't optional.

        I think I have to write my own Snippet. Found sLink which has some of the functionality I need. I'll combine that with Babel and see what I can get...

        Cheers
          • 33968
          • 863 Posts
          Just leave it out, give it a try wink
            • 37582
            • 65 Posts
            Did so, did not work. Thanks anyway...
              • 22295
              • 153 Posts
              See: https://github.com/mikrobi/babel/pull/44
              it allows using cultureKey instead of contextKey