Code: Select all
'MIGRATION_DATA_DONE' => 'Installed Data: %1$s; Time: %2$.2f seconds',
Code: Select all
'MIGRATION_DATA_DONE' => 'Installed Data: %1$s; Time: %2$.2f seconds',
%2$,2f
?X.YZ
in formation, such as 1.23
or 45.67
or 789.00
.sprintf
function which allows you to specify a string of text and include placeholders for dynamic data where $1%s
is the first placeholder expecting a string (ie. Hello World
) and $2%.2f
is the second and is expecting a float (ie. 12.34
).number_format
after the text has been replaced, not by trying to update the string in a language file.I guess it's impossible using translation. Changing locale would require core code modification or creating some phpBB extension.scootergrisen wrote: Mon Aug 19, 2024 5:31 am Are there any way for translators to choose the value for setlocale?
%2$.2f
can't be changed to %2$,2f
because it's PHP syntax error: sprintf format requires dot followed by a digit to set up a floating point precision.%2$.1f
will give 1-digit presicion for the float or using %2$d
will print integer non-float value.$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
$formatter->setSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, ',');
$number = 1.23;
$formattedNumber = $formatter->format($number);
echo sprintf('Installed Data: %1$s; Time: %s seconds', 'Data', $formattedNumber);
You’re correct. You can’t use php functions inside phpBB language strings.thecoalman wrote: Thu Aug 22, 2024 6:27 pm I may be mistaken but official translations can't have php added.