Guides

Using Translations

Introduction

Translations are intended to be used for site furniture such as labels that you wish to remain consitent across your donation forms and campaign pages but want to have translations of them for different countries and languages.

You can edit them in the WYSIWYG editor and on the translations section of the administration dashboard.

They can be added in two ways:

  • using the {{ __('Translation') }} method which can be edited in the WYSIWYG Editor
  • using the {{ uneditableTranslation('Uneditable') }} method which cannont be edited in the WYSIWYG Editor

Uneditable translations are ones inside HTML elements that mean they are not displayed on the screen in an editable way. A good example of this is form input placeholders.

WYSIWYG Editor

To ensure translations are editable make sure you use the includeAppJavascript() template function to include edit.js and you include the editing_info template function as per the example below.

Include in your template
{% if editing() %}
<script type="application/javascript">
window.dijon = { editingData: {{ editing_info()|json_encode()|raw }}};
</script>
{% endif %}

translations.json

You should have a file called translations.json in the root directory of your Dijon Platform site which tells Dijon Platform all the translations you are expecting.

Dijon Platform comes with a script that will attempt to automatically populate this file for you. You can run php cli.php translations:finder yoursite replacing "yoursite" with the name of your site to populate the translations.json file automatically from your templates.

Example translations.json
[
  "Make a secure donation",
  "Thank you!",
  "Your contribution goes a long way",
  "Supporter",
  "Give Once",
  "Give Monthly",
  "Donate Now",
  "Other"
]

On this page