Leeps-Lab/random_number_game

Add translation system for Cyrillic

Closed this issue · 0 comments

The front-end requires a Mongolian translation. Mongoljin mentioned he could handle it to us, so it would be really helpful to start with that asap for the experiment. Django has a system for doing that.

  • Each HTML template requires this at the beginning: {% load i18n %}
  • Each text should be between the blocktrans tag, like in this code:
{% extends "global/Page.html" %}
{% load staticfiles otree_tags %}
{% load i18n %}

{% block title %}
{% blocktrans trimmed %}Real Effort Task{% endblocktrans %}
{% endblock %}

{% block content %}

<html>
	<head></head>
	<body>
		<p>{% blocktrans trimmed %}Click the next button to play the game.{% endblocktrans %}</p>
	</body>
</html>
    {% next_button %}
    <p>
    {% include Constants.instructions_button %}
    </p>
{% endblock %}
  • I'm almost sure that the content inside the blocktrans tag doesn't support content with HTML tags like <p>, but it can handle the <br> ones.
  • In order to include variables within a blocktrans block, you can use this syntax:
<p>
    {% blocktrans with ranking_actual=ranking_actual ranking_guess=ranking_guess system_actual=system_actual system_guess=system_guess ranking_guess_payoff=ranking_guess_payoff system_guess_payoff=system_guess_payoff %}

        Your ranking was {{ ranking_actual }} and you guessed that your ranking was {{ ranking_guess }}</br></br>

        Your wealth was determined by {{ system_actual }} and you guessed that your wealth was determined 
        by {{ system_guess }}</br></br>

        Your guess on the performance or luck system yielded you {{ system_guess_payoff }}, and your guess on ranking yielded you {{ ranking_guess_payoff }}

    {% endblocktrans %}
</p> 
  • I'm using almost all the previous pages, but I've one called "ProcessingPage" that doesn't have a Next button. That one is ok, so don't add anything different than its respective translation
  • After finishing adding the tags, follow the instructions of this page: https://docs.djangoproject.com/en/3.1/topics/i18n/translation/, specifically the Localization: how to create language files section in order to create a .po file. It will allow you to add the line by line translation from english to cyrilic. I'm almost sure you have to run the makemessages and compilemessages commands from the project folder.
  • To do the translation, you require that .po file and a program called Poedit https://poedit.net/. Just open the file and everything should be intuitive from that point