Skip to content

Commit 16bb293

Browse files
[Intl] Compress intl data
1 parent 11dec7b commit 16bb293

File tree

2,491 files changed

+14
-365642
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,491 files changed

+14
-365642
lines changed

src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Intl\Data\Bundle\Reader;
1313

1414
use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException;
15+
use Symfony\Component\Intl\Util\GzipStreamWrapper;
1516

1617
/**
1718
* Reads .php resource bundles.
@@ -31,6 +32,10 @@ public function read(string $path, string $locale): mixed
3132
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3233
}
3334

35+
if (is_file($fileName.'.gz')) {
36+
return GzipStreamWrapper::require($fileName.'.gz');
37+
}
38+
3439
if (!is_file($fileName)) {
3540
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3641
}

src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ public function write(string $path, string $locale, mixed $data): void
4848
$data = sprintf($template, $data);
4949

5050
file_put_contents($path.'/'.$locale.'.php', $data);
51+
file_put_contents('compress.zlib://'.$path.'/'.$locale.'.php.gz', $data);
52+
53+
unlink($path.'/'.$locale.'.php'.(filesize($path.'/'.$locale.'.php.gz') >= filesize($path.'/'.$locale.'.php') ? '.gz' : ''));
5154
}
5255
}

0 commit comments

Comments
 (0)