LocaleScanner example

private string $dirName;

    public function __construct(BundleCompilerInterface $compiler, string $dirName)
    {
        $this->compiler = $compiler;
        $this->dirName = $dirName;
    }

    public function generateData(GeneratorConfig $config): void
    {
        $filesystem = new Filesystem();
        $localeScanner = new LocaleScanner();
        $reader = new BundleEntryReader(new IntlBundleReader());

        $writers = $config->getBundleWriters();
        $tempDir = sys_get_temp_dir().'/icu-data-'.$this->dirName;

        // Prepare filesystem directories         foreach ($writers as $targetDir => $writer) {
            $filesystem->remove($targetDir.'/'.$this->dirName);
            $filesystem->mkdir($targetDir.'/'.$this->dirName);
        }

        

class LocaleScannerTest extends TestCase
{
    private string $directory;
    private Filesystem $filesystem;
    private LocaleScanner $scanner;

    protected function setUp(): void
    {
        $this->directory = sys_get_temp_dir().'/LocaleScannerTest/'.mt_rand(1000, 9999);
        $this->filesystem = new Filesystem();
        $this->scanner = new LocaleScanner();

        $this->filesystem->mkdir($this->directory);

        $this->filesystem->touch($this->directory.'/en.txt');
        $this->filesystem->touch($this->directory.'/en_alias.txt');
        $this->filesystem->touch($this->directory.'/en_child.txt');
        $this->filesystem->touch($this->directory.'/de.txt');
        $this->filesystem->touch($this->directory.'/de_alias.txt');
        $this->filesystem->touch($this->directory.'/de_child.txt');
        $this->filesystem->touch($this->directory.'/fr.txt');
        $this->filesystem->touch($this->directory.'/fr_alias.txt');
        
Home | Imprint | This part of the site doesn't use cookies.