I'm from Valencia, Spain and the proper answer is "depends".
For most non-public/non-OS things i do a mix of English and Spanish in variable naming, but all my comments are in Spanish and I hope noone tells me to document/comment things in Valencian
But things change when you're publishing something under Open Source, since doing it in your local language restricts your potential users and collaborators to a smaller audience.
I can give you an example of language as a barrier: When I was running a WoW guild i began to look for alternatives to EQDKP and i found them, but most had it's documentation and comments in german so i lost any interest because relying on Google Translator wasn't an option for me, heck, some of them were awesome projects.
You also asked for a code example, as i told i tend to mix English and Spanish, but this snippet is so brief that i did not need any kind of mixture
function validaDNINIE(numero) {
// Eliminar todo lo que no sea número o letra
numero.replace(/[^0-9A-Z]/i, '').toUpperCase();
if (!numero.match(/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/i)) {
return false;
}
// Comprobación de NIF
if (numero.match(/^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKE]{1}$/i)) {
var letra = numero.charAt(numero.length-1);
if (letra == "TRWAGMYFPDXBNJZSQVHLCKE".charAt(numero.substr(0, numero.length-1) % 23)) {
return true;
}
}
// Comprobación de NIE
// T00000000
if (numero.match(/^[T]/)) {
if (numero == numero.match(/^[T]{1}[A-Z0-9]{8}$/)) return true;
}
// ZXY
if (numero.match(/^[XYZ]{1}/)) {
// X = 88, asi conseguimos X=0;Y=1;Z=2
var su = numero.charCodeAt(0)-88 + '' + numero.substr(1, numero.length-2);
if (numero.charAt(numero.length-1) == "TRWAGMYFPDXBNJZSQVHLCKE".charAt(su % 23)) {
return true;
}
}
// Si hemos llegado aqui es que el numero no es valido
return false;
}