Inserting source tags without any extra spaces
Thread poster: Michael Mestre
Michael Mestre
Michael Mestre
France
Local time: 00:14
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: 00:14
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: 00:14
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






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 »
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 »