! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Some strings are not localized correctly when setting of the xdg-user-dirs-up...
Status:
RESOLVED: FIXED

Comments

Description Masato Hashimoto 2008-12-28 07:51:36 CET
When setting of the xdg-user-dirs-update ($(XDG_CONFIG_HOME)/user-dirs.local) is not same as $LANG (e.g. set the xdg-user-dirs-update to C, $LANG=ja_JP.UTF8), Thunar does not show some strings by $LANG (context menu, contents in side pane, etc... but not all and erratically).

I think that it should give priority to $LANG over setting of the xdg-user-dirs.
In the case of Japan, to set xdg-user-dirs-update to C is usual because to input Japanese characters is more troublesome than alphabet.

Thunar: 0.9.92 (svn-trunk)
Distro: Arch Linux
Comment 1 Martin Jürgens 2011-03-28 02:41:23 CEST
Created attachment 3582 
fixes clobbering setlocale() calls

I have had a the same problem with the translation falling back to "C" locale or whatever is indicated in ~/.config/user-dirs.locale. The problem seem to be 2 setlocale() calls which do not properly save (i.e. strdup()) the old locale.

The solution is derived from the example usage here: http://www.gnu.org/software/libc/manual/html_mono/libc.html#Setting-the-Locale

Patch tested with thunar-1.2.1 on Gentoo (x86_64). Should work fine on current git repository. Files are identical.

Maybe this should be fixed in plugins/thunar-uca/thunar-uca-model.c as well. But I am not sure.

This is my first real patch submit ever. Just let me know if you need anything else.
Comment 2 Samuli Suominen 2011-08-05 13:58:11 CEST
I don't want to annoy anyone but it seems this bug is still present in latest Thunar.
Comment 3 Jannis Pohlmann editbugs 2011-08-05 14:08:55 CEST
Two remarks after taking a quick look:

  1. we use g_strdup() instead of strdup()
  2. if you duplicate a string, you also need to free it (with g_free() in this case)
Comment 4 Mark Trompell 2011-08-09 12:36:56 CEST
Created attachment 3814 
proposed patch

does that patch look reasonable?
Comment 5 Mark Trompell 2011-08-09 13:46:36 CEST
Created attachment 3815 
test for NULL

maybe we need to check for NULL?
Why does thunar-shortcuts-model.c use const char * instead of gchar like in thunar-window.c?
Comment 6 Jannis Pohlmann editbugs 2011-08-10 12:24:39 CEST
(In reply to comment #5)
> Created attachment 3815 
> test for NULL
> 
> maybe we need to check for NULL?

Nope, we don't have to. g_strdup() and g_free() handle NULL just fine.

> Why does thunar-shortcuts-model.c use const char * instead of gchar like in
> thunar-window.c?

"gchar *" is correct if we want to change the content of the pointer once more after the assignment. Also, using "const gchar *" with g_free() shouldn't even compile...
Comment 7 Mark Trompell 2011-08-10 12:34:04 CEST
Created attachment 3817 
v3 of the patch

Ok, reworked the patch once more.
Thx
Comment 8 Jannis Pohlmann editbugs 2011-09-19 15:20:44 CEST
Ok, fixed in master and xfce-4.8 (see the commit message below). I also applied the g_strdup(setlocale(...)) trick to thunar-uca just to be save.

commit 594aa7b5be815a84f31a12d8ec49052865734855
Author: Jannis Pohlmann <jannis@xfce.org>
Date:   Mon Sep 19 15:11:01 2011 +0200

    Prevent falling back to an unexpected locale (bug #4746).
    
    setlocale() returns a pointer to its internal locale string, so if we
    want to store the returned string for later use, we need to duplicate
    it.
    
    Patch by Martin Jürgens<martin.accounts@gmx.de> and Mark
    Trompell<mark@foresightlinux.org>.

Bug #4746

Reported by:
Masato Hashimoto
Reported on: 2008-12-28
Last modified on: 2011-09-19

People

Assignee:
Jannis Pohlmann
CC List:
3 users

Version

Version:
unspecified

Attachments

fixes clobbering setlocale() calls (1000 bytes, patch)
2011-03-28 02:41 CEST , Martin Jürgens
no flags
proposed patch (1.46 KB, patch)
2011-08-09 12:36 CEST , Mark Trompell
no flags
test for NULL (1.85 KB, patch)
2011-08-09 13:46 CEST , Mark Trompell
no flags
v3 of the patch (1.85 KB, application/octet-stream)
2011-08-10 12:34 CEST , Mark Trompell
mark : review? ( jannis )

Additional information