Web based family history software

Solved How to translate a module ?

  • Halloy
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 20 hours ago - 1 week 4 days ago #1 by Halloy
How to translate a module ? was created by Halloy
Hi, I installed the addon favorites-menu to display and add favorites easier. But this module has no .po or .mo file to translate it<. How can I do it ? By adding text to translate in webtrees/resources/lang/fr/messages.php ? or by creating a "lang" directory in "resources' in this module repertory ?
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 !
Last edit: 1 week 4 days ago by Halloy.

Please Log in or Create an account to join the conversation.

More
2 weeks 19 hours ago #2 by fisharebest
Replied by fisharebest on topic How to translate a module ?
Is this a module that you wrote - or are you adding translations to somebody else's module?

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

More
2 weeks 19 hours ago #3 by Franz Frese
Replied by Franz Frese on topic How to translate a module ?
Favourites is a block of the home page.
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
  • New Member
More
2 weeks 19 hours ago #4 by Halloy
Replied by Halloy on topic How to translate a module ?
Thanks for your attention. I was talking about an add-on, not the block. github.com/bwong789/webtrees-favorites-menu

Please Log in or Create an account to join the conversation.

More
2 weeks 18 hours ago #5 by Franz Frese
Replied by Franz Frese on topic How to translate a module ?
That module is not yet designed for translation (as you have seen).
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
  • New Member
More
2 weeks 18 hours ago #6 by Halloy
Replied by Halloy on topic How to translate a module ?
Thanks for your reply. I thought it might be possible to create the necessary files myself or maybe add the sentences to translate in the basic file of translations (/webtrees/resources/lang/fr/messages.php) because they are written in this way : I18N::translate('Make any changes and then click').
If not, I'll contact the dev.

Thanks a lot !

Please Log in or Create an account to join the conversation.

More
2 weeks 18 hours ago #7 by fisharebest
Replied by fisharebest on topic How to translate a module ?
Yes you can do this.

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.

More
2 weeks 16 hours ago - 2 weeks 16 hours ago #8 by Franz Frese
Replied by Franz Frese on topic How to translate a module ?
Sorry, I did not take a look into the code. (In module.php)
There it seems that all output is done with the I18 calling.

So the way for translations is easy, and as Greg did say.
Last edit: 2 weeks 16 hours ago by Franz Frese.

Please Log in or Create an account to join the conversation.

  • Halloy
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 15 hours ago #9 by Halloy
Replied by Halloy on topic How to translate a module ?
Thanks a lot, but ... where can I find the template/example what you're talking about ?

Please Log in or Create an account to join the conversation.

More
2 weeks 14 hours ago #10 by fisharebest
Replied by fisharebest on topic How to translate a module ?
github.com/webtrees/example-module

Sorry, I though I included the link

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
  • New Member
More
1 week 6 days ago #11 by Halloy
Replied by Halloy on topic How to translate a module ?
A great thanks !
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.

More
1 week 6 days ago #12 by fisharebest
Replied by fisharebest on topic How to translate a module ?
You create a .PO file from a .POT file.

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
  • New Member
More
1 week 6 days ago #13 by Halloy
Replied by Halloy on topic How to translate a module ?
Super ! I created the .po file from module.php with PoEdit, the .mo is compilated, I added the public function in module.php and a lang directory in resources with both files and it works fine !
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
  • New Member
More
1 week 4 days ago #14 by Halloy
Replied by Halloy on topic How to translate a module ?
It's ok, I opened a .po file of an other module wich contained translations of .php and .phtml. Thus I copied content of the second .po file created with PoEdit and containing the phtml translations, and copied it in the first po file. After compiling in a mo file, strings of settings are well translated.
It's really not complicated :-)

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum