After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 710412 - bogus locale encoding appended
bogus locale encoding appended
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Region & Language
3.10.x
Other OpenBSD
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-17 19:15 UTC by Antoine Jacoutot
Modified: 2014-10-29 14:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
do not add a codeset specifier (1.34 KB, patch)
2013-10-26 13:00 UTC, Antoine Jacoutot
rejected Details | Review
languages: Use a more broadly compatible locale codeset suffix (2.43 KB, patch)
2014-01-20 21:55 UTC, Rui Matos
reviewed Details | Review
Use 'UTF-8' instead of 'utf8' as locale codeset suffix (4.27 KB, patch)
2014-01-20 21:56 UTC, Rui Matos
committed Details | Review
languages: Use a more broadly compatible locale codeset suffix v2 (4.09 KB, patch)
2014-04-11 19:07 UTC, Antoine Jacoutot
needs-work Details | Review
cc-common-language.c: Remove a bunch of unused code (14.91 KB, patch)
2014-04-14 13:38 UTC, Rui Matos
committed Details | Review
cc-common-language.c: Don't check if we have translations here (1.83 KB, patch)
2014-04-14 13:39 UTC, Rui Matos
committed Details | Review
languages: Use a more broadly compatible locale codeset suffix (2.80 KB, patch)
2014-04-14 13:46 UTC, Rui Matos
committed Details | Review

Description Antoine Jacoutot 2013-10-17 19:15:28 UTC
Hi.

Is there any reason to a codeset specifier to locale names?
The encoding part of a locale is optional and locale normalisation is
already done by the gnome-desktop library, and adding something here
gets in the way of that.

On OpenBSD this leads to warnings like this when entering the Users capplet:
(gnome-control-center:30413): GnomeDesktop-WARNING **: locale 'en_US.UTF-8.utf8' isn't valid

Is there any reason to do what is currently done; is it needed on Linux
for some reason?

This patch fixes the issue for me. I did not git-format it because I
want to make sure I am not missing something obvious here and would love
to get some feedback on that idea...
Thanks for looking.

--- panels/common/cc-common-language.c.orig	Thu Oct 17 18:09:54 2013
+++ panels/common/cc-common-language.c	Thu Oct 17 18:24:50 2013
@@ -601,11 +601,7 @@ insert_language (GHashTable *ht,
 
         g_debug ("We have translations for %s", lang);
 
-        if (g_str_has_suffix (lang, ".utf8"))
-                key = g_strdup (lang);
-        else
-                key = g_strdup_printf ("%s.utf8", lang);
-
+        key = g_strdup (lang);
         label_own_lang = gnome_get_language_from_locale (key, key);
         label_current_lang = gnome_get_language_from_locale (key, NULL);
         label_untranslated = gnome_get_language_from_locale (key, "C");
Comment 1 Antoine Jacoutot 2013-10-26 13:00:59 UTC
Created attachment 258173 [details] [review]
do not add a codeset specifier

Any thoughts on that? git-format patch added.
Comment 2 Rui Matos 2013-10-26 13:06:15 UTC
See bug 709272
Comment 3 Antoine Jacoutot 2013-10-26 13:15:25 UTC
(In reply to comment #2)
> See bug 709272

Thanks Rui, I missed it somehow.

*** This bug has been marked as a duplicate of bug 709272 ***
Comment 4 Antoine Jacoutot 2013-10-26 15:56:36 UTC
Hmm actually, while related, the issue is different here, reopening.
Comment 5 Antoine Jacoutot 2013-10-29 11:27:50 UTC
So now that https://bugzilla.gnome.org/show_bug.cgi?id=709272 has been committed, wouldn't it make sense to use this patch as well?
Thanks.
Comment 6 Antoine Jacoutot 2013-11-14 10:25:41 UTC
It would be nice to have some inputs guys... ;-)
Comment 7 Rui Matos 2014-01-20 21:52:28 UTC
Review of attachment 258173 [details] [review]:

This unfortunately doesn't work. We really need the suffix here because the keys on this hash table need to be compared with the return of gnome_get_all_locales() which always returns with the suffix. And we need the suffix _there_ because we use those locale strings to set your session and/or system locale and you definitely don't want a non-UTF-8 locale if you can avoid it.

I'm going to attach a couple of patches which make UTF-8 be the preferred suffix instead, seeing as that seems to work both on OpenBSD and GNU libc.
Comment 8 Rui Matos 2014-01-20 21:55:59 UTC
Created attachment 266811 [details] [review]
languages: Use a more broadly compatible locale codeset suffix

At least OpenBSD's libc doesn't accept 'utf8' as a locale codeset
suffix but does accept 'UTF-8'. Since GNU libc accepts both suffixes
let's use the one which works on a broader set of systems.

--

The normalization done here isn't of course what we were doing but do
we care about any other codesets?
Comment 9 Rui Matos 2014-01-20 21:56:22 UTC
Created attachment 266812 [details] [review]
Use 'UTF-8' instead of 'utf8' as locale codeset suffix

This makes us work on OpenBSD's libc. GNU libc accepts both suffixes.
Comment 10 Bastien Nocera 2014-01-21 06:37:16 UTC
Review of attachment 266812 [details] [review]:

::: panels/common/cc-common-language.c
@@ +752,3 @@
+
+                if (!codeset || !g_str_equal (codeset, "UTF-8"))
+                        g_warning ("Current user locale codeset isn't UTF-8");

That shouldn't be a warning. We still support other locales, and if I want to run my system in fr_FR.ISO-8859-15 it should be able to.
Comment 11 Bastien Nocera 2014-01-21 06:45:53 UTC
Review of attachment 266811 [details] [review]:

::: libgnome-desktop/gnome-languages.c
@@ -112,1 @@
-        return normalized_codeset;

This will stop normalising things like ISO-88590-15 as a codeset, is that expected?
Comment 12 Rui Matos 2014-01-21 14:52:25 UTC
(In reply to comment #10)
> Review of attachment 266812 [details] [review]:
> 
> ::: panels/common/cc-common-language.c
> @@ +752,3 @@
> +
> +                if (!codeset || !g_str_equal (codeset, "UTF-8"))
> +                        g_warning ("Current user locale codeset isn't UTF-8");
> 
> That shouldn't be a warning.

Sure, I'll remove that.

> We still support other locales, and if I want to
> run my system in fr_FR.ISO-8859-15 it should be able to.

I don't know all the ramifications of this, I admit. I guess most apps will run fine, sure.

My big concern is what we present to users. I definitely don't think presenting users with a list of languages like:

...
French (France)
French (France) [ISO-8859-15]
...

is something we want. Which means we have to standardize on a codeset. In fact, gnome-languages.c has always enforced this[1], i.e. when you query the list of locales with gnome_get_all_locales() it will *only* return UTF-8 locales.

So yeah, in practice, using GNOME UI, you can't set a non-UTF-8 locale and I think that's perfectly fine and in fact the only sane thing to do.


[1] see add_locale(), it takes a boolean utf8_only argument which is always TRUE[2]. It was like that already when I moved the code to gnome-desktop.

[2] yeah, I think I should clean that up and just remove that argument...
Comment 13 Rui Matos 2014-01-21 14:55:20 UTC
(In reply to comment #11)
> Review of attachment 266811 [details] [review]:
> 
> ::: libgnome-desktop/gnome-languages.c
> @@ -112,1 @@
> -        return normalized_codeset;
> 
> This will stop normalising things like ISO-88590-15 as a codeset, is that
> expected?

Yes it's expected. With the way things work currently I can't see it breaking anything.
Comment 14 Antoine Jacoutot 2014-01-21 16:35:36 UTC
(In reply to comment #9)
> Created an attachment (id=266812) [details] [review]
> Use 'UTF-8' instead of 'utf8' as locale codeset suffix
> 
> This makes us work on OpenBSD's libc. GNU libc accepts both suffixes.

Hi Rui.

When running with only the gnome-cc patch, all is fine.
If I add up the gnome-desktop patch I am getting this:
(gnome-control-center:10930): GnomeDesktop-WARNING **: locale 'Pig.ISO8859-1.UTF-8' isn't valid

And gnome-cc core dumps.
  • #0 construct_language_name
    from /usr/local/lib/libgnome-desktop-3.so.2.0
  • #0 construct_language_name
    from /usr/local/lib/libgnome-desktop-3.so.2.0
  • #1 add_locale
    from /usr/local/lib/libgnome-desktop-3.so.2.0
  • #2 collect_locales
    from /usr/local/lib/libgnome-desktop-3.so.2.0
  • #3 gnome_get_language_from_locale
    from /usr/local/lib/libgnome-desktop-3.so.2.0
  • #4 gd_notification_new
    from /usr/local/bin/gnome-control-center
  • #5 cc_common_language_get_initial_languages
    from /usr/local/bin/gnome-control-center
  • #6 cc_common_language_add_user_languages
    from /usr/local/bin/gnome-control-center
  • #7 cc_user_panel_get_type
    from /usr/local/bin/gnome-control-center
  • #8 cc_user_panel_get_type
    from /usr/local/bin/gnome-control-center
  • #9 _g_closure_invoke_va
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #10 g_signal_emit_valist
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #11 g_signal_emit
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #12 gtk_tree_selection_select_path
    from /usr/local/lib/libgtk-3.so.1000.0
  • #13 gtk_tree_selection_select_iter
    from /usr/local/lib/libgtk-3.so.1000.0
  • #14 cc_user_panel_get_type
    from /usr/local/bin/gnome-control-center
  • #15 cc_user_panel_get_type
    from /usr/local/bin/gnome-control-center
  • #16 g_closure_invoke
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #17 signal_emit_unlocked_R
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #18 g_signal_emit_valist
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #19 g_signal_emit
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #20 g_object_dispatch_properties_changed
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #21 g_object_notify
    from /usr/local/lib/libgobject-2.0.so.3800.0
  • #22 on_get_sessions_finished
    from /usr/local/lib/libaccountsservice.so.0.0
  • #23 g_simple_async_result_complete
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #24 reply_cb
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #25 g_simple_async_result_complete
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #26 g_dbus_connection_call_done
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #27 g_simple_async_result_complete
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #28 complete_in_idle_cb
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #29 g_main_context_dispatch
    from /usr/local/lib/libglib-2.0.so.3800.0
  • #30 g_main_context_iterate
    from /usr/local/lib/libglib-2.0.so.3800.0
  • #31 g_main_context_iteration
    from /usr/local/lib/libglib-2.0.so.3800.0
  • #32 g_application_run
    from /usr/local/lib/libgio-2.0.so.3800.0
  • #33 main
    from /usr/local/bin/gnome-control-center

Comment 15 Antoine Jacoutot 2014-04-11 14:39:58 UTC
Hi guys.

I think you should go ahead with these patches if you think they are fine for Linux as well. The issue I mentioned is OpenBSD specific and will eventually be fixed there.

Thanks.
Comment 16 Antoine Jacoutot 2014-04-11 19:07:14 UTC
Created attachment 274127 [details] [review]
languages: Use a more broadly compatible locale codeset suffix v2

Actually this new patch for gnome-desktop fixes *all* issues I've been seeing on OpenBSD (along with your gnome-cc patch). I regened the patch using git-format so it comes with my name on it -- if this ever goes in, please amend it to drop me and take credit for it as well as Stefan Sperling (our locale guy) who came up with the modified patch.

I hope this is OK for you guys, it would bring me one step closer to have a working jhbuild run on OpenBSD...
Thank you.
Comment 17 Rui Matos 2014-04-14 13:38:25 UTC
Created attachment 274269 [details] [review]
cc-common-language.c: Remove a bunch of unused code

--

Lots of dead code in this file. This patch isn't stricly needed.
Comment 18 Rui Matos 2014-04-14 13:39:48 UTC
Created attachment 274270 [details] [review]
cc-common-language.c: Don't check if we have translations here

The list of locales returned from gnome_get_all_locales() already
filters out the locales for which we don't have translations so this
is a redundant check since users of get_initial_languages() only show
a language if it exists in gnome_get_all_locales() .

In fact, this code stopped working correctly since we started passing
locales including the codeset suffix to insert_language() because the
translation directories usually don't include the suffix and we
weren't stripping the suffix here.
--

This one is needed if we go forward with attachment 266812 [details] [review] .
Comment 19 Rui Matos 2014-04-14 13:44:29 UTC
Review of attachment 274127 [details] [review]:

::: libgnome-desktop/gnome-languages.c
@@ +401,3 @@
                 name = g_strdup (language_name);
         } else if (utf8_only) {
+                name = g_strdup_printf ("%s.UTF-8", language_name);

this is leaked.

@@ +415,2 @@
                 }
+                return FALSE;

this should be: else { return FALSE; }
Comment 20 Rui Matos 2014-04-14 13:46:22 UTC
Created attachment 274272 [details] [review]
languages: Use a more broadly compatible locale codeset suffix

--

Antoine can you test this one? Your patch had some thinkos as I
pointed out.
Comment 21 Antoine Jacoutot 2014-04-14 17:23:12 UTC
> Antoine can you test this one? Your patch had some thinkos as I
> pointed out.

Hi Rui. This one works just fine, thanks :-)

Regarding your gnome-cc patches, you left out the chunk in panels/region/cc-input-chooser.c, was it on purpose?
Comment 22 Rui Matos 2014-04-14 19:23:45 UTC
(In reply to comment #21)
> Regarding your gnome-cc patches, you left out the chunk in
> panels/region/cc-input-chooser.c, was it on purpose?

You mean

-          gchar *locale = g_strdup_printf ("%s_%s.utf8", lang_code, country_code);
+          gchar *locale = g_strdup_printf ("%s_%s.UTF-8", lang_code, country_code);

? Yes this is on purpose. We're changing everything to use UTF-8, right?
Comment 23 Antoine Jacoutot 2014-04-14 20:02:50 UTC
> You mean
> 
> -          gchar *locale = g_strdup_printf ("%s_%s.utf8", lang_code,
> country_code);
> +          gchar *locale = g_strdup_printf ("%s_%s.UTF-8", lang_code,
> country_code);
> 
> ? Yes this is on purpose. We're changing everything to use UTF-8, right?

Indeed. I was just confused as to why we were keeping utf8 instead of moving to UTF-8.
Comment 24 Antoine Jacoutot 2014-04-19 10:14:31 UTC
Hi Rui. Any hold up on these patches?
Thanks :-)
Comment 26 Antoine Jacoutot 2014-10-25 16:54:12 UTC
Rui I'd really appreciate if you could comment on this. Thanks in advance.
Comment 27 Bastien Nocera 2014-10-29 13:28:53 UTC
Review of attachment 274272 [details] [review]:

Looks good.
Comment 28 Bastien Nocera 2014-10-29 13:29:37 UTC
Review of attachment 274270 [details] [review]:

Sure.
Comment 29 Bastien Nocera 2014-10-29 13:31:14 UTC
Review of attachment 274269 [details] [review]:

Reasoning as to why it's unused would be helpful (is it dead code? when did we stop using it?)
Comment 30 Rui Matos 2014-10-29 13:41:42 UTC
(In reply to comment #29)
> Review of attachment 274269 [details] [review]:
> 
> Reasoning as to why it's unused would be helpful (is it dead code? when did we
> stop using it?)

We stopped using them with the not-so-new-anymore design in https://git.gnome.org/browse/gnome-control-center/commit/?id=35d920f1b887fb0f1df243e4d80ef8165a4f772e .

I'll add the reference to the commit message.
Comment 31 Rui Matos 2014-10-29 14:06:03 UTC
Comment on attachment 274272 [details] [review]
languages: Use a more broadly compatible locale codeset suffix

Attachment 274272 [details] pushed as 093e0a5 - languages: Use a more broadly compatible locale codeset suffix
Comment 32 Rui Matos 2014-10-29 14:09:39 UTC
All pushed to the respective master branches.

Antoine, sorry for taking so long with this. You're of course free to
use the patches in 3.14 for OpenBSD if they work fine for yout but I
didn't want to push them upstream for that branch for fear of
regressing something.

Attachment 266812 [details] pushed as 880f9f1 - Use 'UTF-8' instead of 'utf8' as locale codeset suffix
Attachment 274269 [details] pushed as c244568 - cc-common-language.c: Remove a bunch of unused code
Attachment 274270 [details] pushed as ed273aa - cc-common-language.c: Don't check if we have translations here
Comment 33 Antoine Jacoutot 2014-10-29 14:32:40 UTC
> Antoine, sorry for taking so long with this. You're of course free to

No problem, I was already using them in 3.12 and then 3.14.

> use the patches in 3.14 for OpenBSD if they work fine for yout but I
> didn't want to push them upstream for that branch for fear of
> regressing something.

Ok.
Anyway, thanks to you and Bastien for looking at them.
Cheers!