0

I have installed a Drupal 8.5 site in French (monolingual). Then, I added content.

Of course, there are many strings in the PHP files of my custom theme/module I pass to t(). There are also many strings in the Twig files I translated with {{ 'a string'|trans }}.

After a while, I added English.

Unfortunately, I discovered that all the strings (interface) I just mentioned are seen by Drupal as English string. As commented by @Berdir: ALL THE STRINGS IN THOSE FILES MUST BE IN ENGLISH.

The only thing that Drupal brings on the table (according to the @Berdir comment) for this situation is a checkbox/option in /admin/config/regional/language/edit/en that allow to translate MANUALLY in the UI the Original strings (French strings, but seen as English) into English.

According to the same comment, the Translation template extractor module and the Translation Management Tool module doesn't handle this option /admin/config/regional/language/edit/en

To summarize: Drupal 8 can't handle a multilingual site with original strings other than English (Except is you search all the strings manually in the UI, which is not doable if there are a lot of strings)

Thus, I assume that to handle this, we need some extra tools that I don't know about.

Process Idea :

1- A tool will extract all the French strings coming from my php/twig files (into a PO file?)

2- After the translation, this tool (or another one) will replace the French strings in my php/twig file by the corresponding English Strings

3- I will replace my "old" php/twig files with the newly created (with English string inside)

4- I assume that some tool exist to swap the language of the PO file created by step 1 (FR=>EN to EN=>FR)

5- I assume I can import the swapped PO file into my Site to translate it into French

I have 2 questions:

A-Is it the best process? If not, do you have a better idea?

B-If it is the best process, do you know the tool(s) that can handle this?

  • You add your string in the t() function like t('Bonjour')? – Adrian Cid Almaguer Apr 5 '18 at 14:53
1

How do I tell Drupal that all my strings (PHP and Twig) are French strings?

You can not. There is no setting for that, the source code must be english.

Drupal does allow to translate the code/system-english to the actual english if you enable the checkbox when editing the english language. I don't know what that does exactly to potx and I don't think TMGMT supports it either.

  • Many thanks... but this is a really bad news! What would be the best process to translate my French site into English? You can link me to any resource. – Baud Apr 3 '18 at 21:15
  • As I said, the only thing that comes to mind is that you enable the checkbox on /admin/config/regional/language/edit/en, then you can manually translate it in the UI, but I don't know if/how you can export or use TMGMT. – Berdir Apr 4 '18 at 7:10
  • Thank you. I have adapted my question to reflect what you said. In the mean time, I will check if POTX and or TMGMT can handle this process. – Baud Apr 4 '18 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.