Translate your English source code into a foreign language I have noticed that there are a disproportionate number of computer languages based on English. I propose to fix this by translating existing computer languages into foreign languages!


Pick a computer language that uses English keywords/functions
Pick any natural* language other than English
Write a program that translates its own source code or any other program written using the same subset of keywords/functions into the other language
Post the source code and the output (the translated code)


Start your post with something like:

BASIC, French

or

BASIC, French - FONDAMENTAL

You don't have to translate the language name if you don't want to, it's just for fun!

You don't have to translate all the keywords/functions in your chosen language, just the ones you actually use in your source code. For instance, PHP has thousands so you definitely don't need to translate them all! Also, if you use any comments please do your best to translate them too! After your program has finished there should be no recognisable English words, unless they are appropriate for the foreign language. Words in strings should be translated too (meaning your translated program won't work on English source code anymore, even if it could be run!). Hopefully your program will make some sort of sense to a programmer who speaks the other language!

For example, if () {} elseif () {} else {} might become si () {} sinonsi () {} sinon {} in French! If you were translating Perl's elsif into French, maybe you'd drop the second n the way the second e is dropped in English: sinosi. In French else would more likely be autre but the alternative sinon (or else, otherwise) feels nicer to me!

Be creative! Try to capture the feel of both the computer and natural languages! Languages like Brainfuck, CJam, etc. that don't have English tokens can't be used. Languages like BASIC or COBOL are much more suitable. Use meaningful variable names and translate them too unless your language doesn't support variable names that can be English words.

You may post multiple answers, one for each combination of computer/natural language. You may not use a library or an external tool to do the translation! Your code should do the translation itself, not call something else that does translation! This is not Code Golf! If your program takes any input it must only be its own source code, if it reads from the disc it can only be the source file, etc.

* For the purposes of this challenge I will consider Esperanto, Lojban, Volapük, Interlingua, etc. as natural languages. You may not invent your own language for this challenge!

I have added a rule to prevent explicit quines. You may pick any subset of keywords/functions - even all of them - to translate. Your program must be able to translate itself as a minimum, i.e. if your original source includes the word print then adding print(42) anywhere to the input code (not your program itself) should still produce the correct results.

For example:

function translate() {
  ...
}
print(translate());


might become

fonction traduire() {
  ...
}
imprimer(traduire());


If the input is changed to

print(42);
function translate() {
  ...
}
print(translate());
print(42);


the output should then become

imprimer(42);
fonction traduire() {
  ...
}
imprimer(traduire());
imprimer(42);
Python, Koine Greek - Πύθων
My favorite programming language, in my favorite foreign language--perfect! And it doesn't hurt that the name is already Greek.
The translator program in Python 3 (thank goodness for native Unicode support):
with open(__file__, encoding=&quot;utf-8&quot;) as f:
    code = f.read()

replacements = [
    (&quot;print&quot;, &quot;γραψάτω&quot;),
    (&quot;input&quot;, &quot;λαβέτω&quot;),
    (&quot;read&quot;, &quot;ἀναγνώτω&quot;),
    (&quot;open&quot;, &quot;ἀνεῳξάτω&quot;),
    (&quot;file&quot;, &quot;βιβλίον&quot;),
    (&quot;import&quot;, &quot;εἰσενεγκάτω&quot;),
    (&quot;encoding&quot;, &quot;τύπος&quot;),
    (&quot;code&quot;, &quot;λόγοι&quot;),
    (&quot;replacements&quot;, &quot;νεόλογοι&quot;),
    (&quot;location&quot;, &quot;τόπος&quot;),
    (&quot;old&quot;, &quot;παλαιόν&quot;),
    (&quot;new&quot;, &quot;νέον&quot;),
    (&quot;find&quot;, &quot;εὑρέτω&quot;),
    (&quot;replace&quot;, &quot;ἀλλαξάτω&quot;),
    (&quot;for&quot;, &quot;ἕκαστον&quot;),
    (&quot;while&quot;, &quot;ἐν τῷ&quot;),
    (&quot;elif&quot;, &quot;εἰ δὲ&quot;),
    (&quot;if&quot;, &quot;εἰ&quot;),
    (&quot;else&quot;, &quot;εἰ δὲ μή&quot;),
    (&quot;is not&quot;, &quot;οὐκ ἔστιν&quot;),
    (&quot;is&quot;, &quot;ἔστιν&quot;),
    (&quot;not in&quot;, &quot;οὐκ ἐν&quot;),
    (&quot;in&quot;, &quot;ἐν&quot;),
    (&quot;and&quot;, &quot;καὶ&quot;),
    (&quot;or&quot;, &quot;ἢ&quot;),
    (&quot;not&quot;, &quot;οὐ&quot;),
    (&quot;with&quot;, &quot;μετὰ&quot;),
    (&quot;as&quot;, &quot;ὡς&quot;),
    (&quot;re&quot;, &quot;ῥλ&quot;),
    (&quot;sys&quot;, &quot;σύς&quot;),
    (&quot;:&quot;, &quot;·&quot;),
    (&quot;ph&quot;, &quot;φ&quot;),
    (&quot;th&quot;, &quot;θ&quot;),
    (&quot;ch&quot;, &quot;χ&quot;),
    (&quot;ps&quot;, &quot;ψ&quot;),
    (&quot;a&quot;, &quot;α&quot;),
    (&quot;b&quot;, &quot;β&quot;),
    (&quot;c&quot;, &quot;κ&quot;),
    (&quot;d&quot;, &quot;δ&quot;),
    (&quot;e&quot;, &quot;ε&quot;),
    (&quot;f&quot;, &quot;φ&quot;),
    (&quot;g&quot;, &quot;γ&quot;),
    (&quot;h&quot;, &quot;&quot;),
    (&quot;i&quot;, &quot;ι&quot;),
    (&quot;j&quot;, &quot;ι&quot;),
    (&quot;k&quot;, &quot;κ&quot;),
    (&quot;l&quot;, &quot;λ&quot;),
    (&quot;m&quot;, &quot;μ&quot;),
    (&quot;n&quot;, &quot;ν&quot;),
    (&quot;o&quot;, &quot;ο&quot;),
    (&quot;p&quot;, &quot;π&quot;),
    (&quot;r&quot;, &quot;ρ&quot;),
    (&quot;s &quot;, &quot;ς &quot;),
    (&quot;s.&quot;, &quot;ς.&quot;),
    (&quot;s,&quot;, &quot;ς,&quot;),
    (&quot;s·&quot;, &quot;ς·&quot;),
    (&quot;s&quot;, &quot;σ&quot;),
    (&quot;t&quot;, &quot;τ&quot;),
    (&quot;u&quot;, &quot;ου&quot;),
    (&quot;v&quot;, &quot;ου&quot;),
    (&quot;w&quot;, &quot;ου&quot;),
    (&quot;x&quot;, &quot;ξ&quot;),
    (&quot;y&quot;, &quot;υ&quot;),
    (&quot;z&quot;, &quot;ζ&quot;)
    ]

for old, new in replacements:
    if old == &quot;for&quot;:
        location = 0
        while old in code[location:]:
            location = code.find(old, location)
            if code[location+3] != '&quot;':
                location = code.find(&quot;in&quot;, location)
                code = code[:location] + &quot;ἐκ&quot; + code[location+2:]
            else:
                location += 1
    code = code.replace(old, new)

print(code)

Results of running the code on itself (with the big translation list redacted):
μετὰ ἀνεῳξάτω(__βιβλίον__, τύπος=&quot;ουτφ-8&quot;) ὡς φ·
    λόγοι = φ.ἀναγνώτω()

νεόλογοι = [
    (&quot;γραψάτω&quot;, &quot;γραψάτω&quot;),
    (&quot;λαβέτω&quot;, &quot;λαβέτω&quot;),
    (&quot;ἀναγνώτω&quot;, &quot;ἀναγνώτω&quot;),
    ...
    ]

ἕκαστον παλαιόν, νέον ἐκ νεόλογοι·
    εἰ παλαιόν == &quot;ἕκαστον&quot;·
        τόπος = 0
        ἐν τῷ παλαιόν ἐν λόγοι[τόπος·]·
            τόπος = λόγοι.εὑρέτω(παλαιόν, τόπος)
            εἰ λόγοι[τόπος+3] != '&quot;'·
                τόπος = λόγοι.εὑρέτω(&quot;ἐν&quot;, τόπος)
                λόγοι = λόγοι[·τόπος] + &quot;ἐκ&quot; + λόγοι[τόπος+2·]
            εἰ δὲ μή·
                τόπος += 1
    λόγοι = λόγοι.ἀλλαξάτω(παλαιόν, νέον)

γραψάτω(λόγοι)

Koine Greek is 2000 years old, so it was fun translating programming terms. Here's a few of my favorites:

βιβλίον = &quot;scroll&quot; (file)
γραψάτω = &quot;write&quot; (print)
λαβέτω = &quot;take&quot; (input)
εἰσενεγκάτω = &quot;bring in&quot; (import)
τύπος = &quot;pattern, type&quot; (encoding)
λόγοι/νεόλογοι = &quot;words&quot;/&quot;new words&quot; (code/replacements)
ἕκαστον... ἐκ = &quot;each... from&quot; (for ... in)
εἰ... εἰ δὲ... εἰ δὲ μή = &quot;if... but if... but if not&quot; (if ... elif ... else)
ἐν τῷ literally means &quot;in the,&quot; but in certain contexts it can be an idiom for &quot;when, while&quot;
&quot;Regular expression&quot; became ῥήμα λογικόν, &quot;rational/reasonable saying&quot;; thus, the abbreviation re is ῥλ

Most of the words can be also found by searching on Wiktionary.
Some other salient features:

English programming uses a bunch of imperative verbs (print, read, replace). I suspect the ancient Greeks would feel a bit foolish talking to the computer like this, so I made them all third-person imperatives: &quot;it must print,&quot; &quot;it must read,&quot; &quot;it must replace.&quot;
Greek punctuation is a bit different from English. I didn't go overboard with this, because I'm not sure what to replace the square brackets and underscores with, but I did swap out colons for ano teleia or &quot;high period&quot; (·).
For words that aren't in the list, I made sure to transliterate all the lowercase letters too. There isn't always a straight one-to-one correspondence; so for example, utf turns into ουτφ--which sounds about like &quot;ootf&quot; if you try to pronounce it.

This still leaves a lot to be desired grammar-wise. Greek is a much more highly inflected language than English, and my code isn't nearly sophisticated enough to get all the cases and numbers right. For example, ἕκαστον παλαιόν, νέον ἐκ νεόλογοι ought to read ἐκ νεολόγων, with the object of the preposition in the genitive case. However, I'm not about to put that much time into this! The look is sufficiently Greek (at least to the untrained eye) and the high periods add a nice touch. All in all, I'm pretty satisfied with the results.