Language Switcher tip: accented characters menu

Also helpful if you’re using the Language Switcher plugin for Wordpress is to have a dropdown menu in the edit post/page section for inserting the HTML codes for accented characters. Donald Noble’s website has a solution – here’s a breakdown of what it does.

1. In the wordpress/wp-includes/js/quicktags.js file, add the following code before function edToolbar() { (around line 257).

// 2 new functions added by DRN to give dropdown character select
function edInsertChar(tmpChar) {
	edInsertContent(edCanvas, tmpChar);
	document.getElementById('ed_char').value=0;
}
function edInsertCharSelect(){
								//  1/4    1/2    3/4                         ^2     ^3
	var edChars = new Array(
	'auml','euml','iuml','ouml','uuml','Auml','Euml','Iuml',
'Ouml','Uuml','agrave','aacute','egrave','eacute','igrave',
'iacute','ograve','oacute','ugrave','uacute','Agrave',
'Aacute','Egrave','Eacute','Igrave','Iacute','Ograve',
'Oacute','Ugrave','Uacute','ccedil','Ccedil','nbsp','trade',
'copy','times','#188','#189','#190','euro','times','deg',
'#178','#179'
	);

	document.write('<select id="ed_char" onchange="edInsertChar(this.value);" title="">');
	document.write('<option value="0" selected="selected">char </option>');
	for(i=0;i<edChars.length;i++) {
		document.write('<option value="&amp;'+edChars[i]+';">&'+edChars[i]+';</option>');
	}
	document.write('</select>');

}

Note that more characters can be inserted into this list or the order changed – just insert the HTML character codes between single quotes, minus the ‘&’ and the ‘;’.

2. Then, in the edToolbar function itself, add the line edInsertCharSelect(); as shown:

function edToolbar() {
	document.write('<div id="ed_toolbar">');
	for (i = 0; i < edButtons.length; i++) {
		edShowButton(edButtons[i], i);
	}
	document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');
	document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');
//	edShowLinks(); // disabled by default
	edInsertCharSelect(); // DRN addition
	document.write('</div>');
}

The result should look something like this:

dropdown

You should now be able to select accented characters from the list and drop them into your post, without having to remember the HTML codes.

Leave a Reply