Hi Andrey,

Andrey G. Grozin wrote:
Finally, an old bug which seems immortal: in the Go menu, file names are translated!!! index.html looks as указатель.html !!! As I said at the workshop, plugin names in the Help -> Plug-ins menu are also translated, Axiom becomes Аксиома.
It took me a while, and I'm not quite sure it's completely right, so I won't commit it to the repo yet, but in the meantime, you can apply the patch I've attached. The problem was that any strings used as labels in the menus or elsewhere are automatically translated, so I created a new tag "nolocale" which can be used to bypass this feature. In your menu definitions you can use it like this:

(menu-bing tools-menu
 (former)
 ---
 ((nolocale "Document") (noop)))

I suppose you already filed a bug, can you send me the link so I post the patch there?

Thanks,
--
______________
Miguel de Benito.

diff --git a/src/TeXmacs/progs/doc/help-menu.scm 
b/src/TeXmacs/progs/doc/help-menu.scm
index 423d55b..14b0bec 100644
--- a/src/TeXmacs/progs/doc/help-menu.scm
+++ b/src/TeXmacs/progs/doc/help-menu.scm
@@ -27,7 +27,7 @@
                           plugin-documented?))
     (with menu-name (or (ahash-ref supported-sessions-table name)
                         (upcase-first name))
-      ((eval menu-name)
+      ((nolocale (eval menu-name))
        (load-help-article (string-append name))))))
 
 (menu-bind help-menu
diff --git a/src/TeXmacs/progs/kernel/gui/gui-markup.scm 
b/src/TeXmacs/progs/kernel/gui/gui-markup.scm
index 272c343..a301c17 100644
--- a/src/TeXmacs/progs/kernel/gui/gui-markup.scm
+++ b/src/TeXmacs/progs/kernel/gui/gui-markup.scm
@@ -262,6 +262,10 @@
   (:synopsis "Make text")
   `(list 'text ,text))
 
+(tm-define-macro ($nolocale text)
+  (:synopsis "Make non-localizable text")
+  `(list 'nolocale ,text))
+
 (tm-define-macro ($input cmd type proposals width)
   (:synopsis "Make input field")
   `(list 'input (lambda (answer) ,cmd) ,type (lambda () ,proposals) ,width))
diff --git a/src/TeXmacs/progs/kernel/gui/menu-define.scm 
b/src/TeXmacs/progs/kernel/gui/menu-define.scm
index 071322f..df87d34 100644
--- a/src/TeXmacs/progs/kernel/gui/menu-define.scm
+++ b/src/TeXmacs/progs/kernel/gui/menu-define.scm
@@ -22,6 +22,10 @@
   (if (not (match? x pattern))
     (texmacs-error "gui-make" "invalid menu item ~S" x)))
 
+(define (gui-make-nolocale x)
+  (require-format x '(nolocale :%1))
+  `($nolocale ,(cadr x)))
+
 (define (gui-make-eval x)
   (require-format x '(eval :%1))
   (cadr x))
@@ -295,6 +299,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-table gui-make-table
+  (nolocale ,gui-make-nolocale)
   (eval ,gui-make-eval)
   (dynamic ,gui-make-dynamic)
   (former ,gui-make-former)
@@ -373,11 +378,11 @@
                ((== x (string->symbol "|")) '$/)
                (else
                  (texmacs-error "gui-make" "invalid menu item ~S" x))))
-       ((string? x) x)
+        ((string? x) x)
         ((and (pair? x) (ahash-ref gui-make-table (car x)))
          (apply (car (ahash-ref gui-make-table (car x))) (list x)))
-       ((and (pair? x) (or (string? (car x)) (pair? (car x))))
-        `($> ,(gui-make (car x)) ,@(cdr x)))
+        ((and (pair? x) (or (string? (car x)) (pair? (car x))))
+         `($> ,(gui-make (car x)) ,@(cdr x)))
         (else
           (texmacs-error "gui-make" "invalid menu item ~S" x))))
 
diff --git a/src/TeXmacs/progs/kernel/gui/menu-widget.scm 
b/src/TeXmacs/progs/kernel/gui/menu-widget.scm
index 94011e7..7cc7e83 100644
--- a/src/TeXmacs/progs/kernel/gui/menu-widget.scm
+++ b/src/TeXmacs/progs/kernel/gui/menu-widget.scm
@@ -23,6 +23,7 @@
 (define-regexp-grammar
   (:menu-label (:or
     :string?
+    (nolocale :string?)
     (concat :*)
     (color :%5)
     (verbatim :%1)
@@ -38,6 +39,7 @@
   (:menu-item (:or
     ---
     |
+    (nolocale :string?)
     (group :string?)
     (text :string?)
     (glue :boolean? :boolean? :integer? :integer?)
@@ -134,7 +136,8 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (translatable? s)
-  (or (string? s) (func? s 'concat) (func? s 'verbatim)))
+  (and (not (func? s 'nolocale)) 
+       (or (string? s) (func? s 'concat) (func? s 'verbatim))))
 
 (define (active? style)
   (== (logand style widget-style-inert) 0))
@@ -153,19 +156,24 @@
   ;;     Example default values are: family="roman", class="mr",
   ;;     series="medium", shape="normal", size=10, dpi=600.
   ;;   <label> :: <string>
-  ;;     Simple menu label, its display style is controlled by tt? and style
+  ;;     Simple menu label, its display style is controlled by tt? and style.
+  ;;   <label> :: (nolocale <string>)
+  ;;     Simple menu label which won't be translated.
   ;;   <label> :: (icon <string>)
   ;;     Pixmap menu label, the <string> is the name of the pixmap.
   (let ((tt? (and (nnull? opt) (car opt)))
        (col (color (if (greyed? style) "dark grey" "black"))))
     (cond ((translatable? p)           ; "text"
-          (widget-text (translate p) style col #t))
-         ((tuple? p 'balloon 2)        ; (balloon <label> "balloon text")
-          (make-menu-label (cadr p) style tt?))
-         ((tuple? p 'extend)           ; (extend <label> . ws)
+           (widget-text (translate p) style col #t))
+          ((func? p 'nolocale)
+           (display* "hi there! : " p "\n")
+           (widget-text (cadr p) style col #t))
+          ((tuple? p 'balloon 2)        ; (balloon <label> "balloon text")
+           (make-menu-label (cadr p) style tt?))
+          ((tuple? p 'extend)          ; (extend <label> . ws)
            (with l (make-menu-items (cddr p) style tt?)
-             (widget-extend (make-menu-label (cadr p) style tt?) l)))
-         ((tuple? p 'style 2)          ; (style st <label>)
+            (widget-extend (make-menu-label (cadr p) style tt?) l)))
+          ((tuple? p 'style 2)         ; (style st <label>)
            (let* ((x (cadr p))
                   (new-style (if (> x 0) (logior style x)
                                  (logand style (lognot (- x))))))
@@ -576,6 +584,8 @@
         ,(lambda (p style bar?) (list (make-menu-group (cadr p) style))))
   (text (:string?)
         ,(lambda (p style bar?) (list (make-menu-text (cadr p) style))))
+  (nolocale (:string?)
+        ,(lambda (p style bar?) (list (make-menu-text (cadr p) style))))
   (symbol (:string? :*)
          ,(lambda (p style bar?) (list (make-menu-symbol p style))))
   (texmacs-output (:%1)
_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/texmacs-dev

Reply via email to