-
Notifications
You must be signed in to change notification settings - Fork 28
Translate error messages for end user #601
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
Conversation
The plug-in stores the error message based on the current user language. This PR stores the message on English and translates the message on the client side, so on GLPI instances with multilanguage user, the task log will show the error message based on the current user language instead of the language of the user that the error message has been generated.
This reverts commit 6d9f113.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, strings will never be translated at all, because sources won't be extracted to POT file.
|
@trasher I think so, thanks to this Now the string is translated on demand (depending on the user's language) |
|
@stonebuzz nope. Strings have to exist in source code, and be "marked" as translatable for extraction to work. So this code cans indeed give a translated value, my comment concerns source strings extraction from source code. |
I see, you're right |
|
We should keep the call to gettext (__(‘string to translate’, ‘context’) so that the CI can extract the string and translate it in Transifex. ex : if (
$result['run']['state'] == PluginGlpiinventoryTaskjobstate::SERVER_HAS_SENT_DATA
or $result['run']['state'] == PluginGlpiinventoryTaskjobstate::AGENT_HAS_SENT_DATA
) {
$msg = "The agent is requesting a configuration that has already been sent to him by the server. It is more likely that the agent is subject to a critical error.";
$translatable_msg = __($msg, 'glpiinventory');
$jobstates_to_cancel[$jobstate->fields['id']] = [
'jobstate' => $jobstate,
'reason' => $msg
'code' => $jobstate::IN_ERROR
];
continue;
} |
Nope, this is still wrong :/ String to translate must be in gettext function (gettext extraction will not execute any php code): |
|
I updated this PR following the instructions from @stonebuzz and @trasher. |
|
Tests are failing... :/ |
|
Hello @trasher, now the tests works as expected. |
|
I do not understand the error, and I do not understand the fix neither. Nor why this is breaking now - seems unrelated. As far a we can see, it can have several causes; I'd prefer to be sure understanding the fail. |
|
From what I've seem while testing at #606, it seems that the task ID wasn't being selected correctly and the task status wasn't being updated to success at https://github.com/eduardomozart/glpi-inventory-plugin/blob/a9bd8766d1282804829ccb4747878bbe5d18ee0d/tests/Integration/Tasks/CronTaskTest.php#L701, which also makes the test at https://github.com/eduardomozart/glpi-inventory-plugin/blob/a9bd8766d1282804829ccb4747878bbe5d18ee0d/tests/Integration/Tasks/CronTaskTest.php#L753 fails because the task status wasn't being set as completed. |
|
Oo => #607 no error XD |
|
can you revert last commit about test ? to try |
|
I believe there should be an error on my branch, I'm unable to commit on it using GitHub Desktop, only through GitHub WebUI. As iCloud sync is enabled for Documents folder, I think that while changing branches it get lost. I'll try to revert my last commit. |
|
😄 maybe a problem with Github? |

The plug-in stores the error message based on the current user language. This PR stores the message on English and translates the message on the client side, so on GLPI instances with multilanguage user, the task log will show the error message based on the current user language instead of the language of the user that the error message has been generated.
Before this PR, an Portuguese language user was seeing error messages on English:
After this PR, a Portuguese Language user can see error messages in their native language independent of the language of the user that the error has been generated:
Edit: The only known issue I can think of this PR can cause is that those strings would be removed from the POT file, so I believe it would need a way to keep them there or do a dummy call/register of them into JS/PHP code (maybe a fake/unused property of the same object that I modified into this PR) so they would be gathered by Transiflex bot and wouldn't be missing.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Screenshots (if appropriate):