Re: setlocale doesn't change the language. Why?

2015-03-13 Thread Joerg Desch
Am Thu, 12 Mar 2015 20:24:21 +0100 schrieb Wouter Verhelst:

> I've been fighting with that myself the other day.
> echo $LANGUAGE?

is already unset.


> This is a GNU extension which does have some use, but it *breaks* in
> some non-wrong use cases.

Until now, I'm really happy with the toolchain around gettext. IMO using 
poedit for external translation teams is a good way to go.


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdu7td$8et$1...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Wouter Verhelst
On Wed, Mar 11, 2015 at 01:27:21PM +, Joerg Desch wrote:
> Hi.
> 
> I'm running Debian Squezze on a small AMD Geode based embedded PC. I need 
> to use the gettext library independend from the system wide language 
> settings to toggle the language for strings only.
> 
> On my PC, the test runs within a chroot environment als expected. On the 
> embedded PC, it doesn't switch the language with setlocale().

I've been fighting with that myself the other day.

echo $LANGUAGE?

If you don't want that, you need to

putenv("LANGUAGE=");

This is a GNU extension which does have some use, but it *breaks* in some
non-wrong use cases.

-- 
It is easy to love a country that is famous for chocolate and beer

  -- Barack Obama, speaking in Brussels, Belgium, 2014-03-26


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20150312192421.gb3...@grep.be



SOLVED: setlocale doesn't change the language. Why?

2015-03-12 Thread Joerg Desch
Am Thu, 12 Mar 2015 09:29:01 +0100 schrieb Tomas Pospisek:

> /etc/locale.gen

The solution was simple. While "dpkg-reconfigure locales" only allows the 
selection of one language. I thought that this should be the default. But 
instead all not selected entries are not possible.

So the solution was to enable all languages I need to select in my code. 
After this, my sample works as expected.

Thanks for your help.


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdrpfm$mf$3...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Jonas Smedegaard
Quoting Joerg Desch (2015-03-12 11:08:41)
> Am Thu, 12 Mar 2015 09:29:01 +0100 schrieb Tomas Pospisek:
> 
> > /etc/locale.gen
> > 
> > Also 'man locale'
> > *t
> 
> OK, the package "locales" wasn't installed by the embedded 
> distribution.
> 
> After installing locales and selecting "en_GB.UTF8" as default, my 
> sample still not use "de_DE.UTF8". So I've called dpkg-reconfigure 
> locales and chosen de_DE.UTF8 as a default. No I can switch to it.
> 
> But does that mean, that I only can switch between the default 
> language and none? It enhanced the sample to try es_ES.UTF8 without a 
> reconfigure locales and it doesn't work.

It probably means that only locales actually created (default or not) on 
the system works.

An alternative to installing package "locales" and enabling locales via 
debconf is to install package "locales-all".


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private


signature.asc
Description: signature


Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Joerg Desch
Am Thu, 12 Mar 2015 09:57:08 + schrieb Colin Watson:

> There is no such locale.  Perhaps you meant en_GB.UTF-8 or en_US.UTF-8.

You are right. But this selection isn't needed. ;-)

I've already changed this in my current sample.



-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdron5$mf$2...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Joerg Desch
Am Thu, 12 Mar 2015 09:29:01 +0100 schrieb Tomas Pospisek:

> /etc/locale.gen
> 
> Also 'man locale'
> *t

OK, the package "locales" wasn't installed by the embedded distribution.

After installing locales and selecting "en_GB.UTF8" as default, my sample 
still not use "de_DE.UTF8". So I've called dpkg-reconfigure locales and
chosen de_DE.UTF8 as a default. No I can switch to it.

But does that mean, that I only can switch between the default language 
and none? It enhanced the sample to try es_ES.UTF8 without a reconfigure 
locales and it doesn't work.


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdroj9$mf$1...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Colin Watson
On Wed, Mar 11, 2015 at 01:27:21PM +, Joerg Desch wrote:
> printf("Switch to 'en'\n");
> setlocale(LC_MESSAGES,"en_EN.UTF8");

There is no such locale.  Perhaps you meant en_GB.UTF-8 or en_US.UTF-8.

-- 
Colin Watson   [cjwat...@debian.org]


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20150312095708.ga5...@riva.ucam.org



Re: setlocale doesn't change the language. Why?

2015-03-12 Thread Tomas Pospisek
Am 12.03.2015 um 06:50 schrieb Joerg Desch:
> Am Wed, 11 Mar 2015 21:16:20 +0500 schrieb Andrey Rahmatullin:
> 
>> On Wed, Mar 11, 2015 at 01:27:21PM +, Joerg Desch wrote:
>>> Switch to 'en'
>>> New LOCALE: 'C'
>>> Hello World Switch to 'de'
>>> New LOCALE: 'C'
>>> Hello World
>> So these cases are expected to you?
> 
> No. I expect the same output as shown by the other example. I expected 
> that either "de_DE" or "de_DE.UTF8" should fit.
> 
> 
>> You don't have 'de.utf8' locale on this system.
> 
> How can I check which locales are available?

/etc/locale.gen

Also 'man locale'
*t


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/55014e4d.8030...@sourcepole.ch



setlocale doesn't change the language. Why?

2015-03-12 Thread Joerg Desch
Hi.

I'm running Debian Squezze on a small AMD Geode based embedded PC. I need 
to use the gettext library independend from the system wide language 
settings to toggle the language for strings only.

On my PC, the test runs within a chroot environment als expected. On the 
embedded PC, it doesn't switch the language with setlocale().

Please can some help me?

Here's the code snippet I use.


#define PACKAGE "sample2"
#define _(String) gettext (String)

int main()
{
printf("Current LOCALE: '%s'\n",setlocale(LC_ALL,0));
bindtextdomain(PACKAGE,"./locale");
textdomain(PACKAGE);

printf("Switch to 'en'\n");
setlocale(LC_MESSAGES,"en_EN.UTF8");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));

printf("Switch to 'de'\n");
setlocale(LC_MESSAGES,"de_DE");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));

printf("Switch to 'de.utf8'\n");
setlocale(LC_MESSAGES,"de_DE.UTF8");
printf("New LOCALE: '%s'\n",setlocale(LC_MESSAGES,0));
printf(_("Hello World\n"));

return 0;
}


The output in the chroot is:
$ ./sample2
Current LOCALE: 'C'
Switch to 'en'
New LOCALE: 'C'
Hello World
Switch to 'de'
New LOCALE: 'C'
Hello World
Switch to 'de.utf8'
New LOCALE: 'de_DE.UTF8'
Hallo Welt

And on the embedded PC:
# ./sample2
Current LOCALE: 'C'
Switch to 'en'
New LOCALE: 'C'
Hello World
Switch to 'de'
New LOCALE: 'C'
Hello World
Switch to 'de.utf8'
New LOCALE: 'C'
Hello World


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdpfrp$v2m$1...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-11 Thread Joerg Desch
Am Wed, 11 Mar 2015 21:16:20 +0500 schrieb Andrey Rahmatullin:

> On Wed, Mar 11, 2015 at 01:27:21PM +, Joerg Desch wrote:
>> Switch to 'en'
>> New LOCALE: 'C'
>> Hello World Switch to 'de'
>> New LOCALE: 'C'
>> Hello World
> So these cases are expected to you?

No. I expect the same output as shown by the other example. I expected 
that either "de_DE" or "de_DE.UTF8" should fit.


> You don't have 'de.utf8' locale on this system.

How can I check which locales are available?


> setlocale(3) has a return value which you should check if you are
> interested whether it succeeded.

Yes. So the example shows that neither of my calls to setlocale() result 
in the expected language. The big question is why? The sample works on my 
Desktop (Debian Wheezy) and in the chroot (Debian Squeeze) environment.



-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/mdr9ff$j09$1...@ger.gmane.org



Re: setlocale doesn't change the language. Why?

2015-03-11 Thread Andrey Rahmatullin
On Wed, Mar 11, 2015 at 01:27:21PM +, Joerg Desch wrote:
> Switch to 'en'
> New LOCALE: 'C'
> Hello World
> Switch to 'de'
> New LOCALE: 'C'
> Hello World
So these cases are expected to you?

> Switch to 'de.utf8'
> New LOCALE: 'de_DE.UTF8'
> Hallo Welt
> 
> And on the embedded PC:
> # ./sample2
> Current LOCALE: 'C'
> Switch to 'en'
> New LOCALE: 'C'
> Hello World
> Switch to 'de'
> New LOCALE: 'C'
> Hello World
> Switch to 'de.utf8'
> New LOCALE: 'C'
> Hello World
You don't have 'de.utf8' locale on this system.
setlocale(3) has a return value which you should check if you are
interested whether it succeeded.

-- 
WBR, wRAR


signature.asc
Description: Digital signature