pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2958 - branches/pingus_sdl/data/po


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2958 - branches/pingus_sdl/data/po
Date: Thu, 16 Aug 2007 16:27:56 +0200

Author: grumbel
Date: 2007-08-16 16:27:56 +0200 (Thu, 16 Aug 2007)
New Revision: 2958

Removed:
   branches/pingus_sdl/data/po/extract-levels.sh
Modified:
   branches/pingus_sdl/data/po/extract-levels.guile
   branches/pingus_sdl/data/po/extract-po.sh
Log:
- fixed a few bugs, added line numbers to .pot file

Modified: branches/pingus_sdl/data/po/extract-levels.guile
===================================================================
--- branches/pingus_sdl/data/po/extract-levels.guile    2007-08-16 14:26:04 UTC 
(rev 2957)
+++ branches/pingus_sdl/data/po/extract-levels.guile    2007-08-16 14:27:56 UTC 
(rev 2958)
@@ -8,51 +8,64 @@
   '((pingus-level head levelname)
     (pingus-level head description)))
 
+;; FIXME: add (pingus-worldmap (end_story intro_story)  pages page text) 
support
 (define worldmap-pattern-list
-  '((pingus-worldmap head name)
-    (pingus-worldmap head description)
-    (pingus-worldmap intro_story title)
-    (pingus-worldmap intro_story text)
-    (pingus-worldmap intro_story pages page text)
-    (pingus-worldmap end_story   title)
-    (pingus-worldmap end_story   pages page text)
-    ))
+  '((pingus-worldmap head (name description))
+    (pingus-worldmap (intro_story end_story) title)
+    (pingus-worldmap (intro_story end_story) pages page text)))
 
-(define *current-file* "")
-
 (define (escape-string str)
   (regexp-substitute/global #f "\"" str 'pre "\\\"" 'post))
 
-(define (print-msg sexpr)
+(define (print-msg sexpr props)
   (let ((str  (escape-string (apply string-append sexpr))) )
     (cond ((not (string-null? str))
            (display "#: ")
-           (display *current-file*)
+           (display (assoc-ref props 'filename))
+           (display ":")
+           (display (+ (assoc-ref props 'line) 1))
            (newline)
-           (display "msgid = \"")
+           (display "msgid \"")
            (display str)
            (display "\"\n")
-           (display "msgstr = \"\"\n")
+           (display "msgstr \"\"\n")
            (newline)
            ))))
 
-(define (grep-sexpr func pattern sexpr)
+(define (pattern-match pattern sym)
+  (cond ((list? pattern)
+         (let loop ((pat pattern))
+           (if (null? pat)
+               #f
+               (if (pattern-match (car pat) sym)
+                   #t
+                   (loop (cdr pat))))))
+        ((symbol? pattern)
+         (equal? pattern sym))
+        ((string? pattern)
+         (string-match pattern (symbol->string sym)))
+        (else 
+         (error "Unknown pattern: " pattern))))
+
+(define (grep-sexpr func pattern sexpr props)
   (cond ((null? pattern)
-         (func sexpr))
+         (func sexpr props))
         (else
          (for-each (lambda (el)
-                     (if (equal? (car pattern) (car el))
-                         (grep-sexpr func (cdr pattern) (cdr el))))
+                     (cond ((pattern-match (car pattern) (car el))
+                            (grep-sexpr func (cdr pattern) (cdr el)
+                                        (source-properties el)
+                                        ))))
                    sexpr))))
 
 (define (main args)
+  (read-enable 'positions)
   (set! args (cdr args))
   (for-each (lambda (file)
-              (set! *current-file* file)
               (let* ((port  (open-input-file file))
                      (sexpr (list (read port))))
                 (for-each (lambda (pattern)
-                            (grep-sexpr print-msg pattern sexpr))
+                            (grep-sexpr print-msg pattern sexpr 0))
                           (cond ((string-suffix? ".worldmap" file)
                                  worldmap-pattern-list)
                                 ((string-suffix? ".pingus" file)
@@ -60,7 +73,6 @@
                                 (else
                                  (error "Unknown file suffix\n"))))
                 (close-port port)))
-            args)
-  (display "\n# EOF #\n"))
+            args))
 
 ;; EOF ;;

Deleted: branches/pingus_sdl/data/po/extract-levels.sh
===================================================================
--- branches/pingus_sdl/data/po/extract-levels.sh       2007-08-16 14:26:04 UTC 
(rev 2957)
+++ branches/pingus_sdl/data/po/extract-levels.sh       2007-08-16 14:27:56 UTC 
(rev 2958)
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-set -e 
-
-echo -n "Extracting strings from levels... "
-./extract-levels.guile ../levels/*/*.pingus > levels.pot
-echo "done"
-
-echo -n "Extracting strings from worldmaps... "
-./extract-levels.guile ../worldmaps/*.worldmap > worldmaps.pot
-echo "done"
-
-# EOF #

Modified: branches/pingus_sdl/data/po/extract-po.sh
===================================================================
--- branches/pingus_sdl/data/po/extract-po.sh   2007-08-16 14:26:04 UTC (rev 
2957)
+++ branches/pingus_sdl/data/po/extract-po.sh   2007-08-16 14:27:56 UTC (rev 
2958)
@@ -3,25 +3,45 @@
 set -e
 
 TMP=$(tempfile)
-OUT="pingus.pot"
+OUT="data/po/pingus.pot"
 
-echo -n "Generating file list... "
-find ../../src/ -name "*.?pp" | sed "s/..\/..\///" > "$TMP"
+cd ../.. # go to toplevel dir
+echo -n "Generating C++ file list... "
+find src/ -name "*.?pp" > "$TMP"
 echo "done"
 
-echo -n "Extracting strings..."
+echo -n "Extracting strings from C++..."
 xgettext \
     --c++ \
     --boost \
-    --directory "../../" \
-    --output "$OUT" \
+    --directory "." \
+    --output "${OUT}.tmp" \
+    --from=code=ASCII \
     --keyword=_ \
     --keyword=N_ \
     --files-from "$TMP"
 echo "done"
 
-echo "Output written to $OUT"
+echo "" >> "${OUT}.tmp"
 
+echo -n "Extracting strings from levels... "
+data/po/extract-levels.guile data/levels/*/*.pingus >> "${OUT}.tmp"
+echo "done"
+
+echo -n "Extracting strings from worldmaps... "
+data/po/extract-levels.guile data/worldmaps/*.worldmap >> "${OUT}.tmp"
+echo "done"
+
+rpl "\"Content-Type: text/plain; charset=CHARSET\\n\"" \
+    "\"Content-Type: text/plain; charset=ASCII\\n\"" \
+    "${OUT}.tmp"
+
+echo -n "Removing duplicate entries... "
+msguniq -o "$OUT" "${OUT}.tmp"
+echo "done"
+
+echo "Output written to pingus.pot"
+
 rm $TMP
 
 # EOF #





reply via email to

[Prev in Thread] Current Thread [Next in Thread]