mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-11-30 12:09:57 +09:00
feat: Dynamically add all languages to db
Add unit test to find missing translations
This commit is contained in:
committed by
Attila Jozsef Kerekes
parent
99193a578e
commit
edb51e56f1
48
tests/Unit/lang/LangTest.php
Normal file
48
tests/Unit/lang/LangTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\lang;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class LangTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* All language keys are defined in all languages based on the en language file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAllLanguageKeysAreDefined()
|
||||
{
|
||||
$this->markTestSkipped('2022-11-14 Lot of keys missing. Enable this test to see them all.');
|
||||
$languageDirectories = array_filter(glob(resource_path().'/lang/*'), 'is_dir');
|
||||
|
||||
$enLanguageDirectory = array_values(array_filter($languageDirectories, function($v) {
|
||||
return substr($v, -2) === 'en';
|
||||
}))[0];
|
||||
$notENLanguageDirectories = array_filter($languageDirectories, function ($v) {
|
||||
return substr($v, -2) !== 'en';
|
||||
});
|
||||
|
||||
$enLanguageKeys = require_once($enLanguageDirectory.'/app.php');
|
||||
$missingKeys = [];
|
||||
|
||||
foreach ($notENLanguageDirectories as $langDirectory) {
|
||||
$testingLangKeys = require_once($langDirectory . '/app.php');
|
||||
|
||||
foreach ($enLanguageKeys as $langKey => $langValue) {
|
||||
if (!array_key_exists($langKey, $testingLangKeys)) {
|
||||
if(!isset($missingKeys[$langDirectory])) {
|
||||
$missingKeys[$langDirectory] = [];
|
||||
}
|
||||
$missingKeys[$langDirectory][] = $langKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($missingKeys) > 0) {
|
||||
print_r(json_encode($missingKeys));
|
||||
}
|
||||
|
||||
$this->assertEmpty($missingKeys);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user