Skip to content

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

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

rakekniven wants to merge 1 commit into
nextcloud:mainfrom
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 affected string:

File Before After
templates/usersettings.php Could not contact the wiki at %s. Please try again later, or ask for help to its administrator. The error was: %s Could not contact the wiki at %1$s. Please try again later, or ask for help to its administrator. The error was: %2$s

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. I did not run the tests locally.

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

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