summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2001-03-11 16:59:35 +0000
committerBruno Haible <bruno@clisp.org>2001-03-11 16:59:35 +0000
commit90aa38be0e6761fb2d731daad2e32345ede3bd9b (patch)
tree67610e01a3312105d60463e4f395c8380078449e
parent0a5b6a62b386d936d2ac2ce29f79034129cbf1e5 (diff)
downloadexternal_gettext-90aa38be0e6761fb2d731daad2e32345ede3bd9b.zip
external_gettext-90aa38be0e6761fb2d731daad2e32345ede3bd9b.tar.gz
external_gettext-90aa38be0e6761fb2d731daad2e32345ede3bd9b.tar.bz2
From Karl Eichwalder:
First attempt at supporting 'msgid_plural' and 'msgstr[]'.
-rw-r--r--misc/ChangeLog11
-rw-r--r--misc/po-mode.el32
2 files changed, 37 insertions, 6 deletions
diff --git a/misc/ChangeLog b/misc/ChangeLog
index cdecf05..fd51976 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,14 @@
+2001-03-10 Karl Eichwalder <ke@suse.de>
+
+ * po-mode.el (po-font-lock-keywords): Respect entry types
+ 'msgid_plural' and 'msgstr[]'.
+ '%*s' is a valid sformat, too.
+ (po-font-lock-keywords): Fix regexp; '[]' part is optional.
+ (po-any-msgstr-regexp): Also match msgstr[] fields.
+ (po-msgstr-idx-keyword-regexp): New variable.
+ (po-set-msgstr): Respect indexed msgstr entries; use
+ `po-msgstr-idx-keyword-regexp'.
+
2001-03-09 Bruno Haible <haible@clisp.cons.org>
* gettextize.in: Update copyright year. Add code to update
diff --git a/misc/po-mode.el b/misc/po-mode.el
index 7e0b02f..07c8ab7 100644
--- a/misc/po-mode.el
+++ b/misc/po-mode.el
@@ -652,8 +652,13 @@ into a Mule coding system.")
"Regexp matching a whole msgid field, whether obsolete or not.")
(defvar po-any-msgstr-regexp
- "^\\(#~?[ \t]*\\)?msgstr.*\n\\(\\(#~?[ \t]*\\)?\".*\n\\)*"
- "Regexp matching a whole msgstr field, whether obsolete or not.")
+ ;; "^\\(#~?[ \t]*\\)?msgstr.*\n\\(\\(#~?[ \t]*\\)?\".*\n\\)*"
+ "^\\(#~?[ \t]*\\)?msgstr\\(\\[[0-9]\\]\\)?.*\n\\(\\(#~?[ \t]*\\)?\".*\n\\)*"
+ "Regexp matching a whole msgstr or msgstr[] field, whether obsolete or not.")
+
+(defvar po-msgstr-idx-keyword-regexp
+ "^\\(#~?[ \t]*\\)?msgstr\\[[0-9]\\]"
+ "Regexp matching an indexed msgstr keyword, whether obsolete or not.")
(defvar po-msgfmt-program "msgfmt"
"Path to msgfmt program from GNU gettext package.")
@@ -661,8 +666,12 @@ into a Mule coding system.")
;; Font lock based highlighting code.
(defconst po-font-lock-keywords
'(
- ("^\\(msgid \\|msgstr \\)?\"\\|\"$" . font-lock-keyword-face)
- ("\\\\.\\|%[-.0-9ul]*[a-zA-Z]" . font-lock-variable-name-face)
+ ;; ("^\\(msgid \\|msgstr \\)?\"\\|\"$" . font-lock-keyword-face)
+ ;; (regexp-opt
+ ;; '("msgid " "msgid_plural " "msgstr " "msgstr[0] " "msgstr[1] "))
+ ("^\\(\\(msg\\(id\\(_plural\\)?\\|str\\(\\[[0-9]\\]\\)?\\)?\\) \\)?\"\\|\"$"
+ . font-lock-keyword-face)
+ ("\\\\.\\|%\\*?[-.0-9ul]*[a-zA-Z]" . font-lock-variable-name-face)
("^# .*\\|^#[:,]?" . font-lock-comment-face)
("^#:\\(.*\\)" 1 font-lock-reference-face)
;; The following line does not work, and I wonder why.
@@ -1548,16 +1557,21 @@ described by FORM is merely identical to the msgid already in place."
t)))))
(defun po-set-msgstr (form)
- "Replace the current msgstr, using FORM to get a string.
+ "Replace the current msgstr or msgstr[], using FORM to get a string.
Evaluating FORM should insert the wanted string in the current buffer. If
FORM is itself a string, then this string is used for insertion. The string
is properly requoted before the replacement occurs.
Returns `nil' if the buffer has not been modified, for if the new msgstr
described by FORM is merely identical to the msgstr already in place."
- (let ((string (po-eval-requoted form "msgstr" (eq po-entry-type 'obsolete))))
+ (let ((string (po-eval-requoted form "msgstr" (eq po-entry-type 'obsolete)))
+ (msgstr-idx nil))
(save-excursion
(goto-char po-start-of-entry)
+ (save-excursion ; check for an indexed msgstr
+ (when (re-search-forward po-msgstr-idx-keyword-regexp po-end-of-entry t)
+ (setq msgstr-idx (buffer-substring-no-properties
+ (match-beginning 0) (match-end 0)))))
(re-search-forward po-any-msgstr-regexp po-end-of-entry)
(and (not (string-equal (po-buffer-substring (match-beginning 0)
(match-end 0))
@@ -1565,6 +1579,12 @@ described by FORM is merely identical to the msgstr already in place."
(let ((buffer-read-only po-read-only))
(po-decrease-type-counter)
(replace-match string t t)
+ (goto-char (match-beginning 0))
+ (unless (eq msgstr-idx nil) ; hack: replace msgstr with msgstr[d]
+ (progn
+ (insert msgstr-idx)
+ (looking-at "\\(#~?[ \t]*\\)?msgstr")
+ (replace-match "")))
(goto-char po-start-of-msgid)
(po-find-span-of-entry)
(po-increase-type-counter)