unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Sascha Wilde <wilde@sha-bang.de>
To: David Kastrup <dak@gnu.org>
Cc: Thomas Arendsen Hein <thomas@intevation.de>, emacs-devel@gnu.org
Subject: Re: set-locale-environement: strange default detection
Date: Wed, 18 Jul 2007 14:28:55 +0200	[thread overview]
Message-ID: <m2bqe93ng8.fsf@kenny.sha-bang.de> (raw)
In-Reply-To: <86ps2qm1de.fsf@lola.quinscape.zz> (David Kastrup's message of "Wed\, 18 Jul 2007 12\:50\:53 +0200")

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

David Kastrup <dak@gnu.org> wrote:

> Sascha Wilde <wilde@sha-bang.de> writes:
>
>> David Kastrup <dak@gnu.org> wrote:
>>> Sascha Wilde <wilde@sha-bang.de> writes:
>>
>>>> a friend of mine (unfortunately a vim user, but a nice guy otherwise),
>>>> tried emacs on Gnu/Linux and was surprised that `C-h t' presented him
>>>> the German version of the tutorial.
>> [...]
[...]
>> So maybe we should check for LANG, LC_ALL and maybe LC_MESSAGES in
>> tutorial.el itself.
>
> Possibly.  I am not sure whether environment variables tell the whole
> story, and in a readable way (there are locale system calls, too), but
> they would probably cover 90% of the cases.

I attached a rough patch, which solves the problem at least on
POSIX-like systems:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs-tutorial-lang.patch --]
[-- Type: text/x-patch, Size: 2296 bytes --]

diff -c -L /vol1/opt/cvs-emacs-sarge/share/emacs/22.1.50/lisp/tutorial.el.gz -L /vol1/opt/src/emacs-hg-sarge/lisp/tutorial.el /tmp/jka-com32572F4r /vol1/opt/src/emacs-hg-sarge/lisp/tutorial.el
*** /vol1/opt/cvs-emacs-sarge/share/emacs/22.1.50/lisp/tutorial.el.gz
--- /vol1/opt/src/emacs-hg-sarge/lisp/tutorial.el
***************
*** 621,626 ****
--- 621,636 ----
  					      face tutorial-warning-face
  					      read-only t)))))))))))
  
+ (defun tutorial-get-language ()
+   "Use LC_ALL, LC_MESSAGES, LANG in turn to determine language to use.
+ This is more reliable then current-language-environment, which is not
+ intended to chose the language used for messages and documentation."
+   (let ((locale "") (vars '("LC_ALL" "LC_MESSAGES" "LANG")))
+     (while (and vars
+ 		(= 0 (length locale))) ; nil or empty string
+       (setq locale (getenv (pop vars))))
+     (locale-name-match locale locale-language-names)))
+ 
  (defun tutorial--saved-dir ()
    "Directory to which tutorials are saved."
    (expand-file-name "tutorial" user-emacs-directory))
***************
*** 766,774 ****
                         (add-hook 'minibuffer-setup-hook
                                   'minibuffer-completion-help)
                         (read-language-name 'tutorial "Language: " "English"))
!                    (if (get-language-info current-language-environment 'tutorial)
!                        current-language-environment
!                      "English")))
             (filename (get-language-info lang 'tutorial))
             ;; Choose a buffer name including the language so that
             ;; several languages can be tested simultaneously:
--- 776,785 ----
                         (add-hook 'minibuffer-setup-hook
                                   'minibuffer-completion-help)
                         (read-language-name 'tutorial "Language: " "English"))
!                    (or (tutorial-get-language)
! 		       (if (get-language-info current-language-environment 'tutorial)
! 			   current-language-environment
! 			 "English"))))
             (filename (get-language-info lang 'tutorial))
             ;; Choose a buffer name including the language so that
             ;; several languages can be tested simultaneously:

Diff finished.  Wed Jul 18 14:23:30 2007

[-- Attachment #3: Type: text/plain, Size: 80 bytes --]


sascha
-- 
Sascha Wilde
Nothing is fool-proof to a sufficiently talented fool.

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2007-07-18 12:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 10:14 set-locale-environement: strange default detection Sascha Wilde
2007-07-18 10:19 ` David Kastrup
2007-07-18 10:40   ` Sascha Wilde
2007-07-18 10:50     ` David Kastrup
2007-07-18 11:04       ` Jan Djärv
2007-07-18 12:28       ` Sascha Wilde [this message]
2007-07-18 18:54 ` Reiner Steib
2007-07-18 21:24   ` David Kastrup
2007-07-19  8:21     ` Sascha Wilde
2007-07-19  9:16       ` David Kastrup
2007-07-22 14:59         ` Better language detection for tutorial (was: set-locale-environement: strange default detection) Sascha Wilde
2007-07-22 15:41           ` Andreas Schwab
2007-07-22 15:44             ` Better language detection for tutorial David Kastrup
2007-07-22 23:16               ` Andreas Schwab
2007-07-22 20:20             ` Sascha Wilde
2007-07-23  3:11               ` Eli Zaretskii
2007-07-23  9:25                 ` Sascha Wilde
2007-07-23 19:29                   ` Eli Zaretskii
2007-07-23 20:29                     ` Sascha Wilde
2007-07-23 20:38                       ` David Kastrup
2007-07-24  6:18                       ` Eli Zaretskii
2007-07-24  7:17                         ` Kenichi Handa
2007-07-24  7:36                           ` Eli Zaretskii
2007-07-24  7:53                             ` Kenichi Handa
2007-07-24 18:45                               ` Eli Zaretskii
2007-07-25  1:01                                 ` Kenichi Handa
2007-07-25  3:14                                   ` Eli Zaretskii
2007-07-25  4:48                                     ` Kenichi Handa
2007-07-25 19:24                                       ` Eli Zaretskii
2007-07-26  2:29                                         ` Kenichi Handa
2007-07-26 11:40                                           ` Eli Zaretskii
2007-07-26 12:19                                             ` Kenichi Handa
2007-07-26 12:25                                               ` Eli Zaretskii
2007-07-26 12:54                                                 ` Kenichi Handa
2007-07-20 17:42     ` set-locale-environement: strange default detection Reiner Steib

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2bqe93ng8.fsf@kenny.sha-bang.de \
    --to=wilde@sha-bang.de \
    --cc=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=thomas@intevation.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).