Linux localization: check if locale exists in /usr/share/locale and bindtextdomain accordingly
This commit is contained in:
parent
2e366f8b74
commit
d8869b8b34
16
gui.cpp
16
gui.cpp
@ -5,6 +5,7 @@
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "filesystem.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
#include "resources_linux.h"
|
||||
#include "tv_rename.hpp"
|
||||
@ -18,10 +19,17 @@ int main( int argc, char **argv ) {
|
||||
|
||||
if ( setlocale( LC_ALL, "" ) == NULL )
|
||||
error( 1, errno, _( INVALID_LOCALE ).c_str() );
|
||||
if ( bindtextdomain( DOMAIN, "./locale" ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( textdomain( DOMAIN ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( FSLib::exists( "/usr/share/locale/en_US/LC_MESSAGES/tv_rename.mo" ) ) {
|
||||
if ( bindtextdomain( DOMAIN, "/usr/share/locale" ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( textdomain( DOMAIN ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
} else {
|
||||
if ( bindtextdomain( DOMAIN, "./locale" ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( textdomain( DOMAIN ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
}
|
||||
|
||||
authenticate( API_KEY );
|
||||
|
||||
|
18
main.cpp
18
main.cpp
@ -19,6 +19,8 @@ using string = std::wstring;
|
||||
#else
|
||||
|
||||
#include "resources_linux.h"
|
||||
#include <error.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
|
||||
using char_t = char;
|
||||
@ -255,9 +257,19 @@ int main
|
||||
// set console to unicode
|
||||
_setmode( _fileno( stdout ), _O_U16TEXT );
|
||||
#else
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( DOMAIN, "./locale" );
|
||||
textdomain( DOMAIN );
|
||||
if ( setlocale( LC_ALL, "" ) == NULL )
|
||||
error( 1, errno, _( INVALID_LOCALE ).c_str() );
|
||||
if ( FSLib::exists( "/usr/share/locale/en_US/LC_MESSAGES/tv_rename.mo" ) ) {
|
||||
if ( bindtextdomain( DOMAIN, "/usr/share/locale" ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( textdomain( DOMAIN ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
} else {
|
||||
if ( bindtextdomain( DOMAIN, "./locale" ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
if ( textdomain( DOMAIN ) == NULL )
|
||||
error( 1, errno, _( MEM_ALLOC_FAILED ).c_str() );
|
||||
}
|
||||
#endif
|
||||
string show{};
|
||||
std::set< int > seasons_num{};
|
||||
|
@ -250,7 +250,7 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
|
||||
menu->append( *item );
|
||||
|
||||
// File menu
|
||||
item->set_label( _( FILE ) );
|
||||
item->set_label( _( ID_FILE ) );
|
||||
item->set_submenu( *submenu );
|
||||
|
||||
// Exit item for File menu
|
||||
|
Loading…
Reference in New Issue
Block a user