Copied to clipboard

Flag this post as spam?

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


  • Morten 105 posts 345 karma points
    Mar 08, 2017 @ 13:32
    Morten
    0

    Multiple languages without copying

    Hello!

    I'm trying to expand my site to multiple languages. The layout and code on all pages are exactly the same. The only thing I want is different languages.

    I know from experience with Angular and i18n before, that creating a language file for each langauge is really easy. It would go something like this:

    {
        "FIRST_NAME": "First name",
        "EMAIL": "Email address"
    }
    

    and then another file for another language (like Danish):

    {
        "FIRST_NAME": "Fornavn",
        "EMAIL": "Email adresse"
    }
    

    On the page, I would then do something like this:

    <span>{{"FIRST_NAME" | translate}}</span>
    

    Which would, depending on the language you have set, output the string.

    I know I can do something like this by creating a content page called "EN", then copy it and rename it "DK". However, these pages would contain the exact same values/models/objects, except if I go and add a new one. This is extremely bad practise, unless they are paired and always in sync, but the pages are not.

    I know I can achieve the above using a dictionary (one for each translation). That is exactly what I want, but I don't want the culture from the content page to be the "determiner".

    This seems like an extremely easy thing to do, but doing the "if I use this language, use this dictionary" doesn't seem to play nice with me.

    Requirements:

    • No /en/ or /dk/ in the URL
    • Relatively easy to add new translations
    • Distinguish between each language

    I will have a dropdown in my header with country selection.

    Thanks!

    EDIT: I should also mention, that I want labels/text to be translated (like I showed above), but I also want each content item to be translated. I can do this using Vorto or creating a new input. That won't be hard.

  • Morten 105 posts 345 karma points
    Mar 08, 2017 @ 15:19
    Morten
    0

    Ended up using Vorto. I simply created an input for each text I wanted translated.

    A bit more work than I was hoping, but now I simply have one content page with two cultures for languages. Pretty neat.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies