Skip to content

fix(l10n): Use positional placeholders in strings with multiple %s - #647

Open
rakekniven wants to merge 1 commit into
nextcloud:masterfrom
rakekniven:fix/l10n-positional-placeholders
Open

rakekniven wants to merge 1 commit into
nextcloud:masterfrom
rakekniven:fix/l10n-positional-placeholders

Conversation

@rakekniven

Copy link
Copy Markdown
Member

Summary

Translatable strings that contain more than one plain %s fix the order of the inserted values: the first %s always gets the first value. Languages with a different word order cannot move them, so translators either have to bend the sentence or end up with values in the wrong place.

This PR replaces the plain %s with numbered placeholders in the two affected email texts in lib/Services/Request.php:

Before After
The user %s, identified by user id "%s", has requested an export of their personal data. Please take action accordingly. The user %1$s, identified by user id "%2$s", has requested an export of their personal data. Please take action accordingly.
The user %s, identified by user id "%s", has requested to delete their account. Please take action accordingly. The user %1$s, identified by user id "%2$s", has requested to delete their account. Please take action accordingly.

IL10N::t() formats with vsprintf(), which renders %1$s %2$s exactly like %s %s, so the English output does not change. Only the placeholders change; the wording stays the same.

Effect on translations: the source strings change, so Transifex treats them as new. Translation memory should offer the old translations as close matches, but translators have to accept them and add the numbered placeholders.

Tests: no test refers to these strings.

Related: the same change for other apps in nextcloud/server#67609, nextcloud/calendar#9337, nextcloud/circles#3204, nextcloud/deck#8843, nextcloud/passman#896 and nextcloud/app_api#1237.

AI

The content of this PR was partly generated using AI.

🤖 Generated with Claude Code

Strings with more than one plain %s force translators to keep the
English order of the values. Numbered placeholders (%1$s, %2$s) let
them reorder the values where their language needs it. IL10N::t()
formats with vsprintf(), which renders both forms identically, so the
output does not change.

Signed-off-by: rakekniven <2069590+rakekniven@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant