Releases: utopia-php/locale
Releases · utopia-php/locale
0.6.0
- We adjusted the second parameter of
getText
-$placeholders
for achieving more consistency and better support from localizing software. Before, you used your placeholder likeHello {name}
, now it'sHello {{name}}
. More examples:
// BEFORE.json
{
'age: 'You are {age} years old',
'fullName': 'You are logged in as {name} {surname}.',
'post-info': 'Your post has {likeAmount} likes and {commentAmount} comments.'
}
// AFTER.json
{
'age: 'You are {{age}} years old',
'fullName': 'You are logged in as {{name} {{surname}}.',
'post-info': 'Your post has {{likeAmount}} likes and {{commentAmount}} comments.'
}
0.5.0
- We removed second parameter
$default
. To achieve the same logic, you can do this in your code:
$translation = $locale->getText('myMissingTranslation');
if($translation == '{{myMissingTranslation}}') {
$translation = 'Translation not found!';
}
echo $translation;
If you have exceptions enabled, you could:
Locale::$exceptions = true;
try {
$translation = $locale->getText('myMissingTranslation');
echo $translation;
} catch (\Throwable $exception) {
echo "Translation not found!";
}
- We added new second parameter
$placeholders
. Please refer to README.md to learn how to use it.