unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to change language of format-date-string
@ 2015-03-21  1:50 Rasmus
  2015-03-21  8:21 ` Philipp Stephani
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Rasmus @ 2015-03-21  1:50 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I would like to change the language that format-date-string assumes, as my
OS is not in English for leaning purposes.  I tried to issue
(set-language-environment "English"), but this does not seem to have an
effect.

I tried to grok the code it editfns.c, but I'm not really sure what is
going on...

I'd appreciate any hints.

—Rasmus

-- 
. . . The proofs are technical in nature and provides no real understanding




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
       [not found] <mailman.2427.1426902650.31049.help-gnu-emacs@gnu.org>
@ 2015-03-21  2:41 ` Emanuel Berg
  2015-03-21  2:48   ` Rasmus
  0 siblings, 1 reply; 14+ messages in thread
From: Emanuel Berg @ 2015-03-21  2:41 UTC (permalink / raw)
  To: help-gnu-emacs

Rasmus <rasmus@gmx.us> writes:

> I would like to change the language that
> format-date-string assumes, as my OS is not in
> English for leaning purposes.

When it comes to computers, there isn't a leaner
language than the old Anglo-American. So that won't
work anyway. If you want to learn such stuff, you are
not helped by the computer, on the contrary.
Remember the words of Dr. Jones, "If you want to be
a good archaeologist, you gotta get out of
the library."

> I tried to issue (set-language-environment
> "English"), but this does not seem to have
> an effect.

See? This is no use. Set the whole damn computer to
English, then turn it off and do that other thing,
then come back and do computer things (in English)
which is what the computer is intended for.

Some people (not you) say computers are not of any
particular language, the use "symbols", the "interface
is completely intuitive", etc. - this is total
bullcrap. Computers are in Anglo-American and there is
no way around it, nor is such a way desired.

But: when you say, format-date-string, do you mean
`format-time-string'? Put it this way, what would you
like the `format-time-string' to output?

-- 
underground experts united


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21  2:41 ` how to change language of format-date-string Emanuel Berg
@ 2015-03-21  2:48   ` Rasmus
  0 siblings, 0 replies; 14+ messages in thread
From: Rasmus @ 2015-03-21  2:48 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> But: when you say, format-date-string, do you mean
> `format-time-string'? Put it this way, what would you
> like the `format-time-string' to output?

I would like something like this:

    (let ((magically-bind-language "English"))
      (format-time-string "%B"))
      => "Marts"

—Rasmus

-- 
Dobbelt-A




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21  1:50 Rasmus
@ 2015-03-21  8:21 ` Philipp Stephani
  2015-03-21 11:37   ` Rasmus
  2015-03-21  8:36 ` Eli Zaretskii
       [not found] ` <mailman.2436.1426926072.31049.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 14+ messages in thread
From: Philipp Stephani @ 2015-03-21  8:21 UTC (permalink / raw)
  To: Rasmus, help-gnu-emacs

Rasmus <rasmus@gmx.us> schrieb am Sa., 21. März 2015 um 02:51 Uhr:

> Hi,
>
> I would like to change the language that format-date-string assumes, as my
> OS is not in English for leaning purposes.  I tried to issue
> (set-language-environment "English"), but this does not seem to have an
> effect.
>
>
You need set-locale-environment, which sets more locale properties:

(set-locale-environment "en_US.UTF-8")

If you only want to change the language for format-time-string, use the
system-time-locale variable:

(setq system-time-locale "da_DK.UTF-8")


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21  1:50 Rasmus
  2015-03-21  8:21 ` Philipp Stephani
@ 2015-03-21  8:36 ` Eli Zaretskii
       [not found] ` <mailman.2436.1426926072.31049.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2015-03-21  8:36 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rasmus <rasmus@gmx.us>
> Date: Sat, 21 Mar 2015 02:50:11 +0100
> 
> I would like to change the language that format-date-string assumes, as my
> OS is not in English for leaning purposes.  I tried to issue
> (set-language-environment "English"), but this does not seem to have an
> effect.

Try using set-locale-environment instead.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21  8:21 ` Philipp Stephani
@ 2015-03-21 11:37   ` Rasmus
  2015-03-21 12:30     ` Eli Zaretskii
  2015-03-21 15:47     ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Rasmus @ 2015-03-21 11:37 UTC (permalink / raw)
  To: help-gnu-emacs

Philipp Stephani <p.stephani2@gmail.com> writes:

> If you only want to change the language for format-time-string, use the
> system-time-locale variable:
>
> (setq system-time-locale "da_DK.UTF-8")

Thanks that works.  Is this Unix specific or would it also work in
Windows?

Thanks,
Rasmus

-- 
Send from my Emacs




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 11:37   ` Rasmus
@ 2015-03-21 12:30     ` Eli Zaretskii
  2015-03-21 12:48       ` Rasmus
  2015-03-21 15:47     ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2015-03-21 12:30 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rasmus <rasmus@gmx.us>
> Date: Sat, 21 Mar 2015 12:37:39 +0100
> 
> > (setq system-time-locale "da_DK.UTF-8")
> 
> Thanks that works.  Is this Unix specific or would it also work in
> Windows?

It works for Windows, but the locale names are different on Windows,
and UTF-8 is not supported as the locale's encoding.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 12:30     ` Eli Zaretskii
@ 2015-03-21 12:48       ` Rasmus
  2015-03-21 13:20         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Rasmus @ 2015-03-21 12:48 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Rasmus <rasmus@gmx.us>
>> Date: Sat, 21 Mar 2015 12:37:39 +0100
>> 
>> > (setq system-time-locale "da_DK.UTF-8")
>> 
>> Thanks that works.  Is this Unix specific or would it also work in
>> Windows?
>
> It works for Windows, but the locale names are different on Windows,
> and UTF-8 is not supported as the locale's encoding.

Is there a OS-agnostic way to change a locale?

—Rasmus

-- 
Bang bang




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 12:48       ` Rasmus
@ 2015-03-21 13:20         ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2015-03-21 13:20 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rasmus <rasmus@gmx.us>
> Date: Sat, 21 Mar 2015 13:48:38 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Rasmus <rasmus@gmx.us>
> >> Date: Sat, 21 Mar 2015 12:37:39 +0100
> >> 
> >> > (setq system-time-locale "da_DK.UTF-8")
> >> 
> >> Thanks that works.  Is this Unix specific or would it also work in
> >> Windows?
> >
> > It works for Windows, but the locale names are different on Windows,
> > and UTF-8 is not supported as the locale's encoding.
> 
> Is there a OS-agnostic way to change a locale?

Not sure what you are asking here.  You cannot even change a locale on
a Unix system without knowing that the locale is installed on that
system; not all the locales are.

So no, AFAIK there's no way of changing the locale without knowing
something about the system on which you do that, and without adapting
the locale to that system.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 11:37   ` Rasmus
  2015-03-21 12:30     ` Eli Zaretskii
@ 2015-03-21 15:47     ` Eli Zaretskii
  2015-03-21 15:54       ` Rasmus
       [not found]       ` <mailman.2458.1426953287.31049.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2015-03-21 15:47 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rasmus <rasmus@gmx.us>
> Date: Sat, 21 Mar 2015 12:37:39 +0100
> 
> Philipp Stephani <p.stephani2@gmail.com> writes:
> 
> > If you only want to change the language for format-time-string, use the
> > system-time-locale variable:
> >
> > (setq system-time-locale "da_DK.UTF-8")
> 
> Thanks that works.

If you set system-time-locale alone, without also setting
locale-coding-system to the same encoding as specified by
system-time-locale, you will get garbled strings (unless you _know_
that the encoding of both locales is the same, which in practice can
only be true if they use UTF-8).



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 15:47     ` Eli Zaretskii
@ 2015-03-21 15:54       ` Rasmus
  2015-03-21 16:47         ` Eli Zaretskii
       [not found]       ` <mailman.2458.1426953287.31049.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 14+ messages in thread
From: Rasmus @ 2015-03-21 15:54 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Rasmus <rasmus@gmx.us>
>> Date: Sat, 21 Mar 2015 12:37:39 +0100
>
>> 
>> Philipp Stephani <p.stephani2@gmail.com> writes:
>> 
>> > If you only want to change the language for format-time-string, use the
>> > system-time-locale variable:
>> >
>> > (setq system-time-locale "da_DK.UTF-8")
>> 
>> Thanks that works.
>
> If you set system-time-locale alone, without also setting
> locale-coding-system to the same encoding as specified by
> system-time-locale, you will get garbled strings (unless you _know_
> that the encoding of both locales is the same, which in practice can
> only be true if they use UTF-8).

I conclude this is a nontrivial problem with a pretty local-specific
solution.  It's a shame.  It would be quite useful when composing
documents in different languages (especially in terms of %B).

Thanks for the tips.

—Rasmus

-- 
Enough with the bla bla!




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
  2015-03-21 15:54       ` Rasmus
@ 2015-03-21 16:47         ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2015-03-21 16:47 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rasmus <rasmus@gmx.us>
> Date: Sat, 21 Mar 2015 16:54:17 +0100
> 
> >> > (setq system-time-locale "da_DK.UTF-8")
> >> 
> >> Thanks that works.
> >
> > If you set system-time-locale alone, without also setting
> > locale-coding-system to the same encoding as specified by
> > system-time-locale, you will get garbled strings (unless you _know_
> > that the encoding of both locales is the same, which in practice can
> > only be true if they use UTF-8).
> 
> I conclude this is a nontrivial problem with a pretty local-specific
> solution.  It's a shame.  It would be quite useful when composing
> documents in different languages (especially in terms of %B).

I don't see how it is less trivial in Emacs than it is in any other
program.  Changing the locale on the fly is not something you are
supposed to do a lot, so it's little wonder it's complicated.  And we
didn't even start talking about locale's local to a thread, only about
a global program-wide locale.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
       [not found]       ` <mailman.2458.1426953287.31049.help-gnu-emacs@gnu.org>
@ 2015-03-21 19:12         ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2015-03-21 19:12 UTC (permalink / raw)
  To: help-gnu-emacs

Rasmus <rasmus@gmx.us> writes:

> I conclude this is a nontrivial problem with
> a pretty local-specific solution. It's a shame.
> It would be quite useful when composing documents in
> different languages (especially in terms of %B).

I got it to work using either of these methods:
evaluate

    (set-locale-environment "sv_SE.ISO-8859-1")
    (format-time-string "%B")

or invoke Emacs like this:

    LC_ALL="sv_SE.ISO-8859-1" emacs

But, as expected - trouble. All my rewired chars which
I setup like this

    loadkeys -q -c -s /etc/console-setup/remap.inc

then don't work anymore. (Note there is no mention of
the locale which is setup elsewhere and then no one
has to bother with that ever again.)

You see the essence of this? Put the OS into another
language, ouch, put Emacs back to English, ouch, make
it portable, ouch, get the keys back (my example), oh
ah, the pain is tremendous ... where the hell is my
prescription of codeine?

This illustrates that the best idea is to have the
computer in English, with the US keyboard layout, and
then do adjustments (e.g., a compose key) when
material in a specific language is to be produced.
What you do is the other way around, which is the
source of all problems mentioned. And I can see many
other problems: for example, what happens if you bring
up man pages?

But you got it to work. That is good.

-- 
underground experts united


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: how to change language of format-date-string
       [not found] ` <mailman.2436.1426926072.31049.help-gnu-emacs@gnu.org>
@ 2015-03-21 19:52   ` Emanuel Berg
  0 siblings, 0 replies; 14+ messages in thread
From: Emanuel Berg @ 2015-03-21 19:52 UTC (permalink / raw)
  To: help-gnu-emacs

Philipp Stephani <p.stephani2@gmail.com> writes:

> (setq system-time-locale "da_DK.UTF-8")

OK, this works without the complications I mentioned.
Good answer!

-- 
underground experts united


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-03-21 19:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2427.1426902650.31049.help-gnu-emacs@gnu.org>
2015-03-21  2:41 ` how to change language of format-date-string Emanuel Berg
2015-03-21  2:48   ` Rasmus
2015-03-21  1:50 Rasmus
2015-03-21  8:21 ` Philipp Stephani
2015-03-21 11:37   ` Rasmus
2015-03-21 12:30     ` Eli Zaretskii
2015-03-21 12:48       ` Rasmus
2015-03-21 13:20         ` Eli Zaretskii
2015-03-21 15:47     ` Eli Zaretskii
2015-03-21 15:54       ` Rasmus
2015-03-21 16:47         ` Eli Zaretskii
     [not found]       ` <mailman.2458.1426953287.31049.help-gnu-emacs@gnu.org>
2015-03-21 19:12         ` Emanuel Berg
2015-03-21  8:36 ` Eli Zaretskii
     [not found] ` <mailman.2436.1426926072.31049.help-gnu-emacs@gnu.org>
2015-03-21 19:52   ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).