Inserting source tags without any extra spaces
Auteur du fil: Michael Mestre
Michael Mestre
Michael Mestre
France
Local time: 22:46
anglais vers français
+ ...
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: 22:46
anglais vers français
+ ...
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: 22:46
anglais vers français
+ ...
AUTEUR DU FIL
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


 


Aucun modérateur n'est spécifiquement affecté à ce forum
Pour rapporter des violations des règles du site ou pour obtenir de l'aide, veuillez contacter l'équipe du site »


Inserting source tags without any extra spaces






Trados Business Manager Lite
Create customer quotes and invoices from within Trados Studio

Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.

More info »
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! »