1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 07:29:29 +02:00

Internationalize some of sample-data-export.ny, including HTML...

... The rule that one should avoid markup in translatable strings conflicted
with the more important rule against concatenating too many strings that are
too short.
This commit is contained in:
Paul Licameli 2018-03-01 17:24:57 -05:00
parent 4733899dd7
commit da9471ac7f

View File

@ -55,7 +55,7 @@ $control owrite (_"Allow files to be overwritten") choice ((_"No") (_"Yes")) 0
(when (not (boundp 'LR-prefix))(setq LR-prefix nil)) (when (not (boundp 'LR-prefix))(setq LR-prefix nil))
(setq default-filename "sample-data") ; default filename (setq default-filename (_"sample-data")) ; default filename
(setq err "") ; initialise error mesaage (setq err "") ; initialise error mesaage
(setq *float-format* "%1.5f") ; 5 decimal places (setq *float-format* "%1.5f") ; 5 decimal places
@ -131,7 +131,8 @@ $control owrite (_"Allow files to be overwritten") choice ((_"No") (_"Yes")) 0
(setf ln10over20 (/ (log 10.0) 20)) (setf ln10over20 (/ (log 10.0) 20))
(defun lin-to-db (val) (defun lin-to-db (val)
(if (= val 0) (if (= val 0)
"[-inf]" ;i18n-hint abbreviates negative infinity
(_"[-inf]")
(/ (log val) ln10over20))) (/ (log val) ln10over20)))
@ -259,7 +260,7 @@ $control owrite (_"Allow files to be overwritten") choice ((_"No") (_"Yes")) 0
(if (string-equal path "~/" :end1 2) (if (string-equal path "~/" :end1 2)
(setq path (strcat (home)(subseq path 1))))) (setq path (strcat (home)(subseq path 1)))))
;; If path not set use home directory ;; If path not set use home directory
(if (or (string-equal path "Home directory") (if (or (string-equal path (_"Home directory"))
(string-equal path "")) (string-equal path ""))
(setq path (home))) (setq path (home)))
;; if file name not set use default ;; if file name not set use default
@ -365,7 +366,7 @@ DC offset: ~a~a"
;; HTML Output ;; ;; HTML Output ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun html-head () (defun html-head () (strcat
"<!DOCTYPE html> "<!DOCTYPE html>
<html> <html>
<head> <head>
@ -446,26 +447,29 @@ ul {
color: blue; color: blue;
} }
</style> </style>
<title>Sample Data Export</title> <title>" (_"Sample Data Export") "</title>
</head> </head>
") "))
;;; document headings ;;; document headings
(defun doc-head () (defun doc-head ()
(format nil (format nil
"<body> (strcat "<body>
<h1>Sample Data Export - ~a</h1> <h1>" (_"Sample Data Export") " - ~a</h1>
~a ~a
<h4>~a. &nbsp;&nbsp;~a samples. &nbsp;&nbsp; ~a seconds.<br></h4> <h4>~a. &nbsp;&nbsp;" (_"~a samples.") " &nbsp;&nbsp; " (_"~a seconds.") "<br></h4>
<h3>Audio data analysis:</h3> <h3>" (_"Audio data analysis:") "</h3>
<ul> <ul>
<li><b>Sample Rate:</b> &nbsp;&nbsp;~a Hz.</li> <li>" (_"<b>Sample Rate:</b> &nbsp;&nbsp;~a Hz.") "</li>"
<li><b>Peak Amplitude:</b> &nbsp;&nbsp;~a (lin) &nbsp;&nbsp;~a dB.</li> ; i18n-hint: abbreviates "linear" and "decibels"
<li><b>RMS</b> (unweighted): &nbsp;&nbsp;~a dB.</li> "<li>" (_"<b>Peak Amplitude:</b> &nbsp;&nbsp;~a (lin) &nbsp;&nbsp;~a dB.") "</li>"
<li><b>DC Offset:</b> &nbsp;&nbsp;~a</li> ; i18n-hint: RMS abbreviates root-mean-square, a method of averaging a signal; there also "weighted" versions of it but this isn't that
"<li>" (_"<b>RMS</b> (unweighted): &nbsp;&nbsp;~a dB.") "</li>"
; i18n-hint: DC derives from "direct current" in electronics, really means the zero frequency component of a signal
"<li>" (_"<b>DC Offset:</b> &nbsp;&nbsp;~a") "</li>
</ul> </ul>
" ") ; end concatenated format string with inserted translations
(string-right-trim ".html" filename) (string-right-trim ".html" filename)
(format nil "<h2>~a</h2>" optext) ; Optional heading (format nil "<h2>~a</h2>" optext) ; Optional heading
(get 'info 'channels) ; mono/stereo (get 'info 'channels) ; mono/stereo
@ -485,36 +489,37 @@ ul {
;;; table headings (mono) ;;; table headings (mono)
(defun table-head-mono () (defun table-head-mono ()
"<table title=\"sample data\"> (strcat "<table title=\"" (_"sample data") "\">
<tr> <tr>
<th>Sample #</th> <th>" (_"Sample #") "</th>
<th>Seconds</th> <th>" (_"Seconds") "</th>
<th>Value (linear)</th> <th>" (_"Value (linear)") "</th>
<th>Value (dB)</th> <th>" (_"Value (dB)") "</th>
</tr>") </tr>"))
;;; table headings (stereo) ;;; table headings (stereo)
(defun table-head-stereo () (defun table-head-stereo ()
"<table title=\"audio sample value analysis\"> (strcat "<table title=\"" (_"audio sample value analysis") "\">
<tr> <tr>
<th>Sample #</th> <th>" (_"Sample #") "</th>
<th>Seconds </th> <th>" (_"Seconds") "</th>
<th>Left (linear)</th> <th>" (_"Left (linear)") "</th>
<th>Right (linear)</th> <th>" (_"Right (linear)") "</th>
<th>Left (dB)</th> <th>" (_"Left (dB)") "</th>
<th>Right (dB)</th> <th>" (_"Right (dB)") "</th>
</tr>") </tr>"))
(defun html-foot () (defun html-foot ()
(format nil (strcat
"</table> "</table>
<p id=\"footer\">Produced with <span>Sample Data Export</span> for <p id=\"footer\">" (_"Produced with <span>Sample Data Export</span> for
<a href=\"https://www.audacityteam.org/\">Audacity</a> by Steve <a href=\"~a\">Audacity</a> by Steve
Daulton (<a href= Daulton") " (<a href=
\"http://www.easyspacepro.com\">www.easyspacepro.com</a>)</p> \"http://www.easyspacepro.com\">www.easyspacepro.com</a>)</p>
</body> </body>
</html>") </html>") "https://www.audacityteam.org/"))
;;; html generator ;;; html generator
@ -567,25 +572,25 @@ Daulton (<a href=
;;; basic info for headers ;;; basic info for headers
(defun put-head-info () (defun put-head-info ()
(putprop 'info (truncate *sound-srate*) 'srate) (putprop 'info (truncate *sound-srate*) 'srate)
(putprop 'info (if (= units 0) "dB" "linear") 'units) (putprop 'info (if (= units 0) (_"dB") (_"linear")) 'units)
(putprop 'info (/ number *sound-srate*) 'duration) (putprop 'info (/ number *sound-srate*) 'duration)
(putprop 'info (putprop 'info
(if (arrayp s) (if (arrayp s)
"2 channels (stereo)""1 channel (mono)") (_"2 channels (stereo)") (_"1 channel (mono)"))
'channels) 'channels)
;; stereo sample order ;; stereo sample order
(putprop 'info (putprop 'info
(cond (cond
((and (= fileformat 3)(= chan 0)) ; csv, channel in column ((and (= fileformat 3)(= chan 0)) ; csv, channel in column
"One column per channel.\n") (_"One column per channel.\n"))
((and (= fileformat 3)(= chan 2)) ; csv, channel in row ((and (= fileformat 3)(= chan 2)) ; csv, channel in row
"One row per channel.\n") (_"One row per channel.\n"))
((or (soundp s)(= fileformat 4)) ; mono soundor HTML ((or (soundp s)(= fileformat 4)) ; mono soundor HTML
"") "")
((= chan 0) "Left channel then Right channel on same line.\n") ((= chan 0) (_"Left channel then Right channel on same line.\n"))
((= chan 1) "Left and right channels on alternate lines.\n") ((= chan 1) (_"Left and right channels on alternate lines.\n"))
((= chan 2) "Left channel first then right channel.\n") ((= chan 2) (_"Left channel first then right channel.\n"))
(T "Unspecified channel order")) (T (_"Unspecified channel order")))
'chan-order)) 'chan-order))