Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
95 lines
2.8 KiB
PHP
95 lines
2.8 KiB
PHP
<?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\Translation\Dumper;
|
|
|
|
use Symfony\Component\Translation\MessageCatalogue;
|
|
|
|
/**
|
|
* IcuResDumper generates an ICU ResourceBundle formatted string representation of a message catalogue.
|
|
*
|
|
* @author Stealth35
|
|
*/
|
|
class IcuResFileDumper extends FileDumper
|
|
{
|
|
protected string $relativePathTemplate = '%domain%/%locale%.%extension%';
|
|
|
|
public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string
|
|
{
|
|
$data = $indexes = $resources = '';
|
|
|
|
foreach ($messages->all($domain) as $source => $target) {
|
|
$indexes .= pack('v', \strlen($data) + 28);
|
|
$data .= $source."\0";
|
|
}
|
|
|
|
$data .= $this->writePadding($data);
|
|
|
|
$keyTop = $this->getPosition($data);
|
|
|
|
foreach ($messages->all($domain) as $source => $target) {
|
|
$resources .= pack('V', $this->getPosition($data));
|
|
|
|
$data .= pack('V', \strlen($target))
|
|
.mb_convert_encoding($target."\0", 'UTF-16LE', 'UTF-8')
|
|
.$this->writePadding($data)
|
|
;
|
|
}
|
|
|
|
$resOffset = $this->getPosition($data);
|
|
|
|
$data .= pack('v', \count($messages->all($domain)))
|
|
.$indexes
|
|
.$this->writePadding($data)
|
|
.$resources
|
|
;
|
|
|
|
$bundleTop = $this->getPosition($data);
|
|
|
|
$root = pack('V7',
|
|
$resOffset + (2 << 28), // Resource Offset + Resource Type
|
|
6, // Index length
|
|
$keyTop, // Index keys top
|
|
$bundleTop, // Index resources top
|
|
$bundleTop, // Index bundle top
|
|
\count($messages->all($domain)), // Index max table length
|
|
0 // Index attributes
|
|
);
|
|
|
|
$header = pack('vC2v4C12@32',
|
|
32, // Header size
|
|
0xDA, 0x27, // Magic number 1 and 2
|
|
20, 0, 0, 2, // Rest of the header, ..., Size of a char
|
|
0x52, 0x65, 0x73, 0x42, // Data format identifier
|
|
1, 2, 0, 0, // Data version
|
|
1, 4, 0, 0 // Unicode version
|
|
);
|
|
|
|
return $header.$root.$data;
|
|
}
|
|
|
|
private function writePadding(string $data): ?string
|
|
{
|
|
$padding = \strlen($data) % 4;
|
|
|
|
return $padding ? str_repeat("\xAA", 4 - $padding) : null;
|
|
}
|
|
|
|
private function getPosition(string $data): float|int
|
|
{
|
|
return (\strlen($data) + 28) / 4;
|
|
}
|
|
|
|
protected function getExtension(): string
|
|
{
|
|
return 'res';
|
|
}
|
|
}
|