Multi language support

How to add multiple languages to a Bedrock prototype.

  • Open bedrock.config.js
  • Add the following “languages” configuration (change accordingly to which language you want to support)
languages: [{
    id: "langEn",
    label: "English",
    default: true
  },{
    id: "langFr",
    label: "Français"
  }]

Them in your pug templates, you can specify multiple string for each languages, see form-example.pug:

if error
        p(style="color: red") 
            span(data-lang="langEn") Hey! Some fields were marked as invalid.
            span(data-lang="langFr") Oups! Certain champs sont invalides.

    p
        label
            span(data-lang="langEn") First Name
            span(data-lang="langFr") Nom
        input(type="text")
    p
        label
            span(data-lang="langEn") Last Name
            span(data-lang="langFr") Prénom
        input(type="text")
    p
        label
            span(data-lang="langEn") Message
            span(data-lang="langFr") Message
        textarea

That’s it, you need to re-start Bedrock in order to have the config file reloaded, and you should see a language selector in the sidebar (trigger the sidebar with CTRL + M), your language selection will be persisted.