Pages in topic:   [1 2] >
Trados 2009: "\n" in regular expressions
Thread poster: Bjørnar Magnussen

Bjørnar Magnussen  Identity Verified
Local time: 10:18
English to Norwegian
+ ...
Jan 24, 2010

The following find/replace operation with regular expressions work in Words 2007 and other programs:

Find: ([0-9]),([0-9])
Replace with: \1 \2

If you are familiar with regular expressions, your probably understand what it does - changes commas into spaces.

This does not work in Trados 2009, as "\1" "\2" et.c. are treated as literals.

Has anyone found a workaround for this?

[Edited at 2010-01-25 11:30 GMT]


Direct link Reply with quote
 

Jerzy Czopik  Identity Verified
Germany
Local time: 10:18
Member (2003)
Polish to German
+ ...
I'm afraid no Jan 24, 2010

I also struggled with such and did not find a solution.
So I used the filter to show just segments containing only numbers to adapt them and confirm upfront. The corresponding regular expression can be found here: http://ideas.sdltrados.com/ideas/detail.asp?i=2757


Direct link Reply with quote
 

Bjørnar Magnussen  Identity Verified
Local time: 10:18
English to Norwegian
+ ...
TOPIC STARTER
a shame Jan 24, 2010

This seems to be one of the areas where Word 2007/Workbench still is superior to Trados 2009...

I hope that SDL can get the regular expression option to work similar to the tool that most of us know, i.e. Word.


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
refreshing, though Jan 24, 2010

Bjørnar Magnussen wrote:
This seems to be one of the areas where Word 2007/Workbench still is superior to Trados 2009...

It's rarely, if ever, heard around here that TWB/Word2007 is superior to anything but, say, falling down a cliff…

I've been using the combination for any and all file formats for quite some time now.

So I'm just wondering, while Studio is closing in on becoming a well established second best: do you also:

Export [unknown] segments (into a docx)
Use AutoHotkey to correct Insert placeable (and add further niceties)
Occasionally shrink tags by some well considered Find/Replace

Now that TagEditor is gone and no longer crippling further development…


Direct link Reply with quote
 

Bjørnar Magnussen  Identity Verified
Local time: 10:18
English to Norwegian
+ ...
TOPIC STARTER
Answers to Stefan Jan 24, 2010

I suppose you ask wheter I am doing these actions in T2009?

Export [unknown] segments (into a docx)
Yes, but I translate the docx in Trados Studio 2009

Use AutoHotkey to correct Insert placeable (and add further niceties)
I use AutoHotkey to a lot in T2009, but not for this purpose - actually I am not at all familiar with the issue of wrong Insert placeable.

Occasionally shrink tags by some well considered Find/Replace.
No, never had this problem in T2009.


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
different planet Jan 25, 2010

Bjørnar Magnussen wrote:

I suppose you're asking whether I am doing these actions in T2009?



No, I'm not -- but thanks for replying all the same.

Best,

Stefan


Direct link Reply with quote
 

Bjørnar Magnussen  Identity Verified
Local time: 10:18
English to Norwegian
+ ...
TOPIC STARTER
Lonely Planet Jan 25, 2010

Stefan de Boeck wrote:

No, I'm not -- but thanks for replying all the same.



Sorry about that - probably it's just a case of me not understanding Dutch irony...


Direct link Reply with quote
 

Grzegorz Gryc  Identity Verified
Local time: 10:18
French to Polish
+ ...
Bug... poor documentation... Jan 25, 2010

Bjørnar Magnussen wrote:

The following find/replace operation with regular expressions work in Words 2007 and other programs:

Find: ([0-9]),([0-9])
Replace with: \1 \2

If you are familiar with regular expressions, your probably understand what it does - changes commas into spaces.

This does not work in Trados 2009, as "\1" "\2" et.c. are treated as literals.


IMO, it's a bug.
The regular expressions indeed work but only for the Find feature, not for Replace.

BTW.
It's no help topic related to the syntax used for the regular expressions.
The problem is the regular expression syntax used in Studio is not the Word syntax (it's some PERL like dialect, I suppose...), so it's possible it works but you should use some cryptic expression instead of \1 etc.
Neither $1 nor %1 work, escaped or not.

Cheers
GG

[Edited at 2010-01-25 11:41 GMT]


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
caught in the .NET Jan 25, 2010

In the Studio Help's opinion*, "These are the .NET set of regular expressions from Microsoft." Which means backreferencing within Studio is nonexistent and here to stay.

Find works fine on target (Editor) or Batch edit TM; except of course that Replace inserts only literals.

Tried also: \\1 \\2 and even \\\\1 \\\\2. No good.

It's back to the old TextEditor and trying to change source.sdlxliff?

* Search the Help for "regular expressions". Dig around a bit in http://www.regular-expressions.info and lose all hope.


Direct link Reply with quote
 
PMz
Different expression Jan 25, 2010

Bjørnar Magnussen wrote:

The following find/replace operation with regular expressions work in Words 2007 and other programs:

Find: ([0-9]),([0-9])
Replace with: \1 \2

If you are familiar with regular expressions, your probably understand what it does - changes commas into spaces.

This does not work in Trados 2009, as "\1" "\2" et.c. are treated as literals.

Has anyone found a workaround for this?

[Edited at 2010-01-25 11:30 GMT]


Hi,
you can use following expression for matching comma between number:
(?


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
a wrong by any other name Jan 25, 2010

PMz wrote:
Different expression

Just looking at your (?


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
two acres Jan 25, 2010

Bjørnar Magnussen wrote:
Has anyone found a workaround for this?

Hi Bjørnar, (and Jerzy)

Don't forget that for the translation of Word files the easiest solution -not even a workaround, really- is to prep your document by using regex F/R to apply the DO_NOT_TRANSLATE style (or any other you should care to use) rather than inserting spaces and so on -- all of which, moreover, still need to be reversed after translation.



[Edited at 2010-01-25 20:15 GMT]


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 10:18
English
Works for me Jan 25, 2010

Stefan de Boeck wrote:

But by all means prove me wrong.


Hi Stefan,

I don't really want to prove you wrong. But I thought I would try this out and it worked in my example as follows - 3 screenshots.

First I open a test file and ctrl+f


Then look for a couple and replace them to see how this works;


Then as it seems to work I replace all;


So in my example it works. We would agree there is a bug here because the replace should really use regex too, and we have logged this for resolution. 2007 did not have this capability at all, only through Word, so for any other file types you couldn't use it anyway, so we have some improvement. But I agree, it requires cleverer regex expressions at the moment, and in some more complex scenarios it may not be possible in one go at all.

Regards

Paul


[Edited at 2010-01-25 20:26 GMT]


Direct link Reply with quote
 
Stefan de Boeck  Identity Verified
Belgium
Local time: 10:18
English to Dutch
+ ...
oh well... Jan 26, 2010

Hi Paul,

Paul Filkin wrote:
So in my example it works.


Great; so it's a bug, and it's going to be fixed. Thanks for dropping by. The syntax used by PMz is at a remove at least one planet away from Word regex, or UltraEdit regex as kindly listed here. I have been scurrying all over that bloody regular-expressions.info site again and found out exactly this:
nothing

but that \d is shorthand for [0-9].
All the same, as soon as the Replace field is fixed, simple Word regex will be usable, won't it.

Paul Filkin wrote:
2007 did not have this capability at all, only through Word, so for any other file types you couldn't use it anyway, so we have some improvement.


You need to realise that an sdlxliff file, when opened in a TextEditor, makes an old inx.ttx file look like a children's drawing: plain, simple, and -in short- accessible to do some good kicking around in, just in case you needed to tweak the source file a little. So back in 2007 we had some workarounds more or less at the ready…

On the other hand, and I'm happy to highlight this,
being able to use regex on a Studio translation memory - hitting both source and target - is a truly marvellous thing and a major advance

which still leaves us with certain source files, before translation.

What is it about certain source files that makes them such a nuisance?
Well, let's just say they're riddled with things like this:
1A.285
xOPyz25
1.0.0.1

only much longer. And more of it.

This may not be SDL's problem but it's every translator's nightmare.

So let's sit down and design a new tool. By all means, call in a few people from Team Marketing. And, look, here's the new product's name already:

sdlBook



So what does it do?
It works on an existing file, the Unknown_Segments.sdlxliff which can be generated with Analyse and is stored - outside of the actual project - in the Reports folder. So far, everything exists. Let's sort of shift angles and look at the product from a user's point of view; rephrase the question to read:

What does the user do?
Open your wonderfully designed sdlBook app.*
Open Unknown_Segments.sdlxliff.
Select a string of regrettable horrors (e.g. xOPyz25) and copy them to the clipboard (Ctrl+C).

Open the Code Calculator widget.**
Paste the string (Ctrl+V) into the "Calibrate This" field.
Click OK. Alternatively, type "run kill" and press Enter.
The regular expression, or 'Code', for the selected string is now presented in the "You've got mail!" field.
At this point you can either copy the code to the clipboard, to be used externally***, or close the widget to continue in sdlBook.
In sdlBook click Import code.
Select the action you want to see performed. There are two actions available:
AlteredState: In the Replace field you can use simple backreferencing, as in Word, to apply certain alterations to the selected string, and all of its little brethren strings. These changes are saved to an alteredstates.xml file, of which you need to know nothing further.
Immobilise: Click OK. The selected string, and all of its little brethren strings, have been wheelclamped with DO_NOT_TRANSLATE tags and will be available as simple placeables within the Editor. These changes are saved to an alteredstates.xml file, of which you need to know nothing further.

It is now possible to close the sdlBook and translate the Unknown_Segments.sdlxliff. Enjoy. After translation you will again have the opportunity to open the - by now fully translated - Unknown_Segments.sdlxliff in your sdlBook. sdlBook will run a rapid scan of the file and instantly a beautiful icon will appear, upon which it is written:
Finalise?

Click Yes. Or OK. Or press Enter. Or just breathe.
All changes, as recorded in the alteredstates.xml, have now been undone; and the TM you have selected in the project has been duly updated.

Go back to the original project. Click Batch translate or something somewhere. Observe. You're done and ready.

And SDL International will have created a
Rolls

Royce

It's a Sweet Thing…

that'll make the competition weep****.



* This is a good time to display a brand new boilerplate slogan over the customer's screen. It should by no means be as lame as "… because brand matters…" which has users shudder and cringe all over the planet, but, say, something good this time.
** No, we will not hear of yet another Dialoguing Box, nor a Tooth Extraction Wizard. The widget is a thing as used in the Opera browser, a little add-on, which will be designed to look like the Aston Martin of Widgetry.
*** People will want to use this in, e.g., Microsoft Word. So, like, almost everybody will want the sdlBook. Worldwide. Which is also why it needs to be a widget.
**** Not with laughter, this time around.


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 10:18
English
Or perhaps... Jan 26, 2010

Hi Stefan,

Perhaps all we really need is a single button that says "translate", and then whilst you have a cup of tea* and respond to a few threads on the forums everything will be done for you including delivery in perfect condition back to your client. Better if this could be done on the SDL t-phone of course

But seriously, why would you want to get into the xliff in the first place? Wouldn't it be better if the software just allowed you to do what you wanted to do? Maybe it would be better if you simply had an option to override the source and amend the file in wysiwyg in the editor? ( http://ideas.sdl.com/ideas/detail.asp?i=2189 ) I know many would view the source as sacrosanct but sometimes there are valid reasons as you allude to.

Many of the tricky strings are sorted out automatically today (possibly even the comma to space issue if you are using the right language pair, although it doesn't allow for non standard requirements), and we are working on improvements to this aspect to make it easier, but regex does give you a degree of ability to handle anything that is thrown your way..... or was it that you need a degree to use it It's not too hard at a basic level, but for more complex use it does require a lot of practice. I think a better tool (and I am no expert, but do get a lot of help from this source) is RegexBuddy - http://www.regexbuddy.com - because you can create (with explanations), test, get help etc all from one tool and then just copy and paste into whatever application you need.

Tea* break over...

Regards

Paul

* Amend to suit locale


[Edited at 2010-01-26 13:00 GMT]

[Edited at 2010-01-26 13:01 GMT]


Direct link Reply with quote
 
Pages in topic:   [1 2] >


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Trados 2009: "\n" in regular expressions

Advanced search







PerfectIt consistency checker
Faster Checking, Greater Accuracy

PerfectIt helps deliver error-free documents. It improves consistency, ensures quality and helps to enforce style guides. It’s a powerful tool for pro users, and comes with the assurance of a 30-day money back guarantee.

More info »
Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search