Esempio n. 1
0
// load names depending on current locale
void init_names()
{
    std::locale loc;

    try {
        loc = std::locale("");
    }
    catch( std::exception ) {
        loc = std::locale("C");
    }

    std::string loc_name = loc.name();
    if (loc_name == "C") {
        loc_name = "en";
    }
    size_t dotpos = loc_name.find('.');
    if (dotpos != std::string::npos) {
        loc_name = loc_name.substr(0, dotpos);
    }
    // test if a local version exists
    std::string filename = FILENAMES["namesdir"] + loc_name + ".json";
    std::ifstream fin(filename.c_str(), std::ifstream::in | std::ifstream::binary);
    if (!fin.good()) {
        // if not, use "en.json"
        filename = FILENAMES["names"];
    }
    fin.close();

    load_names_from_file(filename);
}
Esempio n. 2
0
// load names depending on current locale
void init_names()
{
    std::locale loc("");
    std::string loc_name = loc.name();
    if (loc_name == "C") {
        loc_name = "en";
    }
    size_t dotpos = loc_name.find('.');
    if (dotpos != std::string::npos) {
        loc_name = loc_name.substr(0, dotpos);
    }
    // test if a local version exists
    std::string filename = "data/names/" + loc_name + ".json";
    std::ifstream fin(filename.c_str(), std::ifstream::in | std::ifstream::binary);
    if (!fin.good()) {
        // if not, use "en.json"
        filename = "data/names/en.json";
    }
    fin.close();

    load_names_from_file(filename);
}
Esempio n. 3
0
void init_names()
{
    const std::string filename = PATH_INFO::find_translated_file( "namesdir",
                                 ".json", "names" );
    load_names_from_file(filename);
}
Esempio n. 4
0
void init_names()
{
    load_names_from_file("data/names/en.json");
}
Esempio n. 5
0
void init_names()
{
    load_names_from_file(FILENAMES["names"]);
}