Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"Entry1": {
"Array": [
"foo",
"bar"
],
"Integer": 5,
"Boolean": false,
"Float": 1.23
},
"Entry2": "String",
"Traversable": {
"Foo": "Bar"
}
}

View File

@@ -0,0 +1,17 @@
<?php
return [
'Entry1' => [
'Array' => [
0 => 'foo',
1 => 'bar',
],
'Integer' => 5,
'Boolean' => false,
'Float' => 1.23,
],
'Entry2' => 'String',
'Traversable' => [
'Foo' => 'Bar',
],
];

Binary file not shown.

View File

@@ -0,0 +1,39 @@
en{
Entry1{
Array{
"foo",
"bar",
{
Key{"value"}
},
}
Integer:int{5}
IntVector:intvector{
0,
1,
2,
3,
}
NotAnIntVector{
0:int{0}
2:int{1}
1:int{2}
3:int{3}
}
IntVectorWithStringKeys{
a:int{0}
b:int{1}
c:int{2}
}
TableWithIntKeys{
0:int{0}
1:int{1}
3:int{3}
}
FalseBoolean{"false"}
TrueBoolean{"true"}
Null{""}
Float{"1.23"}
}
Entry2{"String"}
}

View File

@@ -0,0 +1,3 @@
en_nofallback:table(nofallback){
Entry{"Value"}
}

View File

@@ -0,0 +1,4 @@
escaped{
"EntryWith:Colon"{"Value"}
"Entry With Spaces"{"Value"}
}

View File

@@ -0,0 +1,5 @@
{
"Entry": {
"NestedEntry": "Value"
}
}

View File

@@ -0,0 +1,7 @@
<?php
return [
'Entry' => [
'NestedEntry' => 'Value',
],
];

Binary file not shown.

View File

@@ -0,0 +1,5 @@
rb{
Entry{
NestedEntry{"Value"}
}
}

View File

@@ -0,0 +1,78 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\Tests\Data\Bundle\Writer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class JsonBundleWriterTest extends TestCase
{
/**
* @var JsonBundleWriter
*/
private $writer;
private $directory;
/**
* @var Filesystem
*/
private $filesystem;
protected function setUp()
{
$this->writer = new JsonBundleWriter();
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.mt_rand(1000, 9999);
$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->directory);
}
protected function tearDown()
{
$this->filesystem->remove($this->directory);
}
public function testWrite()
{
$this->writer->write($this->directory, 'en', [
'Entry1' => [
'Array' => ['foo', 'bar'],
'Integer' => 5,
'Boolean' => false,
'Float' => 1.23,
],
'Entry2' => 'String',
'Traversable' => new \ArrayIterator([
'Foo' => 'Bar',
]),
]);
$this->assertFileEquals(__DIR__.'/Fixtures/en.json', $this->directory.'/en.json');
}
/**
* @requires extension intl
*/
public function testWriteResourceBundle()
{
$bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false);
$this->writer->write($this->directory, 'en', $bundle);
$this->assertFileEquals(__DIR__.'/Fixtures/rb.json', $this->directory.'/en.json');
}
}

View File

@@ -0,0 +1,78 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\Tests\Data\Bundle\Writer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class PhpBundleWriterTest extends TestCase
{
/**
* @var PhpBundleWriter
*/
private $writer;
private $directory;
/**
* @var Filesystem
*/
private $filesystem;
protected function setUp()
{
$this->writer = new PhpBundleWriter();
$this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.mt_rand(1000, 9999);
$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->directory);
}
protected function tearDown()
{
$this->filesystem->remove($this->directory);
}
public function testWrite()
{
$this->writer->write($this->directory, 'en', [
'Entry1' => [
'Array' => ['foo', 'bar'],
'Integer' => 5,
'Boolean' => false,
'Float' => 1.23,
],
'Entry2' => 'String',
'Traversable' => new \ArrayIterator([
'Foo' => 'Bar',
]),
]);
$this->assertFileEquals(__DIR__.'/Fixtures/en.php', $this->directory.'/en.php');
}
/**
* @requires extension intl
*/
public function testWriteResourceBundle()
{
$bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false);
$this->writer->write($this->directory, 'en', $bundle);
$this->assertFileEquals(__DIR__.'/Fixtures/rb.php', $this->directory.'/en.php');
}
}

View File

@@ -0,0 +1,116 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\Tests\Data\Bundle\Writer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Writer\TextBundleWriter;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
*/
class TextBundleWriterTest extends TestCase
{
/**
* @var TextBundleWriter
*/
private $writer;
private $directory;
/**
* @var Filesystem
*/
private $filesystem;
protected function setUp()
{
$this->writer = new TextBundleWriter();
$this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.mt_rand(1000, 9999);
$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->directory);
}
protected function tearDown()
{
$this->filesystem->remove($this->directory);
}
public function testWrite()
{
$this->writer->write($this->directory, 'en', [
'Entry1' => [
'Array' => ['foo', 'bar', ['Key' => 'value']],
'Integer' => 5,
'IntVector' => [0, 1, 2, 3],
'NotAnIntVector' => [0 => 0, 2 => 1, 1 => 2, 3 => 3],
'IntVectorWithStringKeys' => ['a' => 0, 'b' => 1, 'c' => 2],
'TableWithIntKeys' => [0 => 0, 1 => 1, 3 => 3],
'FalseBoolean' => false,
'TrueBoolean' => true,
'Null' => null,
'Float' => 1.23,
],
'Entry2' => 'String',
]);
$this->assertFileEquals(__DIR__.'/Fixtures/en.txt', $this->directory.'/en.txt');
}
public function testWriteTraversable()
{
$this->writer->write($this->directory, 'en', new \ArrayIterator([
'Entry1' => new \ArrayIterator([
'Array' => ['foo', 'bar', ['Key' => 'value']],
'Integer' => 5,
'IntVector' => [0, 1, 2, 3],
'NotAnIntVector' => [0 => 0, 2 => 1, 1 => 2, 3 => 3],
'IntVectorWithStringKeys' => ['a' => 0, 'b' => 1, 'c' => 2],
'TableWithIntKeys' => [0 => 0, 1 => 1, 3 => 3],
'FalseBoolean' => false,
'TrueBoolean' => true,
'Null' => null,
'Float' => 1.23,
]),
'Entry2' => 'String',
]));
$this->assertFileEquals(__DIR__.'/Fixtures/en.txt', $this->directory.'/en.txt');
}
public function testWriteNoFallback()
{
$data = [
'Entry' => 'Value',
];
$this->writer->write($this->directory, 'en_nofallback', $data, $fallback = false);
$this->assertFileEquals(__DIR__.'/Fixtures/en_nofallback.txt', $this->directory.'/en_nofallback.txt');
}
public function testEscapeKeysIfNecessary()
{
$this->writer->write($this->directory, 'escaped', [
// Keys with colons must be escaped, otherwise the part after the
// colon is interpreted as resource type
'EntryWith:Colon' => 'Value',
// Keys with spaces must be escaped
'Entry With Spaces' => 'Value',
]);
$this->assertFileEquals(__DIR__.'/Fixtures/escaped.txt', $this->directory.'/escaped.txt');
}
}