Skip to content

How to customize translations

Pau Pérez Fabregat edited this page Jun 22, 2020 · 2 revisions

At Donalo we have adopted a good-enough mechanism to override some of the translations Sharetribe provides. Donalo's business model differs a bit from the traditional marketplace and it needs to change the meaning of some copies. So that's something that can't be done in the Spanish or Catalan Sharetribe translations and needs to be for Donalo only.

This approach relies on Sharetribe's community translations feature where each community can have its own custom translations. That fits Donalo because it is itself a community in a Sharetribe installation. We just provided the means to make it a bit easier for non-devs to manage these overrides through a rake task included in Donalo's Rails engine, https://github.com/coopdevs/sharetribe/tree/master/engines/donalo.

More details in the pull request that introduced the feature: https://github.com/coopdevs/sharetribe/pull/39. Additionally, you can check the whole investigation and team discussion in its Trello card. Note that this requires access to Coopdevs' Trello boards.

Adding a custom translation

To do that, first, create a new git branch off master (ask a dev if you're not confident enough).

Then, you need to add a call to the #translate method specifying the locale the translation belongs to, its key in the corresponding locale file and the custom translation that you want instead in engines/donalo/lib/tasks/donalo_tasks.rake. You need to then open a pull request so that it gets reviewed by a developer, as done in https://github.com/coopdevs/sharetribe/pull/50.

With such a long locale file, it's not always easy to find the complete key the identifies a translation. For that, https://yaml.now.sh/ is a little web tool that comes in handy.

Deleting a custom translation

Deleting a translation is just a matter of doing the reverse of what's described above. Create a new branch from master and delete the specific translation you don't longer want. Then, open the pull request and wait for a dev to take it over from here.

Clone this wiki locally