-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1429 from headlamp-k8s/revamp-i18n
Add tools and more tests for translations
- Loading branch information
Showing
11 changed files
with
267 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"About": "Über", | ||
"Quit": "Beenden", | ||
"Select All": "Alles auswählen", | ||
"Delete": "Löschen", | ||
"Services": "Dienste", | ||
"Hide": "Ausblenden", | ||
"Hide Others": "Andere ausblenden", | ||
"Show All": "Alle anzeigen", | ||
"File": "Datei", | ||
"Close": "Schließen", | ||
"Edit": "Bearbeiten", | ||
"Cut": "Ausschneiden", | ||
"Copy": "Kopieren", | ||
"Paste": "Einfügen", | ||
"Paste and Match Style": "Einfügen und Stil anpassen", | ||
"Speech": "Sprache", | ||
"Start Speaking": "Sprechen starten", | ||
"Stop Speaking": "Sprechen stoppen", | ||
"View": "Ansicht", | ||
"Reload": "Neu laden", | ||
"Toggle Developer Tools": "Entwicklertools umschalten", | ||
"Reset Zoom": "Zoom zurücksetzen", | ||
"Zoom In": "Vergrößern", | ||
"Zoom Out": "Verkleinern", | ||
"Toggle Fullscreen": "Vollbild umschalten", | ||
"Window": "Fenster", | ||
"Minimize": "Minimieren", | ||
"Bring All to Front": "Alle nach vorne bringen", | ||
"Help": "Hilfe", | ||
"Documentation": "Dokumentation", | ||
"Open an Issue": "Ein Problem melden", | ||
"Invalid URL": "Ungültige URL", | ||
"Application opened with an invalid URL: {{ url }}": "Anwendung mit einer ungültigen URL geöffnet: {{ url }}", | ||
"Another process is running": "Ein anderer Prozess läuft", | ||
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Es sieht so aus, als ob bereits ein anderer Prozess läuft. Fortfahren, indem Sie diesen Prozess automatisch beenden, oder beenden?", | ||
"Continue": "Weiter", | ||
"Failed to quit the other running process": "Konnte den anderen laufenden Prozess nicht beenden", | ||
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Konnte den anderen laufenden Prozess nicht beenden, PIDs: {{ process_list }}. Bitte stoppen Sie diesen Prozess und starten Sie die App neu." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"About": "À propos", | ||
"Quit": "Quitter", | ||
"Select All": "Tout sélectionner", | ||
"Delete": "Supprimer", | ||
"Services": "Services", | ||
"Hide": "Masquer", | ||
"Hide Others": "Masquer les autres", | ||
"Show All": "Tout afficher", | ||
"File": "Fichier", | ||
"Close": "Fermer", | ||
"Edit": "Éditer", | ||
"Cut": "Couper", | ||
"Copy": "Copier", | ||
"Paste": "Coller", | ||
"Paste and Match Style": "Coller et adapter le style", | ||
"Speech": "Parole", | ||
"Start Speaking": "Commencer à parler", | ||
"Stop Speaking": "Arrêter de parler", | ||
"View": "Vue", | ||
"Reload": "Recharger", | ||
"Toggle Developer Tools": "Basculer les outils de développement", | ||
"Reset Zoom": "Réinitialiser le zoom", | ||
"Zoom In": "Zoomer", | ||
"Zoom Out": "Dézoomer", | ||
"Toggle Fullscreen": "Basculer en plein écran", | ||
"Window": "Fenêtre", | ||
"Minimize": "Minimiser", | ||
"Bring All to Front": "Tout ramener au premier plan", | ||
"Help": "Aide", | ||
"Documentation": "Documentation", | ||
"Open an Issue": "Ouvrir un problème", | ||
"Invalid URL": "URL invalide", | ||
"Application opened with an invalid URL: {{ url }}": "Application ouverte avec une URL invalide : {{ url }}", | ||
"Another process is running": "Un autre processus est en cours", | ||
"Looks like another process is already running. Continue by terminating that process automatically, or quit?": "Il semble qu'un autre processus soit déjà en cours. Continuer en terminant ce processus automatiquement, ou quitter ?", | ||
"Continue": "Continuer", | ||
"Failed to quit the other running process": "Échec de la fermeture de l'autre processus en cours", | ||
"Could not quit the other running process, PIDs: {{ process_list }}. Please stop that process and relaunch the app.": "Impossible de quitter l'autre processus en cours, PIDs : {{ process_list }}. Veuillez arrêter ce processus et relancer l'application." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// This script copies the translations from a translations file to an existing file. | ||
// By default, it 1) only overwrites translations that are missing or are empty, in the destination file, | ||
// and 2) only copies translations that are in the destination file. | ||
// You can use the --force option to overwrite translations that are not empty in the destination file. | ||
// You can use the --all option to copy all translations, even if they are not in the destination file. | ||
|
||
const fs = require('fs'); | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.command('$0 <srcFile> <destFile>', 'Process a translations file', yargs => { | ||
yargs.positional('srcFile', { | ||
describe: 'Path to the translations file to copy translations from', | ||
demandOption: true, | ||
type: 'string', | ||
}); | ||
yargs.positional('destFile', { | ||
describe: 'Path to the translations file to copy translations into', | ||
demandOption: true, | ||
type: 'string', | ||
}); | ||
}) | ||
.option('force', { | ||
alias: 'f', | ||
type: 'boolean', | ||
default: false, | ||
describe: 'Force overwrite non-empty values', | ||
}) | ||
.option('all', { | ||
alias: 'a', | ||
type: 'boolean', | ||
default: false, | ||
describe: 'Copy all translations, even if they are not in the destination file', | ||
}) | ||
.version(false).argv; | ||
|
||
const src = fs.readFileSync(argv.srcFile, 'utf8'); | ||
const dest = fs.readFileSync(argv.destFile, 'utf8'); | ||
|
||
const srcData = JSON.parse(src); | ||
const destData = JSON.parse(dest); | ||
const copyAll = argv.all; | ||
let isChanged = false; | ||
|
||
for (const key in srcData) { | ||
if ( | ||
(!!srcData[key] || copyAll) && | ||
(destData.hasOwnProperty(key) || argv.all) && | ||
(!destData[key] || argv.force) | ||
) { | ||
isChanged = true; | ||
destData[key] = srcData[key]; | ||
} | ||
} | ||
|
||
if (!isChanged) { | ||
console.log('No translations copied.'); | ||
process.exit(0); | ||
} | ||
|
||
// Write the updated destData back to the file | ||
fs.writeFileSync(argv.destFile, JSON.stringify(destData, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This script copies the empty translations from a translations file to a new file. So they can | ||
// be easily spotted and translated. | ||
// | ||
// Usage: node extract-empty-translations.js <translationsFile> [-o <outputFile>] | ||
// Example (creates a ./src/i18n/locales/de/translations_empty.json file): | ||
// node extract-empty-translations.js ./src/i18n/locales/de/translations.json | ||
|
||
const fs = require('fs'); | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.command('$0 <translationsFile>', 'Process a translations file', yargs => { | ||
yargs.positional('translationsFile', { | ||
describe: 'Path to the translations file', | ||
type: 'string', | ||
}); | ||
}) | ||
.option('outputFile', { | ||
alias: 'o', | ||
type: 'string', | ||
describe: 'Path to the output file', | ||
}) | ||
.version(false).argv; | ||
|
||
const translations = fs.readFileSync(argv.translationsFile, 'utf8'); | ||
const translationsData = JSON.parse(translations); | ||
|
||
// Extract the keys with empty values | ||
const emptyKeys = Object.keys(translationsData).filter(key => translationsData[key] === ''); | ||
|
||
// Create an object with the empty keys and empty values | ||
const emptyTranslationsData = emptyKeys.reduce((obj, key) => { | ||
obj[key] = ''; | ||
return obj; | ||
}, {}); | ||
|
||
// If an output file is specified, write the data to the file | ||
if (Object.keys(emptyTranslationsData).length === 0) { | ||
console.log('No missing translations found.'); | ||
process.exit(0); | ||
} | ||
|
||
const outputFileName = | ||
argv.outputFile || | ||
argv.translationsFile.slice(0, argv.translationsFile.lastIndexOf('.')) + '_empty.json'; | ||
// Write the empty translations data to the output file | ||
fs.writeFileSync(outputFileName, JSON.stringify(emptyTranslationsData, null, 2)); | ||
|
||
console.log(`Created ${outputFileName}`); |