all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Swedish calendar localization in official release (sv-kalender.el)?
@ 2021-07-04 11:40 Arthur Miller
  2021-07-05 11:51 ` Stefan Kangas
  0 siblings, 1 reply; 16+ messages in thread
From: Arthur Miller @ 2021-07-04 11:40 UTC (permalink / raw)
  To: emacs-devel

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


Just a question/suggestion: can we get a localized calendar for swedish
language into official release? There is a small file by Daniel Jensen,
found at: http://bigwalter.net/daniel/elisp/.

I did a small hack to it, just added names for abbreviated day names and
header array since it seems to not be properly initialized if
sv-kalender is loaded after the calender.el.

In a short mail correspondence with Daniel, he says he has signed FSF
copyrights, so I guess, legaly it shouldn't be a problem to include that
file amongst few other localizations in lisp/calender?

I don't know what is your policy to include localizations, I see there
are not many there, and those that are there (French "revolutionary")
and Chinese do much more than just localize names and few
hollidays. Anyway, it would be convenient if it was included. Maybe the
name of the file itself should be adjusted, like calender-swedish.el or
something?

Also a side question about localizations as found on Emacs Wiki:

https://www.emacswiki.org/emacs/CalendarLocalization

I can't imagine that day and month names and few other bits related to
that information can be copyrighted. Would ot be interesting to
collect info from that wiki page into some file with localized names
and maybe have Emacs auto load localized names when avialable based on
value in LANG env (or whatever variable is suitable), and a variable to
turn on/off that behaviour?


[-- Attachment #2: sv-kalender.el --]
[-- Type: text/plain, Size: 10946 bytes --]

;;; sv-kalender.el --- Swedish calendar for Emacs

;; Copyright (C) 2002,2003,2004,2007,2009,2018 Daniel Jensen

;; Author: Daniel Jensen <daniel@bigwalter.net>
;; Version: 1.9
;; Keywords: calendar swedish localization

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
;;; Kommentarer:

;; Swedish calendar localization. Note: Only a few comments in this
;; file are in English. The rest is in Swedish.

;; Denna fil modifierar hur Emacs kalender ser ut. Den byter namn på
;; veckodagar, månader etc., samt inför svenska helgdagar och högtider
;; i stället för de amerikanska.
;;
;; För att använda den svenska kalendern, spara filen i din load-path
;; och använd (load "sv-kalender") i din ~/.emacs.

;;; History (ändringar):

;; 1.9.1 - added provide statement
;; 1.9 - Update for Emacs 25
;; 1.8 - Emacs 23 support. GPLv3.
;; 1.6 - Lunar phase names, sunrise/sunset
;;       (månfasernas namn, soluppgång och -nedgång)
;; 1.5 - Cleanup, introduce sv prefix (städning, nytt sv-prefix)
;; 1.4 - Months and days use lower-case initials
;;       (månader och dagar med små begynnelsebokstäver)
;; 1.3 - New flag days, Easter bug fixes
;;       (nya flaggdagar och en bugg i "mer påsk" fixad) (Alan Campbell)
;; 1.2 - Advent Sundays fixed (adventsdagarna justerade) (Alan Campbell)
;; 1.1 - Fat Tuesday moved back a week (fettisdagen flyttad en vecka bakåt).

;;; Code:

(require 'calendar)
(require 'holidays)
(require 'solar)
(require 'lunar)

;; Veckan börjar med en måndag
(setq calendar-week-start-day 1)

;; Använd "europeiska" datum (dag/måndad)
(setq calendar-date-style 'european)

;; Datumformat
(setq calendar-date-display-form
      '((if dayname
            (concat dayname ", "))
        day " " monthname " " year))

;; 24-timmarsklocka utan tidszon
(setq calendar-time-display-form
      '(24-hours ":" minutes))

;; Dagarnas namn
(setq calendar-day-name-array
      ["söndag" "måndag" "tisdag" "onsdag" "torsdag" "fredag" "lördag"]
      calendar-day-abbrev-array
      ["sön" "mån" "tis" "ons" "tors" "fre" "lör"]
      calendar-day-header-array
      ["sö" "må" "ti" "on" "to" "fr" "lö"])

;; Månadernas namn
(setq calendar-month-name-array
      ["januari" "februari" "mars" "april" "maj" "juni"
       "juli" "augusti" "september" "oktober" "november" "december"])

;; Årets vändpunkter
(eval-after-load "solar"
  '(setq solar-n-hemi-seasons
         '("Vårdagjämningen" "Sommarsolståndet"
           "Höstdagjämningen" "Vintersolståndet")))

;; Månfaser
(defadvice lunar-phase-name (around sv-lunar-phase-name activate)
  "Månfasernas namn på svenska."
  (setq ad-return-value
	(let ((phase (ad-get-arg 0)))
	  (cond ((= 0 phase) "Nymåne")
		((= 1 phase) "Växande halvmåne")
		((= 2 phase) "Fullmåne")
		((= 3 phase) "Avtagande halvmåne")))))

;; Soluppgång och -nedgång
(defadvice solar-sunrise-sunset-string (around sv-solar-sunrise-sunset-string
                                               activate)
  "Soluppgång och solnedgång på svenska."
  (setq ad-return-value
        (let ((l (solar-sunrise-sunset date)))
          (format
           "%s, %s vid %s (%s timmar dagsljus)"
           (if (car l)
               (concat "Sol upp " (apply 'solar-time-string (car l)))
             "Ingen soluppgång")
           (if (car (cdr l))
               (concat "ned " (apply 'solar-time-string (car (cdr l))))
             "ingen solnedgång")
           (eval calendar-location-name)
           (car (cdr (cdr l)))))))

;; Göm vissa helgdagar?
(defvar sv-hide-some-holidays nil
  "Non-nil means some holidays won't show in the calendar.
Om icke-nil, göm vissa helgdagar i kalendern.")

;; Påskdagen (from holiday-easter-etc)
(defun sv-easter (year)
  "Calculate the date for Easter in YEAR.
Beräkna påskdagen för år YEAR."
  (let* ((century (1+ (/ year 100)))
         (shifted-epact (% (+ 14 (* 11 (% year 19))
                              (- (/ (* 3 century) 4))
                              (/ (+ 5 (* 8 century)) 25)
                              (* 30 century))
                           30))
         (adjusted-epact (if (or (= shifted-epact 0)
                                 (and (= shifted-epact 1)
                                      (< 10 (% year 19))))
                             (1+ shifted-epact)
                           shifted-epact))
         (paschal-moon (- (calendar-absolute-from-gregorian
                           (list 4 19 year))
                          adjusted-epact)))
    (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))

;; Helgdagar
(setq holiday-general-holidays
      '((holiday-fixed 1 1 "Nyårsdagen")
        (holiday-fixed 1 6 "Trettondedag jul")

        ;; Påsk och pingst
        (holiday-filter-visible-calendar
         (mapcar
          (lambda (dag)
            (list (calendar-gregorian-from-absolute
                   (+ (sv-easter displayed-year) (car dag)))
                  (cadr dag)))
          '((  -2 "Långfredagen")
            (  -1 "Påskafton")
            (   0 "Påskdagen")
            (  +1 "Annandag påsk")
            ( +39 "Kristi himmelfärdsdag")
            ( +49 "Pingstdagen")
            ( +50 "Annandag pingst"))))

        (holiday-fixed 5 1 "Första maj")

        (let ((midsommar-d (calendar-dayname-on-or-before
                            6 (calendar-absolute-from-gregorian
                               (list 6 26 displayed-year)))))
          ;; Midsommar
          (holiday-filter-visible-calendar
           (list
            (list
             (calendar-gregorian-from-absolute (1- midsommar-d))
             "Midsommarafton")
            (list
             (calendar-gregorian-from-absolute midsommar-d)
             "Midsommardagen")
            ;; Alla helgons dag
            (list
             (calendar-gregorian-from-absolute
              (calendar-dayname-on-or-before
               6 (calendar-absolute-from-gregorian
                  (list 11 6 displayed-year))))
             "Alla helgons dag"))))
        
        (holiday-fixed 12 25 "Juldagen")
        (holiday-fixed 12 26 "Annandag jul")))

;; Andra högtider
(setq holiday-other-holidays
      '((holiday-fixed 1 13 "Tjugondag Knut")
        (unless sv-hide-some-holidays
          (holiday-fixed 1 28 "Konungens namnsdag"))
        (unless sv-hide-some-holidays
          (holiday-fixed 2 2 "Kyndelsmässodagen"))
        (holiday-fixed 2 14 "Alla hjärtans dag")

        ;; Fettisdagen
        (holiday-filter-visible-calendar
         (list
          (list
           (calendar-gregorian-from-absolute
            (calendar-dayname-on-or-before
             2 (- (sv-easter displayed-year) 47)))
           "Fettisdagen")))

        (holiday-fixed 3 8 "Internationella kvinnodagen")
        (unless sv-hide-some-holidays
          (holiday-fixed 3 12 "Kronprinsessans namnsdag"))
        (holiday-fixed 3 25 "Vårfrudagen")

        ;; Mer påsk
        (holiday-filter-visible-calendar
         (mapcar
          (lambda (dag)
            (list (calendar-gregorian-from-absolute
                   (+ (sv-easter displayed-year) (car dag)))
                  (cadr dag)))
          (if sv-hide-some-holidays
              '(( -3 "Skärtorsdagen"))
            '(( -7 "Palmsöndagen")
              ( -4 "Dymmelonsdagen")
              ( -3 "Skärtorsdagen")))))

        (unless sv-hide-some-holidays
          (holiday-fixed 4 30 "Konungens födelsedag"))
        (unless sv-hide-some-holidays
          (holiday-fixed 4 1 "Första april"))
        (holiday-fixed 4 30 "Valborgsmässoafton")
        (holiday-float 5 0 -1 "Mors dag")
        (holiday-fixed 6 6 "Sveriges nationaldag")
        (unless sv-hide-some-holidays
          (holiday-fixed 7 14 "Kronprinsessans födelsedag"))
        (unless sv-hide-some-holidays
          (holiday-fixed 8 8 "Drottningens namnsdag"))
        (holiday-fixed 10 24 "FN-dagen")
        (holiday-float 11 0 2 "Fars dag")
        (unless sv-hide-some-holidays
          (holiday-fixed 11 6 "Gustaf Adolfsdagen"))
        (holiday-fixed 11 10 "Mårtensafton")
        (holiday-float 12 0 -4 "Första advent" 24)
        (holiday-float 12 0 -3 "Andra advent" 24)
        (holiday-float 12 0 -2 "Tredje advent" 24)
        (holiday-float 12 0 -1 "Fjärde advent" 24)
        (holiday-fixed 12 10 "Nobeldagen")
        (holiday-fixed 12 13 "Lucia")
        (unless sv-hide-some-holidays
          (holiday-fixed 12 23 "Drottningens födelsedag"))
        (holiday-fixed 12 24 "Julafton")
        (holiday-fixed 12 31 "Nyårsafton")))

;; Solstånd, dagjämningar, vinter- och sommartid
(setq holiday-solar-holidays
      (if sv-hide-some-holidays
          nil
        '((if (fboundp 'atan)
              (solar-equinoxes-solstices))
          (if (progn
                (require 'cal-dst)
                t)
              (funcall 'holiday-sexp calendar-daylight-savings-starts
                       '(format "Sommartid börjar %s"
                                (if
                                    (fboundp 'atan)
                                    (solar-time-string
                                     (/ calendar-daylight-savings-starts-time
                                        (float 60))
                                     calendar-standard-time-zone-name)
                                  ""))))
          (funcall 'holiday-sexp calendar-daylight-savings-ends
                   '(format "Vintertid börjar %s"
                            (if
                                (fboundp 'atan)
                                (solar-time-string
                                 (/ calendar-daylight-savings-ends-time
                                    (float 60))
                                 calendar-daylight-time-zone-name)
                              ""))))))

;; Listan med kalenderns helgdagar
(setq calendar-holidays
      (append holiday-general-holidays holiday-local-holidays
              holiday-other-holidays holiday-solar-holidays))

(provide 'sv-kalender)

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

end of thread, other threads:[~2021-07-09  9:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-04 11:40 Swedish calendar localization in official release (sv-kalender.el)? Arthur Miller
2021-07-05 11:51 ` Stefan Kangas
2021-07-05 13:00   ` Teemu Likonen
2021-07-05 21:02     ` Arthur Miller
2021-07-05 20:58   ` Arthur Miller
2021-07-06  7:55   ` Teemu Likonen
2021-07-06  9:38     ` Arthur Miller
2021-07-06 10:30       ` Teemu Likonen
2021-07-06 13:38         ` Arthur Miller
2021-07-06 16:38           ` Stefan Kangas
2021-07-06 17:23             ` Arthur Miller
2021-07-07 14:31               ` Filipp Gunbin
2021-07-08  2:23                 ` Arthur Miller
2021-07-08 14:27                   ` Filipp Gunbin
2021-07-09  9:00                     ` Arthur Miller
2021-07-06 12:20     ` Stefan Kangas

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.