Increased robustness of get_lang() function

svn path=/trunk/; revision=940
This commit is contained in:
Curtis Gedak 2008-10-24 15:48:25 +00:00
parent be0c53a282
commit e9c44ad13e
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2008-10-24 Curtis Gedak <gedakc@gmail.com>
* src/Utils.cc: Increased robustness of get_lang() function
- Assists with GParted bug #556965
2008-10-17 Curtis Gedak <gedakc@gmail.com> 2008-10-17 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Progress.cc: Converted more words for translation * src/Dialog_Progress.cc: Converted more words for translation

View File

@ -361,10 +361,15 @@ Glib::ustring Utils::get_lang()
//Extract base language from string that may look like "en_CA.UTF-8" //Extract base language from string that may look like "en_CA.UTF-8"
// and return in the form "en-CA" // and return in the form "en-CA"
Glib::ustring lang = setlocale( LC_CTYPE, NULL ) ; 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 sought = "_" ;
Glib::ustring replacement = "-" ; Glib::ustring replacement = "-" ;
lang = Utils::regexp_label( lang .c_str(), "^([^.]*)") ;
lang .replace( lang .find(sought), sought .size(), replacement ) ; lang .replace( lang .find(sought), sought .size(), replacement ) ;
return lang ; return lang ;
} }