¿Es posible codificar java en otro idioma?

I was curious as to whether or not a person could code in another language. I DON'T mean naming your variables in different languages like this:

String[] tableau = {"Janvier", "Fevrier"};

Pero mas como

Chaîne[] tableau = {"Janvier", "Fevrier"};

Is that doable or would you need to write your own french or [insert language] based coding language?

preguntado el 27 de noviembre de 13 a las 02:11

It would be a different language though - pun intended -

Sometimes dreams come true :), but sometimes not this time -

No puedes rebautizar existing types or identifiers in Java source code, but you can use Unicode (for better or worse) in your es dueño types and identifiers. However, as American as this may make me sound: please use English (or at least the ASCII subset of Unicode). -

Excel does something like this, all function names are localized. It's a nightmare. -

You could write it in Kotlin -

4 Respuestas

Si tuviera que usar un Preprocesador to accomplish this - I believe it would work perfectly well. Java does not ship with one, but C and C++ did (e.g. cpp) - So, you could add a step in your build chain to perform preprocessing and then your code would be translated into the "hosted" English Java before being compiled. For another example, consider the language CofeeScript; a language that translates itself into JavaScript. So, as long as your mapping is one for one equivalent I believe the answer is Oui.

respondido 27 nov., 13:02

I mean of course the type String won't change name to French, but surely you can declare your own type called Chaîne? Surely Java handles UTF-8 source files? - Kaz

@Kaz I believe OP's intent was to localize the Java Programming Language in general. At least OP asked specifically about localizing the String class, its' field length and System.out.println. Java uses UTF-8 strings, I'm pretty sure the host environment of the build (or possibly the source repository) system dictates locale of source files. - Elliot Frisch

You can get part way with a pre-processor, but are you going to preprocess every identifier in all the packages that come with Java? I stand by my answer: "aucun" - John3136

@John3136 Will I? Non. Could I? Oui. Hence it is possible. I make no claims about it being a good idea. - Elliot Frisch


You could write your own frontend to convert "French Java source" to "English Java" (either bytecode or source) for the base language, but you are still going to have problems with all the libraries and any 3rd party tools which will still be English based.

Respondido 21 ago 17, 00:08

Java syntax should be written in plain English. JVM will use English syntax to convert into byte code. Surely you can display labels, message in other languages using Locale.

respondido 27 nov., 13:03

Programming languages need not change their library identifiers, and built-in keywords, from one language to another.

If you're programming in Java, you can use UTF-8 for encoding your source files.

You can then use Unicode symbols such as characters from languages other than English in your own identifiers.

You can name your own type Chaîne; but the String type stays String, and keywords like if or for or public stay English.

The concept of localizing the keywords of a language has been tried. For instance in the obscure language Protium. (I'd give a link if all leads weren't defunct; but Código Rosetta has some examples.) In Protium, all symbols are made up of character trigraphs to create semi-readable abbreviations. For instance, this code snippet which is rendered in English:

<@ SAI>
    <@ ITEFORLI3>2121|2008|
    <@ LETVARCAP>Christmas Day|25-Dec-<@ SAYVALFOR>...</@></@>
        <@ TSTDOWVARLIT>Christmas Day|1</@>
        <@ IFF>
            <@ SAYCAP>Christmas Day <@ SAYVALFOR>...</@> is a Sunday</@><@ SAYKEY>__Newline</@>

Now the idea is that these trigraphs, like LET VAR CAP, which make up an identifier like LETVARCAP, individually map to some corresponding trigraphs in other languages. Or perhaps, in the case of languages with complex characters in their writing system like Chinese or Japanese, to a single ideographic character.

Haz de ello lo que quieras.

respondido 27 nov., 13:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.