Author Topic: Patches for codeblocks about internationalization  (Read 21739 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #15 on: August 13, 2005, 06:41:18 pm »
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

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #16 on: August 13, 2005, 08:10:13 pm »
None of this helps?

Code
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

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

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

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

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

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

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #17 on: August 13, 2005, 08:36:33 pm »
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?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #18 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.

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Ask: Why use '$$' instead of '$' in XRC Resource
« Reply #19 on: August 14, 2005, 07:49:04 am »
Suppose there has something like this:
   
Code
<label>$$compiler<label>
in a XRC file. When some programs use this XRC file to show the label, we can see this:
   
Code
$compiler

The '$$' has changed into '$'. If we change to:
   
Code
<label>$compiler<label>
Now we can see that:
   
Code
[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!?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #20 on: August 14, 2005, 10:56:27 am »
Hmmm perhaps it would be good to ask this question in the wxWidgets forums...

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Patches for codeblocks about internationalization
« Reply #21 on: August 14, 2005, 11:03:06 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())?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Patches for codeblocks about internationalization
« Reply #22 on: August 14, 2005, 11:07:22 am »
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:

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #23 on: August 15, 2005, 04:08:06 pm »
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]
« Last Edit: August 16, 2005, 04:13:28 am by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #24 on: August 16, 2005, 07:10:54 am »
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:
Code
<resource>
in all XRC files in Code::Blocks to :
Code
<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]
« Last Edit: August 16, 2005, 12:46:39 pm by heromyth »

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #25 on: August 17, 2005, 09:42:42 am »

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

Code
#: 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]
« Last Edit: August 17, 2005, 09:52:55 am by heromyth »

liweifuj

  • Guest
Re: Patches for codeblocks about internationalization
« Reply #26 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

Offline heromyth

  • Multiple posting newcomer
  • *
  • Posts: 98
    • http://
Re: Patches for codeblocks about internationalization
« Reply #27 on: November 29, 2005, 05:28:38 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


Code
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);
}