Using a string Table On MAC Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Rabah
Earned some good credits
Earned some good credits
Posts: 133
Joined: Fri Jun 08, 2007 8:21 am

Using a string Table On MAC

Post by Rabah »

Dears wxCoders :-),

To display text on panel or frame and other controls...On windows I use a table with "IDS" in Resources of my project.

And I code a function GetString :
wxString GetString(int index)
{
#if defined (__WIN32__)
TCHAR Tchar[250];
LoadString(NULL,index,Tchar,250);
wxString Tstr = _CTS(Tchar);
return Tstr;
#elif defined (__WXMAC__)
return wxT("TO DO");
#endif
}
This function uses TCHAR which is specific to windows.
Please could you say me what the MAC alterniative?

Regards
Rabah
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

AFAIK, there is no string table on Mac.

The "only" cross-platform solution is to use xgettext and extract translatable strings from your code source (those marked with the _("") macro instead of wxT(""))
Rabah
Earned some good credits
Earned some good credits
Posts: 133
Joined: Fri Jun 08, 2007 8:21 am

Post by Rabah »

Hello Benedicte,

Sorry but I do not understand,

What do you mean? where should I call "xgettext"?
is "xgettext" a mac/native function?
And what about "LoadString" which is also specific for windows?

difference between
_("") and wxT("").

Regards
Rabah
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

First, look at the "internat" wxWidget sample installed on your computer(s). It will show you how to use .po files for localized strings.

The aim is to have a special macro "_" instead of "wxT" for all strings that you know you will want to translate.

xgettext is a GNU program (you should be able to get it from gnu.org or another mirror) that extracts strings from your source code (you prepare a list of source files), and generates empty .po files. Then, you just have to translate the strings in the .po files, modify a bit your code to load the .po file corresponding to the language you want in your pp, and that's all.

For more info, you can google "xgettext", or on this forum "xgettext", "i18n" (stands for internationalization, 18 is for the number of letters in the word :!: ), "wxLocale"...

TRex made a tutorial about using xgettext, you should be able to find the URL in this forum.
Rabah
Earned some good credits
Earned some good credits
Posts: 133
Joined: Fri Jun 08, 2007 8:21 am

Post by Rabah »

Thanks a lot for the details.
I searched for the tutorial but nothing.
Have you got the URL please?

Rabah :-)
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

My own quick translation routine looks like this: (google for 'xgettext tutorial' for more info, there are many tutorials)

My project is called 'Aria Maestosa' as you can see, and i keep a subfolder called "international" inside the "Src" folder, i put all translations in it
cd "path/to/Src"
xgettext -d AriaS -s --keyword=_ -p international -o AriaS-new.pot *.cpp
# if you have files in many directories of course you will neeed to specify them instead of '*.cpp'

# if any previous translation exists, don't throw away what already has been translated
cd international
msgmerge -s -U french.po AriaS-new.pot

# remove previous translation and use new one instead
rm AriaS.pot && mv AriaS-new.pot AriaS.pot && rm french.po~
Then i open french.po is smultron (a mac text editor), choose reload in UTF-8 from the menus, translate, save
# generate binary translation file
msgfmt -c -v -o aria_maestosa.mo french.po
also be sure to read this: http://www.wxwidgets.org/manuals/stable ... ation.html
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

Rabah wrote:Thanks a lot for the details.
I searched for the tutorial but nothing.
Have you got the URL please?

Rabah :-)
I gave you the URL for T-Rex's tutorial on the other thread.
Post Reply