Skip to content

Commit ec69975

Browse files
committed
[Intl] Switch from json to php resources
1 parent b1d0321 commit ec69975

File tree

2,477 files changed

+345947
-345465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,477 files changed

+345947
-345465
lines changed

Data/Bundle/Reader/JsonBundleReader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ public function read(string $path, string $locale)
3535
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3636
}
3737

38-
if (!file_exists($fileName)) {
39-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
40-
}
41-
4238
if (!is_file($fileName)) {
43-
throw new RuntimeException(sprintf('The resource bundle "%s" is not a file.', $fileName));
39+
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
4440
}
4541

4642
$data = json_decode(file_get_contents($fileName), true);

Data/Bundle/Reader/PhpBundleReader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ public function read(string $path, string $locale)
3535
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3636
}
3737

38-
if (!file_exists($fileName)) {
39-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.php" does not exist.', $path, $locale));
40-
}
41-
4238
if (!is_file($fileName)) {
43-
throw new RuntimeException(sprintf('The resource bundle "%s/%s.php" is not a file.', $path, $locale));
39+
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
4440
}
4541

4642
return include $fileName;

Data/Generator/CurrencyDataGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, strin
130130

131131
private function generateSymbolNamePairs(ArrayAccessibleResourceBundle $rootBundle): array
132132
{
133-
$symbolNamePairs = iterator_to_array($rootBundle['Currencies']);
133+
$symbolNamePairs = array_map(function ($pair) {
134+
return \array_slice(iterator_to_array($pair), 0, 2);
135+
}, iterator_to_array($rootBundle['Currencies']));
134136

135137
// Remove unwanted currencies
136138
$symbolNamePairs = array_diff_key($symbolNamePairs, self::DENYLIST);

Intl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function getIcuDataVersion(): string
125125
*/
126126
public static function getIcuStubVersion(): string
127127
{
128-
return '68.2';
128+
return '69.1';
129129
}
130130

131131
/**

ResourceBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Intl\Data\Bundle\Reader\BufferedBundleReader;
1515
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader;
1616
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
17-
use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader;
17+
use Symfony\Component\Intl\Data\Bundle\Reader\PhpBundleReader;
1818

1919
/**
2020
* @author Roland Franssen <franssen.roland@gmail.com>
@@ -47,7 +47,7 @@ final protected static function readEntry(array $indices, string $locale = null,
4747
{
4848
if (null === self::$entryReader) {
4949
self::$entryReader = new BundleEntryReader(new BufferedBundleReader(
50-
new JsonBundleReader(),
50+
new PhpBundleReader(),
5151
Intl::BUFFER_SIZE
5252
));
5353

Resources/bin/update-data.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Symfony\Component\Filesystem\Filesystem;
1313
use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler;
14-
use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter;
14+
use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter;
1515
use Symfony\Component\Intl\Data\Generator\CurrencyDataGenerator;
1616
use Symfony\Component\Intl\Data\Generator\GeneratorConfig;
1717
use Symfony\Component\Intl\Data\Generator\LanguageDataGenerator;
@@ -166,9 +166,9 @@
166166

167167
$compiler = new GenrbCompiler($genrb, $genrbEnv);
168168
$config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
169-
$jsonDir = dirname(__DIR__).'/data';
169+
$dataDir = dirname(__DIR__).'/data';
170170

171-
$config->addBundleWriter($jsonDir, new JsonBundleWriter());
171+
$config->addBundleWriter($dataDir, new PhpBundleWriter());
172172

173173
echo "Starting resource bundle compilation. This may take a while...\n";
174174

@@ -218,13 +218,13 @@
218218
219219
GIT_INFO;
220220

221-
$gitInfoFile = $jsonDir.'/git-info.txt';
221+
$gitInfoFile = $dataDir.'/git-info.txt';
222222

223223
file_put_contents($gitInfoFile, $gitInfo);
224224

225225
echo "Wrote $gitInfoFile.\n";
226226

227-
$versionFile = $jsonDir.'/version.txt';
227+
$versionFile = $dataDir.'/version.txt';
228228

229229
file_put_contents($versionFile, "$icuVersionInDownload\n");
230230

0 commit comments

Comments
 (0)