Skip to content

Commit

Permalink
minor #31337 [Intl] Apply localeDisplayPattern and fix locale generat…
Browse files Browse the repository at this point in the history
…ion (ro0NL)

This PR was squashed before being merged into the 3.4 branch (closes #31337).

Discussion
----------

[Intl] Apply localeDisplayPattern and fix locale generation

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no (few data changes)
| Deprecations? | no
| Tests pass?   | yes (including intl-data group)
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

See https://github.com/unicode-org/icu/blob/e2d85306162d3a0691b070b4f0a73e4012433444/icu4c/source/data/lang/en.txt#L1281-L1285

Technically, this should be applied here: https://github.com/symfony/symfony/blob/2b923a7c03e1ed1540c9dba224242defd9aa75cd/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php#L211

This PR aims to implement it, but before it got to this point i noticed a false positive during generation (AFAIK). The current state solves this issue first.

While at it, i cleaned up dead-code in `update-data.php` to reduce the noise.

Commits
-------

a20a6cc recompile
29e8aba [Intl] Apply localeDisplayPattern and fix locale generation
  • Loading branch information
fabpot committed May 7, 2019
2 parents 16c460c + a20a6cc commit 7ae5fe0
Show file tree
Hide file tree
Showing 118 changed files with 2,967 additions and 3,018 deletions.
33 changes: 15 additions & 18 deletions src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php
Expand Up @@ -12,8 +12,9 @@
namespace Symfony\Component\Intl\Data\Generator;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface;
use Symfony\Component\Intl\Data\Bundle\Compiler\BundleCompilerInterface;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader;
use Symfony\Component\Intl\Data\Util\LocaleScanner;

Expand All @@ -29,7 +30,7 @@ abstract class AbstractDataGenerator
private $compiler;
private $dirName;

public function __construct(GenrbCompiler $compiler, $dirName)
public function __construct(BundleCompilerInterface $compiler, $dirName)
{
$this->compiler = $compiler;
$this->dirName = (string) $dirName;
Expand All @@ -39,7 +40,7 @@ public function generateData(GeneratorConfig $config)
{
$filesystem = new Filesystem();
$localeScanner = new LocaleScanner();
$reader = new IntlBundleReader();
$reader = new BundleEntryReader(new IntlBundleReader());

$writers = $config->getBundleWriters();
$tempDir = sys_get_temp_dir().'/icu-data-'.$this->dirName;
Expand Down Expand Up @@ -98,36 +99,32 @@ public function generateData(GeneratorConfig $config)
abstract protected function scanLocales(LocaleScanner $scanner, $sourceDir);

/**
* @param GenrbCompiler $compiler
* @param string $sourceDir
* @param string $tempDir
* @param string $sourceDir
* @param string $tempDir
*/
abstract protected function compileTemporaryBundles(GenrbCompiler $compiler, $sourceDir, $tempDir);
abstract protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir);

abstract protected function preGenerate();

/**
* @param BundleReaderInterface $reader
* @param string $tempDir
* @param string $displayLocale
* @param string $tempDir
* @param string $displayLocale
*
* @return array|null
*/
abstract protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir, $displayLocale);
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale);

/**
* @param BundleReaderInterface $reader
* @param string $tempDir
* @param string $tempDir
*
* @return array|null
*/
abstract protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir);
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir);

/**
* @param BundleReaderInterface $reader
* @param string $tempDir
* @param string $tempDir
*
* @return array|null
*/
abstract protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir);
abstract protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir);
}
Expand Up @@ -11,8 +11,8 @@

namespace Symfony\Component\Intl\Data\Generator;

use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface;
use Symfony\Component\Intl\Data\Bundle\Compiler\BundleCompilerInterface;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Util\ArrayAccessibleResourceBundle;
use Symfony\Component\Intl\Data\Util\LocaleScanner;

Expand Down Expand Up @@ -59,7 +59,7 @@ protected function scanLocales(LocaleScanner $scanner, $sourceDir)
/**
* {@inheritdoc}
*/
protected function compileTemporaryBundles(GenrbCompiler $compiler, $sourceDir, $tempDir)
protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir)
{
$compiler->compile($sourceDir.'/curr', $tempDir);
$compiler->compile($sourceDir.'/misc/currencyNumericCodes.txt', $tempDir);
Expand All @@ -76,7 +76,7 @@ protected function preGenerate()
/**
* {@inheritdoc}
*/
protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir, $displayLocale)
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
{
$localeBundle = $reader->read($tempDir, $displayLocale);

Expand All @@ -95,7 +95,7 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir
/**
* {@inheritdoc}
*/
protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir)
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
{
$rootBundle = $reader->read($tempDir, 'root');

Expand All @@ -108,7 +108,7 @@ protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir)
/**
* {@inheritdoc}
*/
protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
{
$rootBundle = $reader->read($tempDir, 'root');
$supplementalDataBundle = $reader->read($tempDir, 'supplementalData');
Expand Down
Expand Up @@ -11,8 +11,8 @@

namespace Symfony\Component\Intl\Data\Generator;

use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface;
use Symfony\Component\Intl\Data\Bundle\Compiler\BundleCompilerInterface;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Util\ArrayAccessibleResourceBundle;
use Symfony\Component\Intl\Data\Util\LocaleScanner;
use Symfony\Component\Intl\Exception\RuntimeException;
Expand Down Expand Up @@ -102,7 +102,7 @@ protected function scanLocales(LocaleScanner $scanner, $sourceDir)
/**
* {@inheritdoc}
*/
protected function compileTemporaryBundles(GenrbCompiler $compiler, $sourceDir, $tempDir)
protected function compileTemporaryBundles(BundleCompilerInterface $compiler, $sourceDir, $tempDir)
{
$compiler->compile($sourceDir.'/lang', $tempDir);
$compiler->compile($sourceDir.'/misc/metadata.txt', $tempDir);
Expand All @@ -119,7 +119,7 @@ protected function preGenerate()
/**
* {@inheritdoc}
*/
protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir, $displayLocale)
protected function generateDataForLocale(BundleEntryReaderInterface $reader, $tempDir, $displayLocale)
{
$localeBundle = $reader->read($tempDir, $displayLocale);

Expand All @@ -139,14 +139,14 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir
/**
* {@inheritdoc}
*/
protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir)
protected function generateDataForRoot(BundleEntryReaderInterface $reader, $tempDir)
{
}

/**
* {@inheritdoc}
*/
protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
protected function generateDataForMeta(BundleEntryReaderInterface $reader, $tempDir)
{
$rootBundle = $reader->read($tempDir, 'root');
$metadataBundle = $reader->read($tempDir, 'metadata');
Expand Down

0 comments on commit 7ae5fe0

Please sign in to comment.