* calendar m17n
@ 2006-09-14 7:31 Andreas Roehler
2006-09-14 8:43 ` Reiner Steib
2006-09-14 8:52 ` Andreas Schwab
0 siblings, 2 replies; 11+ messages in thread
From: Andreas Roehler @ 2006-09-14 7:31 UTC (permalink / raw)
Hi,
I'm looking for a way to localize names in calendar.el.
Below an example with German names.
As there will exist several lists already with names in
different languages, seems no need to collect it from
the scratch.
It's just to find and pick the right one. Could someone
give me a hint, where to collect it respecting GPl
questions?
Thanks!
__
Andreas Roehler
(defun calendar-local-names ()
"Read months and days in your mothers tongue"
(interactive)
(let ((lang (getenv "LANG")))
(cond ((string-match "\\(de\\)\\|\\(DE\\)" lang)
(message "%s" (format "%s" (match-string 0 lang)))
(setq calendar-day-name-array
["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag"
"Freitag" "Samstag"])
(setq calendar-month-name-array
["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
"September" "Oktober" "November" "Dezember"])))))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 7:31 calendar m17n Andreas Roehler
@ 2006-09-14 8:43 ` Reiner Steib
2006-09-14 8:52 ` Andreas Schwab
1 sibling, 0 replies; 11+ messages in thread
From: Reiner Steib @ 2006-09-14 8:43 UTC (permalink / raw)
Cc: emacs-devel
On Thu, Sep 14 2006, Andreas Roehler wrote:
> I'm looking for a way to localize names in calendar.el.
Probably this should go to `language-info-alist', see
e.g. `european.el' for German. See the function `get-language-info'.
> As there will exist several lists already with names in
> different languages, seems no need to collect it from
> the scratch.
>
> It's just to find and pick the right one. Could someone give me a
> hint, where to collect it respecting GPl questions?
I wonder if we could pick up these names from the `date' command
automatically at runtime without maintaining a list.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 7:31 calendar m17n Andreas Roehler
2006-09-14 8:43 ` Reiner Steib
@ 2006-09-14 8:52 ` Andreas Schwab
2006-09-14 15:39 ` Kevin Rodgers
2006-09-14 18:56 ` Andreas Roehler
1 sibling, 2 replies; 11+ messages in thread
From: Andreas Schwab @ 2006-09-14 8:52 UTC (permalink / raw)
Cc: emacs-devel
Andreas Roehler <andreas.roehler@easy-emacs.de> writes:
> It's just to find and pick the right one. Could someone
> give me a hint, where to collect it respecting GPl
> questions?
You could read it from the output of "locale day" and "locale mon".
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 8:52 ` Andreas Schwab
@ 2006-09-14 15:39 ` Kevin Rodgers
2006-09-14 18:56 ` Andreas Roehler
1 sibling, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2006-09-14 15:39 UTC (permalink / raw)
Andreas Schwab wrote:
> Andreas Roehler <andreas.roehler@easy-emacs.de> writes:
>
>> It's just to find and pick the right one. Could someone
>> give me a hint, where to collect it respecting GPl
>> questions?
>
> You could read it from the output of "locale day" and "locale mon".
Brilliant!
Just curious: does format-time-string take into account the locale?
This is something I came up with a few years ago:
(defvar autocap-abbrev-months
(let ((year (string-to-number (format-time-string "%Y"))))
(apply 'nconc
(mapcar (lambda (month)
(let ((first (encode-time 0 0 0 1 month year 0)))
(list (format-time-string "%b." first t)
(format-time-string "%B" first t))))
'(1 2 3 4 5 6 7 8 9 10 11 12))))
"The list of month names and abbreviations to be automatically
capitalized.")
(defvar autocap-abbrev-days
(let ((year (string-to-number (format-time-string "%Y")))
(month (string-to-number (format-time-string "%m"))))
(apply 'nconc
(mapcar (lambda (time)
(list (format-time-string "%a." time)
(format-time-string "%A" time)))
(sort (mapcar (lambda (day)
(encode-time 0 0 0 day month year 0))
'(1 2 3 4 5 6 7))
;; by day of week:
(lambda (time-1 time-2)
(< (nth 6 (decode-time time-1))
(nth 6 (decode-time time-2))))))))
"The list of day names and abbreviations to be automatically
capitalized.")
--
Kevin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 8:52 ` Andreas Schwab
2006-09-14 15:39 ` Kevin Rodgers
@ 2006-09-14 18:56 ` Andreas Roehler
2006-09-15 17:38 ` Glenn Morris
2006-09-15 17:48 ` Kevin Rodgers
1 sibling, 2 replies; 11+ messages in thread
From: Andreas Roehler @ 2006-09-14 18:56 UTC (permalink / raw)
Cc: Reiner Steib, Richard Stallman, emacs-devel
>> It's just to find and pick the right one. Could someone
>> give me a hint, where to collect it respecting GPl
>> questions?
>>
>
> You could read it from the output of "locale day" and "locale mon".
>
> Andreas.
>
>
Thanks all for your useful hints. Here an already working draft:
;; (defcustom calendar-use-locales nil
;; "Use local names of day and month"
;; :type 'boolean
;; :group 'calendar)
(setq calendar-use-locales t)
(defun calendar-use-locales-function ()
" "
(interactive)
(when calendar-use-locales
(progn
(setq calendar-day-name-array (locale-info 'days))
(setq calendar-month-name-array (locale-info 'months)))))
;; with $LANG=de_DE.UTF-8
GNU Emacs 22.0.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
2006-09-11
Would be nice to hear from users with different languages.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 18:56 ` Andreas Roehler
@ 2006-09-15 17:38 ` Glenn Morris
2006-09-15 17:48 ` Kevin Rodgers
1 sibling, 0 replies; 11+ messages in thread
From: Glenn Morris @ 2006-09-15 17:38 UTC (permalink / raw)
Cc: Andreas Schwab, emacs-devel, Richard Stallman, Reiner Steib
Andreas Roehler wrote:
> Thanks all for your useful hints. Here an already working draft:
Thanks for the forward. Will consider something along these lines
after the release of Emacs 22.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-14 18:56 ` Andreas Roehler
2006-09-15 17:38 ` Glenn Morris
@ 2006-09-15 17:48 ` Kevin Rodgers
2006-09-16 7:21 ` Andreas Roehler
2006-09-16 11:08 ` Eli Zaretskii
1 sibling, 2 replies; 11+ messages in thread
From: Kevin Rodgers @ 2006-09-15 17:48 UTC (permalink / raw)
Andreas Roehler wrote:
> Thanks all for your useful hints. Here an already working draft:
>
> ;; (defcustom calendar-use-locales nil
> ;; "Use local names of day and month"
>
> ;; :type 'boolean
> ;; :group 'calendar)
>
>
> (setq calendar-use-locales t)
>
> (defun calendar-use-locales-function ()
> " "
> (interactive)
> (when calendar-use-locales
> (progn
> (setq calendar-day-name-array (locale-info 'days))
> (setq calendar-month-name-array (locale-info 'months)))))
>
> ;; with $LANG=de_DE.UTF-8
>
> GNU Emacs 22.0.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
> 2006-09-11
>
> Would be nice to hear from users with different languages.
locale-info returns nil on:
GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-04-22 on YAMALOK
so maybe the default value of calendar-use-locales should depend on
system-type, or you should just get rid of it:
(let ((days (locale-info 'days))
(months (locale-info 'months)))
(when days
(setq calendar-day-name-array days))
(when months
(setq calendar-month-name-array months)))
And since format-time-string's doc string claims that it takes the
locale into account, you could use it to provide the values when
locale-info can't:
(let ((days (locale-info 'days))
(months (locale-info 'months)))
(if days
(setq calendar-day-name-array days)
(let ((this-year
(string-to-number (format-time-string "%Y")))
(this-month
(string-to-number (format-time-string "%m"))))
(setq calendar-day-name-array
(apply 'vector
(mapcar (lambda (time)
(format-time-string "%A" time))
(sort (mapcar (lambda (day)
(encode-time 0 0 0 day
this-month this-year
0))
'(1 2 3 4 5 6 7))
;; by day of week:
(lambda (time-1 time-2)
(< (nth 6 (decode-time time-1))
(nth 6 (decode-time time-2))))))))))
(if months
(setq calendar-month-name-array months)
(let ((this-year
(string-to-number (format-time-string "%Y"))))
(setq calendar-month-name-array
(apply 'vector
(mapcar (lambda (month)
(let ((first (encode-time 0 0 0 1 month
this-year
0)))
(format-time-string "%B" first t)))
'(1 2 3 4 5 6 7 8 9 10 11 12)))))))
Is there any reason not to roll that directly into each variable's
defcustom in calendar.el, where the default values are defined?
And note that "%a" and "%b" can be used the same way to initialize
calendar-day-abbrev-array and calendar-month-abbrev-array, resp.
--
Kevin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-15 17:48 ` Kevin Rodgers
@ 2006-09-16 7:21 ` Andreas Roehler
2006-09-16 11:08 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Andreas Roehler @ 2006-09-16 7:21 UTC (permalink / raw)
Cc: Glenn Morris, emacs-devel
Kevin Rodgers schrieb:
> Andreas Roehler wrote:
>> Thanks all for your useful hints. Here an already working draft:
>>
>> ;; (defcustom calendar-use-locales nil
>> ;; "Use local names of day and month"
>>
>> ;; :type 'boolean
>> ;; :group 'calendar)
>>
>>
>> (setq calendar-use-locales t)
>>
>> (defun calendar-use-locales-function ()
>> " "
>> (interactive)
>> (when calendar-use-locales
>> (progn
>> (setq calendar-day-name-array (locale-info 'days))
>> (setq calendar-month-name-array (locale-info 'months)))))
>> ;; with $LANG=de_DE.UTF-8
>>
>> GNU Emacs 22.0.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
>> of 2006-09-11
>>
>> Would be nice to hear from users with different languages.
>
> locale-info returns nil on:
>
> GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-04-22 on YAMALOK
>
> so maybe the default value of calendar-use-locales should depend on
> system-type, or you should just get rid of it:
>
> (let ((days (locale-info 'days))
> (months (locale-info 'months)))
> (when days
> (setq calendar-day-name-array days))
> (when months
> (setq calendar-month-name-array months)))
>
> And since format-time-string's doc string claims that it takes the
> locale into account, you could use it to provide the values when
> locale-info can't:
>
> (let ((days (locale-info 'days))
> (months (locale-info 'months)))
> (if days
> (setq calendar-day-name-array days)
> (let ((this-year
> (string-to-number (format-time-string "%Y")))
> (this-month
> (string-to-number (format-time-string "%m"))))
> (setq calendar-day-name-array
> (apply 'vector
> (mapcar (lambda (time)
> (format-time-string "%A" time))
> (sort (mapcar (lambda (day)
> (encode-time 0 0 0 day
> this-month this-year
> 0))
> '(1 2 3 4 5 6 7))
> ;; by day of week:
> (lambda (time-1 time-2)
> (< (nth 6 (decode-time time-1))
> (nth 6 (decode-time time-2))))))))))
> (if months
> (setq calendar-month-name-array months)
> (let ((this-year
> (string-to-number (format-time-string "%Y"))))
> (setq calendar-month-name-array
> (apply 'vector
> (mapcar (lambda (month)
> (let ((first (encode-time 0 0 0 1 month
> this-year
> 0)))
> (format-time-string "%B" first t)))
> '(1 2 3 4 5 6 7 8 9 10 11 12)))))))
>
> Is there any reason not to roll that directly into each variable's
> defcustom in calendar.el, where the default values are defined?
> And note that "%a" and "%b" can be used the same way to initialize
> calendar-day-abbrev-array and calendar-month-abbrev-array, resp.
>
OK, thanks! Last question I would leave to the maintainer.
Here the combined results so far:
(defcustom calendar-use-locales nil
"Use local names of day and month"
:type 'boolean
:group 'calendar)
;; Sometimes `defcustom' doesn't take effect immediatitly
;; (setq calendar-use-locales t)
(defun calendar-use-locales-function ()
" "
(interactive)
(when calendar-use-locales
(progn
(let ((days (locale-info 'days))
(months (locale-info 'months)))
(if days
(setq calendar-day-name-array days)
(let ((this-year
(string-to-number (format-time-string "%Y")))
(this-month
(string-to-number (format-time-string "%m"))))
(setq calendar-day-name-array
(apply 'vector
(mapcar (lambda (time)
(format-time-string "%A" time))
(sort (mapcar (lambda (day)
(encode-time 0 0 0 day
this-month this-year
0))
'(1 2 3 4 5 6 7))
;; by day of week:
(lambda (time-1 time-2)
(< (nth 6 (decode-time time-1))
(nth 6 (decode-time time-2))))))))))
(if months
(setq calendar-month-name-array months)
(let ((this-year
(string-to-number (format-time-string "%Y"))))
(setq calendar-month-name-array
(apply 'vector
(mapcar (lambda (month)
(let ((first (encode-time 0 0 0 1 month
this-year
0)))
(format-time-string "%B" first t)))
'(1 2 3 4 5 6 7 8 9 10 11 12))))))))))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-15 17:48 ` Kevin Rodgers
2006-09-16 7:21 ` Andreas Roehler
@ 2006-09-16 11:08 ` Eli Zaretskii
2006-09-16 19:05 ` Richard Stallman
2006-09-24 12:53 ` Eli Zaretskii
1 sibling, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2006-09-16 11:08 UTC (permalink / raw)
> From: Kevin Rodgers <ihs_4664@yahoo.com>
> Date: Fri, 15 Sep 2006 11:48:27 -0600
>
> locale-info returns nil on:
>
> GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-04-22 on YAMALOK
Which is really a bad mantra for Emacs, IMO. (To say nothing of the
fact that the introduction of locale-info, originally under the name
of langinfo, is not in the ChangeLog files.)
Perhaps someone will wish to implement the missing functionality for
the w32 port, before locale-info proliferates into Lisp code, which
will then require ugly hacks to work on Windows.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-16 11:08 ` Eli Zaretskii
@ 2006-09-16 19:05 ` Richard Stallman
2006-09-24 12:53 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2006-09-16 19:05 UTC (permalink / raw)
Cc: emacs-devel
(To say nothing of the
fact that the introduction of locale-info, originally under the name
of langinfo, is not in the ChangeLog files.)
I put the missing entry in src/ChangeLog.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: calendar m17n
2006-09-16 11:08 ` Eli Zaretskii
2006-09-16 19:05 ` Richard Stallman
@ 2006-09-24 12:53 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2006-09-24 12:53 UTC (permalink / raw)
> Date: Sat, 16 Sep 2006 14:08:43 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > From: Kevin Rodgers <ihs_4664@yahoo.com>
> > Date: Fri, 15 Sep 2006 11:48:27 -0600
> >
> > locale-info returns nil on:
> >
> > GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-04-22 on YAMALOK
> [...]
> Perhaps someone will wish to implement the missing functionality for
> the w32 port
I just did. Please test and report any problems, especially on older
Windows version (such as 9x). Critique of how I implemented it is
also welcome.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-09-24 12:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-14 7:31 calendar m17n Andreas Roehler
2006-09-14 8:43 ` Reiner Steib
2006-09-14 8:52 ` Andreas Schwab
2006-09-14 15:39 ` Kevin Rodgers
2006-09-14 18:56 ` Andreas Roehler
2006-09-15 17:38 ` Glenn Morris
2006-09-15 17:48 ` Kevin Rodgers
2006-09-16 7:21 ` Andreas Roehler
2006-09-16 11:08 ` Eli Zaretskii
2006-09-16 19:05 ` Richard Stallman
2006-09-24 12:53 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.