Inserting source tags without any extra spaces
Thread poster: Michael Mestre
Michael Mestre
Michael Mestre
France
Local time: 03:16
English to French
+ ...
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
France
Local time: 03:16
English to French
+ ...
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
France
Local time: 03:16
English to French
+ ...
TOPIC STARTER
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


 


There is no moderator assigned specifically to this forum.
To report site rules violations or get help, please contact site staff »


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! »
TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »