@@ -19,8 +19,8 @@ Available translations
1919
2020The following languages are currently included in the botogram package:
2121
22- * ``en `` (English)
23- * ``it `` (Italian)
22+ * ``en `` (English)
23+ * ``it `` (Italian)
2424
2525.. _i18n-setting-language :
2626
@@ -45,6 +45,33 @@ After doing this, the bot will start using the translated messages included in
4545the package. If a message hasn't been translated to the selected language, the
4646bot will fall back on the English default.
4747
48+ .. _i18n-overriding :
49+
50+ Overriding default messages
51+ ===========================
52+
53+ .. versionadded :: 0.5
54+
55+ As described in :ref: `i18n-new-language `, new and updated translations'
56+ availability is limited to new botogram releases, meaning that it could take
57+ some time for them to reach end users.
58+
59+ Packaged translations may also not always fit a specific use case, making it
60+ necessary for you to edit some of the messages. While you could use a custom
61+ build of the package with a modified translation, it is also possible to
62+ programmatically override the translation of single messages through
63+ :py:attr: `botogram.Bot.override_i18n `, a dictionary that works basically the
64+ same way as a ``.po `` file, associating ``msgid ``'s to ``msgstr ``'s:
65+
66+ .. code-block :: python
67+
68+ bot.override_i18n = {
69+ " Use /help to get a list of all the commands." : \
70+ " Utilizza /help per ottenere la lista di tutti i comandi."
71+ }
72+
73+ We'll go more in depth on the translation format in the next section.
74+
4875.. _i18n-new-language :
4976
5077Translating botogram to a new language
@@ -133,7 +160,7 @@ As botogram evolves, more message will probably be added to the codebase, and it
133160is also possible for currently included translations to contain mistakes.
134161
135162The workflow for updating a translation is basically the same as the one
136- described in `i18n-new-language `_ , but you may also need to use ::
163+ described in :ref: `i18n-new-language `, but you may also need to use ::
137164
138165 $ invoke i18n-extract
139166
@@ -148,30 +175,6 @@ actual translation and the source code references in comments.
148175While trivial, it would be nice if you also changed the ``PO-Revision-Date ``
149176header to reflect your changes.
150177
151- .. _i18n-overriding :
152-
153- Overriding default messages
154- ===========================
155-
156- .. versionadded :: 0.5
157-
158- Translating botogram to a new language is a non-trivial process and its effects
159- are only available once a new version has been released. To avoid needing to
160- use a custom build of the package in order to use your new translation, you can
161- programmatically override botogram's messages while you wait for the next
162- release.
163-
164- This is possible through :py:attr: `botogram.Bot.override_i18n `, a dictionary
165- that works basically the same way as a ``.po `` file, associating ``msgid ``'s to
166- ``msgstr ``'s:
167-
168- .. code-block :: python
169-
170- bot.override_i18n = {
171- " Use /help to get a list of all the commands." : \
172- " Utilizza /help per ottenere la lista di tutti i comandi."
173- }
174-
175178
176179.. _`GNU gettext` : https://www.gnu.org/software/gettext/
177180
0 commit comments