views:

331

answers:

2

I've never made "macros" or anything like that with any program.

I'm moving my php code to use "gettext", so I have to look for all my static text and change it up.

For example, I need to change page title to <?php echo _('page title'); ?>.

I don't think there is a way to change it all up in one shot, as it involves looking to see if it looks like static text, but I'm sure it's possible in one of those editors to maybe, select a text, press some keyboard shortcut, and it would do the replacement for me.

Is that possible? How?

I have both Dreamweaver and Notepad++ handy. I'm open to using some other tool.

Thanks!

A: 

You can use the replace in all open documents function.

  1. Select all the documents on the right that have that text and right click -> open
  2. Do a search and replace on all open documents.

If you give more info on what the page titles look like now it would be easier to help.


Edit: If you need your entire site changed to use gettext, it would be best to do it manually

Galen
I don't think you can do a search/replace in this case. There is no sarch string (it's just any static text, so I have to look for them myself), and the replacement involed puting something before AND after the original string.
nute
"page title" was just a string example, I need to translate the entire site
nute
nute, you're right about searching "any static text", but you CAN put something before and after the search string in Notepad++, using regex search. Just capture the string you want (with () ) and replace it to something like BEFORE_STRING\1AFTER_STRING (note the \1)
Eli Krupitsky
+1  A: 

Download and install PSPad.

Then save the following script into a VBS file in <PSPadFolder>\Script\VBScript and re-open PSPad.

'Enclose It! by Lukman
const module_name  = "Enclose It!"
const module_ver   = "0.1"
const enclose_token = "_SRC_"
const enclose_hotkey = "CTRL+Q"

enclose_last = enclose_token

sub Init
    addMenuItem "Enclose It!","", "EncloseIt", enclose_hotkey
end sub

sub EncloseIt
    encloser = InputBox("Enclose content", module_name, enclose_last)
    If encloser = False Then Exit Sub

    Set editor = newEditor()
    editor.assignActiveEditor
    editor.selText Replace(encloser, enclose_token, editor.selText)        
    enclose_last = encloser
end sub

Then open your document.

Highlight some text in the documentand press Ctrl + Q hotkey (customizable in the script itself) to open a input dialog with _SRC_ predefault in it. Just change the keyword to <?php echo _('_SRC_'); ?> and press enter. Repeat. (The script remembers the last keyword used so you don't have to type it all again).

Lukman