Skip to content

Conversation

@driusan
Copy link
Collaborator

@driusan driusan commented Apr 14, 2025

This builds on #9747 to add support for translating the "My Tasks" widgets on the LORIS dashboard. In the current code, an "s" is hardcoded to be added when count > 1, which doesn't work for other languages.

The signature had to be updated to include a singular and plural label, as well as the text domain that the labels come from, since they come from the module providing the widget and not the dashboard. (The dngettext call also could not be done in the module, because the module doesn't have the count to know if it's plural.)

@driusan driusan added Category: Feature PR or issue that aims to introduce a new feature Language: PHP PR or issue that update PHP code Difficulty: Simple PR or issue that should be easy to implement, review, or test Module: issue_tracker PR or issue related to issue tracker module Module: conflict_resolver PR or issue related to conflict_resolver module Module: dashboard PR or issue related to dashboard module Module: imaging_browser PR or issue related to imaging_browser module Module: instruments PR or issue related to instruments module Module: mri_violations PR or issue related to mri_violations module Module: user_accounts PR or issue related to the user_accounts module Multilingual Any tasks related to making LORIS multilingual State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed labels Apr 14, 2025
msgstr "問題トラッカー"


# Google Translate is giving me completely different translations for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is your answer

No, not all languages have a clear and consistent distinction between singular and plural forms. While many languages, like English, have distinct singular and plural forms for nouns, some languages, such as Japanese and Chinese, rely on context to indicate whether a noun refers to one or multiple entities. 

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's the source of my confusion. It should be the same and "問題" is, but the machine translation of the "Your assigned" part is completely different based on if "issues" is singular or plural in the original English.

*/
public function __construct(
\User $user,
string $labeldomain,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither @ridz1208 nor I like this. One proposed change is passing something like:

class TranslatableString {
     function __construct(public readonly string $singular, public readonly string $plural, public readonly string  $textdomain) {}
    public function getPlural(int $n) : string { return dngettext($this->textdomain, $this->singular, $this->plural, $n); }
    public function __toString() : string { return dgettext($this->textdomain, $this->singular); }
}

instead of many parameters.

This updates the "My Tasks" to handle plurals with gettext,
rather than hardcoding adding an "s" in the code. Translations
are added for existing "My Tasks" widgets at the same time.
@racostas racostas self-assigned this Aug 25, 2025
@driusan driusan removed the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Aug 26, 2025
Copy link
Contributor

@racostas racostas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
image

@racostas racostas added the Passed manual tests PR has been successfully tested by at least one peer label Aug 27, 2025
@driusan driusan merged commit b019aca into aces:main Aug 27, 2025
20 checks passed
SKADE2303 pushed a commit to SKADE2303/Loris that referenced this pull request Sep 5, 2025
This builds on aces#9747 to add support for translating the "My Tasks"
widgets on the LORIS dashboard. In the current code, an "s" is hardcoded
to be added when count > 1, which doesn't work for other languages.

The signature had to be updated to include a singular and plural label,
as well as the text domain that the labels come from, since they come
from the module providing the widget and not the dashboard. (The
dngettext call also could not be done in the module, because the module
doesn't have the count to know if it's plural.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Feature PR or issue that aims to introduce a new feature Difficulty: Simple PR or issue that should be easy to implement, review, or test Language: PHP PR or issue that update PHP code Module: conflict_resolver PR or issue related to conflict_resolver module Module: dashboard PR or issue related to dashboard module Module: imaging_browser PR or issue related to imaging_browser module Module: instruments PR or issue related to instruments module Module: issue_tracker PR or issue related to issue tracker module Module: mri_violations PR or issue related to mri_violations module Module: user_accounts PR or issue related to the user_accounts module Multilingual Any tasks related to making LORIS multilingual Passed manual tests PR has been successfully tested by at least one peer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants