Let's make a step towards the growing strace userbase all around
the world and translate something to the language of their choice.

This change enables translation of error messages corresponding
to errno codes, e.g.

$ LANG=fr_FR strace -P /missing rm -f /missing
newfstatat(AT_FDCWD, "/missing", 0x615478, AT_SYMLINK_NOFOLLOW) = -1 ENOENT 
(Aucun fichier ou dossier de ce type)
unlinkat(AT_FDCWD, "/missing", 0)       = -1 ENOENT (Aucun fichier ou dossier 
de ce type)

Subsequent changes may extend i18n support further by implementing
translation of other strings, e.g. syscall names and symbolic constants.

* strace.c: Include <locale.h>.
(main): Call setlocale.
* tests/init.sh: Export LC_ALL=C.
---
 strace.c      | 2 ++
 tests/init.sh | 1 +
 2 files changed, 3 insertions(+)

diff --git a/strace.c b/strace.c
index 7214e6e..3791c3f 100644
--- a/strace.c
+++ b/strace.c
@@ -39,6 +39,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <dirent.h>
+#include <locale.h>
 #include <sys/utsname.h>
 #ifdef HAVE_PRCTL
 # include <sys/prctl.h>
@@ -2488,6 +2489,7 @@ restart_tracee:
 int
 main(int argc, char *argv[])
 {
+       setlocale(LC_ALL, "");
        init(argc, argv);
 
        exit_code = !nprocs;
diff --git a/tests/init.sh b/tests/init.sh
index e190797..f9ce08c 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -25,6 +25,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+export LC_ALL=C
 ME_="${0##*/}"
 LOG="$ME_.tmp"
 OUT="$LOG.out"

-- 
ldv

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to