Important: Please read the Qt Code of Conduct -

Translating Into Russian on a milti-window platform

  • Hello,

    Im An entry level programmer and new to QT too. I have a project where i am hard coding my programing into a three diffrent languages. I am having an issue on figuring out how to hard code Russian instead of letters i get ?????.

    my code is broken down into FR.h
    Russian.h ->i understand the others use a latin codec but russian doesnt
    english.h example bellow of how files look-each word is defined
    @#ifndef EN_H
    #define EN_H

    #define TR_PRG_EN "Program"
    #define TR_HELP_EN "Help"
    #define TR_PASSRW_EN "Pass: R/W"
    #define TR_ALLOWWRITE_EN "Allow Write"
    #define TR_SERIAL_EN "Serial #"
    #define TR_ALLOWREAD_EN "Allow Read"
    #define TR_PRO_EN "Product #"
    #define TR_MEMSIZE_EN "Mem. Size"
    #define TR_TRIP_EN "Trip #"
    #define TR_RANGE_EN "Range"
    #define TR_DESCR_EN "Description"
    #define TR_LOGSET_EN "Logger Settings"
    #define TR_INTTEMP_EN "Int. Temp (NTC)"
    #define TR_HHIGH_EN "HHigh(°F)"
    #define TR_HIGH_EN "High(°F)"
    #define TR_LOW_EN "Low(°F)"
    #define TR_LLOW_EN "LLow(°F)"@

    with russian.h
    @#ifndef RU_H
    #define RU_H

    #define TR_ENCODING "utf-8"
    #define TR_PRG_RU "??????????"
    #define TR_HELP_RU "Help"
    #define TR_PASSRW_RU "?????????"
    #define TR_ALLOWWRITE_RU "????????"
    #define TR_SERIAL_RU "???????? #"
    #define TR_ALLOWREAD_RU "????????? ??????"
    #define TR_PRO_RU "??????? #"
    #define TR_MEMSIZE_RU "?????? ?????? "
    #define TR_TRIP_RU "??????? #"
    #define TR_RANGE_RU "????????"
    #define TR_DESCR_RU "????????"@

    i then have Clang.cpp(class,with.h file) file which i put the words into a Qlist<qlist<qstringlist>>(2d array)->below is an example

    const char *trL[NB_LAN]={TR_L_EN,TR_L_FR,TR_L_SP,TR_L_IT,TR_L_RU,TR_L_GR,TR_L_PR};
    const char *trH[NB_LAN]={TR_H_EN,TR_H_FR,TR_H_SP,TR_H_IT,TR_H_RU,TR_H_GR,TR_H_PR};
    for(int i=0;i<NB_LAN;i++)

        strTab << QStringList();
        strTab[i] << trPrg[i];            //m_tabLogger
        strTab[i] << trHelp[i];           //m_textBrowserHelp
        strTab[i] << trPassrw[i];         //label_13
        strTab[i] << trAllowWrite[i];     //m_checkBoxLoggerAllowWrite
        strTab[i] << trSerial[i];         //label_2
        strTab[i] << trAllowRead[i];      //m_checkBoxLoggerAllowRead
        strTab[i] << trPro[i];            //label_3
        strTab[i] << trMemSize[i];        //label_5
        strTab[i] << trTrip[i];           //label_6@

    then i call it in the main window , so my question how do i make the russian language show the letters
    another question i have is i mulitple windows how do i call these translations on those different windows

  • Please check out how to do internationalization properly:
    The way you do it is just... well... suboptimal.

    PS: The reason why you get strange characters is that your code file is probably in a different encoding (UTF-8, ISO-xxxx,...) than what the according display functions expect. But don't fix that, throw away your internationalization code and do it like described in the article above. It will be much easier for you and your translators (if that's also you, then it will be easier for you quadratically!)

Log in to reply