fix(Sharing): Fix l10n interpolation

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/62393/head
provokateurin 4 weeks ago
parent b03799a266
commit 22b3ca5ccd
No known key found for this signature in database
  1. 2
      lib/public/Sharing/Property/ABooleanSharePropertyType.php
  2. 6
      lib/public/Sharing/Property/ADateSharePropertyType.php
  3. 2
      lib/public/Sharing/Property/AEnumSharePropertyType.php
  4. 4
      lib/public/Sharing/Property/AStringSharePropertyType.php

@ -30,7 +30,7 @@ abstract class ABooleanSharePropertyType implements ISharePropertyType {
return true;
}
return $l10nFactory->get(Application::APP_ID)->t('Only true and false are valid values: ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Only true and false are valid values: %s', [$value]);
}
/**

@ -46,15 +46,15 @@ abstract class ADateSharePropertyType implements ISharePropertyType {
}
if ($date === false) {
return $l10nFactory->get(Application::APP_ID)->t('Invalid ISO date: ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Invalid ISO date: %s', [$value]);
}
if (($minDate = $this->getMinDate()) instanceof DateTimeImmutable && $date->diff($minDate)->invert === 0) {
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be after ' . $minDate->format(DateTimeInterface::ATOM) . ': ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be after %s: %s', [$minDate->format(DateTimeInterface::ATOM), $value]);
}
if (($maxDate = $this->getMaxDate()) instanceof DateTimeImmutable && $date->diff($maxDate)->invert === 1) {
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be before ' . $maxDate->format(DateTimeInterface::ATOM) . ': ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Date needs to be before %s: %s', [$maxDate->format(DateTimeInterface::ATOM), $value]);
}
return true;

@ -37,7 +37,7 @@ abstract class AEnumSharePropertyType implements ISharePropertyType {
return true;
}
return $l10nFactory->get(Application::APP_ID)->t('Only ' . implode(', ', $validValues) . ' are valid values: ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Only %s are valid values: %s', [implode(', ', $validValues), $value]);
}
/**

@ -39,11 +39,11 @@ abstract class AStringSharePropertyType implements ISharePropertyType {
#[\Override]
public function validateValue(IFactory $l10nFactory, string $value): true|string {
if (($minLength = $this->getMinLength()) !== null && mb_strlen($value) < $minLength) {
return $l10nFactory->get(Application::APP_ID)->t('Need at least ' . $minLength . ' characters: ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Need at least %s characters: %s', [$minLength, $value]);
}
if (($maxLength = $this->getMaxLength()) !== null && mb_strlen($value) > $maxLength) {
return $l10nFactory->get(Application::APP_ID)->t('Provide ' . $maxLength . ' characters at most: ' . $value);
return $l10nFactory->get(Application::APP_ID)->t('Provide %s characters at most: %s', [$maxLength, $value]);
}
return true;

Loading…
Cancel
Save