Skip to content

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

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 two affected strings in lib/SetupChecks/HarpVersionCheck.php:

Before After
HaRP version for daemon "%s" is "%s", which is too old. The minimum required version is "%s". Please update the daemon to the latest version. HaRP version for daemon "%1$s" is "%2$s", which is too old. The minimum required version is "%3$s". Please update the daemon to the latest version.
Failed to check HaRP version for daemon "%s": %s Failed to check HaRP version for daemon "%1$s": %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: tests/php/SetupChecks/HarpVersionCheckTest.php mocks t() with vsprintf() and checks the formatted message, which stays the same. 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 and nextcloud/passman#896.

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>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

The too-old-version and check-failure messages now use positional translation placeholders. Their content, arguments, version-check behavior, and exception logging remain unchanged.

Merge Risk: Low · up to ade1b

English output is unchanged. Non-English users may see these two HaRP warnings in English until the updated translations are shipped, as the PR already notes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: numbered positional placeholders replace plain %s in strings with multiple placeholders, so translators can reorder values. The changeset edits two strings in HarpVers…
Description check Passed The description explains the problem (plain %s forces the first argument into the first slot, which blocks word reordering in translations), lists the before and after strings for both affected messag…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: numbered positional placeholders replace plain %s in strings with multiple placeholders, so translators can reorder values. The changeset edits two strings in HarpVersionCheck.php to use %1$s, %2$s, %3$s, which matches the title. The title uses the fix(l10n) prefix, which is conventional and clear.

Full details: Description check

Explanation

The description explains the problem (plain %s forces the first argument into the first slot, which blocks word reordering in translations), lists the before and after strings for both affected messages, and states that English output is unchanged. It also covers the Transifex impact and the test setup, so it relates directly to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments

Minor 1
  1. Preserve the existing translations for both warnings.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6cea883e-535d-4d36-8f9e-6a686753d89b
Commits

Reviewing files that changed from the base of the PR and between 729cabc and ade1bf6.

Files selected for processing: 1

  • lib/SetupChecks/HarpVersionCheck.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

}
if (!$this->fulfillsMinimumVersionRequirement($versionString)) {
$issues[] = $this->l10n->t('HaRP version for daemon "%s" is "%s", which is too old. The minimum required version is "%s". Please update the daemon to the latest version.', [$daemonConfig->getName(), $versionString, Application::MINIMUM_HARP_VERSION]);
$issues[] = $this->l10n->t('HaRP version for daemon "%1$s" is "%2$s", which is too old. The minimum required version is "%3$s". Please update the daemon to the latest version.', [$daemonConfig->getName(), $versionString, Application::MINIMUM_HARP_VERSION]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Preserve the existing translations for both warnings.

The new message IDs do not match the shipped catalog entries. Non-English users will therefore see these warnings in English until updated translations are shipped. Coordinate the catalog updates with this change, or migrate the existing translations to the numbered placeholders.

Also applies to: 75-75

This branch has not been deployed

No deployments
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