Skip to content

Commit

Permalink
added l10n check
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Apr 17, 2024
1 parent bb47f33 commit ff6fed8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
56 changes: 56 additions & 0 deletions .github/scripts/check_l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php




if( !isset($argv) || count($argv)<=1 ) {
phpDie("Usage: php ".__FILE__." /path/to/resources/l10n");
exit(1);
}

$resourceDir = $argv[1];

if( !is_dir($resourceDir) ) {
phpDie( $resourceDir." is not a dir" );
}

if( !file_exists( $resourceDir."/labels.properties")) {
phpDie( $resourceDir." is missing default labels.properties file" );
}

$defaultLang = parse_ini_file($resourceDir."/labels.properties", false, INI_SCANNER_RAW);

//print_r($defaultLang);

if( empty($defaultLang)) {
phpDie( "labels.properties is invalid or empty" );
}

$langFiles = glob($resourceDir."/labels_*");

$errors = 0;

foreach( $langFiles as $langfile ) {
$checkLang = parse_ini_file($langfile, false, INI_SCANNER_RAW);
if( empty($checkLang)) {
echo $langfile." is invalid or empty".PHP_EOL;
$errors++;

}
foreach( $defaultLang as $l10nKey => $l10nval ) {
if( !isset($checkLang[$l10nKey]) || empty($checkLang[$l10nKey]) ) {
echo basename($langfile)." is missing translation for key ".$l10nKey.PHP_EOL;
$errors++;
}
}
}

if( $errors > 0 ) {
phpDie("l10n check failed with ".$errors." errors");
}


function phpDie($msg) {
echo $msg.PHP_EOL;
exit(1);
}
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
java-version: '8'
- name: "Build jar"
run: |
php $GITHUB_WORKSPACE/.github/scripts/check_l10n.php src/main/resources/l10n
[ $? -eq 0 ] || die "Missing translations"
jar_file="build/ESP32PartitionTool.jar"
. $GITHUB_WORKSPACE/.github/scripts/build_jar.sh $jar_file
[ $? -eq 0 ] || die "Jar creation failed"
Expand Down Expand Up @@ -60,4 +62,4 @@ jobs:
with:
files: |
/home/runner/work/esp32partitiontool/esp32partitiontool/archives/**
token: ${{ secrets.RELEASE_TOKEN }} # Use the secret here
token: ${{ secrets.RELEASE_TOKEN }} # Use the secret here

0 comments on commit ff6fed8

Please sign in to comment.