Inserting source tags without any extra spaces
De persoon die dit onderwerp heeft geplaatst: Michael Mestre
Michael Mestre
Michael Mestre
Frankrijk
Local time: 17:15
Engels naar Frans
+ ...
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
Frankrijk
Local time: 17:15
Engels naar Frans
+ ...
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
Frankrijk
Local time: 17:15
Engels naar Frans
+ ...
ONDERWERPSTARTER
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


 


We hebben geen speciale moderator aangesteld voor dit forum.
Wanneer u overtredingen van de sitevoorschriften wilt melden of hulp wilt hebben, neem dan contact op met ProZ.com-medewerkers »


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! »
Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »