private function PoFileLoader::addMessage in Plug 7
Save a translation item to the messages.
A .po file could contain by error missing plural indexes. We need to fix these before saving them.
Parameters
array $messages:
array $item:
1 call to PoFileLoader::addMessage()
- PoFileLoader::loadResource in lib/
Symfony/ translation/ Loader/ PoFileLoader.php - Parses portable object (PO) format.
File
- lib/
Symfony/ translation/ Loader/ PoFileLoader.php, line 122
Class
- PoFileLoader
- @copyright Copyright (c) 2010, Union of RAD http://union-of-rad.org (http://lithify.me/) @copyright Copyright (c) 2012, Clemens Tolboom
Namespace
Symfony\Component\Translation\LoaderCode
private function addMessage(array &$messages, array $item) {
if (is_array($item['translated'])) {
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated'][0]);
if (isset($item['ids']['plural'])) {
$plurals = $item['translated'];
// PO are by definition indexed so sort by index.
ksort($plurals);
// Make sure every index is filled.
end($plurals);
$count = key($plurals);
// Fill missing spots with '-'.
$empties = array_fill(0, $count + 1, '-');
$plurals += $empties;
ksort($plurals);
$messages[stripcslashes($item['ids']['plural'])] = stripcslashes(implode('|', $plurals));
}
}
elseif (!empty($item['ids']['singular'])) {
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']);
}
}