Skip to content

Instantly share code, notes, and snippets.

@bravosierrasierra
Created October 24, 2017 12:46
Show Gist options
  • Save bravosierrasierra/6ce309c2d5b697bebd7a13dac83c146e to your computer and use it in GitHub Desktop.
Save bravosierrasierra/6ce309c2d5b697bebd7a13dac83c146e to your computer and use it in GitHub Desktop.
;;;; Локализация
;;the below breaks gnus. The problem is that message-make-date, which actually shouldn't be localized, uses parse-time-weekdays and parse-time-months, which are localized. So, some more work is needed, along the lines of this:
(use-package parse-time)
(require 'message)
;; Do this before setting the variables correctly.
(setq parse-time-months-unlocalized parse-time-months)
(setq parse-time-weekdays-unlocalized parse-time-weekdays)
(mapc (lambda (x) (add-to-list 'parse-time-months x))
'(("янв" . 1) ("фев" . 2) ("мар" . 3) ("апр" . 4)
("май" . 5) ("мая" . 5) ("июн" . 6) ("июл" . 7)
("авг" . 8) ("сен" . 9) ("окт" . 10) ("ноя" . 11) ("дек" . 12)
("январь" . 1) ("февраль" . 2) ("март" . 3) ("апрель" . 4)
("января" . 1) ("февраля" . 2) ("марта" . 3) ("апреля" . 4)
("июнь" . 6) ("июня" . 6) ("июль" . 7) ("июля" . 7)
("август" . 8) ("августа" . 8) ("сентябрь" . 9) ("сентября" . 9)
("октябрь" . 10) ("ноябрь" . 11) ("декабрь" . 12)
("октября" . 10) ("ноября" . 11) ("декабря" . 12)))
(mapc (lambda (x) (add-to-list 'parse-time-weekdays x))
'(("пн" . 1) ("пон" . 1) ("вт" . 2) ("ср" . 3) ("чт" . 4) ("пт" . 5)
("сб" . 6) ("вс" . 0) ("понедельник" . 1) ("вторник" . 2)
("среда" . 3) ("среду" . 3) ("четверг" . 4) ("пятница" . 5)
("пятницу" . 5) ("суббота" . 6) ("субботу" . 6) ("воскресенье" . 0)))
(defun message-make-date-localized (&optional now)
"Make a valid data header. Uses localized values from parse-time.el. If NOW, use that time instead."
(let* ((now (or now (current-time)))
(zone (nth 8 (decode-time now)))
(sign "+"))
(when (< zone 0)
(setq sign "-")
(setq zone (- zone)))
(concat
;; The day name of the %a spec is locale-specific. Pfff.
(format "%s, " (capitalize (car (rassoc (nth 6 (decode-time now))
parse-time-weekdays))))
(format-time-string "%d" now)
;; The month name of the %b spec is locale-specific. Pfff.
(format " %s "
(capitalize (car (rassoc (nth 4 (decode-time now))
parse-time-months))))
(format-time-string "%Y %H:%M:%S " now)
;; We do all of this because XEmacs doesn't have the %z spec.
(format "%s%02d%02d" sign (/ zone 3600) (/ (% zone 3600) 60)))))
(defun message-make-date-unlocalized (&optional now)
(let ((parse-time-weekdays parse-time-weekdays-unlocalized)
(parse-time-months parse-time-months-unlocalized))
(message-make-date now)))
;(defalias 'message-make-date message-make-date-unlocalized)
;; локализуем функции даты-времени. from http://thenybble.de/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment