bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Gettext Mac GUI application returning wrong characters


From: Gonzalo Garramuno
Subject: Gettext Mac GUI application returning wrong characters
Date: Fri, 10 Jul 2020 11:13:09 -0300

I have an application that uses gettext / libintl for translation (to Spanish). 
 It works fine on Linux.  On macOS Catalina 10.15.5, however, it only works 
fine when the application is started command-line.  If the application is 
started from the Finder or from the Applications directory, the text is 
translated to Spanish, but the non ASCII characters are sent as two characters, 
like ~n or ´o.
My environment is Spanish.  

$ locale
LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

The code that binds the locale is the following:



namespace fs = boost::filesystem;

int main(int argc, char** argv)
{

    const char* tmp = setlocale(LC_ALL, "");

    // Create and install global locale
    try {
        std::locale::global( std::locale("") );
        // Make boost.filesystem use it
        fs::path::imbue(std::locale());
    }
    catch( const std::runtime_error& e )
    {
        std::cerr << e.what() << std::endl;
    }


    char buf[1024];
    sprintf( buf, “mrViewer%s”, mrv::version() );

    std::string program = argv[0];
    fs::path file = fs::path( program );

    file = fs::absolute( file );

    fs::path dir = file.branch_path();
    std::string path = fs::canonical( dir ).generic_string();
    path += "/share/locale";

    std::cerr << "Looking for translation in " << path << std::endl;

    bindtextdomain(buf, path.c_str() );
    textdomain(buf);

// the rest of the code….
}

I don’t know if this is a bug or something I am doing wrong on my side.  I am 
using the latest gettext from brew ( 0.20.2_1 ).


—
Gonzalo Garramuno
ggarra13@gmail.com







reply via email to

[Prev in Thread] Current Thread [Next in Thread]