Translations

How to add translations

All translations are stored in the top-level translations directory.

Adding a New Language

  • Add a new json file in the translations directory with the locale code of the language you want to add translations for, e.g. fr for French.
  1. ~/minikube$ touch translations/fr.json
  2. ~/minikube$ ls translations/
  3. de.json es.json fr.json ja.json ko.json pl.json zh-CN.json
  • Run make extract from root directory to populate that file with the strings to translate in json form.
  1. ~/minikube$ make extract
  2. go run cmd/extract/extract.go
  3. Compiling translation strings...
  4. Writing to de.json
  5. Writing to es.json
  6. Writing to fr.json
  7. Writing to ja.json
  8. Writing to ko.json
  9. Writing to pl.json
  10. Writing to zh-CN.json
  11. Done!
  • Add translated strings to the json file as the value of the map where the English phrase is the key.
  1. ~/minikube$ head translations/fr.json
  2. {
  3. "\"The '{{.minikube_addon}}' addon is disabled": "",
  4. "\"{{.machineName}}\" does not exist, nothing to stop": "",
  5. "\"{{.name}}\" profile does not exist, trying anyways.": "",
  6. "'none' driver does not support 'minikube docker-env' command": "",
  7. "'none' driver does not support 'minikube mount' command": "",
  8. "'none' driver does not support 'minikube podman-env' command": "",
  9. "'none' driver does not support 'minikube ssh' command": "",
  10. "'{{.driver}}' driver reported an issue: {{.error}}": "",
  • Add the translations as the values of the map, keeping in mind that anything in double braces {{}} are variable names describing what gets injected and should not be translated.
  1. ~/minikube$ vi translations/fr.json
  2. {
  3. [...]
  4. "Amount of time to wait for a service in seconds": "",
  5. "Amount of time to wait for service in seconds": "",
  6. "Another hypervisor, such as VirtualBox, is conflicting with KVM. Please stop the other hypervisor, or use --driver to switch to it.": "",
  7. "Automatically selected the {{.driver}} driver": "Choix automatique du driver {{.driver}}",
  8. "Automatically selected the {{.driver}} driver. Other choices: {{.alternates}}": "Choix automatique du driver {{.driver}}. Autres choix: {{.alternatives}}",
  9. "Available Commands": "",
  10. "Basic Commands:": "",
  11. "Because you are using docker driver on Mac, the terminal needs to be open to run it.": "",
  12. [...]
  13. }

Adding Translations To an Existing Language

  • Run make extract to make sure all strings are up to date
  • Edit the appropriate json file in the ‘translations’ directory, in the same way as described above.

Testing translations

  • Once you have all the translations you want, save the file and rebuild the minikube from scratch to pick up your new translations:
  1. ~/minikube$ make clean
  2. rm -rf ./out
  3. rm -f pkg/minikube/assets/assets.go
  4. rm -f pkg/minikube/translate/translations.go
  5. rm -rf ./vendor
  6. ~/minikube$ make

Note: the clean is required to regenerate the embedded translations.go file

  • You now have a fresh minikube binary in the out directory. If your system locale is that of the language you added translations for, a simple out/minikube start will work as a test, assuming you translated phrases from minikube start. You can use whatever command you’d like in that way.

  • If you have a different system locale, you can override the printed language using the LC_ALL environment variable:

  1. ~/minikube$ LC_ALL=fr out/minikube start
  2. 😄 minikube v1.9.2 sur Darwin 10.14.5
  3. Choix automatique du driver hyperkit. Autres choix: docker
  4. 👍 Démarrage du noeud de plan de contrôle minikube dans le cluster minikube
  5. 🔥 Création de VM hyperkit (CPUs=2, Mémoire=4000MB, Disque=20000MB)...
  6. 🐳 Préparation de Kubernetes v1.18.0 sur Docker 19.03.8...
  7. 🌟 Installation des addons: default-storageclass, storage-provisioner
  8. 🏄 Terminé ! kubectl est maintenant configuré pour utiliser "minikube".

Last modified November 14, 2020: Fix whitespace issues in the site content markdown (ebf37ad15)