13-05-2026 implementation FR
This commit is contained in:
parent
245c281541
commit
70240d2b6a
61 changed files with 4472 additions and 2 deletions
48
tests/Feature/FrenchLocalizationTest.php
Normal file
48
tests/Feature/FrenchLocalizationTest.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use App\Services\LocaleGuard;
|
||||
|
||||
uses(Tests\TestCase::class);
|
||||
|
||||
it('supports french as an application locale', function () {
|
||||
expect(config('localization.supportedLocales'))
|
||||
->toHaveKey('fr')
|
||||
->and(LocaleGuard::normalize('FR'))
|
||||
->toBe('fr');
|
||||
});
|
||||
|
||||
it('keeps french translation files in sync with the german source keys', function () {
|
||||
foreach (glob(resource_path('lang/de/*.php')) as $germanFile) {
|
||||
$fileName = basename($germanFile);
|
||||
$frenchFile = resource_path('lang/fr/'.$fileName);
|
||||
|
||||
expect($frenchFile)->toBeFile();
|
||||
expect(frenchLocalizationFlattenTranslationKeys(require $frenchFile))
|
||||
->toEqualCanonicalizing(frenchLocalizationFlattenTranslationKeys(require $germanFile));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
function frenchLocalizationFlattenTranslationKeys(array $translations, string $prefix = ''): array
|
||||
{
|
||||
$keys = [];
|
||||
|
||||
foreach ($translations as $key => $value) {
|
||||
$translationKey = $prefix.(string) $key;
|
||||
|
||||
if (is_array($value)) {
|
||||
$keys = [
|
||||
...$keys,
|
||||
...frenchLocalizationFlattenTranslationKeys($value, $translationKey.'.'),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$keys[] = $translationKey;
|
||||
}
|
||||
|
||||
return $keys;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue