Running language, again...

View: New views
12 Messages — Rating Filter:   Alert me  

Running language, again...

by Sever P A :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I know that questions related about languages are always difficult to
explain & manage...

Indeed, language is an environmental question. For that, in GNU/Linux
systems, we have
LANG and LANGUAGE (among others like LC...) enviroment variables.
Moreover, display managers
like GDM left another variables as GDM_LANG, in which the system
stores our selected session
language. Programms launched after this moment could have -I think-
the way to know this
preferred language, mainly, because the system applies locales, if so...

Glib::getenv() provides us a way to access to these vars, but maybe
it's not the best portable
way to discover these values.

I simply ask you if there is a more portable mechanism to know the
environmental language, for
the one side, and then to know if it works with an standard
equivalence language list for each code.

Any idea...

S.
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by José Alburquerque-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-06-17 at 16:34 +0200, Sever P A wrote:
> I simply ask you if there is a more portable mechanism to know the
> environmental language, for
> the one side, and then to know if it works with an standard
> equivalence language list for each code.

if you have your distribution's development man pages (on ubuntu it is
called manpages-dev) you can run 'man setlocale' and get info on the
system's setlocale() function.  Here's a portion:

NAME
       setlocale - set the current locale

SYNOPSIS
       #include <locale.h>

       char *setlocale(int category, const char *locale);

DESCRIPTION
       The setlocale() function is used to set or query the program’s current
       locale.

       If locale is not  NULL,  the  program’s  current  locale  is modified
       according  to  the  arguments.  The argument category determines which
       parts of the program’s current locale should be modified.

--
José Alburquerque


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by David King-17 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-06-17 at 20:46 -0400, José Alburquerque wrote:
> On Wed, 2009-06-17 at 16:34 +0200, Sever P A wrote:
> > I simply ask you if there is a more portable mechanism to know the
> > environmental language, for
> > the one side, and then to know if it works with an standard
> > equivalence language list for each code.
>
> if you have your distribution's development man pages (on ubuntu it is
> called manpages-dev) you can run 'man setlocale' and get info on the
> system's setlocale() function.

This is for C locales, which are pretty inflexible. If you want
something that can be changed non-globally, then C++ locales could be
what you want. You may want to look at:

http://www.cantrip.org/locale.html
http://www.unc.edu/depts/case/pgi/pgC++_lib/stdlibug/sta_9169.htm

for some more details, or maybe pick up Nicolai Josuttis' book on "The C
++ Standard Library", which has a chapter dedicated to
internationalisation.

--
David King | http://amigadave.blogspot.com/ | davidk@...


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2009-06-17 at 20:46 -0400, José Alburquerque wrote:
> On Wed, 2009-06-17 at 16:34 +0200, Sever P A wrote:
> > I simply ask you if there is a more portable mechanism to know the
> > environmental language, for
> > the one side, and then to know if it works with an standard
> > equivalence language list for each code.
>
> if you have your distribution's development man pages (on ubuntu it is
> called manpages-dev) you can run 'man setlocale' and get info on the
> system's setlocale() function.

Yes, that's what I use in Glom, in the
TranslatableItem::get_current_locale() function. I'm not very proud of
it:

http://git.gnome.org/cgit/glom/tree/glom/libglom/data_structure/translatable_item.cc#n189

It seems to work.

I also use iso-codes in Glom to discover human-readable names for
locales and their languages, and to get translated text for those
human-readable names.

--
murrayc@...
www.murrayc.com
www.openismus.com

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Daniel Elstner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Mittwoch, den 17.06.2009, 16:34 +0200 schrieb Sever P A:

> I simply ask you if there is a more portable mechanism to know the
> environmental language, for
> the one side, and then to know if it works with an standard
> equivalence language list for each code.

It depends on what you mean by "know".  Do you need to check whether it
is some specific language?  Or do you need a string representation?  Do
you really want the language, or the locale?  Or do you want to know the
language your application is translated to?  (For the latter case, the
solution could be as simple as using gettext("translated-language") and
have the translators fill it in.)

If you don't necessarily need to display the language name to the user,
then this might be helpful:

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classPango_1_1Context.html#3aa0ee8cb20cf8c3994756e515b4925f

If you use Pango anyway then that's certainly more portable than
guessing from the locale.  It can even give you the language code as a
string.

--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Daniel Elstner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Donnerstag, den 18.06.2009, 16:49 +0200 schrieb Daniel Elstner:
> Am Mittwoch, den 17.06.2009, 16:34 +0200 schrieb Sever P A:

> If you don't necessarily need to display the language name to the user,
> then this might be helpful:

There is also g_get_language_names(), which gets the language list from
the environment.

--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Sever P A :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, all,

Firstly, I must to explain that problems with the my phone line have
caused me one entire day out of internet. Once the connection
restablished, I got a great surprise,

Thanks to John Albuquerque. The problem is that not always know the
correct word to search for. I think, this is just the importance of
this kind of lists...

Thanks to David King... also for the suggestion of Nicolai Josuttis'
book. It seems good and I'd like to get it in e-book format (as pdf
file...).

Thanks to Murry Cumming. Examples for me are always... very appreciated !

Thanks to Daniel Elstner. Probably, you understood me better.

I need to elaborate a list of languages supported (strings like
"spanish", "english",...) by the environtment (so, the available
ones), while GDM, for example, cannot pemits log in in a different
language that of those set by a locale-gen process.

After this list gotten, I'd like to know the environment language, and
then, if it's possible, to get all this list according the current
language...

For example,

In a system in that only has generated the four English, Spanish,
French and Italian locales...

The appropiate list for an english environment, would be,
("English", "Spanish", "French", "Italian")

And for the french environment...
("Anglais", "Espagnole", "Français", "Italien")

And for the spanish environment...
("Inglés", "Español", "Francés", "Italiano")

and so on ..

Thanks for your suggestions,

S.
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by José Alburquerque-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-06-19 at 16:12 +0200, Sever P A wrote:
> Hello, all,
>
> Firstly, I must to explain that problems with the my phone line have
> caused me one entire day out of internet. Once the connection
> restablished, I got a great surprise,
>
> Thanks to John Albuquerque. The problem is that not always know the
> correct word to search for. I think, this is just the importance of
> this kind of lists...

One thing I would say.  Sometimes using google also helps out a lot.
The way I found 'setlocale' was by googling 'Linux locale language'.  I
admit that I only thought of Linux (and not windows), but sometimes
googling the right phrase often gives a lot of good information.

--
José Alburquerque

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Daniel Elstner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Freitag, den 19.06.2009, 16:12 +0200 schrieb Sever P A:

> I need to elaborate a list of languages supported (strings like
> "spanish", "english",...) by the environtment (so, the available
> ones), while GDM, for example, cannot pemits log in in a different
> language that of those set by a locale-gen process.

The available ones *are* those which have locales generated for them.
Or are you writing a system tool that can install language packs?  You
might want to look at how the Ubuntu language selector does it, then.

In either case, you've hit on a hard problem.  I don't think there is an
even remotely portable way to do that sort of thing.  You will be lucky
already if it works across different Linux distributions.

> After this list gotten, I'd like to know the environment language, and
> then, if it's possible, to get all this list according the current
> language...

Since I think GDM does what you want, I had a look at the GDM source and
found this:

http://git.gnome.org/cgit/gdm/tree/gui/simple-greeter/gdm-languages.c

To me, this looks like a thorough attempt to provide this sort of
functionality in a generic manner.  From what I can see, it does *not*
hard-code the list of languages but gets them from the system.  It also
appears to translate the language names to the currently selected local
language by accessing a special locale name.

It is quite likely that this code relies on features only available on
the modern Linux desktop.  But given the reality constraints, it looks a
solid piece of work worth building upon.

> For example,
>
> In a system in that only has generated the four English, Spanish,
> French and Italian locales...
>
> The appropiate list for an english environment, would be,
> ("English", "Spanish", "French", "Italian")

So you want to list only languages with available locales, after all.
Isn't this just what GDM does?

--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Mark Roberts-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 19 Jun 2009, Daniel Elstner wrote:

>> After this list gotten, I'd like to know the environment language, and
>> then, if it's possible, to get all this list according the current
>> language...
>
> Since I think GDM does what you want, I had a look at the GDM source and
> found this:
>
> http://git.gnome.org/cgit/gdm/tree/gui/simple-greeter/gdm-languages.c
>
> [...]

This mailing list is a never ending source of useful information. I am
again amazed at the quality of the postings and the time and love the
list members put into it. Daniel Elstner in particular must live for this
list. Or else he has more than one head and days longer than 24 hours.

Thank you, Daniel, you are a great help to all of us.

Mark Roberts
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Murray Cumming :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-06-19 at 16:12 +0200, Sever P A wrote:
> The appropiate list for an english environment, would be,
> ("English", "Spanish", "French", "Italian")
>
> And for the french environment...
> ("Anglais", "Espagnole", "Français", "Italien")
>
> And for the spanish environment...
> ("Inglés", "Español", "Francés", "Italiano")

iso-codes can give you this. It provides XML that you'll need to parse,
and gettext translations that you'll need to use via a specific gettext
domain.

Glom uses it, for instance in
get_locale_name():
http://git.gnome.org/cgit/glom/tree/glom/libglom/data_structure/iso_codes.cc#n99
(You could probably just take the whole .h/.cc files for that if your
application is GPL.)

Maybe we should have a real C++ API around iso-codes to make life
easier.


--
murrayc@...
www.murrayc.com
www.openismus.com

_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Re: Running language, again...

by Daniel Elstner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Freitag, den 19.06.2009, 22:07 +0200 schrieb Murray Cumming:

> iso-codes can give you this. It provides XML that you'll need to parse,
> and gettext translations that you'll need to use via a specific gettext
> domain.

It looks like the GDM code uses iso-codes in its implementation as well,
judging from the dgettext() call.

Maybe the support for this sort of thing is better than I expected.

--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list