2

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")
2
  • 1
    Ce n'est pas JavaScript. Dec 1, 2009 at 22:29
  • Your clients don't learn from past mistakes. There were some programming languages, which used french. The problem, then is that you will be limited to work only with french developers.
    – Bakudan
    Dec 7, 2012 at 23:27

9 Answers 9

31

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

2
  • 9
    Not sad at all. Can you imagine a programming language written to approximate English? You'd have crap like "MULTIPLY PRICE BY UNITS GIVING COST." May 9, 2009 at 21:58
  • Actually, most programming languages are written in English. Jan 15, 2021 at 14:18
25

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.

2
  • Great idea about the variables and function names. May 8, 2009 at 14:17
  • The best thing you can do is heavily document the code with the foreign language. As Jeremy has said, using descriptive variable and function names (also language specific) will also help. Dec 1, 2009 at 22:22
14

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.

2
  • Great idea about the variable and function names. May 8, 2009 at 14:17
  • I suppose you could end up with a mini api for the target language, but it would be so specialised, I can't see how it would help in the long run. Whenever you go outside the API you would face a bad learning curve. May 8, 2009 at 14:19
8

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.

1
  • 1
    Hmmm... needs more regex parsing and a dash of eval() ;) Dec 1, 2009 at 22:35
4

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

2
  • 1
    Who cares about the non-French when everybody's French :) May 8, 2009 at 14:19
  • 3
    I speak french myself and work in a french environment. But not one coder here would ever consider writing code in french, what if you hire someone who isn't french?
    – Peter D
    May 8, 2009 at 14:21
3

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.

1
  • It's true. I've had to describe simple systems in Spanish before, which didn't work out to be brief or nearly as simple as in English. Dec 1, 2009 at 22:26
1

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.

1

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...

0

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.

1
  • 1
    Great idea about translating it. I'm thinking server-side translating before sending the script file. May 8, 2009 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.