Skip to content

Adding a new language

Michael Saugstad edited this page May 11, 2023 · 2 revisions

Below are the steps that we should go through when adding new languages to the Project Sidewalk website. At the time of this writing, we have English ('en', 'en-US', and 'en-NZ'), Spanish ('es'), Dutch ('nl'), and we just added Mandarin ('zh').

  1. Ask for translations for everything that we already have translated in other languages by giving them conf/messages.en and public/locales/en/*.json and then adding the newly translated files that we get from them in our repo. Some helpful tips:
    1. Let them know to not edit the keys. Especially important for partners that aren't especially technically savvy.
    2. If they are only providing regional variations, like when we added 'en-NZ' when we already had 'en', then it might be best to ask them to delete any lines that they aren't changing.
  2. Add the new locale to the list of supported languages in conf/application.conf.
  3. Add the piece of the moment.js library for the new locale (and maybe grab the newest version of moment.js while you're at it). We are adding each locale individually to keep the overall size of the package small. Add the appropriate import to main.scala.html. There is a Github issue that suggests moving on to a different library for this purpose: #1258. But I wouldn't recommend doing that as part of this process if we care about speed at all :)
  4. Check the unit-distance translation in public/locales/*/common.js. It should probably be changed to "kilometers" since that shouldn't actually be translated. It's just used by the front end to know which type of units to input to the turf.js library, and should be passed through in English.
  5. Check each of our main pages that have translations to make sure that everything looks okay. Typically I'll match up the English version to the new version in adjacent tabs, and flip between them quickly with keyboard shortcuts to compare. This can reveal spacing issues that arise from different lengths of text. Make sure to test out adding a label of each label type on Explore, and opening sub-menus on various pages to check for issues.
  6. Make a PR and push these changes to the test servers. We'll want our partners that are asking for these translations to use as many aspects of the website as they can to check for errors!