Search code examples
configgnupg

Changing the output language of gpg2.exe


I am automating a process and I use GPG2.exe for it. Because I need to parse console output - potentially from different systems I need to set the languge to a controlled value.

I am following the Instructions from the manual which states that

LANGUAGE
Apart from its use by GNU, it is used in the W32 version to override the language selection done through the Registry. If used and set to a valid and available language name (langid), the file with the translation is loaded from gpgdir/gnupg.nls/langid.mo. Here gpgdir is the directory out of which the gpg binary has been loaded. If it can’t be loaded the Registry is tried and as last resort the native Windows locale system is used.

I found a thread from 2011 that goes into a bit more detail regarding this problem, but this may actaully concern a different version.

I created a batch file for manual testing.

@echo off
REM C is meant to display untranslated messages according to one internet source
set LANGUAGE="C"
call "C:\Program Files (x86)\GNU\GnuPG\gpg2.exe" --version
pause

I ecpext the output to be english but it is still german.

enter image description here

The manual states something about there beegin a "gnupg.nls" folder somewhere. I was not able to locate this folder, which makes me wonder where german is loaded from. Is there an error in the man page? The pdf Version of the man page shows the same content as the man page that came with the installation.

Can someone shed some light on this?


Solution

  • This isn't a programming question, as noted in the votes to close.

    To answer a different question that could be asked from a programming perspective: Don't parse inherently-changeable console output, when there is a well-defined library API for the same functionality.