diff --git a/.github/workflows/android_workflow.yml b/.github/workflows/android_workflow.yml index af9214983..bf22dd39f 100644 --- a/.github/workflows/android_workflow.yml +++ b/.github/workflows/android_workflow.yml @@ -35,9 +35,22 @@ jobs: dependencies-cache-enabled: true configuration-cache-enabled: true - - name: Upload artifact + - name: Generate translation report + run: | + chmod +x ./gradlew + ./gradlew :app:checkTranslations + shell: bash + + - name: Upload APK uses: actions/upload-artifact@v2 if: ${{ !github.head_ref }} with: name: apk-debug - path: app/build/outputs/apk/debug/app-debug.apk \ No newline at end of file + path: app/build/outputs/apk/debug/app-debug.apk + + - name: Upload translation report + uses: actions/upload-artifact@v2 + if: ${{ !github.head_ref }} + with: + name: translation-report + path: build/translation-reports/ \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 000000000..8b57f4527 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.tools/strings-check.php b/.tools/strings-check.php new file mode 100644 index 000000000..887104ac4 --- /dev/null +++ b/.tools/strings-check.php @@ -0,0 +1,157 @@ +#!/usr/bin/php -q + +// +// 2010-07-03: Initial release +// 2017-04-25: Code cleanup; Added exit code + +class Convert { + + public function XmlToArray( $n ) + { + $xml_array = array(); + $occurance = array(); + + foreach($n->childNodes as $nc) { + if (isset($occurance[$nc->nodeName])) { + $occurance[$nc->nodeName]++; + } else { + $occurance[$nc->nodeName] = 1; + } + } + + foreach($n->childNodes as $nc) { + if( $nc->hasChildNodes() ) { + $childNodes = $nc->childNodes; + $children = $childNodes->length; + + if ($children>1) { + $xml_array[$nc->nodeName][] = $this->XmlToArray($nc); + + $counter = count($xml_array[$nc->nodeName])-1; + + $attrs = $nc->attributes; + for ($k = 0; $k < $attrs->length; $k++) { + $xml_array[$nc->nodeName][$counter]['attribute'][$attrs->item($k)->nodeName] = $attrs->item($k)->nodeValue; + } + //$counter++; + } else { + $xml_array[$nc->nodeName][]['cdata'] = $nc->nodeValue; + $counter = count($xml_array[$nc->nodeName])-1; + $attrs = $nc->attributes; + for ($k = 0; $k < $attrs->length; $k++) { + $xml_array[$nc->nodeName][$counter]['attribute'][$attrs->item($k)->nodeName] = $attrs->item($k)->nodeValue; + } + } + } else { + if( $nc->hasAttributes() ) { + $attrs = $nc->attributes; + for ($k = 0; $k < $attrs->length; $k++) { + $xml_array[$nc->nodeName][0]['attribute'][$attrs->item($k)->nodeName]= $attrs->item($k)->nodeValue; + } + } + } + } + + return $xml_array; + } + + public function GetLabels( $fileName ) + { + $xml = new DOMDocument('1.0','UTF-8'); + $xml->load( $fileName ); + + $data = $this->XmlToArray( $xml ); + + $result = array(); + + foreach( $data['resources'][0]['string'] AS $entry ) { + $tmp = sprintf("%s", trim($entry['attribute']['name'])); + $result[$tmp] = $tmp; + } + + return $result; + } + +// class convert +} + + + if( $_SERVER['argc'] != 3 ) { + printf("Usage: %s strings-BASE.xml string-LANG.xml\n", $_SERVER['argv'][0] ); + die( "*** Aborted\n"); + } + + $fileBase = $_SERVER['argv'][1]; + $fileLang = $_SERVER['argv'][2]; + + if( file_exists( $fileBase ) == FALSE ) { + die( sprintf("*** Missing BASE file '%s'\n", $fileBase )); + } + + if( file_exists( $fileLang ) == FALSE ) { + die( sprintf("*** Missing LANG file '%s'\n", $fileLang ) ); + } + + + $convert = new Convert(); + $dataLang = $convert->GetLabels( $fileLang ); + $dataBase = $convert->GetLabels( $fileBase ); + + $cntLang = $cntBase = 0; + + echo "\n"; + + // comparing + printf("Missing in LANG (You need to translate these)\n"); + printf("File: %s\n", $fileLang); + printf("------------------------- BEGIN ----------------------\n"); + foreach( $dataBase as $string ) { + if( !array_key_exists($string, $dataLang)) { + printf("%s\n", $string); + $cntLang++; + } + } + printf("-------------------------- END -----------------------\n"); + + echo "\n\n"; + printf("Not present in BASE (you need to remove it from LANG)\n"); + printf("File: %s\n", $fileBase); + printf("------------------------- BEGIN ----------------------\n"); + foreach( $dataLang as $string ) { + if( !array_key_exists($string, $dataBase)) { + printf("%s\n", $string); + $cntBase++; + } + } + printf("-------------------------- END -----------------------\n"); + + echo "\n\nSummary\n----------------\n"; + + echo "BASE file: '{$fileBase}'\n"; + echo "LANG file: '{$fileLang}'\n"; + echo "\n"; + + $rc = 1; + if( ($cntLang == 0) && ($cntBase==0) ) { + echo "OK. Files seem to be up to date.\n"; + $rc = 0; + } else { + if( $cntLang > 0 ) { + printf( "%4d missing strings.\n", $cntLang ); + } + + if( $cntBase > 0 ) { + printf("%4d orphaned strings.\n", $cntBase ); + } + } + + echo "\n"; + + exit($rc); diff --git a/app/build.gradle b/app/build.gradle index 803e50c8b..c0115a2ba 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -134,8 +134,4 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' -} - - - - +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index a34d788f6..d59537f63 100755 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { versionCode = 200 versionName = "2.0-beta" packageName = "com.itsaky.androidide" - + javaSourceVersion = JavaVersion.VERSION_11 javaTargetVersion = JavaVersion.VERSION_11 } @@ -17,9 +17,9 @@ buildscript { google() mavenLocal() mavenCentral() - maven { url 'https://jitpack.io'} + maven { url 'https://jitpack.io' } } - + dependencies { classpath 'com.android.tools.build:gradle:7.1.2' classpath 'com.google.gms:google-services:4.3.10' @@ -30,6 +30,59 @@ buildscript { subprojects { apply from: "${rootDir}/gradle/dependencies.gradle" + + task checkTranslations() { + + def php = new File ("/usr/bin/php") + if (!php.exists()) { + project.logger.lifecycle("'${php.absolutePath}' not found. Skipping translation check.") + return + } + + def resDir = project.file("src/main/res") + def strings = new File(resDir, "values/strings.xml") + def reportDir = new File(project.rootProject.buildDir, "translation-reports") + reportDir.delete() + + if (resDir.exists() && strings.exists()) { + def translationDirs = resDir.listFiles((FileFilter) (file -> { + return file.isDirectory() && file.getName().startsWith("values-") })) + for (def dir : translationDirs) { + final var translation = new File(dir, "strings.xml") + if (translation.exists()) { + def out = new File(reportDir, "${project.path.replace(':', '/')}/${dir.name}.txt") + if (!out.parentFile.exists()) { + out.parentFile.mkdirs() + } + + if (out.exists()) { + out.delete() + } + out.createNewFile() + + def result = exec { + ignoreExitValue true + standardOutput new FileOutputStream(out) + commandLine "${php.absolutePath}", + "${project.rootProject.file(".tools/strings-check.php")}", + "${strings.absolutePath}", + "${translation.absolutePath}" + } + + if (result.getExitValue() == 0) { + out.delete() + } else { + project.logger.lifecycle("Translation report for '${project.path}/${dir.name}' is written to '${out.absolutePath}'") + } + + } else { + project.logger.info("No translation file specifed for '${dir.name}'. Skipping..") + } + } + } else { + project.logger.info("Default strings.xml file does not exist for project '${project.name}'") + } + } } allprojects { @@ -37,17 +90,10 @@ allprojects { google() mavenLocal() mavenCentral() - maven { url 'https://jitpack.io'} + maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir -} - - - - - - - +} \ No newline at end of file diff --git a/build/translation-reports/app/values-de.txt b/build/translation-reports/app/values-de.txt new file mode 100644 index 000000000..381084d4a --- /dev/null +++ b/build/translation-reports/app/values-de.txt @@ -0,0 +1,79 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-de/strings.xml +------------------------- BEGIN ---------------------- +template_libgdx +template_description_libgdx +idepref_editor_ligatures_title +idepref_editor_ligatures_summary +yes +no +title_use_popup_actions +msg_use_popup_actions +title_use_horizontal_popup +msg_use_horizontal_popup +msg_apk_install_intent_failed +msg_viewaction_add_attr +msg_search_attrs +msg_attr_added +msg_attr_not_updated +hint_dimension_val +hint_dimension_res +hint_boolean_res +msg_file_tree +hint_color_resource +title_color_picker +hint_string_value +hint_string_resource +hint_resource_reference +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +title_developers +msg_developers +cancel +msg_sdk_info_load_failed +msg_no_code_actions +msg_starting_completion_failed +menu_project_info +header_module_info +msg_module_count +msg_task_count +msg_dependency_count +msg_package_name +msg_min_sdk +msg_target_sdk +show_files +msg_failed_save +idepref_build_editgradleproperties_title +idepref_build_editgradleproperties_summary +err_completion +err_no_server_implementation +err_init_server +err_cannot_save_files +err_cannot_start_server +err_cannot_write_socket +err_server_disconnected +msg_attr_edit_hint +sym_equal +msg_attr_namespace +msg_unknown_package +msg_attr_editor_select_view +msg_attr_editor_no_attrs +msg_enter_attr_value +msg_enter_dimension_value +msg_attr_editor_null +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-de/strings.xml' + + 24 missing strings. + 34 orphaned strings. + diff --git a/build/translation-reports/app/values-fr.txt b/build/translation-reports/app/values-fr.txt new file mode 100644 index 000000000..e133b4f8b --- /dev/null +++ b/build/translation-reports/app/values-fr.txt @@ -0,0 +1,94 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-fr/strings.xml +------------------------- BEGIN ---------------------- +template_kotlin_basic +template_description_kotlin_basic +template_libgdx +template_description_libgdx +title_compiler_module_install +msg_compiler_module_install +msg_compiler_module_install_failed +msg_compiler_module_installed +action_expand_selection +idepref_java_matchLower_title +idepref_editor_category_common +idepref_editor_category_java +title_files_unsaved +msg_files_unsaved +idepref_editor_autoSave_title +idepref_editor_autoSave_summary +idepref_java_matchLower_summary +idepref_editor_ligatures_title +idepref_editor_ligatures_summary +yes +no +title_use_popup_actions +msg_use_popup_actions +title_use_horizontal_popup +msg_use_horizontal_popup +msg_apk_install_intent_failed +msg_viewaction_add_attr +msg_search_attrs +msg_attr_added +msg_attr_not_updated +hint_dimension_val +hint_dimension_res +hint_boolean_res +msg_file_tree +hint_color_resource +title_color_picker +hint_string_value +hint_string_resource +hint_resource_reference +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +title_developers +msg_developers +cancel +msg_sdk_info_load_failed +msg_no_code_actions +msg_starting_completion_failed +menu_project_info +header_module_info +msg_module_count +msg_task_count +msg_dependency_count +msg_package_name +msg_min_sdk +msg_target_sdk +show_files +msg_failed_save +idepref_build_editgradleproperties_title +idepref_build_editgradleproperties_summary +err_completion +err_no_server_implementation +err_init_server +err_cannot_save_files +err_cannot_start_server +err_cannot_write_socket +err_server_disconnected +msg_attr_edit_hint +sym_equal +msg_attr_namespace +msg_unknown_package +msg_attr_editor_select_view +msg_attr_editor_no_attrs +msg_enter_attr_value +msg_enter_dimension_value +msg_attr_editor_null +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-fr/strings.xml' + + 39 missing strings. + 34 orphaned strings. + diff --git a/build/translation-reports/app/values-hi.txt b/build/translation-reports/app/values-hi.txt new file mode 100644 index 000000000..ce5e095cd --- /dev/null +++ b/build/translation-reports/app/values-hi.txt @@ -0,0 +1,21 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-hi/strings.xml +------------------------- BEGIN ---------------------- +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +cancel +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-hi/strings.xml' + + 1 orphaned strings. + diff --git a/build/translation-reports/app/values-in.txt b/build/translation-reports/app/values-in.txt new file mode 100644 index 000000000..6e71c39cd --- /dev/null +++ b/build/translation-reports/app/values-in.txt @@ -0,0 +1,21 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-in/strings.xml +------------------------- BEGIN ---------------------- +msg_fix_diagnostic +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-in/strings.xml' + + 1 missing strings. + diff --git a/build/translation-reports/app/values-ru.txt b/build/translation-reports/app/values-ru.txt new file mode 100644 index 000000000..d67cd29ca --- /dev/null +++ b/build/translation-reports/app/values-ru.txt @@ -0,0 +1,69 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-ru/strings.xml +------------------------- BEGIN ---------------------- +msg_apk_install_intent_failed +msg_viewaction_add_attr +msg_search_attrs +msg_attr_added +msg_attr_not_updated +hint_dimension_val +hint_dimension_res +hint_boolean_res +msg_file_tree +hint_color_resource +title_color_picker +hint_string_value +hint_string_resource +hint_resource_reference +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +title_developers +msg_developers +cancel +msg_sdk_info_load_failed +msg_no_code_actions +msg_starting_completion_failed +menu_project_info +header_module_info +msg_module_count +msg_task_count +msg_dependency_count +msg_package_name +msg_min_sdk +msg_target_sdk +show_files +msg_failed_save +idepref_build_editgradleproperties_title +idepref_build_editgradleproperties_summary +err_completion +err_no_server_implementation +err_init_server +err_cannot_save_files +err_cannot_start_server +err_cannot_write_socket +err_server_disconnected +msg_attr_edit_hint +sym_equal +msg_attr_namespace +msg_unknown_package +msg_attr_editor_select_view +msg_attr_editor_no_attrs +msg_enter_attr_value +msg_enter_dimension_value +msg_attr_editor_null +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-ru/strings.xml' + + 14 missing strings. + 34 orphaned strings. + diff --git a/build/translation-reports/app/values-zh.txt b/build/translation-reports/app/values-zh.txt new file mode 100644 index 000000000..0fc095cdc --- /dev/null +++ b/build/translation-reports/app/values-zh.txt @@ -0,0 +1,54 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-zh/strings.xml +------------------------- BEGIN ---------------------- +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +title_developers +msg_developers +cancel +msg_sdk_info_load_failed +msg_no_code_actions +msg_starting_completion_failed +menu_project_info +header_module_info +msg_module_count +msg_task_count +msg_dependency_count +msg_package_name +msg_min_sdk +msg_target_sdk +show_files +msg_failed_save +idepref_build_editgradleproperties_title +idepref_build_editgradleproperties_summary +err_completion +err_no_server_implementation +err_init_server +err_cannot_save_files +err_cannot_start_server +err_cannot_write_socket +err_server_disconnected +msg_attr_edit_hint +sym_equal +msg_attr_namespace +msg_unknown_package +msg_attr_editor_select_view +msg_attr_editor_no_attrs +msg_enter_attr_value +msg_enter_dimension_value +msg_attr_editor_null +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/app/src/main/res/values-zh/strings.xml' + + 34 orphaned strings. + diff --git a/build/translation-reports/common/values-in.txt b/build/translation-reports/common/values-in.txt new file mode 100644 index 000000000..b8c421fb2 --- /dev/null +++ b/build/translation-reports/common/values-in.txt @@ -0,0 +1,22 @@ + +Missing in LANG (You need to translate these) +File: /mnt/d/projects/androidstudioprojects/androidide/common/src/main/res/values-in/strings.xml +------------------------- BEGIN ---------------------- +cms_channel_id_devs +cms_channel_id_update +-------------------------- END ----------------------- + + +Not present in BASE (you need to remove it from LANG) +File: /mnt/d/projects/androidstudioprojects/androidide/common/src/main/res/values/strings.xml +------------------------- BEGIN ---------------------- +-------------------------- END ----------------------- + + +Summary +---------------- +BASE file: '/mnt/d/projects/androidstudioprojects/androidide/common/src/main/res/values/strings.xml' +LANG file: '/mnt/d/projects/androidstudioprojects/androidide/common/src/main/res/values-in/strings.xml' + + 2 missing strings. +