Localization of Elm app

I think the best solution depends on the size of your company, who does the writing/translation, and how many languages you want to support. We will only ever need to support 2 languages, so I think we’ll go with compile-time translations like @gampleman, but just write them directly as Elm files.

I’m thinking of having two folders like:

  • Swedish
    • Common.elm
    • Salaryfiles.elm
  • English
    • Common.elm
    • Salaryfiles.elm

And then the build script would rename one of the folders to Text and build, and then rename the other one to Text and build. If the languages don’t match, you’ll get an error at build time.
For development you could have a symlink like Text -> Swedish

Btw, all phrases wouldn’t need to be simple strings either, you could have functions like:

pluralFruit : Int -> Fruit -> String
pluralFruit count frut =
  case fruit of
    Banana ->
      String.fromInt count ++ " banan" ++ (if count == 1 then "" else "er")

Like string templates but type safe :slightly_smiling_face:

1 Like