Skip to content
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

i18n: Translation does not work with multiple placeholders #49756

Open
rakekniven opened this issue Dec 10, 2024 · 3 comments · May be fixed by #49852
Open

i18n: Translation does not work with multiple placeholders #49756

rakekniven opened this issue Dec 10, 2024 · 3 comments · May be fixed by #49852
Assignees
Labels

Comments

@rakekniven
Copy link
Member

rakekniven commented Dec 10, 2024

Code:

// TRANSLATORS
// Indicates when a calendar event will happen, shown on invitation emails
// Output produced in order:
// In a day/week/month/year on July 1, 2024
// In a day/week/month/year on July 1, 2024 then on July 3, 2024
// In a day/week/month/year on July 1, 2024 then on July 3, 2024 and July 5, 2024
// In 2 days/weeks/months/years on July 1, 2024
// In 2 days/weeks/months/years on July 1, 2024 then on July 3, 2024
// In 2 days/weeks/months/years on July 1, 2024 then on July 3, 2024 and July 5, 2024
return match ([($occurrenceIn[0] > 1), !empty($occurrence2), !empty($occurrence3)]) {
[false, false, false] => $this->l10n->t('In a %1$s on %2$s', [$occurrenceIn[1], $occurrence]),
[false, true, false] => $this->l10n->t('In a %1$s on %2$s then on %3$s', [$occurrenceIn[1], $occurrence, $occurrence2]),
[false, true, true] => $this->l10n->t('In a %1$s on %2$s then on %3$s and %4$s', [$occurrenceIn[1], $occurrence, $occurrence2, $occurrence3]),
[true, false, false] => $this->l10n->t('In %1$s %2$s on %3$s', [$occurrenceIn[0], $occurrenceIn[1], $occurrence]),
[true, true, false] => $this->l10n->t('In %1$s %2$s on %3$s then on %4$s', [$occurrenceIn[0], $occurrenceIn[1], $occurrence, $occurrence2]),
[true, true, true] => $this->l10n->t('In %1$s %2$s on %3$s then on %4$s and %5$s', [$occurrenceIn[0], $occurrenceIn[1], $occurrence, $occurrence2, $occurrence3]),
default => $this->l10n->t('Could not generate next recurrence statement')

Example:

Image

[true, false, false] => $this->l10n->t('In %1$s %2$s on %3$s', [$occurrenceIn[0], $occurrenceIn[1], $occurrence]),

%2$s need to be converted to text like days, hours
'In %1$s hours on %3$s'
'In %1$s days on %3$s'
same for singular.

@rakekniven
Copy link
Member Author

@SebastianKrupinski Your image shows "In 19 Hours". Where does hour come from. The comment for translators does not mention hours?

@SebastianKrupinski
Copy link
Contributor

Thank you for confirming! I will make the changes

@SebastianKrupinski
Copy link
Contributor

SebastianKrupinski commented Dec 13, 2024

Your image shows "In 19 Hours". Where does hour come from.

I just forgot to mention hours in the comments, the options are past/minutes/hours/days/weeks/months/years

I've made changes, using a plurals function now and included the time interval in the phrase.

Fix #49852

@ChristophWurst ChristophWurst added 3. to review Waiting for reviews and removed 1. to develop Accepted and waiting to be taken care of labels Dec 16, 2024
@ChristophWurst ChristophWurst moved this to 🏗️ In progress in 💌 📅 👥 Groupware team Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗️ In progress
Development

Successfully merging a pull request may close this issue.

4 participants