Created function get_lang() to retrieve language locale
svn path=/trunk/; revision=935
This commit is contained in:
parent
7c077aad2c
commit
6a28b6810a
|
@ -1,5 +1,8 @@
|
||||||
2008-10-16 Curtis Gedak <gedakc@gmail.com>
|
2008-10-16 Curtis Gedak <gedakc@gmail.com>
|
||||||
|
|
||||||
|
* include/Utils.h,
|
||||||
|
src/Utils.cc: Created function get_lang()
|
||||||
|
|
||||||
* src/main.cc: Update copyright years
|
* src/main.cc: Update copyright years
|
||||||
|
|
||||||
2008-10-15 Curtis Gedak <gedakc@gmail.com>
|
2008-10-15 Curtis Gedak <gedakc@gmail.com>
|
||||||
|
|
|
@ -141,6 +141,7 @@ public:
|
||||||
static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
|
static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
|
||||||
static Glib::ustring trim( const Glib::ustring & src, const Glib::ustring & c = " \t\r\n" ) ;
|
static Glib::ustring trim( const Glib::ustring & src, const Glib::ustring & c = " \t\r\n" ) ;
|
||||||
static Glib::ustring cleanup_cursor( const Glib::ustring & text ) ;
|
static Glib::ustring cleanup_cursor( const Glib::ustring & text ) ;
|
||||||
|
static Glib::ustring get_lang() ;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
13
src/Utils.cc
13
src/Utils.cc
|
@ -20,6 +20,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
@ -355,5 +356,17 @@ Glib::ustring Utils::cleanup_cursor( const Glib::ustring & text )
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ) ;
|
||||||
|
Glib::ustring sought = "_" ;
|
||||||
|
Glib::ustring replacement = "-" ;
|
||||||
|
lang = Utils::regexp_label( lang .c_str(), "^([^.]*)") ;
|
||||||
|
lang .replace( lang .find(sought), sought .size(), replacement ) ;
|
||||||
|
return lang ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} //GParted..
|
} //GParted..
|
||||||
|
|
Loading…
Reference in New Issue