-
Notifications
You must be signed in to change notification settings - Fork 25
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').
- Ask for translations for everything that we already have translated in other languages by giving them
conf/messages.en
andpublic/locales/en/*.json
and then adding the newly translated files that we get from them in our repo. Some helpful tips:- Let them know to not edit the keys. Especially important for partners that aren't especially technically savvy.
- 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.
- Add the new locale to the list of supported languages in
conf/application.conf
. - 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 :) - Check the
unit-distance
translation inpublic/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. - 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.
- 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!