Re: How to create a simple multilingual GUI

2007-05-30 Thread John Zoidberg

Ooop, took wrong file.
It's hello_intl-0.1.tar.gz which is the GTK app, not gettext-0.16 (gettext
tarball). :/
=
I finally managed to make a dynamically language-changing console app.
However, I'm still trying to understand how to correctly use gettext with
Anjuta+Glade.

Here is my source code for my apps, as well as .mo files I took from the
gettext tarball.

How should I proceed to use .mo files with a GTK app created using the
Anjuta+Glade combo?
I tried placing .po files (created from the Anjuta generated .pot template)
in the po directory and adding a LINGUAS file with the available languages,
but it didn't work.

On 5/29/07, John Zoidberg [EMAIL PROTECTED] wrote:


I finally managed to make a dynamically language-changing console app.
However, I'm still trying to understand how to correctly use gettext with
Anjuta+Glade.

Here is my source code for my apps, as well as .mo files I took from the
gettext tarball.

How should I proceed to use .mo files with a GTK app created using the
Anjuta+Glade combo?
I tried placing .po files (created from the Anjuta generated .pot
template) in the po directory and adding a LINGUAS file with the available
languages, but it didn't work.


On 5/18/07, Michelle Konzack [EMAIL PROTECTED] wrote:

 Am 2007-05-16 09:47:07, schrieb Andreas Stricker:
  It works only for the widget itself. Usually there is also
  localized code in the program control flow like this:
 
  if (condition)
   status_text = _(Condition is true);
 
  If a branch like this is not executed again on reload or branch
  into another part of the code, the language of the text stays
  in the former language.

 Ah right...

 I had put all strings in an array which I reload. :-)
 Then, all strings are new translated if I reinitialize the array.

 This is why it worked 4me.

 Greetings
 Michelle Konzack


 --
 Linux-User #280138 with the Linux Counter, http://counter.li.org/
 # Debian GNU/Linux Consultant #
 Michelle Konzack   Apt. 917  ICQ #328449886
50, rue de Soultz MSN LinuxMichi
 0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to create a simple multilingual GUI

2007-05-16 Thread Andreas Stricker
Michelle Konzack wrote:
 Am 2007-05-14 20:43:42, schrieb David Ne?as (Yeti):
 On Mon, May 14, 2007 at 08:04:09PM +0200, Michelle Konzack wrote:
 Does
 setlocale(LC_ALL, de_DE);

 not work?
 It works.  Future locale-dependent calls will use the new
 locale.

 So if you do this while your application is already running,
 you can watch it trasmuting slowly to German, with some parts
 probably never getting there.
 
 AFAIK it is enough, if you reload all the Widgets...

It works only for the widget itself. Usually there is also
localized code in the program control flow like this:

if (condition)
 status_text = _(Condition is true);

If a branch like this is not executed again on reload or branch
into another part of the code, the language of the text stays
in the former language.

Cheers, Andy
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-15 Thread John Zoidberg
Well, it's possible to change the language in Firefox and in a lot of other
programs.
I don't mind having to restart the program to do it.
I just don't want to have to change the system's local language to do it.

I know that gettext is mostly used for internationalisation. However, I have
problems creating a program with it where I choose the language in the
program, independently of the system settings.

If somebody knows how to do this, I would be really grateful for a simple
example program, even if it's only command-line and without a GUI.
In the meanwhile, I began looking at the source code of tuxtyping, where
changing the language at runtime is possible.
But having a clear simple source code for something like that really makes
it easier.


On 5/12/07, rush ta [EMAIL PROTECTED] wrote:

 if that is at all possible... I would be looking forward to it too !!

 On 5/11/07, John Zoidberg [EMAIL PROTECTED]  wrote:

  I would like to create a GUI with GTK where the language can be chosen
  interactively in a settings menu.
  I would like this to be independant of the machines local language
  settings.
 
  How can I do that?
  ___
  gtk-app-devel-list mailing list
  gtk-app-devel-list@gnome.org
  http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-15 Thread Yeti
On Mon, May 14, 2007 at 12:30:14PM +0200, John Zoidberg wrote:
 Well, it's possible to change the language in Firefox and in a lot of other
 programs.

That does not make it a good idea.

Firefox is designed for Microsoft Windows -- where one had
to reinstall the system it to switch languages.  Applications
tried to work around it and each invented its own language
switching mechanism.

We've had a standard mechanism since ever.  All programs
that support localization respect -- or should respect
-- language preferences expressed with locale variables.
Running

  LC_ALL=cs_CZ app

should run app in Czech.  By editing the command used to
run the application this should be relatively easy to do
with a GUI launcher too -- in fact, the launcher editors in
desktop environments should offer the possibility to set the
language for individual applications to make it easier.

What we don't need is every program inventing its own
method to express language preferences.

 I don't mind having to restart the program to do it.

With restarting it is easy.  The only thing you need to do
is to set locale to the desired one on startup, overriding
what you have inherited from environment.  See below.

 I just don't want to have to change the system's local language to do it.

What is `the system local language'?  Probably there's no
such thing and therefore you cannot change it.  You can set
locale [categories] for each program individually (several
possibilities have been listed), and that's what you also
should do.

 I know that gettext is mostly used for internationalisation. However, I have
 problems creating a program with it where I choose the language in the
 program, independently of the system settings.

Call setlocale() or set LC_* environment variables as
suggested, each process has its own.  And you should use the
inherited locale as the default.

 If somebody knows how to do this, I would be really grateful for a simple
 example program, even if it's only command-line and without a GUI.

=
#include stdio.h
#include time.h
#include locale.h

int
main(int argc, char *argv[])
{
time_t t;
char s[1024];

if (argc  1)
setlocale(LC_ALL, argv[1]);
time(t);
strftime(s, sizeof(s), %c, localtime(t));
printf(%s\n, s);
return 0;
}
=

Pass it a locale name and it will print the current date and
time in the form preferred for that locale (i.e. language
+ region) because %c means locale-defined date and time
format.  Observe it leaves your system local language
(whatever it is) intact.

Everything else (e.g. adding gettext which is controlled by
the same variables or storing the selected language in
some preferences file) is a straighforward extension.

 In the meanwhile, I began looking at the source code of tuxtyping, where
 changing the language at runtime is possible.
 But having a clear simple source code for something like that really makes
 it easier.

It is a lot easier if your user interface is a set of
independent screens, exactly one active at any time.  When
you switch languages, you just discard the current screen
and construct it again.  This is not how a typical Gtk+
application looks like though.

Yeti

--
http://gwyddion.net/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-14 Thread Yeti
On Mon, May 14, 2007 at 09:14:19AM +0300, Gabriel Schulhof wrote:
 On Sun, 2007-05-13 at 02:19 +0200, David Nečas (Yeti) wrote:
  Run-time switching of languages is not
  possible http://bugzilla.gnome.org/show_bug.cgi?id=313736
 
 Oh, it's possible, just very difficult. You have to keep all your
 user-string-displaying widgets in a list, and set the label/text for
 each of them every time the language changes, and after notifying
 gettext of the change.

If the languages differ in the direction of reading
(LTR-RTL), more has to be done.  Calling
gtk_widget_set_default_direction() with the direction
obtained from _(default:LTR) will generally take care of
it, though corner cases can remain.  Also labels (and input
widgets) possibly containing numbers or date  time have to
be rendered again, regettexting is not everything.  And
there are other regional settings you either have to deal
with or it's unclear what to do with upon a switch.  So,
impossible is probably a too strong word but maintenance
nightmare it definitely is.

Yeti

--
http://gwyddion.net/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-14 Thread Samuel Cormier-Iijima
On 5/14/07, Gabriel Schulhof [EMAIL PROTECTED] wrote:

 Hi!

 On Sun, 2007-05-13 at 02:19 +0200, David Nečas (Yeti) wrote:
  Run-time switching of languages is not
  possible http://bugzilla.gnome.org/show_bug.cgi?id=313736

 Oh, it's possible, just very difficult. You have to keep all your
 user-string-displaying widgets in a list, and set the label/text for
 each of them every time the language changes, and after notifying
 gettext of the change.

 This can quickly turn into a nightmare, because the width of labels
 tends to change from language to language, and non-resizable windows
 will not re-shrink after a verbose language.



I seem to remember that Ubuntu's installer Ubiquity has dynamically switches
the language
on the first page of installation (with a list of languages on the left, and
clicking on one
of these languages changes the UI translations at runtime). You might want
to check the
Ubiquity code to see how they do this?

Samuel


Gabriel

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-14 Thread Michelle Konzack
Am 2007-05-13 02:19:39, schrieb David Ne?as (Yeti):
 On Fri, May 11, 2007 at 02:52:06PM +0200, John Zoidberg wrote:
  I would like to create a GUI with GTK where the language can be chosen
  interactively in a settings menu.
  I would like this to be independant of the machines local language settings.
 
 Each user (not machine) has separate language preferences
 and even individual applications can be run with different
 settings, e.g.
 
   LC_ALL=cs_CZ myapp
 
  How can I do that?
 
 If you want your application to disobey for whatever reason,
 set appropriate LC_* variables yourself -- either in
 a wrapper script or with g_setenv() before initializing
 Gtk+. The selector can be GUI or not, this does not matter.

Does
setlocale(LC_ALL, de_DE);

not work?

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSN LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to create a simple multilingual GUI

2007-05-14 Thread Yeti
On Mon, May 14, 2007 at 08:04:09PM +0200, Michelle Konzack wrote:
 
 Does
   setlocale(LC_ALL, de_DE);
 
 not work?

It works.  Future locale-dependent calls will use the new
locale.

So if you do this while your application is already running,
you can watch it trasmuting slowly to German, with some parts
probably never getting there.

Yeti

--
http://gwyddion.net/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


How to create a simple multilingual GUI

2007-05-12 Thread John Zoidberg
I would like to create a GUI with GTK where the language can be chosen
interactively in a settings menu.
I would like this to be independant of the machines local language settings.

How can I do that?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-12 Thread rush ta
if that is at all possible... I would be looking forward to it too !!

On 5/11/07, John Zoidberg [EMAIL PROTECTED] wrote:

 I would like to create a GUI with GTK where the language can be chosen
 interactively in a settings menu.
 I would like this to be independant of the machines local language
 settings.

 How can I do that?
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to create a simple multilingual GUI

2007-05-12 Thread Yeti
On Fri, May 11, 2007 at 02:52:06PM +0200, John Zoidberg wrote:
 I would like to create a GUI with GTK where the language can be chosen
 interactively in a settings menu.
 I would like this to be independant of the machines local language settings.

Each user (not machine) has separate language preferences
and even individual applications can be run with different
settings, e.g.

  LC_ALL=cs_CZ myapp

 How can I do that?

If you want your application to disobey for whatever reason,
set appropriate LC_* variables yourself -- either in
a wrapper script or with g_setenv() before initializing
Gtk+. The selector can be GUI or not, this does not matter.

Yes, this just makes possible to run the applications with
a different locale. Run-time switching of languages is not
possible http://bugzilla.gnome.org/show_bug.cgi?id=313736

Yeti

--
http://gwyddion.net/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list