Question
Error in the order that custom module functions are called
- sevtor
-
Topic Author
- Offline
- New Member
-
Less
More
11 months 4 weeks ago #1
by sevtor
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Error in the order that custom module functions are called was created by sevtor
When adding new custom modules the module structure includes a file module.php which can contain different functions.
For report modules it is important to include translation files for supported languages. The translations are included by the definition of a function customTranslations($lang) which shall return an array of translations.
However, these translations are activated when the report is generated (good, expected) but not when the report was selected. The effect can be seen in the included image Rapporter-orig.png. My proposed solution is to add translations from custom modules already in the file app/Module/ModuleCustomTrait.php as can be seen in the included patch file. After this change clicking on the Reports menu item will yield a menu with translated options.
(This patch is also included in PR#4945)
For report modules it is important to include translation files for supported languages. The translations are included by the definition of a function customTranslations($lang) which shall return an array of translations.
However, these translations are activated when the report is generated (good, expected) but not when the report was selected. The effect can be seen in the included image Rapporter-orig.png. My proposed solution is to add translations from custom modules already in the file app/Module/ModuleCustomTrait.php as can be seen in the included patch file. After this change clicking on the Reports menu item will yield a menu with translated options.
(This patch is also included in PR#4945)
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Elite Member
-
11 months 4 weeks ago #2
by Franz Frese
Replied by Franz Frese on topic Error in the order that custom module functions are called
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
11 months 4 weeks ago #3
by sevtor
But I have own report modules installed under module_v4/ and that is when the error occurs as you can see on my images!
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Replied by sevtor on topic Error in the order that custom module functions are called
This is because you only have standard report modules that are installed in webtrees/resources/xml/reports.I do not think so. When language is changed, also the menu texts are changed.
But I have own report modules installed under module_v4/ and that is when the error occurs as you can see on my images!
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Elite Member
-
11 months 4 weeks ago #4
by Franz Frese
Replied by Franz Frese on topic Error in the order that custom module functions are called
may be it is related to the discussion at
github.com/fisharebest/webtrees/issues/3783
.
Seems as if you have to insert your own menu at this time, like vesta does (for example at www.onsverleden.eu/webtrees/tree/bijlholt# (more charts)
Seems as if you have to insert your own menu at this time, like vesta does (for example at www.onsverleden.eu/webtrees/tree/bijlholt# (more charts)
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Elite Member
-
11 months 4 weeks ago - 11 months 4 weeks ago #5
by Franz Frese
Perhaps Greg can tell the best way, how to do?
I did a close look at your changes and I think there is no need to change the default ModuleCustomTrait.php .
If you use your code of
public function customTranslations(string $language): array
in your custom modules the translation of the webtrees menu is also done correct and in time.
I did a little test within a module of me. I changed the menu text 'Changes' occuring within the repports submenu by the german 'Änderungen'. See the result:
Replied by Franz Frese on topic Error in the order that custom module functions are called
I did a close look at your changes and I think there is no need to change the default ModuleCustomTrait.php .
If you use your code of
public function customTranslations(string $language): array
in your custom modules the translation of the webtrees menu is also done correct and in time.
I did a little test within a module of me. I changed the menu text 'Changes' occuring within the repports submenu by the german 'Änderungen'. See the result:
Last edit: 11 months 4 weeks ago by Franz Frese.
Please Log in or Create an account to join the conversation.
- Jefferson49
-
- Offline
- Senior Member
-
Less
More
- Posts: 291
11 months 4 weeks ago #6
by Jefferson49
Replied by Jefferson49 on topic Error in the order that custom module functions are called
Has this issue already been solved? If I load the latest code from
github.com/sevtor/modules
, all the report menu entries are translated correctly.
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Elite Member
-
11 months 4 weeks ago - 11 months 4 weeks ago #7
by Franz Frese
I see Sevtor has already changed code. A change of the app/Module/ModuleCustomTrait.php is no longer necessary. The file can be removed from the pullrequest #4945.
Replied by Franz Frese on topic Error in the order that custom module functions are called
It is not a matter of correct translation. My concern is flawless integration into webtrees. The less code Greg has to check, the more likely is the integration.Has this issue already been solved? If I load the latest code from github.com/sevtor/modules , all the report menu entries are translated correctly.
I see Sevtor has already changed code. A change of the app/Module/ModuleCustomTrait.php is no longer necessary. The file can be removed from the pullrequest #4945.
Last edit: 11 months 4 weeks ago by Franz Frese.
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
11 months 3 weeks ago #8
by sevtor
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Replied by sevtor on topic Error in the order that custom module functions are called
I am really embarrassed about this matter!
In my test environment I used symbolic links for some files and because of that the reported effect occurred. When I changed to use real files there are no problems.
I will remove the file ModuleCustomTrait.php from PR #4945 !!
In my test environment I used symbolic links for some files and because of that the reported effect occurred. When I changed to use real files there are no problems.
I will remove the file ModuleCustomTrait.php from PR #4945 !!
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.