updated packages
This commit is contained in:
@@ -36,7 +36,7 @@ class ArrayLoader implements LoaderInterface
|
||||
* Flattens an nested array of translations.
|
||||
*
|
||||
* The scheme used is:
|
||||
* 'key' => array('key2' => array('key3' => 'value'))
|
||||
* 'key' => ['key2' => ['key3' => 'value']]
|
||||
* Becomes:
|
||||
* 'key.key2.key3' => 'value'
|
||||
*
|
||||
|
||||
@@ -29,7 +29,7 @@ class CsvFileLoader extends FileLoader
|
||||
*/
|
||||
protected function loadResource($resource)
|
||||
{
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
try {
|
||||
$file = new \SplFileObject($resource, 'rb');
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class FileLoader extends ArrayLoader
|
||||
|
||||
// empty resource
|
||||
if (null === $messages) {
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
}
|
||||
|
||||
// not an array
|
||||
|
||||
@@ -75,7 +75,7 @@ class IcuResFileLoader implements LoaderInterface
|
||||
*
|
||||
* @return array the flattened ResourceBundle
|
||||
*/
|
||||
protected function flatten(\ResourceBundle $rb, array &$messages = array(), $path = null)
|
||||
protected function flatten(\ResourceBundle $rb, array &$messages = [], $path = null)
|
||||
{
|
||||
foreach ($rb as $key => $value) {
|
||||
$nodePath = $path ? $path.'.'.$key : $key;
|
||||
|
||||
@@ -25,7 +25,7 @@ class JsonFileLoader extends FileLoader
|
||||
*/
|
||||
protected function loadResource($resource)
|
||||
{
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
if ($data = file_get_contents($resource)) {
|
||||
$messages = json_decode($data, true);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class MoFileLoader extends FileLoader
|
||||
// offsetHashes
|
||||
$this->readLong($stream, $isBigEndian);
|
||||
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$pluralId = null;
|
||||
@@ -108,13 +108,13 @@ class MoFileLoader extends FileLoader
|
||||
$translated = explode("\000", $translated);
|
||||
}
|
||||
|
||||
$ids = array('singular' => $singularId, 'plural' => $pluralId);
|
||||
$ids = ['singular' => $singularId, 'plural' => $pluralId];
|
||||
$item = compact('ids', 'translated');
|
||||
|
||||
if (\is_array($item['translated'])) {
|
||||
$messages[$item['ids']['singular']] = stripcslashes($item['translated'][0]);
|
||||
if (isset($item['ids']['plural'])) {
|
||||
$plurals = array();
|
||||
$plurals = [];
|
||||
foreach ($item['translated'] as $plural => $translated) {
|
||||
$plurals[] = sprintf('{%d} %s', $plural, $translated);
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ class PoFileLoader extends FileLoader
|
||||
{
|
||||
$stream = fopen($resource, 'r');
|
||||
|
||||
$defaults = array(
|
||||
'ids' => array(),
|
||||
$defaults = [
|
||||
'ids' => [],
|
||||
'translated' => null,
|
||||
);
|
||||
];
|
||||
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
$item = $defaults;
|
||||
$flags = array();
|
||||
$flags = [];
|
||||
|
||||
while ($line = fgets($stream)) {
|
||||
$line = trim($line);
|
||||
@@ -82,7 +82,7 @@ class PoFileLoader extends FileLoader
|
||||
$this->addMessage($messages, $item);
|
||||
}
|
||||
$item = $defaults;
|
||||
$flags = array();
|
||||
$flags = [];
|
||||
} elseif ('#,' === substr($line, 0, 2)) {
|
||||
$flags = array_map('trim', explode(',', substr($line, 2)));
|
||||
} elseif ('msgid "' === substr($line, 0, 7)) {
|
||||
|
||||
@@ -58,7 +58,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
$xliffVersion = XliffUtils::getVersionNumber($dom);
|
||||
if ($errors = XliffUtils::validateSchema($dom)) {
|
||||
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s', $xliffVersion, XliffUtils::getErrorsAsString($errors)));
|
||||
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s', $resource, XliffUtils::getErrorsAsString($errors)));
|
||||
}
|
||||
|
||||
if ('1.2' === $xliffVersion) {
|
||||
@@ -97,13 +97,13 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
$catalogue->set((string) $source, $target, $domain);
|
||||
|
||||
$metadata = array();
|
||||
$metadata = [];
|
||||
if ($notes = $this->parseNotesMetadata($translation->note, $encoding)) {
|
||||
$metadata['notes'] = $notes;
|
||||
}
|
||||
|
||||
if (isset($translation->target) && $translation->target->attributes()) {
|
||||
$metadata['target-attributes'] = array();
|
||||
$metadata['target-attributes'] = [];
|
||||
foreach ($translation->target->attributes() as $key => $value) {
|
||||
$metadata['target-attributes'][$key] = (string) $value;
|
||||
}
|
||||
@@ -134,18 +134,18 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
$catalogue->set((string) $source, $target, $domain);
|
||||
|
||||
$metadata = array();
|
||||
$metadata = [];
|
||||
if (isset($segment->target) && $segment->target->attributes()) {
|
||||
$metadata['target-attributes'] = array();
|
||||
$metadata['target-attributes'] = [];
|
||||
foreach ($segment->target->attributes() as $key => $value) {
|
||||
$metadata['target-attributes'][$key] = (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($unit->notes)) {
|
||||
$metadata['notes'] = array();
|
||||
$metadata['notes'] = [];
|
||||
foreach ($unit->notes->note as $noteNode) {
|
||||
$note = array();
|
||||
$note = [];
|
||||
foreach ($noteNode->attributes() as $key => $value) {
|
||||
$note[$key] = (string) $value;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, string $encoding = null): array
|
||||
{
|
||||
$notes = array();
|
||||
$notes = [];
|
||||
|
||||
if (null === $noteElement) {
|
||||
return $notes;
|
||||
@@ -182,7 +182,7 @@ class XliffFileLoader implements LoaderInterface
|
||||
/** @var \SimpleXMLElement $xmlNote */
|
||||
foreach ($noteElement as $xmlNote) {
|
||||
$noteAttributes = $xmlNote->attributes();
|
||||
$note = array('content' => $this->utf8ToCharset((string) $xmlNote, $encoding));
|
||||
$note = ['content' => $this->utf8ToCharset((string) $xmlNote, $encoding)];
|
||||
if (isset($noteAttributes['priority'])) {
|
||||
$note['priority'] = (int) $noteAttributes['priority'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user