Add a character to the end of every segment (regex)
Thread poster: oerjan
oerjan
oerjan
Local time: 23:47
German to Swedish
Jan 11, 2017

After I finishing a translation I need to add a character to the end of certain segments.
I start by filtering so that only the segments that need to be edited are shown. Then I use Search&Replace with regex to select the segments one by one.
My problem is that regardless of what regex string I use
- either trying to select the entire segment with .* or ^.+$ or ^&$ or ^&\o or (mind you, the backslash before o is neither shown here)
- only the endpart with e.g. .\o or
... See more
After I finishing a translation I need to add a character to the end of certain segments.
I start by filtering so that only the segments that need to be edited are shown. Then I use Search&Replace with regex to select the segments one by one.
My problem is that regardless of what regex string I use
- either trying to select the entire segment with .* or ^.+$ or ^&$ or ^&\o or (mind you, the backslash before o is neither shown here)
- only the endpart with e.g. .\o or .$ (nor here)
and regardless of whether I put the entire or part of the expression in brackets #(expression)0 or not
I´m not able to replace the found selection with anything.
Therefore I´m of course neither able to add any character to the end of the found segment.

I have the feeling that including the segment border somehow hinders the replacement function. I have even tried to deselect the tag protection, but it does not help.
Is there a solution to this?
Thanks in advance
Örjan
Collapse


 
Tricky solution ;-) Jan 12, 2017

Hi Örjan,

it seems as if the end of segments is a kind of write-protected and therefore cannot be used in replace operations.

I have tried to use this effect for a tricky solution. It worked fine on a test file on my site, but I have no idea if it will work for your project too. So usage is on your own risk and please don't blame me if it doesn't work
It will be a very good idea to backup the lan
... See more
Hi Örjan,

it seems as if the end of segments is a kind of write-protected and therefore cannot be used in replace operations.

I have tried to use this effect for a tricky solution. It worked fine on a test file on my site, but I have no idea if it will work for your project too. So usage is on your own risk and please don't blame me if it doesn't work
It will be a very good idea to backup the language files before the following operation!

The solution consists of 3 separate Search-Replace operations:

1) Add a suffix XX behind any character:
Search: #(.)0
Replace by: #0XX

Attention -- may take a while (depending on your file sizes)
As suffix, you should use a string that does not occur in your "normal" text.

2) Remove the suffix before any character except the segment end.
Search: XX#(.)0
Replace: #0

This way, the XX remains only at the end of the segment (as this XXs are not a character).

3) Replease the remaining suffixes by the required character

Hope that helps.

By the way: I am curious -- what character do you need to be added? And why?

Best regards,

O.N.
Collapse


 
oerjan
oerjan
Local time: 23:47
German to Swedish
TOPIC STARTER
Tricky, but size issues Jan 12, 2017

Hello Oiseau noir,
Thanks for the tip.
I can see that it should work, very smart indeed! But I hesitate to use it.
My project is a rather huge one and doubling or tripling the character count would cause problems with the size (there already are beforehand).
(Then I also would not really trust three S&R´s in a row not to confuse something somewhere because in my experience there is always something that you have not foreseen. And I would then be forced to control everyt
... See more
Hello Oiseau noir,
Thanks for the tip.
I can see that it should work, very smart indeed! But I hesitate to use it.
My project is a rather huge one and doubling or tripling the character count would cause problems with the size (there already are beforehand).
(Then I also would not really trust three S&R´s in a row not to confuse something somewhere because in my experience there is always something that you have not foreseen. And I would then be forced to control everything again.)
I´ll keep your good trick as a last resort if there isn´t a "smaller" solution.
BR,
Örjan

PS. The character I need to insert is a NewLine and the reason is that the original has it in some segments (and they go away when I select to the end of the segment and then delete as the last measure when typing my translation).
Collapse


 
CafeTran Training (X)
CafeTran Training (X)
Netherlands
Local time: 23:47
Notepad++ Jan 12, 2017

oerjan wrote:

I have the feeling that including the segment border somehow hinders the replacement function.


Why not use Notepad++ (or TextPad) for this? Close the project in Transit, load the target language files and do a Find and Replace action.


 
Check function to re-insert newlines Jan 12, 2017

PS. The character I need to insert is a NewLine and the reason is that the original has it in some segments (and they go away when I select to the end of the segment and then delete as the last measure when typing my translation).


Maybe the format check function may help in this case? Using the "Check blanks/whitespaces after text" option, Transit will find missing newlines. You may either correct them "interactively" (i.e. you will be asked for any missing newline if Transit shall insert it) or automatically (using the "Autocorrect" option).

Best regards,

O.N.


 
oerjan
oerjan
Local time: 23:47
German to Swedish
TOPIC STARTER
Solved! Jan 15, 2017

Hi Oiseau noir,

You are right. It works very well.
I´ll use that.
Thank you.

Örjan


 


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

Moderator(s) of this forum
Maya Gorgoshidze[Call to this topic]

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

Add a character to the end of every segment (regex)






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 »
Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »