From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.devel Subject: Re: calendar m17n Date: Fri, 15 Sep 2006 11:48:27 -0600 Organization: IHS Message-ID: References: <45090552.3030606@easy-emacs.de> <4509A5DC.50607@easy-emacs.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1158342641 4351 80.91.229.2 (15 Sep 2006 17:50:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Sep 2006 17:50:41 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 15 19:50:40 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GOHpW-00066U-7p for ged-emacs-devel@m.gmane.org; Fri, 15 Sep 2006 19:50:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GOHpV-0005lM-R3 for ged-emacs-devel@m.gmane.org; Fri, 15 Sep 2006 13:50:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GOHpK-0005js-Sn for emacs-devel@gnu.org; Fri, 15 Sep 2006 13:50:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GOHpK-0005it-0f for emacs-devel@gnu.org; Fri, 15 Sep 2006 13:50:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GOHpJ-0005iq-SB for emacs-devel@gnu.org; Fri, 15 Sep 2006 13:50:09 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GOHrW-00068E-UV for emacs-devel@gnu.org; Fri, 15 Sep 2006 13:52:27 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GOHoy-0005yM-4c for emacs-devel@gnu.org; Fri, 15 Sep 2006 19:49:48 +0200 Original-Received: from 207.167.42.206 ([207.167.42.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Sep 2006 19:49:48 +0200 Original-Received: from ihs_4664 by 207.167.42.206 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Sep 2006 19:49:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 86 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.206 User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) In-Reply-To: <4509A5DC.50607@easy-emacs.de> X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59890 Archived-At: 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