Question

I have some clients who are not English speaking. They would like the JavaScript I write for them to be in another language.

Can browsers understand other languages, or am I limited to non-English comments?

navigateur.nomApp.indice("Microsoft")

Instead of :

navigator.appName.indexOf("Microsoft")
Was it helpful?

Solution

You can get any object and assign it to a variable with a French name for instance

var nomAppDeNavigateur = navigator.appName;

Then use it wherever, it's just the keywords that are restricted to Javascriptish. It still has to make sense though, whatever language you are aiming for.

OTHER TIPS

JavaScript isn't written in English, it's written in JavaScript.

JavaScript's keywords are in English and browsers' object names are in English. You can't get around this. Even if all of your variable and function names are in French, you'll still need to have English keywords lying around. Your clients will have to live with this.

JavaScript is a dynamic language that responds well to monkey-patching:

String.prototype.indice= String.prototype.indexOf;
navigator.nomApp= navigator.appName;
window.navigatrice= navigator;

Et voilà! Your code fragment works as-is. Well, except for the curious way your browser is masculine.

PS. Don't do this.

I highly suggest you do not do this. I also think this is not possible. Not only are you throwing away tons of documentation which uses only english but you are making it very difficult for non-french speaking people to code with your application.

See Jeff Atwoods post about this here:

The Ugly American Programmer

Most programming languages are based off of the English language.

As Jeff pointed out in a recent blog post, Eric Raymond notes that functional English is required for true hackers:

Back around 1991 I learned that many hackers who have English as a second language use it in technical discussions even when they share a birth tongue; it was reported to me at the time that English has a richer technical vocabulary than any other language and is therefore simply a better tool for the job. For similar reasons, translations of technical books written in English are often unsatisfactory (when they get done at all).

On a related note, also pointed out in Jeff's post, Wikipedia keeps a list of non-English based programming languages.

Either your client must learn basic English or they must use a non-English based language.

Programming language keywords are fixed. The browser can't translate them from one spoken language to another. Functions you create yourself can be in any spoken language you chose.

In JS as in any other language you can define your own classes/methods in the language you want but the standart libraries are usually written in english so that's what you have...

You are perfectly able to write your own variables, functions and APIs in other languages; however, the vast majority of existing APIs are going to be in English and there is no way for the browser to understand that you ment navigator when you write navigateur.

Ostensibly, you could write a translation framework that would translate French keywords and French API calls into their English counterparts, but that would be a whole lot of work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top