I have a program here, that depends on the output of netstat. More concrete: netstat -apn.Here is an example of a normal output.Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program nametcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -A client of mine has some other output (as an example):Proto Recv-Q Send-Q Endereo Local          Endereo Remoto         Estado      PID/Program nametcp        0      0 0.0.0.0:111             0.0.0.0:*               OUA       -I want to test my software with a changed output of netstat, like the output of the client. So the question is: What should I do to change the output language of netstat, so I can reproduce the errors, the client gets?I already tried to change the language with export LANG=pt_PT, but the output didn't change.
Language in netstat output
locale;netstat
First you need to make sure that your machine has the necessary locale set up. You can see available locales with locale -a. For example, on my system:$ locale -aCC.UTF-8el_GR.utf8en_US.utf8fr_FR.utf8POSIXAs you can see above, I don't have the Portuguese locale. On my Debian, I can create it by running sudo dpkg-reconfigure locales, and choosing the relevant locale:Package configuration                                                             Configuring locales     Locales are a framework to switch between multiple languages and allow        users to use their language, country, characters, collation order, etc.                                                                                     Please choose which locales to generate. UTF-8 locales should be chosen       by default, particularly for new installations. Other character sets may      be useful for backwards compatibility with older systems and software.                                                                                      Locales to be generated:                                                                                                                                       [ ] pt_BR.UTF-8 UTF-8                                                        [ ] pt_PT ISO-8859-1                                                         [*] pt_PT.UTF-8 UTF-8                                                        [ ] pt_PT@euro ISO-8859-15                                                   [ ] quz_PE UTF-8                                                                                                                                                                                                                                         <Ok>                        <Cancel>                                                                                                      After hitting Enter, you should get:$ sudo dpkg-reconfigure localesGenerating locales (this might take a while)...  el_GR.UTF-8... done  en_US.UTF-8... done  fr_FR.UTF-8... done  pt_PT.UTF-8... doneGeneration complete.If you are not using a Debian-based distribution, you will need to do this manually:Add the relevant locale name to /etc/locale.gen. For example:pt_PT.UTF-8 UTF-8Run locale-genAfter the above steps (either the manual approach or the dpkg-reconfigre locales one), locale -a will also list the Portuguese locale:$ locale -aCC.UTF-8el_GR.utf8en_US.utf8fr_FR.utf8POSIXpt_PT.utf8Now, you can choose what language output is displayed in:$ LC_ALL=el_GR.utf8 date 14  2015 12:34:28  EEST$ LC_ALL=fr_FR.utf8 datemercredi 14 octobre 2015, 12:35:07 (UTC+0300)$ LC_ALL=pt_PT.utf8 dateQua Out 14 12:35:11 EEST 2015However, whether or not a particular program is capable of printing output in the selected locale will depend on whether it has been translated; on whether the package ships with the relevant .mo translation file. In the case of netstat, this is /usr/share/locale/${LANG%_*}/LC_MESSAGES/net-tools.mo. On my Debian, the French locale has it but the Portuguese one does not:$ ls /usr/share/locale/{fr,pt}/LC_MESSAGES/net*ls: cannot access /usr/share/locale/pt/LC_MESSAGES/net*: No such file or directory/usr/share/locale/fr/LC_MESSAGES/net-tools.moThis is why I can run netstat in French:$ LC_ALL=fr_FR.utf8 netstat -apn | head -n2(Tous les processus ne peuvent tre identifis, les infos sur les processusnon possds ne seront pas affiches, vous devez tre root pour les voir toutes.)Connexions Internet actives (serveurs et tablies)Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program nameBut not in Portuguese:$ LC_ALL=pt_PT.utf8 netstat -apn | head -n2(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name