improve translation tests

This commit is contained in:
KraXen72
2024-06-10 21:40:43 +02:00
parent 2aa11d7a07
commit 23dfc7ff15
2 changed files with 25 additions and 1 deletions
@@ -0,0 +1,24 @@
const fs = require('fs');
const path = require('path');
const messagesFolder = path.resolve(__dirname, '../src/i18n_messages');
for (const file of fs.readdirSync(messagesFolder)) {
const filePath = path.join(messagesFolder, file);
const content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('${')) {
const index = line.indexOf('${');
const neighborValue = 10
const neighbor = line
.trim()
.slice(
Math.max(0, index - neighborValue),
Math.min(line.length, index + neighborValue),
)
console.log(`${filePath}(${i+1},${index+1}): Likely incorrect placeholder selector \$\{\}: ...${neighbor}...`);
}
}
}
+1 -1
View File
@@ -12,10 +12,10 @@
"lint": "eslint .",
"start": "npx react-native start",
"test": "jest",
"test:i18n": "node __tests__/missingTranslations.js && node __tests__/incorrectTranslationPlaceholders.js",
"adb": "adb devices && adb reverse tcp:9090 tcp:9090 && adb reverse tcp:3000 tcp:3000 && adb reverse tcp:9001 tcp:9001 && adb reverse tcp:8081 tcp:8081",
"adb:unreverse": "adb devices && adb reverse --remove-all",
"adb:inspect": "adb shell input keyevent 82",
"i18n:missing": "node __tests__/missingTranslations.js",
"postinstall": "patch-package --exclude 'nothing'"
},
"dependencies": {