- Posts: 30
Solved How to translate a module ?
- Halloy
- Topic Author
- Offline
- New Member
I searched for information on the translation of untranslated modules, but I could not find anything that matches what I was looking for.
Thanks a lot !
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- Franz Frese
- Offline
- Elite Member
there is nothing to translate beside the default weblate.
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
Please Log in or Create an account to join the conversation.
- Franz Frese
- Offline
- Elite Member
Ask the modules author using github's issues part.
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
If not, I'll contact the dev.
Thanks a lot !
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
You can create your own module that supplies the translations.
Here is a template/example module that shows how to add translations.
Find the "translatable" text from the original module. e.g.
I18N::translate('Manage favorites based on current page.');
In your module, you can add a translation for 'Manage favorites based on current page.'
BUT - it might be easier to provide the translations to the module author and let him add them.
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- Franz Frese
- Offline
- Elite Member
There it seems that all output is done with the I18 calling.
So the way for translations is easy, and as Greg did say.
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
Question 1 : is it possible to add only the public function customtranslation in the module.php file of the original module with each string I wish to translate ?
Question 2 : if yes, perhaps it's possible to create a .po file and the corresponding .mo file using case 'some-other-language':
// Arrays are preferred, and are faster.
// If your module uses .MO files, then you can convert them to arrays like this.
return (new Translation('path/to/file.mo'))->asArray();
If yes, what is necessary to create the .po file (I have PoEdit, I know create a .mo file from a .po but I never created a .po)
Thanks a lot
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
You create a .POT file by using a tool XGETTEXT to scan the software.
Just use PHP arrays, like in the example.
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
But ... module.php doesn't content strings to translate for the module settings. They are in favorites.phtml file wich is in resources > views.
PoEdit created a .po file from this file, I added translations and created the .mo file. Now I don't know what I have to do with them. Add the content of the. mo in the first then compile everything to have only one file but will the phtml find it? Or create a new lang directory in views but I don't believe it's possible to add a public function in a phtml file ...
Thanks for your advice
Please Log in or Create an account to join the conversation.
- Halloy
- Topic Author
- Offline
- New Member
- Posts: 30
It's really not complicated
Please Log in or Create an account to join the conversation.