Monday 23 December 2019

How to change language in a command-line software on debian


i'm using ‘exif’ on a server (Debian GNU/Linux 6.0.6 (squeeze)) and unlike on my dev computer (Mac OS X through MacPort) it runs in french :


exif -h
Utilisation: exif [OPTION...] fichier
-v, --version Display software version
-i, --ids Montre les ID plutôt que les noms des marqueurs
-t, --tag=marqueur Sélection du marqueur
--ifd=IFD Sélection de l'IFD
-l, --list-tags Liste tous les marqueurs EXIF
-|, --show-mnote Show contents of tag MakerNote
--remove Supprime le marqueur ou l'ifd
-s, --show-description Montre la description du marqueur
-e, --extract-thumbnail Extrait la vignette
-r, --remove-thumbnail Supprime la vignette
-n, --insert-thumbnail=FICHIER Insère le FICHIER comme vignette
--no-fixup Do not fix existing tags in files
-o, --output=FICHIER Write data to FILE
--set-value=STRING Value of tag
-c, --create-exif Create EXIF data if not existing
-m, --machine-readable Output in a machine-readable (tab delimited) format
-w, --width=WIDTH Width of output
-x, --xml-output Output in a XML format
-d, --debug Show debugging messages

I check my /etc/default/locale and it was


LANG=fr_FR
LANGUAGE=fr_FR:fr

which I changed in


LANG=en_EN
LANGUAGE=en_EN:en

without any consequences. Any hint on how to force this machin to execute this software in english ? Because i need to have exif-data labels in english :)


Thanks !



Answer



The /etc/default/locale file sets uhm... "global" defaults. That means, these defaults are read by any "top-level" shell when it starts up, and is then inherited by processes it runs.


Long story short, this means such defaults are applied to:



  • All daemons (programs running in background) as they're started using shell scripts located in /etc/init.d.

  • Interactive shells you run in your login session.


So merely changing that file requires a reboot.


But, as the contents of that file is just a shell script that sets a bunch of the so-called "environment variables", to effect one particular program you just have to make that program see different contents of these variables.


The simlest way to achieve this is to just put their assignment before the program to run, that is, at your shell prompt you can do:


$ LANG=en exif -h

and see exif talking to you in English (the $ character here denotes a shell prompt -- do not type it).


The second way is to make all the programs in the current shell see the new contents of the variables; this is done via "exporting" them, as @clarkw showed: an exported variable and its contents is inherited by the environment of all the processes run from the shell, so the following also works:


$ export LANG=en
$ exif -h

or


$ LANG=en
$ export LANG
$ exif -h

These environment variables are described in the locale(1) manual page.


And the last tip: do not change the contents of /etc/default/locale by hand — use the Debian way to manage it: run


# dpkg-reconfigure locales

which will first ask you which locales to compile and install (you can skip this step) and then which one to pick as the default.


Update: here's a page on the Debian wiki dedicated to locales which pretty much explains everything needed including the environment variables.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...