gnope php gtk gui gnope.org  

gettext translation and glade

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Sat Mar 25, 2006 11:23 am    Post subject: gettext translation and glade Reply with quote

Hello,

my applications runs with glade.
Now I've build into my app a gettext based translation.

I extracted the labels from glade file with xgettext, created from the english labels in poEdit the german translation of it and then saved the compiled mo-file

Code:

putenv( "LANG=" . 'de_DE');
setlocale( LC_ALL, 'de_DE');

if( !function_exists( 'gettext')) {
   die( 'gettext extension is not available!');
}
bindtextdomain( 'mp3catalog', dirname( __FILE__) . '/locale');
textdomain( 'mp3catalog');
trigger_error(gettext("scan media"));


the trigger_error show up the right translation.
But my application didn't show up the translation

every label looks like this:
Quote:

<property name="label" translatable="yes">genre</property>


so what I'm doing wrong?

Greetings

Christian
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Sun Mar 26, 2006 10:39 pm    Post subject: Reply with quote

Do you load the translation before loading the glade file? If not, try that.
I don't know if you saw the tutorial:
http://gtk.php.net/manual/en/tutorials.translation.glade.php
Seems that you need to put the file in the right directory. And it could be that there are problems on windows, while it works good on *nix.
Back to top
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Sun Mar 26, 2006 10:49 pm    Post subject: Reply with quote

I've used the tutorial to build in the gettext module.

But I've got the same Problem like tripi at ben-fr dot com (User Contributed Notes).

Text defined in the php-file is translated, but all glade values don't do that (under windows)

I've don't tested my app under linux until now, so i dont know, if the problem occurs on other platforms as well.
Back to top
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Mon Mar 27, 2006 12:34 am    Post subject: Reply with quote

Ok, a workaround for windows platform is, to load all labels by get_widget and rewrite label by get_label , set_label.

but how to rewrite the MenuItems?
and the next question is also about MenuItems:

I build up the submenu like this:
Code:

$catalogSubMenu = new GtkMenu();
foreach ($this->catalogs as $catalogname =>$catalogMedias){
          $catalogSubMenuItem = new GtkMenuItem("{$catalogname}");
          $catalogSubMenuItem->connect(        "activate"        , array( $this, "onCatalogMenuMediaMoveActivate"));
          $catalogSubMenu->append($catalogSubMenuItem);
}                       
self::$arWidgets["menuCatalogMovemedia"]->set_submenu($catalogSubMenu);
$catalogSubMenu->show_all();


I want to know, which submenu-Item was selected. But I've got only the parent MenuItem back, which is an ImageMenuItem.

Any ideas?
Back to top
scott



Joined: 16 Feb 2006
Posts: 35

PostPosted: Mon Mar 27, 2006 4:02 pm    Post subject: Reply with quote

Osiris wrote:
but how to rewrite the MenuItems?


The child of a menu item (which is a GtkBin meaning it can only have one child) is a GtkAccelLabel. GtkAccelLabel is a descendant of GtkLabel. This means that you can grab the menu item's label and then call set_label on that item.
Code:
$menuItem = new GtkMenuItem('TEST');
$label = $menuItem->get_child();
$label->set_label('PHP-GTK 2');

[/code]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.