Pages in topic:   < [1 2]
Share your translation-related AutoHotkey scripts
Thread poster: Hans Lenting
Robert Pätzold
Robert Pätzold
Germany
Local time: 18:11
English to German
+ ...
Script for the replacement of words in text that is already there Jan 13

Even if this thread is a bit old, I would like to share a script of mine:

This is a script for the replacement of words in text that is already there. For example, for the correction of repeated wrong terms in a machine-translated segment.

It is triggered by putting the cursor at the end of a (wrong) word and hitting alt + j.

This is the script:

____________________________________________________
!j::
Send, ^+{Left}

Cl
... See more
Even if this thread is a bit old, I would like to share a script of mine:

This is a script for the replacement of words in text that is already there. For example, for the correction of repeated wrong terms in a machine-translated segment.

It is triggered by putting the cursor at the end of a (wrong) word and hitting alt + j.

This is the script:

____________________________________________________
!j::
Send, ^+{Left}

ClipSaved := ClipboardAll
Clipboard =

FileRead, vList, vListFile.txt

Send, ^c
FixString := Clipboard
Loop, Parse, vList, `r, `n
{
oTemp := StrSplit(A_LoopField, "`t")
FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
SendInput, %FixString%

Return
___________________________________________________

This is the (example) replacement list named "vListFile.txt", which has to be put into the same folder as the script. There has to be a tab in the middle (Find[tab]Locate, etc.):
---------------------------------------------------
Find Locate
appear pop up
Inside From
---------------------------------------------------

Example text to use the script:

*Find "New" in the menu.
Inside the menu, click "AutoHotkey Script".
A window should appear.*

I put the cursor behind "Find", press alt + j, then behind "Inside", press alt +j, and then behind "appear", press alt + j.

I get:

*Locate "New" in the menu.
From the menu, click "AutoHotkey Script".
A window should pop up.*


Known problems:

1) With long lists, the replacements may be not correct, since the script goes through the entire word list and makes not just one replacement, but as many replacements as it can find.

Example:
Let's assume there is another replacement entry "Locate -> Search" in the replacement list. Then "Find" is no longer replaced by "Locate", but by "Search" (which is not what I want).

-----> How can the script be adapted to only replace one found entry and then stop? Stepan, maybe you have an idea? I see that you wrote lots of useful scripts...

2) Can we introduce case sensitivity?
3) Can we introduce functionality for 'multiple word' entries (in the source)?
(Workaround: Add a second script where the line "Send, ^+{Left}" is there twice and use another shortcut and another replacement list for two-word entries, etc. --- But isn't there a more elegant solution?)

I hope this script can be useful for other translators and that we can improve it... I am not very good at scripting, but searched the net and found useful bits and pieces which I used for my script. Thanks to all the original scripters.


Cheers
Rob
Collapse


 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
The other way around Jan 15

I would set this up the other way round: create a list sorted by decreasing length of source term and search for each source term in the populated target segment.

Robert Pätzold wrote:

Known problems:

1) With long lists, the replacements may be not correct, since the script goes through the entire word list and makes not just one replacement, but as many replacements as it can find.
2) Can we introduce case sensitivity?
3) Can we introduce functionality for 'multiple word' entries (in the source)?


1) Yes, via a counter
2) Sure
3) See above.













[/quote]


 
Robert Pätzold
Robert Pätzold
Germany
Local time: 18:11
English to German
+ ...
How exacty? Jan 15

Dear Hans,

thank you for your swift reply and your ideas. The sorting with the most complex entries at the beginning could indeed help, but I don't think that this would avoid multiple (unwanted) replacements on its own...

Since I am not good at programming, could you please help introducing the counter you mentioned so that I understand what the script exactly does?

And your ideas as to the case sensitivity and multiple-words entries, how would you change
... See more
Dear Hans,

thank you for your swift reply and your ideas. The sorting with the most complex entries at the beginning could indeed help, but I don't think that this would avoid multiple (unwanted) replacements on its own...

Since I am not good at programming, could you please help introducing the counter you mentioned so that I understand what the script exactly does?

And your ideas as to the case sensitivity and multiple-words entries, how would you change the script?

I'm sorry for asking so many questions...

Best regards
Robert
Collapse


 
Hans Lenting
Hans Lenting
Netherlands
Member (2006)
German to Dutch
TOPIC STARTER
AHK Forums Jan 15

Your best chance to get quick help is here:
https://www.autohotkey.com/boards/viewforum.php?f=82

Since I work on Mac, I develop those tools with Keyboard Maestro (which is not compatible with Windows).

You could also have a look at GT4T:

https://gt4t.net
... See more
Your best chance to get quick help is here:
https://www.autohotkey.com/boards/viewforum.php?f=82

Since I work on Mac, I develop those tools with Keyboard Maestro (which is not compatible with Windows).

You could also have a look at GT4T:

https://gt4t.net

Or QTranslate:

https://www.proz.com/forum/software_applications/348250-an_application_to_translate_the_hightlighted_text_using_google_translate_api.html

[Edited at 2024-01-16 09:30 GMT]
Collapse


 
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 »

Share your translation-related AutoHotkey scripts






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