I have a translation file that looks like this:
Apple=Apfel
Banana=Banane
Cherry=Kirsche
Train=Zug
…500+ more lines like that
now I have a file I need to work on with text. Only certain parts of text needs to be replaced, example:
The [[Apple]] was next to the [[Banana]]. Meanwhile the [[Cherry]] was chilling by the [[Train]].
Result needs to be
The [[Apfel]] was next to the [[Banane]]. Meanwhile the [[Kirsche]] was chilling by the [[Zug]].
There are way too many incident to copy/paste manually. What is an easy way to search for [[XXX]] and replace from another file as mentioned?
Best Answer
Notepad++ can be used for everything from writing down random notes to advanced text manipulation. But as mentioned in comments you need to install Python Script plugin from Plugin Manager.
Copy the file with your substitutions to e.g. D:/_working/paired-search-replace.txt and separate values with space or as you did
=
:Create a new script.
Run the new script against the text you need to work on and substitute.
Edit:
To include the opening and closing square brackets for your special case, the following addition can be made in the script:
For a small translation list only:
If you don't want to use a script as mentioned by others you need to do some special steps using Notepad++. Please note, this is limited by search and replace string length.
Copy the paired translation list to two files e.g.
search-source.txt
andreplace-target.txt
(for working with) and edit the content and format to search and replace strings as shown below.You can use Notepad++'s RegEx feature and the "Column Editor" mode for this. E.g. select the column you want by holding Alt and dragging down the column. Then go to "Edit -> Column Editor". Choose the "Number to Insert" button, then choose the starting value and the increment. It will replace the column with the values you want. Use STRG+J later to join the lines
Then try a regular expression replace of
with