News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Patches for codeblocks about internationalization

Started by heromyth, August 11, 2005, 07:57:27 AM

Previous topic - Next topic

rickg22

argh

wxMenuBar::FindMenu
int FindMenu(const wxString& title) const

There's no FindMenu(int it) :( The reason is because wxMenu is a wxEvtHandler, not a wxWindow - and therefore, it has no associated Id. It has to be found by string :-(

Solutions anyone?

takeshimiya

None of this helps?


wxMenuItem * FindItem(int id, wxMenu **menu = NULL) const

Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to.
If menu is !NULL, it will be filled with wxMenu this item belongs to

int FindItem(const wxString& itemString) const
Finds the menu item id for a menu item string.

wxString GetTitle() const
Returns the title of the menu.

wxString GetLabel(int id) const
Returns a menu item label.

int GetMenuCount() const
Get the number of menus in the menu bar

wxMenu *GetMenu(size_t pos) const
Get the menu at given position

Urxae

Now maybe I'm saying something stupid here, but wouldn't a quick fix be to just search for the translated string? Two translations of the same string should automatically be the same, right?

rickg22

Yes, but if the strings are translated the same... why didn't the menu creation work? (See previous screenshots).

Or you mean searching for the *untranslated* strings? ugh i think i got confused now.

heromyth

Suppose there has something like this:
    <label>$$compiler<label>
in a XRC file. When some programs use this XRC file to show the label, we can see this:
    $compiler

The '$$' has changed into '$'. If we change to:
    <label>$compiler<label>
Now we can see that:
   [u]c[/u]ompiler

What has happened. I have tried to look into the wxWidget manual, but got nothing.

Why I care about this. That's because I want to translate some strings in XRC files. I use utils\wxxrc.exe to get these strings. Only all the '$$'s were treated as '$'s while being translated,  my program could get the correct translations.

Maybe make wxxrc change '$$' into '$' while getting the strings, we could resolve this problem!?

rickg22

Hmmm perhaps it would be good to ask this question in the wxWidgets forums...

Urxae

Quote from: rickg22 on August 14, 2005, 03:31:24 AM
Yes, but if the strings are translated the same... why didn't the menu creation work? (See previous screenshots).

Or you mean searching for the *untranslated* strings? ugh i think i got confused now.

Oh sorry, I thought I recalled something from a Unicode thread where you mentioned something about not knowing whether to use _() or _T() when searching for menu options. I can't find it now. May have been my imagination.
Anyway, are you sure everywhere you search for menu options, they are translated when converting to Unicode (_(), not _T())?

rickg22

ACK. No, I can't remember.But those menus in particular were in the compilergcc.cpp. Altho I remember I didn't use _( in some other parts...

Luckily, we have multi-file search n replace in C::B :). The trick is knowing what string to search for... :oops:

heromyth

#23
Quote from: rickg22 on August 14, 2005, 10:56:27 AM
Hmmm perhaps it would be good to ask this question in the wxWidgets forums...

I have tested sample\xrc in wxWidget 2.6.1. There is no any problem. For example, I add then '$$' to some labels, and I can see '$$'. I add then '$' to some labels, and I can see '$'. Maybe, I should check the Code::Blocks' codes.

Now, I can sure this problem is because of Code::Blocks. Suppose we use some XRC tools like DialogBlocks to load Code::Blocks' XRC files like plugins\compilergcc\resources\advanced_compiler_options.xrc. We can see the result like the first attachemt. However, we get aonther result like the second attachment in Code::Blocks. I have checked the Code::Blocks' code, and found nothing.



[attachment deleted by admin]

heromyth

#24
Quote
I have tested sample\xrc in wxWidget 2.6.1. There is no any problem. For example, I add then '$$' to some labels, and I can see '$$'. I add then '$' to some labels, and I can see '$'. Maybe, I should check the Code::Blocks' codes.

Now, I can sure this problem is because of Code::Blocks. Suppose we use some XRC tools like DialogBlocks to load Code::Blocks' XRC files like plugins\compilergcc\resources\advanced_compiler_options.xrc. We can see the result like the first attachemt. However, we get aonther result like the second attachment in Code::Blocks. I have checked the Code::Blocks' code, and found nothing.

I think I have known the reasons. If I change the second line:
<resource>
in all XRC files in Code::Blocks to :
<resource version="2.3.0.1">

OK, all the '$$'s in labels will be shown as '$$'s, not as '$'s.

--------------------------------------------------

Here is a patch for utils\wxrc.

[attachment deleted by admin]

heromyth

#25
Quote from: heromyth on August 13, 2005, 05:04:18 PM

However, I have confronted some strang problems during the process of translation. I can't translate these words belown:


#: src\main.cpp:1057
#: src\main.cpp:1084
#: src\src-xrc.cpp:64
msgid "&File"
msgstr ""


Not because they are too difficult to be translated, but because that once I have translated them, some of the sub-menu items will disappear. For example, I have just only translated "&Project". Now you can the result in the second attachment. The first attachement should be the correct. And you can see the third attachement which shows that I just leave  "&Project" untranslated. Of course, the third is also correct.


All the problems have seemed to be fixed. See the first attachment. More details about the fixes can been seen in the second attachment. By now, I think using this patch can totally implement the  internationalization of Code::Blocks v1.0 (CVS with wxWidgets v2.4.2).


[attachment deleted by admin]

liweifuj

Hi Heromyth,

I am looking for a IDE because I have to work under Linux. Seen your production I am really getting exciting, because the English edition could not good support Chinese input, so can you switch a copy to me ? I use fctix as the Chinese input, but can not locate the character in the edit panel. My OS is FC4. Thanks.


David

heromyth

Quote from: liweifuj on November 27, 2005, 11:16:34 AM
Hi Heromyth,

I am looking for a IDE because I have to work under Linux. Seen your production I am really getting exciting, because the English edition could not good support Chinese input, so can you switch a copy to me ? I use fctix as the Chinese input, but can not locate the character in the edit panel. My OS is FC4. Thanks.


David

I just compiled under Windows OS, and haven't tested it under Linux. I'am planning to port it to FreeBSD. It seems to have been done by someone.
The CB in CVS now supports Language Choice perfectly. You must check it out and compile it youself. Here are my codes of InitLocale() in app.cpp


void CodeBlocksApp::InitLocale()
{
    const wxString langs[] =
    {
        _T("(System default)"),
//        _T("English (U.S.)")
//        _T("English"),
        _T("Chinese (Simplified)"),
//        _T("German"),
//        _T("Russian"),
    };

    // Must have the same order than the above
    const long int locales[] =
    {
        wxLANGUAGE_DEFAULT,
//        wxLANGUAGE_ENGLISH_US,
//        wxLANGUAGE_ENGLISH,
        wxLANGUAGE_CHINESE_SIMPLIFIED,
//        wxLANGUAGE_GERMAN,
//        wxLANGUAGE_RUSSIAN
    };

    int lng = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/locale/language"),(int)-2);

    if(lng==-2) // -2 = Undefined / ask
    {
        lng = -1;
        if(WXSIZEOF(langs)>=2)
            lng = wxGetSingleChoiceIndex(_T("Please choose language:"), _T("Language"),
                                           WXSIZEOF(langs), langs);

        if(lng >= 0 && (unsigned)abs(lng) < (unsigned)WXSIZEOF(locales))
            lng = locales[lng];
        else
            lng = -1; // -1 = Don't use locale
    }

ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));
    if(lng>=0)
    {
        m_locale.Init(lng);
        wxLocale::AddCatalogLookupPathPrefix(ConfigManager::GetDataFolder() + _T("/locale"));
        wxLocale::AddCatalogLookupPathPrefix(wxT("."));
        wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
        m_locale.AddCatalog(wxT("codeblocks"));
        cfg->Write(_T("/locale/language"), (int)lng);
    }
    else
        Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/locale/language"),(int)-1);
}