From 274bfa0966e90c4b9cf916c76634bb46acdbbd9e Mon Sep 17 00:00:00 2001 From: Goraf Date: Mon, 16 Sep 2013 20:15:50 +0000 Subject: now handles /") git-svn-id: http://svn.miranda-ng.org/main/trunk@6099 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- tools/lpgen/lpgen.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools/lpgen') diff --git a/tools/lpgen/lpgen.js b/tools/lpgen/lpgen.js index 05bcf289a2..8e61e62aa7 100644 --- a/tools/lpgen/lpgen.js +++ b/tools/lpgen/lpgen.js @@ -437,17 +437,19 @@ function ParseSourceFile (FileTextVar,array) { //not store ?: functions LPGEN or LPGENT? or Translate(T or W) or _T, than any unnecessary space \s, than not stored ?: "(" followed by ' or " (stored and used as \1) than \S\s - magic with multiline capture, ending with not stored ?= \1 (we get " or ' after "("), than none or few spaces \x20 followed by )/m=multiline g=global //var find= /(?:LPGENT?|Translate[TW]?|_T)(?:\s*?\(\s*?L?\s*)(['"])([\S\s]*?)(?=\1,?\x20*?(?:tmp)?\))/mg; //comment previous line and uncomment following line to output templates without _T() function in source files. Too many garbage from _T().. - var find= /(?:LPGEN[TW]?|Translate[TW]?)(?:\s*?\(\s*?L?\s*)(['"])([\S\s]*?)(?=\1,?\x20*?(?:tmp)?\))/mg; + var find= /(?:LPGEN[TW]?|Translate[TW]?)(?:\s*?\(\s*?L?\s*)("[^"\\]*(?:\\[\S\s][^"\\]*)*")(?:\s*?,?\s*?(?:tmp)?\))/mg; //now make a job, till end of matching regexp while ((string = find.exec(FileTextVar)) != null) { //first, init empty var var string; //replace newlines with "" in second [1] subregexp ([\S\s]*?), and Delphi newlines "'#13#10+" replace - onestring=string[2].replace(/'?(\#13\#10)*?\\?\r\n(\x20*?\')?/g,""); + onestring=string[1].replace(/'?(\#13\#10)*?\\?\r\n(\x20*?\')?/g,""); //remove trailing slash from the string. This is a tree item, slesh is a crap :) noslashstring=onestring.replace(/\/(?=$)/g,""); + //remove first and last " + nofirstlaststring=noslashstring.slice(1, -1) //remove escape slashes before ' and " - stringtolangpack=noslashstring.replace(/\\(['"])/g,"$1"); + stringtolangpack=nofirstlaststring.replace(/\\(['"])/g,"$1"); //if our string still exist, and length more than 1 symbol (nothing to translate if only one symbol) if (stringtolangpack.length>1) { //brand new _T() crap filtering engine :) -- cgit v1.2.3