Inserting source tags without any extra spaces
Initiator des Themas: Michael Mestre
Michael Mestre
Michael Mestre
Frankreich
Local time: 16:47
Englisch > Französisch
+ ...
Oct 30, 2012

I am a happy user of the wonderful feature "Insert Source Tags".
However, the way I use it means that I *always* remove the extra spaces that are inserted between tags.

Is there a simple way to insert source tags without adding extra spaces ?
If not, could someone provide a link to some documentation about how to handle tags in the (new) scripting interface ?

Thank you !


 
Didier Briel
Didier Briel  Identity Verified
Frankreich
Local time: 16:47
Englisch > Französisch
+ ...
Not possible currently Oct 30, 2012

Michael Mestre wrote:

I am a happy user of the wonderful feature "Insert Source Tags".
However, the way I use it means that I *always* remove the extra spaces that are inserted between tags.

Is there a simple way to insert source tags without adding extra spaces ?

Not currently.

I think there is an enhancement request on Sourceforge.

If not, could someone provide a link to some documentation about how to handle tags in the (new) scripting interface ?

I don't think someone has documented that.
That said, if you look at the code which does "Insert Source Tags", it shouldn't be too difficult to write the same in Groovy, omitting the extra spaces.

Didier


 
Michael Mestre
Michael Mestre
Frankreich
Local time: 16:47
Englisch > Französisch
+ ...
THEMENSTARTER
Here you go.. Oct 31, 2012

Thank you very much for your answer Didier !

I wrote this script which seems to do the job - it could probably be simplified (my knowledge of Java is extremely limited).

-------------------------------------

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.omegat.util.PatternConsts;

public static String buildPaintPlaceholderList2(String str) {
String res = "";
Pattern placehol
... See more
Thank you very much for your answer Didier !

I wrote this script which seems to do the job - it could probably be simplified (my knowledge of Java is extremely limited).

-------------------------------------

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.omegat.util.PatternConsts;

public static String buildPaintPlaceholderList2(String str) {
String res = "";
Pattern placeholderPattern = PatternConsts.getPlaceholderPattern();
Matcher placeholderMatcher = placeholderPattern.matcher(str);
int last=0;
while (placeholderMatcher.find()) {
int rs = placeholderMatcher.start();
if (rs != last && last !=0) {
res += "";
}
res += placeholderMatcher.group(0);
last = placeholderMatcher.end();
}
return res;
}

def ste = editor.currentEntry;
source=ste.getSrcText();
sourcetags=buildPaintPlaceholderList2(source);
editor.insertText(sourcetags);




[Edited at 2012-10-31 09:56 GMT]

[Edited at 2012-10-31 09:56 GMT]
Collapse


 


Dieses Forum wird von keinem Moderator betreut.
Um Verstöße gegen die ProZ.com-Regeln zu melden oder um Hilfe zu erhalten, wenden Sie sich bitte an unsere ProZ.com-Mitarbeiter »


Inserting source tags without any extra spaces






Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

Buy now! »
Trados Studio 2022 Freelance
The leading translation software used by over 270,000 translators.

Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop and cloud solution, empowering you to work in the most efficient and cost-effective way.

More info »