From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Doug Lewan Newsgroups: gmane.emacs.help Subject: RE: Help with emacs scripting Date: Fri, 13 Apr 2012 13:56:13 +0000 Message-ID: <495248DFDEA08C469BBDED2D4AA6C614425873@DAKIYA1.pegasus.local> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1334325243 7078 80.91.229.3 (13 Apr 2012 13:54:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2012 13:54:03 +0000 (UTC) Cc: Daniel Sousa To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 13 15:54:02 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SIgwr-0004va-02 for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2012 15:54:01 +0200 Original-Received: from localhost ([::1]:33817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIgwq-0007WU-Bd for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Apr 2012 09:54:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIgwj-0007W0-Gd for help-gnu-emacs@gnu.org; Fri, 13 Apr 2012 09:53:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIgwe-0004Ok-E8 for help-gnu-emacs@gnu.org; Fri, 13 Apr 2012 09:53:53 -0400 Original-Received: from mailhost.shubertorg.com ([207.246.209.200]:15778 helo=webmail.shubertorg.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIgwe-0004OL-9m for help-gnu-emacs@gnu.org; Fri, 13 Apr 2012 09:53:48 -0400 Original-Received: from dakiya1.pegasus.local ([::1]) by DAKIYA1.pegasus.local ([::1]) with mapi id 14.01.0339.001; Fri, 13 Apr 2012 09:56:14 -0400 Thread-Topic: Help with emacs scripting Thread-Index: AQHNGMa8Wdv5QZFaYUKaLPZ+RWmxZZaYxcBg In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: AaKp Brqd Feoo FlYt HwIV IyjT L8FY NIsa NP5T OpE0 QWyE RHvg ScUv Snt1 UMRh WPCH; 2; ZABhAG4AaQBlAGwAQABzAG8AdQBzAGEALgBtAGUAOwBoAGUAbABwAC0AZwBuAHUALQBlAG0AYQBjAHMAQABnAG4AdQAuAG8AcgBnAA==; Sosha1_v1; 7; {C00F7164-017E-4780-981E-ABE2B9B22EEA}; ZABvAHUAZwBsAEAAcwBoAHUAYgBlAHIAdAB0AGkAYwBrAGUAdABpAG4AZwAuAGMAbwBtAA==; Fri, 13 Apr 2012 13:53:39 GMT; UgBFADoAIABIAGUAbABwACAAdwBpAHQAaAAgAGUAbQBhAGMAcwAgAHMAYwByAGkAcAB0AGkAbgBnAA== x-cr-puzzleid: {C00F7164-017E-4780-981E-ABE2B9B22EEA} x-originating-ip: [10.0.21.202] X-detected-operating-system: by eggs.gnu.org: Windows XP/2000 (RFC1323+, w+, tstamp-) X-Received-From: 207.246.209.200 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84451 Archived-At: A concrete example always makes vague requirements clearer. Thank you. I think the following will do what you want. The process is this:=20 1. Go through the XSL buffer(s),=20 2. sweeping the strings of interest and 3. type C-cC-c to process. 4. Move on to the next string and repeat. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *ds-languages-dir* "languages") (defvar *ds-php-file* (format "%s/pt.php" *ds-languages-dir*)) (defvar *ds-php-buffer* ()) (defun ds-create-lang-entries () "Change the selection in the current buffer and create a PHP definition i= n the PHP file. The change to make is \'MATCHED_STRING\' --> \'\'. The addition to the PHP file is made at the end of the file; it is \'DEFINE(\"_LANG_MATCHED_STRING\", \"bar\");\'." (interactive) (ensure-php-buffer) (let* ((xsl-format "") (php-format "DEFINE(\"_LANG_%s\", \"bar\");\n") (the-string (buffer-substring-no-properties (point) (mark))) (the-STRING (upcase the-string))) ;; Change the selected text to the appropriate XSL (delete-region (point) (mark)) (goto-char (mark)) (insert (format xsl-format the-string)) ;; Now add a PHP definition at the end of the PHP file. (save-excursion (set-buffer *ds-php-buffer*) (goto-char (point-max)) (insert (format php-format the-STRING))))) (defun ensure-php-buffer () "Make sure that everything about the PHP buffer is good." (unless (file-directory-p *ds-languages-dir*) (make-directory *ds-languag= es-dir* t)) (unless *ds-php-buffer* (setq *ds-php-buffer* (find-file-noselect *ds-php= -file*)))) (local-set-key "\C-c\C-c" 'ds-create-lang-entries) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; I hope this helps. ,Doug From: help-gnu-emacs-bounces+dougl=3Dshubertticketing.com@gnu.org [mailto:h= elp-gnu-emacs-bounces+dougl=3Dshubertticketing.com@gnu.org] On Behalf Of Da= niel Sousa Sent: Thursday, 2012 April 12 12:10 To: help-gnu-emacs@gnu.org Subject: Re: Help with emacs scripting I'm majoring in applied math and computation, I know pretty well that compu= ters are dumb xD I think neither of you have understood what I wanted, so I'll give you an e= xample. I have a lot of .xsl that generate pages and I want to make those pages tra= nslatable. I migth have the file, for exemple, welcome.xsl: =A0

Bem-vindo

  • Coisa
And I wanted to make this translatable, so I change this to =A0

  • =A0=A0
And I create a languages/pt.php with: =A0define('_LANG_WELCOME','Bem-vindo');=20 =A0define('_LANG_STUFF','Coisa'); I have a piece of php code that puts in the xml all the constants that begi= n with "_LANG". I have a lot of these .xsl and I need to go manually through them all to fi= nd the strings that I want to make translatable. What I want this script to= do is, on my input put that=A0= =A0thing on the place I select and append to the language file the repectiv= e define();.