OxyScripts.com
Menu spacer Home Tutorials Articles Code Forums irc.freenode.net #oxyscripts
Main (PHP)
Home Forums PHP News PHP Tutorials Articles PHP Code Snippets Contact Us Sysadmin Resources Books Template Shop
3rd Party Streams
SlashDot PHPDeveloper.org PHP.Net
Resources
PHP Manual MySQL Manual Smarty Manual PEAR Manual PHP-GTK Manual Symfony Manual
Code Snippets
Authentication Database Graphics HTTP Miscellaneous Time/Date
Affiliates
Scripts TutorialMan TutorialGuide CodingForums.com PHP Scripts Cheap Web Hosting Affordable Web Hosting Dreamweaver Templates

Search This Site :     PHP Function Reference :
 
Translating glade files

Translating the strings in a glade file is really easy: If gettext is available and loaded and the textdomain is set, it automatically looks for translations - you just have to provide the translated .mo file in the right directory.

Here is the example application, but with glade:

and here the glade file:
<?xml version="1.0"?>
<GTK-Interface>
<project>
  <name>example-tutorial-translation</name>
  <program_name>example-tutorial-translation</program_name>
  <directory></directory>
  <source_directory>src</source_directory>
  <pixmaps_directory>pixmaps</pixmaps_directory>
  <language>C</language>
  <gnome_support>False</gnome_support>
  <gettext_support>False</gettext_support>
  <output_translatable_strings>True</output_translatable_strings>
  <translatable_strings_file>example-tutorial-translation.strings</translatable_strings_file>
</project>
<widget>
  <class>GtkWindow</class>
  <name>window</name>
  <title>window title</title>
  <type>GTK_WINDOW_TOPLEVEL</type>
  <position>GTK_WIN_POS_NONE</position>
  <modal>False</modal>
  <default_width>300</default_width>
  <default_height>200</default_height>
  <allow_shrink>False</allow_shrink>
  <allow_grow>True</allow_grow>
  <auto_shrink>False</auto_shrink>

  <widget>
    <class>GtkVBox</class>
    <name>vbox</name>
    <homogeneous>False</homogeneous>
    <spacing>0</spacing>

    <widget>
      <class>GtkLabel</class>
      <name>label</name>
      <label>Translation test</label>
      <justify>GTK_JUSTIFY_CENTER</justify>
      <wrap>False</wrap>
      <xalign>0.5</xalign>
      <yalign>0.5</yalign>
      <xpad>0</xpad>
      <ypad>0</ypad>
      <child>
	<padding>0</padding>
	<expand>True</expand>
	<fill>True</fill>
      </child>
    </widget>

    <widget>
      <class>GtkButton</class>
      <name>button</name>
      <can_focus>True</can_focus>
      <label>Close window</label>
      <relief>GTK_RELIEF_NORMAL</relief>
      <child>
	<padding>0</padding>
	<expand>False</expand>
	<fill>False</fill>
      </child>
    </widget>
  </widget>
</widget>
</GTK-Interface>

Just start the script, and you will see a translated application as the string contents are already in testapp.mo.

It can be quite boring to collect all the strings which shall be translated in a .glade file. Glade has the option "save translatable strings" which creates a file containing all the strings from a glade file - it's easy to convert them to a .po file.

 
   Print this page

Top Sponsor
Symantec\'s Norton SystemWorks 2006
Sponsors
CA
Sponsors
AdWords Dominator 125*125
Advertisting


Affiliates
VertexTemplates PHPFreaks CodeWalkers StarGeek DevScripts CGI & PHP Scripts PHP CMS Free Templates

Shopping Rebates   Sell It 4 You   Flash Page Counters   Get Insured
GPS Tracking Service   Charity Donate Info   Web Site Hosting   VOIP Service

Privacy Policy | Links | Site Map | Advertising

All content on OxyScripts.com is (©)2002-2007

 
Powered by Adrastea - Version 1.0.0. Copyright © Rune Solutions, 2004-2005