From e9c44ad13e0f99c6d609ad64dbbf27ea4db609fe Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Fri, 24 Oct 2008 15:48:25 +0000 Subject: [PATCH] Increased robustness of get_lang() function svn path=/trunk/; revision=940 --- ChangeLog | 5 +++++ src/Utils.cc | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7728b06b..d9f6cded 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-10-24 Curtis Gedak + + * src/Utils.cc: Increased robustness of get_lang() function + - Assists with GParted bug #556965 + 2008-10-17 Curtis Gedak * src/Dialog_Progress.cc: Converted more words for translation diff --git a/src/Utils.cc b/src/Utils.cc index 12bc6657..5fdcc331 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -361,10 +361,15 @@ Glib::ustring Utils::get_lang() //Extract base language from string that may look like "en_CA.UTF-8" // and return in the form "en-CA" Glib::ustring lang = setlocale( LC_CTYPE, NULL ) ; + + //Strip off anything after the period "." or at sign "@" + lang = Utils::regexp_label( lang .c_str(), "^([^.@]*)") ; + + //Convert the underscore "_" to a hyphen "-" Glib::ustring sought = "_" ; Glib::ustring replacement = "-" ; - lang = Utils::regexp_label( lang .c_str(), "^([^.]*)") ; lang .replace( lang .find(sought), sought .size(), replacement ) ; + return lang ; }