Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-227: Adding translation documentation. #242

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/links/transifex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import link

link_name = "Transifex"
link_text = "Transifex"
link_url = "https://www.transifex.com/mautic/mautic/"

link.xref_links.update({link_name: (link_text, link_url)})
7 changes: 7 additions & 0 deletions docs/links/transifex_documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import link

link_name = "transifex-documentation"
link_text = "Transifex Documentation"
link_url = "http://docs.transifex.com/tutorials/txeditor/"

link.xref_links.update({link_name: (link_text, link_url)})
7 changes: 7 additions & 0 deletions docs/links/transifex_language_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import link

link_name = "transifex-language-list"
link_text = "list of languages"
link_url = "https://www.transifex.com/mautic/mautic/"

link.xref_links.update({link_name: (link_text, link_url)})
Binary file added docs/translations/images/translations-banana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 113 additions & 1 deletion docs/translations/translations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,116 @@
Translation
###########

.. vale on
.. vale on

Being an international project with a world-wide community, many translations for Mautic exist. If you can't find your language yet, take a look to the section about how to :ref:`How to translate Mautic`.

How to select a language in Mautic
**********************************

There are two places to select the language for the User Interface.

Default language
================

The default language configuration happens first in the Mautic configuration. The default language is ``English - United States``. Every User has this language if they don't set something different in their profile.

1. Open the configuration menu by clicking on the cog icon in the top right corner.
2. Select the **Configuration** menu item.
3. Select the default language.
4. Save the configuration.

.. image:: images/translations-select-language.png
:width: 600
:alt: Select the default language

.. vale off
User language
=============

.. vale on

A User can define their preferred language and override the default language. This allows a multilingual team work on the same Mautic instance.

1. Open the User Account menu by clicking on the User's name in the top right corner.
2. Click on **Account** menu item.
3. Select the User language.
4. Save the User profile.

.. image:: images/translations-select-user-language.png
:width: 600
:alt: Select the user language

Check warning on line 44 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'User' instead of 'user'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'User' instead of 'user'.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 44, "column": 22}}}, "severity": "INFO"}

How to translate Mautic
***********************

It's possible to translate Mautic into any language. As Mautic is a community project, any community member can suggest and translate Mautic into any language. Mautic uses :xref:`Transifex` to crowd source translations.

1. Create an account at :xref:`Transifex` if you don't have one already.
2. Take a look at the :xref:`transifex-language-list` already existing.

Check failure on line 52 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'Transifex' instead of 'transifex'. Raw Output: {"message": "[Vale.Terms] Use 'Transifex' instead of 'transifex'.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 52, "column": 30}}}, "severity": "ERROR"}
3. Create a language if your language is missing, or apply for an existing language.

Take a look at official :xref:`transifex-documentation` if you have any questions about the translation process.

Check failure on line 55 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'Transifex' instead of 'transifex'. Raw Output: {"message": "[Vale.Terms] Use 'Transifex' instead of 'transifex'.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 55, "column": 32}}}, "severity": "ERROR"}

How to update a language
************************

Mautic downloads language updates automatically when saving Mautic's Configuration, if language isn't already downloaded. To force an update of a language:

1. Open the Mautic file system via SFTP or SSH.

Check warning on line 62 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Acronyms] Spell out 'SFTP', if it's unfamiliar to the audience. Raw Output: {"message": "[Google.Acronyms] Spell out 'SFTP', if it's unfamiliar to the audience.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 62, "column": 36}}}, "severity": "INFO"}
2. In the Mautic root folder you should see the folder called **translations**. Open it.
3. In the **translations** folder are the languages available in Mautic. Remove the folder of the language you want to update.
4. Go to the Mautic Configuration and save it with the language you've deleted selected.

Mautic downloads the language again, with the latest translations. There is a daily process which generates the language packs from Transifex.

If you have any questions about translations, join the :xref:`Mautic Community Slack`.

Translation overrides
*********************

Mautic allows you to override the existing language translations without the need to hack the core files. That's a good idea, especially because a Mautic upgrade would remove your modifications. Here's how to change translations correctly:

As an example, to override the first menu item "Dashboard" and change it to "Banana" follow these steps:

.. image:: images/translations-dashboard.png
:width: 600
:alt: Override Dashboard menu item

Search for the translation key
==============================

The best way to search for the right translation key is in a text editor like VS Code that allows you to search for a text in all files of Mautic's source code and filter those files by file extension ``*.ini``.

GitHub has also an option to search for strings in the repository - it's not particularly good search engine but for this example it works well enough.

Try searching for 'Dashboard menu' within the Mautic/Mautic repository, as there is special translation for the menu item and another for the page title. GitHub won't find the right translation when you search for just 'Dashboard' - it requires the full string. Next, use the filter to show only INI files. Here is the link to the search result:

Check warning on line 89 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Landing Page' instead of 'page'. Raw Output: {"message": "[Mautic.FeatureList] Is this referring to a Mautic feature? If so, use 'Landing Page' instead of 'page'.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 89, "column": 143}}}, "severity": "INFO"}

Check warning on line 89 in docs/translations/translations.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Acronyms] Spell out 'INI', if it's unfamiliar to the audience. Raw Output: {"message": "[Google.Acronyms] Spell out 'INI', if it's unfamiliar to the audience.", "location": {"path": "docs/translations/translations.rst", "range": {"start": {"line": 89, "column": 297}}}, "severity": "INFO"}

`https://github.com/mautic/mautic/search?l=INI&q=Dashboard+menu <https://github.com/mautic/mautic/search?l=INI&q=Dashboard+menu>`_

The first file found is ``app/bundles/DashboardBundle/Translations/en_US/messages.ini`` and there is the line ``mautic.dashboard.menu.index="Dashboard"`` within the file, which is text to override.

.. vale off
Override the translation
========================

.. vale on

The string to override is ``mautic.dashboard.menu.index``.

To create the override:

1. Go to the folder ``translations`` in the root directory of the Mautic project
2. Create new folder in it called ``overrides``
3. In this folder, create the folder for the locale to override. In this example, the default locale is in use - ``en_US`` - but if you use different language then you'll see its locale as a folder in the ``translations`` folder - create a folder within the overrides folder using the exact name of the locale.
4. In the ``translations/overrides/en_US`` folder - replace en_US with the locale you are overriding - create new file called ``messages.ini``. Notice it's the same filename as the original. It must be exactly the same. Some translations may be in ``flashes.ini`` or ``validators.ini`` and if you override a translation from those files then you have to create the correct file too, and add the translation strings to be overridden in the file.

In this file, copy the line to override from the original ``app/bundles/DashboardBundle/Translations/en_US/messages.ini`` file and change the translation like so:

``mautic.dashboard.menu.index="Banana"``

Save the file and clear the cache with ``bin/console cache:clear`` command. Refresh your Mautic instance, and the administration is finally perfect:

.. image:: images/translations-banana.png
:width: 600
:alt: Dashboard menu item overridden to Banana
Loading