Language Switcher tip: adding quicktags

Wordpress’s Language Switcher plugin for bilingual blogs requires that text is enclosed in language tags, e.g. [lang_en]English[/lang_en][lang_de]Deutsch[/lang_de].

These language tags can be added to the quicktags menu in the edit post/page screen in Wordpress – it’s simple to do and makes life much easier. Here’s how to do it. (Note that this method applies only to the HTML editor, and not to the visual editor.)

original

1. Open your wordpress/wp-includes/js/quicktags.js file and make a backup copy of the original.

2. From about line 36 you’ll see the code for all the existing buttons. Decide where you want your new quicktags to appear. I wanted mine at the start of the row, so inserted the new code before the code for the first tag (b).

3. Insert the following code, replacing my languages (English (en) and German (de)) with your own and remembering to use the correct two-letter ISO codes. lang_all is for text that you want to appear in all versions, no matter what the language – you might not need it.

edButtons[edButtons.length] =
new edButton('ed_lang_en'
,'lang_en'
,'[lang_en]'
,'[/lang_en]'
,'lang_en'
);

edButtons[edButtons.length] =
new edButton('ed_lang_de'
,'lang_de'
,'[lang_de]'
,'[/lang_de]'
,'lang_de'
);

edButtons[edButtons.length] =
new edButton('ed_lang_all'
,'lang_all'
,'[lang_all]'
,'[/lang_all]'
,'lang_all'
);

4. Save the file, upload to your server and check the edit post/page screen – you should see the new quicktags:

languagetags

5. As with other quicktags, you just need to highlight your text and click on the button and the opening and closing tags be inserted automatically.

Leave a Reply