Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Regenerate native Android translations on app build
Leendert de Borst027557b16d72
diff --git a/apps/mobile-app/android/app/build.gradle b/apps/mobile-app/android/app/build.gradleindex eb2172918..090a1b99e 100644--- a/apps/mobile-app/android/app/build.gradle+++ b/apps/mobile-app/android/app/build.gradle@@ -307,8 +307,17 @@ task lintCheck {dependsOn 'detekt'}+// Regenerate the native strings.xml files from core/i18n to ensure native Android translations are up to date.+def i18nDir = new File(rootDir, "../../../core/i18n").canonicalFile+task exportNativeTranslations(type: Exec) {+ description = "Generate res/values*/strings.xml from core/i18n"+ group = "build"+ commandLine "node", new File(i18nDir, "scripts/export-native.mjs").absolutePath, "--platform", "android"+}+// Add a task dependency to make ktlint run before buildtasks.named("preBuild") {+ dependsOn("exportNativeTranslations")dependsOn("lintFormat")dependsOn("lintCheck")}diff --git a/core/i18n/scripts/export-native.mjs b/core/i18n/scripts/export-native.mjsindex 6f91b762c..975ce313d 100644--- a/core/i18n/scripts/export-native.mjs+++ b/core/i18n/scripts/export-native.mjs@@ -3,8 +3,9 @@* Generates the native translation files of the mobile app (iOS .strings, Android strings.xml) from the shared* translations in core/i18n/locales, using the map in core/i18n/exports/mobile-native.json.*- * node core/i18n/scripts/export-native.mjs # write the files- * node core/i18n/scripts/export-native.mjs --check # exit 1 when a generated file is out of date+ * node core/i18n/scripts/export-native.mjs # write the files for all platforms+ * node core/i18n/scripts/export-native.mjs --check # exit 1 when a generated file is out of date+ * node core/i18n/scripts/export-native.mjs --platform android/ios # only the android or ios files, as used by the app builds** Languages are the `uiLanguages` in core/i18n/languages.json. A missing translation falls back to English.*/@@ -16,10 +17,15 @@ import { fileURLToPath } from 'node:url';const I18N_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');const REPO_ROOT = path.resolve(I18N_DIR, '../..');const CHECK = process.argv.includes('--check');+const PLATFORM = process.argv.includes('--platform') ? process.argv[process.argv.indexOf('--platform') + 1] : undefined;const GENERATED_NOTE = 'Generated from core/i18n/locales by core/i18n/scripts/export-native.mjs. Do not edit, change core/i18n instead.';const languages = JSON.parse(readFileSync(path.join(I18N_DIR, 'languages.json'), 'utf8')).uiLanguages;-const { targets } = JSON.parse(readFileSync(path.join(I18N_DIR, 'exports/mobile-native.json'), 'utf8'));+const { targets: allTargets } = JSON.parse(readFileSync(path.join(I18N_DIR, 'exports/mobile-native.json'), 'utf8'));+const targets = allTargets.filter((target) => !PLATFORM || target.platform === PLATFORM);+if (targets.length === 0) {+ throw new Error(`No targets for platform "${PLATFORM}"`);+}const locales = Object.fromEntries(languages.map((lang) => [lang, JSON.parse(readFileSync(path.join(I18N_DIR, `locales/${lang}.json`), 'utf8'))]));/**