Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function translateTimeString() translate part of the word if translations are overlapping #304

Closed
aK0nshin opened this issue Aug 2, 2018 · 1 comment · Fixed by #317
Closed

Comments

@aK0nshin
Copy link

aK0nshin commented Aug 2, 2018

In Russian translation we have string:
https://github.com/jenssegers/date/blob/master/src/Lang/ru.php#L46

'august' => '{0}август|{1}августа',

So second translation contains first one and when this goes to str_ireplace() we have only part of word replaced:

$time = "02 августа 2018 года 14:29";
$terms = [
    //...
    "august" => [
        0 => "август",
        1 => "августа",
    ],
    //...
];

// Replace the localized words with English words.
$translated = $time;
foreach ($terms as $english => $localized) {
    $translated = str_ireplace($localized, $english, $translated);
}

var_dump($translated); // string(31) "02 augustа 2018 года 14:29"

https://github.com/jenssegers/date/blob/master/src/Date.php#L437

@aK0nshin
Copy link
Author

aK0nshin commented Aug 2, 2018

My solution: #305

@aK0nshin aK0nshin changed the title Function translateTimeString() translate part of the word if one translation contains another Function translateTimeString() translate part of the word if translations are overlapping Mar 12, 2019
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 a pull request may close this issue.

1 participant