Translate your English source code into a foreign language

66

20

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);

CJ Dennis

Posted 2015-06-01T04:47:11.993

Reputation: 4 104

Question was closed 2016-04-24T22:49:45.597

translates its own source code--meaning it has to read its own file, or can the source code be given on stdin? – DLosc – 2015-06-01T06:08:26.227

It doesn't matter how it generates the output as long as it solves the challenge. It may not read a pre-translated version of itself, however! Answering your specific question, both reading its own source from storage or memory is allowed as is passing it through on stdin. – CJ Dennis – 2015-06-01T06:19:40.393

4"print" would become "imprimer" (as in "printer"), not "empreinte" (as in "footprint") :) – Quentin – 2015-06-01T12:02:46.257

4@Quentin I never claimed it was good French! – CJ Dennis – 2015-06-01T12:25:36.270

13I think it's bad enough that Excel has native language support.. :(. Makes debugging formulas so much harder – Mave – 2015-06-01T13:42:49.507

1@Quentin I'm now wondering if the French verbs should use the imperative instead of the infinitive. The only problem is my French isn't good enough for that! – CJ Dennis – 2015-06-01T15:36:03.383

3@CJDennis In French pseudocode I've always seen the infinitive, but I can give a hand if needed :p – Quentin – 2015-06-01T15:43:18.513

@Quentin Would it be imprime and traduis? Or pehaps imprimez and traduites? Although I think a computer should be subordinate to a person, so maybe the former? – CJ Dennis – 2015-06-01T15:52:02.213

@CJDennis Yeah, I guess I'd say "tu" to a computer, not "vous". It's "traduisez", though :) – Quentin – 2015-06-01T15:53:31.710

Can I write a code in a language that translates another language? – Ismael Miguel – 2015-06-02T09:32:20.910

@IsmaelMiguel Unless you can give me a really good reason I'll say no. So far all the submissions have worked on the same language. – CJ Dennis – 2015-06-02T11:45:29.240

@CJDennis The only reason was that I have a syntax highlighter for SQL (written in Javascript) and I would use to translate it in Portuguese. But I realized that that (yes, I meant to repeat that) is not the spirit of this challenge. – Ismael Miguel – 2015-06-02T11:57:33.567

@IsmaelMiguel You meant to repeat that that? – CJ Dennis – 2015-06-02T13:13:34.690

@CJDennis Exactly. That that was intentionally repeated. It isn't a mistake. – Ismael Miguel – 2015-06-02T13:17:17.980

1

It's only tangentially related but you might be interested in http://en.wikipedia.org/wiki/Logo_(programming_language) The English-language article does not really explain it but it was intended to be (and has actually been) translated in various languages so that the primitives match the user's natural language. We used a French version of this language in primary school.

– Relaxed – 2015-06-03T18:13:53.200

@Relaxed Thanks for that! I want to post a few answers myself later and I was considering Logo so if I go ahead with that one I'll check which languages it has already been translated into! – CJ Dennis – 2015-06-04T05:16:09.730

1I would like to see an "ouroboros program" that translates its source code into a foreign language, which, when compiled/interpreted on the appropriate foreign language compiler/interpreter, is a program that outputs the original English source code. – John Peter Thompson Garcés – 2015-06-04T18:19:40.363

1

In case anyone's interested in real non-English programming languages (sorry @Mave!) : here's one in my native tongue Tamil, and here's a bunch more in several different languages.

– sundar - Reinstate Monica – 2015-06-05T11:55:13.037

@IsmaelMiguel — I don't understand what you want to do. Can you give an example? – Nicolas Barbulesco – 2015-06-07T00:52:59.530

@NicolasBarbulesco What do you mean? – Ismael Miguel – 2015-06-07T00:55:33.010

@NicolasBarbulesco I believe Ismael Miguel wanted to use Javascript to translate SQL. He would have to use SQL to translate SQL. – CJ Dennis – 2015-06-07T05:56:15.890

This reminds me of the Arabic Lisp someone made (reddit). It has syntactic features that aren't possible in Latin print, like lining things up by stretching out letters.

– Joey Adams – 2015-06-09T17:07:57.577

There are plenty of programming languages in which you can write a useful program that uses no keywords (and as written, the null program is a valid solution in all the languages where it acts like cat by default). This is likely going to have to require at least one keyword to be translated. – None – 2017-04-11T02:36:08.247

Answers

67

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="utf-8") as f:
    code = f.read()

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

for old, new in replacements:
    if old == "for":
        location = 0
        while old in code[location:]:
            location = code.find(old, location)
            if code[location+3] != '"':
                location = code.find("in", location)
                code = code[:location] + "ἐκ" + 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):

μετὰ ἀνεῳξάτω(__βιβλίον__, τύπος="ουτφ-8") ὡς φ·
    λόγοι = φ.ἀναγνώτω()

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

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

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

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

  • βιβλίον = "scroll" (file)
  • γραψάτω = "write" (print)
  • λαβέτω = "take" (input)
  • εἰσενεγκάτω = "bring in" (import)
  • τύπος = "pattern, type" (encoding)
  • λόγοι/νεόλογοι = "words"/"new words" (code/replacements)
  • ἕκαστον... ἐκ = "each... from" (for ... in)
  • εἰ... εἰ δὲ... εἰ δὲ μή = "if... but if... but if not" (if ... elif ... else)
  • ἐν τῷ literally means "in the," but in certain contexts it can be an idiom for "when, while"
  • "Regular expression" became ῥήμα λογικόν, "rational/reasonable saying"; 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: "it must print," "it must read," "it must replace."
  • 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 "high period" (·).
  • 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 "ootf" 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.

DLosc

Posted 2015-06-01T04:47:11.993

Reputation: 21 213

4It looks like Greek to me! I don't understand Greek but it looks like you've gone to some trouble to get the grammar right, so well done! Would you mind including a few lines from your translation list? – CJ Dennis – 2015-06-01T07:57:02.330

I still only see νεόλογοι = [...]. Can you put just a couple of lines in there? No need for the whole list! – CJ Dennis – 2015-06-01T08:34:31.357

True, it's not terribly interesting but it does give an indication of the whole output! – CJ Dennis – 2015-06-01T08:45:47.040

Isn't the translation supposed to leave the string constants alone and only translate keywords (and possibly variable names)? – kasperd – 2015-06-03T12:04:45.497

@kasperd Au contraire: Words in strings should be translated too. – DLosc – 2015-06-03T20:36:57.987

66

Chicken, Chinese - 鸡

Chicken is much harder to use than I thought.

There isn't a trailing newline. But the final chicken is just for marking the end of this program, which can be replaced with an empty line.

I'm using this interpreter, which prints an extra newline and cannot be suppressed. So the output have one more line than the original, and that can make a Chicken program broken. I hope this won't make it invalid.

It used some tricks like getting an empty strings from index -1 of the input, and detecting EOF by comparing with empty strings. I also used the compare command to discard unused items in the stack, without caring about the type. They may not work in other interpreters. And it prints the string as UTF-8 bytes, where other interpreters may support printing Unicode characters directly.

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken


chicken

Use this command to run this code:

bin/chicken "`<file`" <file

where weirdly enough, the first file is for input, and the second is for the code.

The output (Chinese don't use spaces between words):

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡
鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡
鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡
鸡
鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡

鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡鸡
鸡鸡鸡鸡鸡鸡


鸡

This program replaces h with , leaves newlines unaffected, and ignores everything else.

And as you see, it can translate every valid Chicken program.

jimmy23013

Posted 2015-06-01T04:47:11.993

Reputation: 34 042

3

You know what this makes me think of--https://youtu.be/vExjnn_3ep4

– DLosc – 2015-06-01T09:03:40.750

5Mmm! Chinese chicken! I think the output is easier to understand than the original program! Does anyone else feel like take-away now? – CJ Dennis – 2015-06-01T09:08:07.783

1鸡鸡复鸡鸡 – March Ho – 2015-06-01T16:59:10.887

2

Nice work, Jimmy.

– Alex A. – 2015-06-01T19:40:49.117

18@AlexA. Changed my username then. – jimmy23013 – 2015-06-02T01:15:45.113

6季姬击鸡记 – alephalpha – 2015-06-02T15:49:17.003

*鸡 --> 雞­­­­­­­ – Derek 朕會功夫 – 2015-06-06T19:49:29.033

@Derek朕會功夫 Here it is.

– jimmy23013 – 2015-06-07T00:50:18.463

Upvoting for the slight troll value – Mark K Cowan – 2015-06-08T10:24:14.197

@jimmy23013 Your link is in English... – Derek 朕會功夫 – 2015-06-08T20:31:21.730

@Derek朕會功夫 You can run it with itself as input to get a traditional Chinese version. Or just replace each chicken with to pretend that you have done it. – jimmy23013 – 2015-06-08T20:40:57.953

@jimmy23013 That works fine for me :) – Derek 朕會功夫 – 2015-06-08T20:57:46.670

36

C++, Latin - C Plus Plus

Yes, that is an actual translation of the language name. They didn't have the plus sign, but they gave us the word plus.

#include <iostream>
#include <fstream>

using namespace std;

static const char *reposita[][2] = {
    // Miscellanea
    {"iostream",    "flumineie"},       // flumine inducto/educto
    {"ofstream",    "fluminele"},       // flumine limae educto
    {"ifstream",    "flumineli"},       // flumine limae inducto
    {"fstream",     "fluminel"},        // flumine limae
    {"std",         "cmn"},             // commune
    {"string",      "chorda"},
    {"empty",       "vacuum"},
    {"size_t",      "t·amplitudinis"},  // typus amplitudinis
    {"find",        "inveni"},
    {"npos",        "posn"},            // positio nulla
    {"replace",     "repone"},
    {"main",        "primor"},
    {"getline",     "sumelinea"},

    // Verba gravia
    {"alignas",             "ordinasicut"},
    {"alignof",             "ordinatio"},
    {"asm",                 "cns"},             // construere
    {"auto",                "modic"},           // modicum
    {"bool",                "bic"},             // bicolore
    {"break",               "erumpe"},
    {"case",                "res"},
    {"catch",               "capta"},
    {"char16_t",            "t·littxvi"},       // typus litterae
    {"char32_t",            "t·littxxxii"},
    {"wchar_t",             "t·littv"},         // typus litterae vadae
    {"char",                "litt"},            // littera
    {"class",               "genus"},
    {"constexpr",           "dictconst"},       // dictum constante
    {"const_cast",          "funde·const"},     // funde constanter
    {"continue",            "procede"},
    {"decltype",            "typusdecl"},       // typus declaratus
    {"default",             "ultima"},
    {"delete",              "abole"},
    {"for",                 "cum"},
    {"if",                  "si"},
    {"struct",              "aedif"},           // aedificium
    {"double",              "biforme"},
    {"do",                  "fac"},
    {"dynamic_cast",        "funde·impigre"},
    {"else",                "alter"},
    {"explicit",            "directum"},
    {"export",              "expone"},
    {"false",               "falsum"},
    {"float",               "nante"},
    {"friend",              "amicus"},
    {"goto",                "iad"},
    {"inline",              "inlinea"},
    {"long",                "longum"},
    {"mutable",             "mutabilis"},
    {"namespace",           "plaganominis"},
    {"new",                 "novum"},
    {"noexcept",            "sineexim"},        // sine eximibus
    {"nullptr",             "sgnnullum"},       // signum nullum
    {"private",             "privata"},
    {"protected",           "protecta"},
    {"public",              "publica"},
    {"register",            "arca"},
    {"reinterpret_cast",    "funde·revertendo"},
    {"return",              "redde"},
    {"short",               "breve"},
    {"unsigned",            "sine·signo"},
    {"signed",              "signo"},
    {"sizeof",              "amplitudo"},
    {"static_assert",       "autuma·stant"},    // autuma stantiter
    {"static_cast",         "funde·stant"},     // funde stantiter
    {"static",              "stante"},
    {"switch",              "furca"},
    {"template",            "exemplar"},
    {"this",                "hoc"},
    {"thread_local",        "ligamen·loci"},
    {"throw",               "iaci"},
    {"true",                "verum"},
    {"try",                 "tempta"},
    {"typedef",             "typumdes"},        // typum designa
    {"typeid",              "signumtypi"},
    {"typename",            "nomentypi"},
    {"union",               "iugum"},
    {"using",               "utente"},
    {"virtual",             "virtuale"},
    {"void",                "inane"},
    {"volatile",            "volatilis"},
    {"while",               "dum"},

    // Numeri
    {"0",   "nihil"},
    {"1",   "i"},
    {"2",   "ii"},

    // Miscellanea
    {"length",      "longitudo"}
};

static void omnesRepone(string& chorda, const string& de, const string& ad) {
    if (de.empty()) {
        return;
    }
    size_t index = 0;
    while ((index = chorda.find(de, index)) != string::npos) {
        chorda.replace(index, de.length(), ad);
        index += ad.length();
    }
}

int main(int narg, const char * varg[]) {

    ifstream limaArchetypa(varg[1]);
    ofstream limaTransferenda(varg[2]);

    int elementa = sizeof(reposita) / sizeof(reposita[0]);
    string linea;
    while (getline(limaArchetypa, linea)) {
        for (int index = 0; index < elementa; ++index) {
            omnesRepone(linea, reposita[index][0], reposita[index][1]);
        }
        limaTransferenda << linea << "\n";
    }
    return 0;
}

Notes:

  • Takes an input and output file on the command line
  • Translates all keywords
  • I did not write a full Roman numeral parser but I thought it would be nice to at least translate the numbers present in the source (nihil, i, and ii)
  • I did not go down the road of translating symbols used in C++, which seemed like a huge can of worms
  • The keywords const, enum, int, and operator do not change. They now stand for constante, enumeratum, integrum, and operator.
  • I didn't think the Romans would be into _ as a word divider, so I used interpuncts.
  • The translation is very dumb and inefficient, ignoring word boundaries etc.

Output:

#include <flumineie>
#include <fluminel>

utente plaganominis cmn;

stante const litt *reposita[][ii] = {
    // (redacta)
};

stante inane omnesRepone(chorda& chorda, const chorda& de, const chorda& ad) {
    si (de.vacuum()) {
        redde;
    }
    t·amplitudinis index = nihil;
    dum ((index = chorda.inveni(de, index)) != chorda::posn) {
        chorda.repone(index, de.longitudo(), ad);
        index += ad.longitudo();
    }
}

int primor(int narg, const litt * varg[]) {

    flumineli limaArchetypa(varg[i]);
    fluminele limaTransferenda(varg[ii]);

    int elementa = amplitudo(reposita) / amplitudo(reposita[nihil]);
    chorda linea;
    dum (sumelinea(limaArchetypa, linea)) {
        cum (int index = nihil; index < elementa; ++index) {
            omnesRepone(linea, reposita[index][nihil], reposita[index][i]);
        }
        limaTransferenda << linea << "\n";
    }
    redde nihil;
}

Luke

Posted 2015-06-01T04:47:11.993

Reputation: 5 091

Shouldn't "string" be translated as "catena", like in modern Romance languages? – 200_success – 2015-06-01T18:10:51.263

Depends how literal you're feeling. – Luke – 2015-06-01T19:22:16.367

6Or rather, how romantic you're feeling. – Alex A. – 2015-06-01T20:34:38.427

1I think you missed "empty". – None – 2015-06-02T09:26:21.540

1Thanks. I took a leaf out of @Vioz-'s book and used 'inane' for void, so that I could use 'vacuum' for empty. – Luke – 2015-06-02T12:19:24.987

string is called stringa in italian actually, and it's like a thin rope, e.g. also shoelaces are called "stringhe". Catena means chain.

Also in the programming world the word "stringa" is used, but for once it's not a bastardization of English words. – Formagella – 2015-06-03T20:29:15.140

How about something like "C se auget" as the language name? Forgive me if I mangled the grammar. – hobbs – 2015-06-04T18:24:51.550

25

JavaScript (NodeJS) - Hebrew

My method for encoding is pretty similar to DLosc's Python program: It reads the source code, has a list of tokens, and runs find-and-replace.

var file_system = require('fs');
file_system.readFile(__filename, function(error,code){
    if (error) {throw error;}
    code = code.toString();
    var words = {
        'var': 'מש׳',
        'file_system': 'מערכת_קבצים',
        'require': 'דרוש',
        'fs': 'מ״ק',
        'readFile': 'קראקובץ',
        'filename': 'שםקובץ',
        'function': 'תפקיד',
        'error': 'שבוש',
        'code': 'צופן',
        'if': 'אם',
        'throw': 'זרוק',
        'toString': 'למחרוזת',
        'words': 'מילים',
        'word': 'מילה',
        'for': 'לכל',
        'in ': 'ב',
        'replace': 'החלף',
        'RegExp': 'ביטס״ד',
        'console': 'מסוף',
        'log': 'רשום',
        'new (.+)\\(': '$1 חדש(',
        'g': 'ע׳',
        '\'': '',
        ';': '׃'
    }, word;

    for (word in words) {
        code = code.replace(new RegExp(word,'g'), words[word]);
    }
    console.log(code);
});

This gives the following output:

מש׳ מערכת_קבצים = דרוש(מ״ק)׃
מערכת_קבצים.קראקובץ(__שםקובץ, תפקיד(שבוש,צופן){
    אם (שבוש) {זרוק שבוש׃}
    צופן = צופן.למחרוזת()׃
    מש׳ מילים = {
        מש׳: מש׳,
        מערכת_קבצים: מערכת_קבצים,
        דרוש: דרוש,
        מ״ק: מ״ק,
        קראקובץ: קראקובץ,
        שםקובץ: שםקובץ,
        תפקיד: תפקיד,
        שבוש: שבוש,
        צופן: צופן,
        אם: אם,
        זרוק: זרוק,
        למחרוזת: למחרוזת,
        מילים: מילים,
        מילה: מילה,
        לכל: לכל,
        ב: ב,
        החלף: החלף,
        ביטס״ד: ביטס״ד,
        מסוף: מסוף,
        רשום: רשום,
        (.+)\\(: $1 חדש חדש(,
        ע׳: ע׳,
        \: ,
        ׃: ׃
    }, מילה׃

    לכל (מילה במילים) {
        צופן = צופן.החלף(ביטס״ד חדש(מילה,ע׳), מילים[מילה])׃
    }
    מסוף.רשום(צופן)׃
})׃

Unfortunately, SE doesn't seem to like RTL text. I tried to manually wrap the above code block in <pre dir="rtl">, but it just got stripped. :( The code is actually supposed to look like this: (screenshot of gedit)

code properly displayed with RTL formatting

Some things to note about the Hebrew text:

  • The Hebrew method for abbreviations (which is used multiple times in this code) is to use a single quote mark at the end for abbreviating a single word, and double quotes before the last letter if it is multiple words. For a single word, we have var, which i translated as מש', short for "משתנה" (variable). fs, an acronym of "file system", got translated as מ"ק, the first letters of "מערכת קבצים", seen above.
  • Hebrew doesn't have capital/lowercase letters. A few letters have normal/final forms (כמנפצ and ךםןףץ, respectively), but that's it. So in mashup words like "readFile" and "filename", i also mashed together the Hebrew "קרא קובץ" and "שם קובץ", despite the second one ending up with a final letter in the middle of the word.
  • The above does not apply to toString. In Hebrew, prepositions are single letters which get prepended to the word. So, if "string" is "מחרוזת", "to string" is "למחרוזת". That's also why in the for..in block, the in token includes the space, so that it gets attached to the next word (word in words becomes מילה במילים).
  • I am unable to reproduce this from my computer, but when i went to translate.google.com from my iPad and put in regex, it gave me back ביטוי סדיר, which literally means "ordered expression". Wow! I abbreviated it down to ביטס"ד, as JS's RegExp is.
  • The g regex flag i translated as ע', which stands for עולמי, global.
  • Note the complicated regex form for replacing new. That's because in Hebrew, adjectives (such as "new" - "חדש") come after the noun (such as regex). So, instead of new RegExp(), it would be "RegExp [that is] new()`.
  • I removed the quote marks, as they don't exist in classic Hebrew. It certainly makes the grammar a lot harder! I'm still not sure whether or not it was a good decision.
  • It looks like i'm replacing all the terminating semicolons with colons. It's actually a U+05C3 SOF PASUQ, a punctuation mark which ends a verse in the Bible.

This code certainly does not translate every valid JS program. In fact, it probably only translates this one. But that's good enough for this challenge. ;)

By the way, if you're interested in Hebrew, come follow the Hebrew.SE proposal (and vote on questions with a score of <10)!
Stack Exchange Q&A site proposal: Hebrew Language
(source: stackexchange.com)

Scimonster

Posted 2015-06-01T04:47:11.993

Reputation: 2 905

9

Should have gone with PHP—they've already got T_PAAMAYIM_NEKUDOTAYIM covered!

– wchargin – 2015-06-02T01:18:19.840

2The last line of the RTL source looks like a sad-faced man with a beard. :) – Matt Lyons – 2015-06-03T08:08:49.913

(for that matter either one, for some reason I didn't notice it on the LTR source) – Matt Lyons – 2015-06-03T08:09:45.533

@MattLyons You probably didn't notice in English because it doesn't really look like it as much. – Scimonster – 2015-06-03T08:17:03.100

True, because it's got that colon(-esque) thing. Nice touch by the way! – Matt Lyons – 2015-06-03T08:22:54.627

I think it would be more readable if you used whole words instead of abbreviations. – Erel Segal-Halevi – 2015-06-04T18:25:48.537

@ErelSegal-Halevi But the English uses abbreviations. – Scimonster – 2015-06-04T18:45:11.423

String is מחרוזת in Hebrew and console is מסוף. Other than that, כל הכבוד!‏ – dotancohen – 2015-06-04T20:32:07.247

@dotancohen I did not know that. Thanks! I fixed that in the answer. :) – Scimonster – 2015-06-04T21:09:14.277

I think it's a little weird you remove ' but yet you have some acronyms using ". anyway, Hebrew FTW! – proud haskeller – 2015-06-09T21:02:30.720

מי כאן מדבר עברית? – proud haskeller – 2015-06-09T21:02:42.087

@proudhaskeller The thing that looks like double quotes is actually the Hebrew symbol for acronyms. – Scimonster – 2015-06-09T21:04:37.857

yes, but if you put these in you might as well use that for quotation too (at least here in israel thet's used for quotation. Don't know what the mishnaics and all of these did). – proud haskeller – 2015-06-09T21:09:05.340

@proudhaskeller Ancient Hebrew didn't use quotation marks. Then again, it also didn't have words for "code", "console", or "file". I'll reconsider in the morning. – Scimonster – 2015-06-09T21:11:50.600

1מה קורה @proudhaskeller – sagiksp – 2017-02-02T09:16:29.900

22

Perl, PigLatin - erlPay

First, the actual program is very short, so to demonstrate how it behaves for longer sections of text I included some Perl Poetry as a further example of the input/output. Since the poetry is included after the END line it doesn't actually get executed.

The actual algorithm is pretty straight forward:

  • Split input into tokens on word boundaries
  • For any word with at least two alpha characters translate into Pig Latin
    • Find the leading consonants in the word
    • move them to the end and put the 'ay' suffix on them
  • Print everything. Non alpha input (and single-characters) are not translated

#!/usr/bin/perl

while (<>) {
    print map { 
        s/^([bcdfghjklmnpqrstvwxyz]*)([a-z]+)/$2$1ay/i if /[a-z][a-z]/i; $_ 
    } split(/\b/);
}
__END__
# listen (a perl poem)
# Sharon Hopkins
# rev. June 19, 1995
# Found in the "Perl Poetry" section of the Camel book
APPEAL:

listen(please, please);

open yourself, wide;
    join (you, me),
connect (us, together),

tell me.

do something if distressed;

    @dawn, dance;
    @evening, sing;
    read (books, $poems, stories) until peaceful;
    study if able;

    write me if-you-please;

sort your feelings, reset goals, seek (friends, family, anyone);

    do*not*die (like this)
    if sin abounds;

keys (hidden), open (locks, doors), tell secrets;
do not, I-beg-you, close them, yet.

        accept (yourself, changes),
        bind (grief, despair);

require truth, goodness if-you-will, each moment;

select (always), length (of-days)

Output from running the program on itself:

#!/usray/inbay/erlpay

ilewhay (<>) {
    intpray apmay { 
        s/^([zbcdfghjklmnpqrstvwxyay]*)([a-z]+)/$2$1ay/i ifay /[a-z][a-z]/i; $_ 
    } itsplay(/\b/);
}
__END__
# istenlay (a erlpay oempay)
# aronShay opkinsHay
# evray. uneJay 19, 1995
# oundFay inay ethay "erlPay oetryPay" ectionsay ofay ethay amelCay ookbay
APPEALay:

istenlay(easeplay, easeplay);

openay ourselfyay, ideway;
    oinjay (ouyay, emay),
onnectcay (usay, ogethertay),

elltay emay.

oday omethingsay ifay istressedday;

    @awnday, anceday;
    @eveningay, ingsay;
    eadray (ooksbay, $oemspay, oriesstay) untilay eacefulpay;
    udystay ifay ableay;

    itewray emay ifay-ouyay-easeplay;

ortsay ouryay eelingsfay, esetray oalsgay, eeksay (iendsfray, amilyfay, anyoneay);

    oday*otnay*ieday (ikelay isthay)
    ifay insay aboundsay;

eyskay (iddenhay), openay (ockslay, oorsday), elltay ecretssay;
oday otnay, I-egbay-ouyay, oseclay emthay, etyay.

        acceptay (ourselfyay, angeschay),
        indbay (iefgray, espairday);

equireray uthtray, oodnessgay ifay-ouyay-illway, eachay omentmay;

electsay (alwaysay), engthlay (ofay-aysday)

Ralph Marshall

Posted 2015-06-01T04:47:11.993

Reputation: 729

2

Pig Latin is considered a language game, not a natural language. See the Pig Latin Wikipedia page.

– Alex A. – 2015-06-01T16:13:09.397

5I suppose you could call it that, although I'm not sure that this challenge quite rises to the level of a Federal RFP as far as formality is concerned. – Ralph Marshall – 2015-06-01T17:21:10.520

3The translated language name should be erlPay and I'd love it if it also output __DENAY__. Shouldn't openay and acceptay be enopay and ceptacay? – CJ Dennis – 2015-06-02T01:22:54.447

1The challenge specifies "foreign language". Pig Latin doesn't count. – mbomb007 – 2015-06-02T14:14:14.087

6I guess I'd suggest that you all lighten up about the acceptability of PigLatin as a foreign language. If you don't like my solution, don't vote for it. I believe that CJ is happy enough with it, and since this is just a fun little exercise I'm sticking with my input. – Ralph Marshall – 2015-06-02T14:17:09.430

Since this is a popularity contest I'll let the voters decide. I did expressly allow constructed languages such as Esperanto so it doesn't seem like that much of a stretch to allow Pig Latin even though it's not actually a language but modified English. Still, the program does do the transformation asked for. – CJ Dennis – 2015-06-03T03:58:38.437

I guess Pig Latin may be considered "foreign" by an Estonian... – Mark K Cowan – 2015-06-08T10:28:26.467

17

Visual Basic .Net, Persian

I chose a verbose language so it would be harder. Turns out, I didn't have to change the grammar. The Persian form of the code is just as verbose.

Imports System.Collections.Generic
Module Translator

Sub Main()
    Dim translation As New Dictionary(Of String, String)
    With translation
        .Add("imports", "وارد‌کردن")
        .Add("system", "دستگاه")
        .Add("collections", "مجموعه")
        .Add("generic", "عمومی")
        .Add("module", "واحد")
        .Add("translator", "مترجم")
        .Add("sub", "زیرروال")
        .Add("main", "اصلی")
        .Add("dim", "بعد")
        .Add("translation", "ترجمه")
        .Add("new", "نو")
        .Add("dictionary", "دیکشنری")
        .Add("string", "رشته")
        .Add("with", "با")
        .Add("add", "افزودن")
        .Add("end", "پایان")
        .Add("file", "فایل")
        .Add("create", "درست‌کردن")
        .Add("readalltext", "خواندن‌کل‌متن")
        .Add("writealltext", "نوشتن‌کل‌متن")
        .Add("io", "ورودی‌خروجی")
        .Add("for", "برای")
        .Add("each", "هر")
        .Add("next", "بعدی")
        .Add("tolower", "به‌کوچک")
        .Add("key", "کلید")
        .Add("value", "مقدار")
        .Add("replace", "جایگزین‌کردن")
        .Add("code", "کد")
        .Add("dispose", "رها‌کردن")
        .Add("and", "و")
        .Add("andalso", "و‌همچنین")
        .Add("byte", "بیت")
        .Add("call", "صدا‌کردن")
        .Add("case", "صورت")
        .Add("catch", "گرفتن")
        .Add("object", "شئ")
        .Add("integer", "عدد")
        .Add("if", "اگر")
        .Add("then", "سپس")
        .Add("goto", "برو‌به")
        .Add("true", "درست")
        .Add("false", "نادرست")
        .Add("exit", "خارج‌شدن")
        .Add("loop", "حلقه")
        .Add("function", "تابع")
        .Add("nothing", "هیچی")
        .Add("else", "در‌غیر‌این‌صورت")
        .Add("try", "سعی‌کردن")
        .Add("or", "یا")
        .Add("orelse", "یا")
        .Add("as", "به‌عنوان")
        .Add("of", "از")
        .Add("in", "در")
    End With
    Dim code As String = System.IO.File.ReadAllText("Code.txt").ToLower()
    For Each k In translation
        code = code.Replace(k.Key, k.Value)
    Next
    System.IO.File.Create("Persian.txt").Dispose()
    System.IO.File.WriteAllText("Persian.txt", code)
End Sub

End Module

The result requires a right-to-left text editor. I couldn't get it to display properly here. But if I have to display it, here it is. Here's a picture:

code

Note: It reads from a file named Persian.txt and outputs to code.txt. I couldn't get the console window to write or read Persian without it turning into question marks. (e.g. a four letter word would turn into ????)

Note: If you connect words with each other in Persian, it will be almost unreadable, because letters connect to each other and get a different form. So I had to separate them with spaces which resulted in words having spaces. A word like Imports turned into وارد کردن which is two words.

JNV

Posted 2015-06-01T04:47:11.993

Reputation: 389

In my Hebrew post, i include a screenshot of it displaying properly in an editor that supports RTL.

– Scimonster – 2015-06-01T15:05:54.883

@Scimonster Good idea. I'll do that right away. Thanks. – JNV – 2015-06-01T15:07:30.913

2You can have "درست کردن" with no space, without it turning into "درستکردن", using a Unicode zero-width non-joiner character (U+200C): "درست‌کردن" - this forces the letters to be side-by-side with no gap, without joining them together - though whether the results look good will depend on the font! – psmears – 2015-06-04T14:24:11.497

@psmears You're right; I forgot about it. Thanks! – JNV – 2015-06-04T15:00:38.823

14

Java, German - Java

This program is really straight forward.
It just reads the file given as the first argument and replaces all occurrences of an English word with the respective German translation.

I am using a regular expression with two groups (([^a-zA-Z\\d:])*) to match individual items prepended/followed by a non-alphanumeric character. This solved the issue with overlapping translations (eng. List -> ger. Liste but then Liste would become Listee). Using $1/$2 adds those characters back and leaves us with a translated source code.

Update 1:

Use abbreviations like ea, nbea etc. to follow naming conventions of Java in German.

Update 2:

Now uses a third component in the array to break after their first replacement. This is necessary for my cheaty declination/conjugation approach. class/Klasse is female in German and void/nichts is neutral, so I just skipped replacing the latter and replaced later. Another edit is new's translation turned to neue because I only use it on String, which is female.

Update 3:

Properly deal with capitalization by adding case sensitive regular expressions.

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.util.regex.Pattern;

    public class Main {

        public static void main(String[] args) throws IOException {
            String[][] array = new String[][]{
                    {"import", "importiere", ""},
                    {"public", "öffentliche", "break"},
                    {"public", "öffentliches", ""},
                    {"class", "klasse", ""},
                    {"Main", "Haupt", ""},
                    {"main", "haupt", ""},
                    {"static", "statisches", ""},
                    {"void", "nichts", ""},
                    {"String", "Zeichenkette", ""},
                    {"args", "argumente", ""},
                    {"throws", "wirft", ""},
                    {"IOException", "EAAusnahme", ""},
                    {"FileSystems", "Dateisysteme", ""},
                    {"new", "neue", ""},
                    {"Files", "Dateien", ""},
                    {"readAllBytes", "leseAlleBytes", ""},
                    {"getDefault", "holeStandard", ""},
                    {"getPath", "holePfad", ""},
                    {"array", "ansammlung", ""},
                    {"replaceFirst", "ersetzeErstes", ""},
                    {"find", "finde", ""},
                    {"out", "ausgabe", ""},
                    {"println", "druckeZeile", ""},
                    {"pattern", "muster", ""},
                    {"Pattern", "Muster", ""},
                    {"compile", "zusammenstellen", ""},
                    {"matcher", "abgleicher", ""},
                    {"util", "werkzeug", ""},
                    {"regex", "regaus", ""},
                    {"while", "solange", ""},
                    {"nio", "nbea", ""},
                    {"io", "ea", ""},
                    {"for", "für", ""},
                    {"if", "wenn", ""},
                    {"equals", "gleicht", ""},
                    {"break", "unterbrechen", ""}

            };
            String str = new String(Files.readAllBytes(FileSystems.getDefault().getPath(args[0])));
            for (String[] s : array) {
                Pattern pattern = Pattern.compile("(^|[^a-zA-Z\\d]+)" + s[0] + "([^a-zA-Z\\d]+)");
                while(pattern.matcher(str).find(0)) {
                    str = pattern.matcher(str).replaceFirst("$1" + s[1] + "$2");
                    if(s[2].equals("break")) {
                        break;
                    }
                }
            }
            System.out.println(str);
        }
    }

This outputs the following to System.out:

importiere java.ea.EAAusnahme;
importiere java.nbea.file.Dateisysteme;
importiere java.nbea.file.Dateien;
importiere java.werkzeug.regaus.Muster;

    öffentliche klasse Haupt {

        öffentliches statisches nichts haupt(Zeichenkette[] argumente) wirft EAAusnahme {
            Zeichenkette[][] ansammlung = neue Zeichenkette[][]{
                    {"importiere", "importiere", ""},
                    {"öffentliches", "öffentliche", "unterbrechen"},
                    {"öffentliches", "öffentliches", ""},
                    {"klasse", "klasse", ""},
                    {"Haupt", "Haupt", ""},
                    {"haupt", "haupt", ""},
                    {"statisches", "statisches", ""},
                    {"nichts", "nichts", ""},
                    {"Zeichenkette", "Zeichenkette", ""},
                    {"argumente", "argumente", ""},
                    {"wirft", "wirft", ""},
                    {"EAAusnahme", "EAAusnahme", ""},
                    {"Dateisysteme", "Dateisysteme", ""},
                    {"neue", "neue", ""},
                    {"Dateien", "Dateien", ""},
                    {"leseAlleBytes", "leseAlleBytes", ""},
                    {"holeStandard", "holeStandard", ""},
                    {"holePfad", "holePfad", ""},
                    {"ansammlung", "ansammlung", ""},
                    {"ersetzeErstes", "ersetzeErstes", ""},
                    {"finde", "finde", ""},
                    {"ausgabe", "ausgabe", ""},
                    {"druckeZeile", "druckeZeile", ""},
                    {"muster", "muster", ""},
                    {"Muster", "Muster", ""},
                    {"zusammenstellen", "zusammenstellen", ""},
                    {"abgleicher", "abgleicher", ""},
                    {"werkzeug", "werkzeug", ""},
                    {"regaus", "regaus", ""},
                    {"solange", "solange", ""},
                    {"nbea", "nbea", ""},
                    {"ea", "ea", ""},
                    {"für", "für", ""},
                    {"wenn", "wenn", ""},
                    {"gleicht", "gleicht", ""},
                    {"unterbrechen", "unterbrechen", ""}

            };
            Zeichenkette str = neue Zeichenkette(Dateien.leseAlleBytes(Dateisysteme.holeStandard().holePfad(argumente[0])));
            für (Zeichenkette[] s : ansammlung) {
                Muster muster = Muster.zusammenstellen("(^|[^a-zA-Z\\d]+)" + s[0] + "([^a-zA-Z\\d]+)");
                solange(muster.abgleicher(str).finde(0)) {
                    str = muster.abgleicher(str).ersetzeErstes("$1" + s[1] + "$2");
                    wenn(s[2].gleicht("unterbrechen")) {
                        unterbrechen;
                    }
                }
            }
            System.ausgabe.druckeZeile(str);
        }
    }

If you have any improvements on the code or the translation, let me know and I see if I can implement them.

GiantTree

Posted 2015-06-01T04:47:11.993

Reputation: 885

/, and - are probably not good in identifiers. – Vi. – 2015-06-01T17:15:09.640

6I love the correspondence between the two languages--both of them use humongous compound words for everything. ;) But I do suspect the Germans would still abbreviate Eingabe/Ausgabe somehow--maybe Einaus? – DLosc – 2015-06-01T17:15:22.387

1@DLosc I/O (Input/Output) is usually abbreviated with E/A (Eingabe/Ausgabe). Einaus would be possible, too I think but it doesn't feel right. Rein/Raus would seem possible, as well but again just doesn't feel like a good translation. – GiantTree – 2015-06-01T17:22:26.960

@Vi. you mean as characters in the string to replace (left side)? Those are not needed as Java disallows such characters to be part of a name/identifier. I think you mean because I am checking the whole string over and over and you might think that E/A or similar might cause issues, but they are not interpreted as a regular expression, they are only matched and thus leave the regular expression unaffected. (I could be wrong, but this is what I have experienced with regular expressions) – GiantTree – 2015-06-01T17:29:06.190

@GiantTree, I mean the code would be hard to parse for hypothetical German Java compiler. – Vi. – 2015-06-01T17:37:31.123

@Vi. that's absolutely correct, that's why I'm searching for improved translations. I hope I find one especially for E/A/Eingabe/Ausgabe. – GiantTree – 2015-06-01T17:44:00.023

Just "ea"? And "nio" as "nbea"? Abberviated in source language => abbreviated in destination language. – Vi. – 2015-06-01T17:46:30.993

@Vi. hmm, good idea. Actually I never thought about that, because I don't like such abbreviations but I think they make sense. I update my code with the abbreviations. – GiantTree – 2015-06-01T18:06:00.283

Why don't you suppot conjugation and declination of reserved words and identifiers? – FUZxxl – 2015-06-03T08:57:29.483

@FUZxxl depending on some of the words I think it's possible. Others are just hard to conjugate/declinate and I don't really know how to implement dynamic conjugation/declination. I will update my answer with some declinated/conjugated words, though. – GiantTree – 2015-06-03T16:25:52.603

You don't seem to conserve capitalization in some cases, Muster Muster = Muster... should be Muster muster = Muster... :) – doldt – 2015-06-05T13:14:41.587

@doldt that's correct. This will require a case sensitive regex but I think it's possible. I will update my code as soon as possible. – GiantTree – 2015-06-05T14:18:07.057

In the imports, guess you missed to add the translation for "file" -> "datei". importiere java.nbea.file.Dateisysteme; -> importiere java.nbea.datei.Dateisysteme; – pixma140 – 2019-07-23T06:22:40.400

14

Julia, Tatar - Julia

This uses the unofficial Latin-based Zamanälif alphabet for İdel-Ural Tatar, established in 2001. However, in 2002, the Russian Federation struck down Tatarstan's motion to make Zamanälif the official alphabet for the Tatar language, criminalizing the official use of any alphabet other than Cyrillic.

In the past century, there have been 5 alphabets for the Tatar language:

  • İske imlâ, a variant of the Arabic alphabet, 1870s-1920s
  • Yaña imlâ, another Arabic variant, 1920s and 30s
  • Jaᶇalif, a variant of the Latin alphabet, 1930s
  • Cyrillic, conversion mandated by Joseph Stalin, 1940s-present
  • Zamanälif, unofficial, 2001-present

I've opted for Zamanälif because I think my grandpa would be disappointed if I used Cyrillic. His first language is Tatar and and having been born in the 1920s, he learned to read and write in the iske imlâ alphabet.

English:

function translate(source)
    words = Dict([("function", "funktsiya"),
                  ("if", "ägär"),
                  ("else", "başkaça"),
                  ("elif", "başägär"),
                  ("end", "axır"),
                  ("for", "saen"),
                  ("print", "bastırırga"),
                  ("english", "ingliz"),
                  ("tatar", "tatarça"),
                  ("translate", "tärcemä"),
                  ("words", "süzlär"),
                  ("replace", "alıştıru"),
                  ("Dict", "Süzlek"),
                  ("keys", "açkıçlär"),
                  ("get", "alırga"),
                  ("readall", "ukırgaböten"),
                  ("source", "çıganak")])

    tatar = readall(source)

    for english = keys(words)
        tatar = replace(tatar, english, get(words, english, ""))
    end

    tatar
end

print(translate("tatar.jl"))

Tatar:

funktsiya tärcemä(çıganak)
    süzlär = Süzlek([("funktsiya", "funktsiya"),
                  ("ägär", "ägär"),
                  ("başkaça", "başkaça"),
                  ("başägär", "başägär"),
                  ("axır", "axır"),
                  ("saen", "saen"),
                  ("bastırırga", "bastırırga"),
                  ("ingliz", "ingliz"),
                  ("tatarça", "tatarça"),
                  ("tärcemä", "tärcemä"),
                  ("süzlär", "süzlär"),
                  ("alıştıru", "alıştıru"),
                  ("Süzlek", "Süzlek"),
                  ("açkıçlär", "açkıçlär"),
                  ("alırga", "alırga"),
                  ("ukırgaböten", "ukırgaböten"),
                  ("çıganak", "çıganak")])

    tatarça = ukırgaböten(çıganak)

    saen ingliz = açkıçlär(süzlär)
        tatarça = alıştıru(tatarça, ingliz, alırga(süzlär, ingliz, ""))
    axır

    tatarça
axır

bastırırga(tärcemä("~/tatarça.jl"))

I took a couple liberties to make the translation a little cleaner. For example, for became saen, which translates more literally to "each." I also didn't abbreviate Süzlek, which means "dictionary." ukırgaböten, my translation for readall, is ukırga (read) + böten (all/every). başägär, my translation for elseif, is baş (an abbreviation of başkaça, meaning "else/otherwise") + ägär (if).

If anyone on PPCG knows Tatar, you likely know more than I do. Any suggestions would be welcome.

Alex A.

Posted 2015-06-01T04:47:11.993

Reputation: 23 761

13

Rust, Belarusian (Ржа)

Program:

#![feature(non_ascii_idents)]

use std::io::stdin;
use std::io::Read;

static ЗАМЕНЫ: &'static [(&'static str, &'static str)] =  &[
    ("match", "супастаўленьне"),
    (" if ", " калі "),
    ("else", "інакш"),
    (" as ", " як "),
    ("panic!", "паніка!"),
    ("assert!", "праверыць!"),
    ("box ", "пак "),
    ("break", "перапыніць"),
    ("continue", "працягнуць"),
    ("fn ", "фн "),
    ("extern", "знешняе"),
    (" for ", " кожная "),
    (" in ", " ў "),
    ("impl ", " увасобіць "),
    ("let ", "хай "),
    ("loop ", "цыкл "),
    ("once", "аднойчы"),
    ("pub ", "адкр"),
    ("return", "выйсці"),
    ("super", "бацькоўскі_модуль"),
    ("unsafe ", "непяспечнае "),
    (" where", " дзе"),
    ("while", "пакуль"),
    ("use ", "вык "),
    ("mod ", "модуль "),
    ("trait ", "рыса "),
    ("struct ", "структура "),
    ("enum ", "пералік"),
    ("type ", "тып "),
    ("move ", "перанесьці"),
    ("mut ", "зьмян "),
    ("ref ", "спасыл "),
    ("static ", "статычнае "),
    ("const ", "нязменнае "),
    ("crate ", "скрыня "),
    ("Copy", "МожнаКапіяваць"),
    ("Send", "МожнаПерадаваць"),
    ("Sized", "МаеПамер"),
    ("Sync", "БяспечнаНаПатокі"),
    ("Drop", "МаеЗавяршальнік"),
    ("FnMut", "ЯкЗьмяняемаяФункцыя"),
    ("FnOnce", "ЯкАднаразоваяФункцыя"),
    ("Fn", "ЯкФункцыя"),
    ("macro_rules!", "новы_макрас!"),
    ("alignof", "выраўненьеяку"),
    ("become", "стала"),
    ("do ", "рабі"),
    ("offsetof", "пазіцыяяку"),
    ("priv", "прыватнае"),
    ("pure", "чыстае"),
    ("sizeof", "памер_ад"),
    ("typeof", "тып_ад"),
    ("unsized", "безпамеравы"),
    ("yield", "вырабіць"),
    ("abstract", "абстрактны"),
    ("virtual", "віртуальны"),
    ("final", "канчатковае"),
    ("override", "перавызначыць"),
    ("macro", "макрас"),
    ("Box", "Каробка"),
    ("ToOwned", "МожнаНабыцьУладара"),
    ("Clone", "МожнаКланаваць"),
    ("PartialOrd", "МаеЧастковыПарадак"),
    ("PartialEq", "ЧастковаПараўнальны"),
    ("Eq", "Параўнальны"),
    ("Ord", "МаеПарадак"),
    ("AsRef", "МожнаЯкСпасылку"),
    ("AsMut", "МожнаЯкЗьмяняемые"),
    ("Into", "МожнаУ"),
    ("From", "МожнаЗ"),
    ("Default", "МаеЗначеньнеПаЗмаўчаньні"),
    ("Extend", "Пашырыць"),
    ("IntoIterator", "МожнаУПаўторнік"),
    ("DoubleEndedIterator", "ДвубаковыПаўторнік"),
    ("ExactSizeIterator", "ПаўторнікЗДакладнымПамерам"),
    ("Iterator", "Паўторнік"),
    ("Option", "Недакладна"),
    ("Some", "Ёсць"),
    ("None", "Нічога"),
    ("Result", "Вынік"),
    ("Ok", "Ок"),
    ("Err", "Збой"),
    ("SliceConcatExt", "АбянднальнікЛустаў"),
    ("ToString", "УРадок"),
    ("String", "Радок"),
    ("Vec", "Вэктар"),
    ("vec!", "вэкрар!"),
    ("self", "сам"),
    ("true", "так"),
    ("false", "не"),
    ("feature", "магчымасьць"),

    ("main", "галоўная"),
    ("replace", "замяніць"),
    ("iter","пераліч"),
    ("print!","друк!"),
    ("println!","друкрад!"),
    ("stdin","звыч_уваход"),
    ("stdout","звыч_выхад"),
    ("stderr","звыч_павед"),
    ("Read", "Чытальнік"),
    ("Write", "Пісальнік"),
    ("read_to_string", "чытаць_у_радок"),
    ("to_string", "у_радок"),
    ("std", "стд"),
    ("io", "ув"),
    ("non_ascii_idents", "ідентыфікатары_з_юнікоду"),

    ("str", "радок"),
];


fn main() {
    let mut зьмест : String = "".to_string();
    match stdin().read_to_string(&mut зьмест) {
        Ok(_) => (),
        Err(памылка) => panic!(памылка),
    }
    for замена in ЗАМЕНЫ.iter() {
        зьмест = зьмест.replace(замена.0, замена.1);
    }
    println!("{}", зьмест);
}

Output:

#![магчымасьць(ідентыфікатары_з_юнікоду)]

вык стд::ув::звыч_уваход;
вык стд::ув::Чытальнік;

статычнае ЗАМЕНЫ: &'статычнае [(&'статычнае радок, &'статычнае радок)] =  &[
    ("супастаўленьне", "супастаўленьне"),
    (" калі ", " калі "),
    ("інакш", "інакш"),
    (" як ", " як "),
    ("паніка!", "паніка!"),
    ("праверыць!", "праверыць!"),
    ("пак ", "пак "),
    ("перапыніць", "перапыніць"),
    ("працягнуць", "працягнуць"),
    ("фн ", "фн "),
    ("знешняе", "знешняе"),
    (" кожная ", " кожная "),
    (" ў ", " ў "),
    (" увасобіць ", " увасобіць "),
    ("хай ", "хай "),
    ("цыкл ", "цыкл "),
    ("аднойчы", "аднойчы"),
    ("адкр", "адкр"),
    ("выйсці", "выйсці"),
    ("бацькоўскі_модуль", "бацькоўскі_модуль"),
    ("непяспечнае ", "непяспечнае "),
    (" дзе", " дзе"),
    ("пакуль", "пакуль"),
    ("вык ", "вык "),
    ("модуль ", "модуль "),
    ("рыса ", "рыса "),
    ("структура ", "структура "),
    ("пералік", "пералік"),
    ("тып ", "тып "),
    ("перанесьці", "перанесьці"),
    ("зьмян ", "зьмян "),
    ("спасыл ", "спасыл "),
    ("статычнае ", "статычнае "),
    ("нязменнае ", "нязменнае "),
    ("скрыня ", "скрыня "),
    ("МожнаКапіяваць", "МожнаКапіяваць"),
    ("МожнаПерадаваць", "МожнаПерадаваць"),
    ("МаеПамер", "МаеПамер"),
    ("БяспечнаНаПатокі", "БяспечнаНаПатокі"),
    ("МаеЗавяршальнік", "МаеЗавяршальнік"),
    ("ЯкЗьмяняемаяФункцыя", "ЯкЗьмяняемаяФункцыя"),
    ("ЯкАднаразоваяФункцыя", "ЯкАднаразоваяФункцыя"),
    ("ЯкФункцыя", "ЯкФункцыя"),
    ("новы_макрас!", "новы_макрас!"),
    ("выраўненьеяку", "выраўненьеяку"),
    ("стала", "стала"),
    ("рабі", "рабі"),
    ("пазіцыяяку", "пазіцыяяку"),
    ("прыватнае", "прыватнае"),
    ("чыстае", "чыстае"),
    ("памер_ад", "памер_ад"),
    ("тып_ад", "тып_ад"),
    ("безпамеравы", "безпамеравы"),
    ("вырабіць", "вырабіць"),
    ("абстрактны", "абстрактны"),
    ("віртуальны", "віртуальны"),
    ("канчатковае", "канчатковае"),
    ("перавызначыць", "перавызначыць"),
    ("макрас", "макрас"),
    ("Каробка", "Каробка"),
    ("МожнаНабыцьУладара", "МожнаНабыцьУладара"),
    ("МожнаКланаваць", "МожнаКланаваць"),
    ("МаеЧастковыПарадак", "МаеЧастковыПарадак"),
    ("ЧастковаПараўнальны", "ЧастковаПараўнальны"),
    ("Параўнальны", "Параўнальны"),
    ("МаеПарадак", "МаеПарадак"),
    ("МожнаЯкСпасылку", "МожнаЯкСпасылку"),
    ("МожнаЯкЗьмяняемые", "МожнаЯкЗьмяняемые"),
    ("МожнаУ", "МожнаУ"),
    ("МожнаЗ", "МожнаЗ"),
    ("МаеЗначеньнеПаЗмаўчаньні", "МаеЗначеньнеПаЗмаўчаньні"),
    ("Пашырыць", "Пашырыць"),
    ("МожнаУПаўторнік", "МожнаУПаўторнік"),
    ("ДвубаковыПаўторнік", "ДвубаковыПаўторнік"),
    ("ПаўторнікЗДакладнымПамерам", "ПаўторнікЗДакладнымПамерам"),
    ("Паўторнік", "Паўторнік"),
    ("Недакладна", "Недакладна"),
    ("Ёсць", "Ёсць"),
    ("Нічога", "Нічога"),
    ("Вынік", "Вынік"),
    ("Ок", "Ок"),
    ("Збой", "Збой"),
    ("АбянднальнікЛустаў", "АбянднальнікЛустаў"),
    ("УРадок", "УРадок"),
    ("Радок", "Радок"),
    ("Вэктар", "Вэктар"),
    ("вэкрар!", "вэкрар!"),
    ("сам", "сам"),
    ("так", "так"),
    ("не", "не"),
    ("магчымасьць", "магчымасьць"),

    ("галоўная", "галоўная"),
    ("замяніць", "замяніць"),
    ("пераліч","пераліч"),
    ("друк!","друк!"),
    ("друкрад!","друкрад!"),
    ("звыч_уваход","звыч_уваход"),
    ("звыч_выхад","звыч_выхад"),
    ("звыч_павед","звыч_павед"),
    ("Чытальнік", "Чытальнік"),
    ("Пісальнік", "Пісальнік"),
    ("чытаць_у_радок", "чытаць_у_радок"),
    ("у_радок", "у_радок"),
    ("стд", "стд"),
    ("ув", "ув"),
    ("ідентыфікатары_з_юнікоду", "ідентыфікатары_з_юнікоду"),

    ("радок", "радок"),
];


фн галоўная() {
    хай зьмян зьмест : Радок = "".у_радок();
    супастаўленьне звыч_уваход().чытаць_у_радок(&зьмян зьмест) {
        Ок(_) => (),
        Збой(памылка) => паніка!(памылка),
    }
    кожная замена ў ЗАМЕНЫ.пераліч() {
        зьмест = зьмест.замяніць(замена.0, замена.1);
    }
    друкрад!("{}", зьмест);
}

Vi.

Posted 2015-06-01T04:47:11.993

Reputation: 2 644

No. – Vi. – 2015-06-01T17:07:06.280

Russian and C++? – GamrCorps – 2015-06-01T17:26:19.297

@IonLee, No. Hint: first guess was closer. – Vi. – 2015-06-01T17:31:23.900

@IonLee: The natural language is Belarusian. – Alex A. – 2015-06-01T17:32:22.467

1Rust and Belarusian? – ProgramFOX – 2015-06-01T17:47:19.093

@ProgramFOX, Correct. – Vi. – 2015-06-01T17:53:37.133

12

DogeScript, Spanish - El Código del Perro

DogeScript is interpreted to JavaScript, so any valid JS is valid DogeScript. The translation I've given here actually encompasses the entire keyword specification (plus some more to cover the words used in the program).

"English":

 trained

   very speak is prompt()

very doge is {
    'console': 'consola',
    'doge': 'perro',
    'very': 'muy',
    'concern': 'preocupación',
    'word': 'palabra',
    'much': 'mucho',
    'trained': 'entrenado',
    'with': 'con',
    'doge': 'perro',
    'very': 'muy',
    'much': 'mucho',
    'with': 'con',
    'is': 'es',
    'trained': 'entrenado',
    'such': 'tan',
    'wow': 'guau',
    'plz': 'porFavor',
    'but': 'pero',
    'maybe': 'quizás',
    'rly': 'enserio',
    'many': 'muchos',
    'so': 'tanto',
    'not': 'no',
    'and': 'y',
    'or': 'o',
    'next': 'siguiente',
    'as': 'como',
    'more': 'más',
    'less': 'menos',
    'lots': 'montones',
    'few': 'pocos',
    'bigger': 'másGrande',
    'smaller': 'menor',
    'biggerish': 'unPocoMásGrande',
    'smallerish': 'unPocoMásPequeño',
    'prompt': 'preguntar',
    'in': 'en',
    'replace': 'reemplazar',
    'new': 'nuevo',
    'RegExp': 'ExpReg',
    'loge': 'registro',
    'dose': 'punta',
    'speak': 'habla'
}

much very word in doge
         very concern is new RegExp with word 'g'
 doge is speak dose replace with concern doge[word]
      wow

console dose loge with speak

Spanish:

 entrenado

   muy habla es preguntar()

muy perro es {...}

mucho muy palabra en perro
         muy preocupación es nuevo ExpReg con palabra 'g'
 perro es habla punta reemplazar con preocupación perro[palabra]
      guau

consola punta registro con habla

You may notice that I've taken a few liberties in the translation. This is partially because my Spanish is rather poor and partially because my knowledge of Spanish language memes is lacking.

enter image description here

Alex A.

Posted 2015-06-01T04:47:11.993

Reputation: 23 761

11

C#, Latin - C Acutus

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ToLatin
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> dx = new Dictionary<string, string>();
            dx.Add("using", "usura");
            dx.Add("System", "Ratio");
            dx.Add("Collections", "Comprensio");
            dx.Add("Text", "Scriptum");
            dx.Add("txt", "scrptm");
            dx.Add("output", "scribo");
            dx.Add("namespace", "nomenspatium");
            dx.Add("class", "classis");
            dx.Add("Program", "Libellus");
            dx.Add("static", "immotus");
            dx.Add("void", "inane");
            dx.Add("Main", "Paelagus");
            dx.Add("string", "chorda");
            dx.Add("args", "argumenta");
            dx.Add("Dictionary", "Lexicon");
            dx.Add("new", "novus");
            dx.Add("Add", "Adaugeo");
            dx.Add("IO", "LecticoScribo");
            dx.Add("abstract", "abstracto");
            dx.Add("break", "confractus");
            dx.Add("Math", "Mathematica");
            dx.Add("File", "Ordo");
            dx.Add("file", "ordo");
            dx.Add("foreach", "prosingulus");
            dx.Add("Read", "Lectico");
            dx.Add("Write", "Scribo");
            dx.Add("All", "Omnes");
            dx.Add("translation", "interpretatio");
            dx.Add("bool", "verumfalsus");
            dx.Add("true", "verum");
            dx.Add("false", "falsus");
            dx.Add("0", "nil");
            dx.Add("||", "aut");
            dx.Add("&&", "et");
            dx.Add("Key", "Clavis");
            dx.Add("Value", "Pretium");
            dx.Add("Replace", "Restituo");
            dx.Add("Generic", "Ordinarius");
            dx.Add("ToLatin", "AdLatinam");
            string file = File.ReadAllText(args[0]);
            foreach (var translation in dx )
            {
                file = file.Replace(translation.Key, translation.Value);
            }
            File.WriteAllText("output.txt", file);
        }
    }
}

Reads file from command-line args, writes to output.txt.

Example:

usura Ratio;
usura Ratio.Comprensio.Ordinarius;
usura Ratio.Scriptum;
usura Ratio.LecticoScribo;

nomenspatium AdLatinam
{
    classis Libellus
    {
        immotus inane Paelagus(chorda[] argumenta)
        {
            Lexicon<chorda, chorda> dx = novus Lexicon<chorda, chorda>();
            dx.Adaugeo("usura", "usura");
            dx.Adaugeo("Ratio", "Ratio");
            dx.Adaugeo("Comprensio", "Comprensio");
            dx.Adaugeo("Scriptum", "Scriptum");
            dx.Adaugeo("scrptm", "scrptm");
            dx.Adaugeo("scribo", "scribo");
            dx.Adaugeo("nomenspatium", "nomenspatium");
            dx.Adaugeo("classis", "classisis");
            dx.Adaugeo("Libellus", "Libellus");
            dx.Adaugeo("immotus", "immotus");
            dx.Adaugeo("inane", "inane");
            dx.Adaugeo("Paelagus", "Paelagus");
            dx.Adaugeo("chorda", "chorda");
            dx.Adaugeo("argumenta", "argumenta");
            dx.Adaugeo("Lexicon", "Lexicon");
            dx.Adaugeo("novus", "novus");
            dx.Adaugeo("Adaugeo", "Adaugeo");
            dx.Adaugeo("LecticoScribo", "LecticoScribo");
            dx.Adaugeo("abstracto", "abstractoo");
            dx.Adaugeo("confractus", "confractus");
            dx.Adaugeo("Mathematica", "Mathematicaematica");
            dx.Adaugeo("Ordo", "Ordo");
            dx.Adaugeo("ordo", "ordo");
            dx.Adaugeo("prosingulus", "prosingulus");
            dx.Adaugeo("Lectico", "Lectico");
            dx.Adaugeo("Scribo", "Scribo");
            dx.Adaugeo("Omnes", "Omnes");
            dx.Adaugeo("interpretatio", "interpretatio");
            dx.Adaugeo("verumfalsus", "verumfalsus");
            dx.Adaugeo("verum", "verum");
            dx.Adaugeo("falsus", "falsus");
            dx.Adaugeo("nil", "nil");
            dx.Adaugeo("aut", "aut");
            dx.Adaugeo("et", "et");
            dx.Adaugeo("Clavis", "Clavis");
            dx.Adaugeo("Pretium", "Pretium");
            dx.Adaugeo("Restituo", "Restituo");
            dx.Adaugeo("Ordinarius", "Ordinarius");
            dx.Adaugeo("ToLatin", "AdLatinam");
            chorda ordo = Ordo.LecticoOmnesScriptum(argumenta[nil]);
            prosingulus (var interpretatio in dx )
            {
                ordo = ordo.Restituo(interpretatio.Clavis, interpretatio.Pretium);
            }
            Ordo.ScriboOmnesScriptum("scribo.scrptm", ordo);
        }
    }
}

Darn, just saw the C++ Latin version..

Kade

Posted 2015-06-01T04:47:11.993

Reputation: 7 463

s/ToLatin/AdLatinam/... also, shouldn't args be argumenta (neuter plural)? – DLosc – 2015-06-01T17:07:40.017

@DLosc I don't know if it should, I don't know Latin, but I'll take your word for it. – Kade – 2015-06-01T17:28:00.317

Good stuff, I'm comparing our translations for common terms. "or" should be "aut". – Luke – 2015-06-01T20:16:58.340

Why is System Ratio in Latin? Then what's ratio in Latin? – phuclv – 2015-06-05T08:57:49.920

@LưuVĩnhPhúc ratio -> ratione/proportio – Kade – 2015-06-05T20:26:52.067

8

HTML5/ Javascript to French (HTML5 avec le Script au Caoua)

<script>
    var a=document.currentScript.outerHTML;
    alert(a.replace(/var a/g,"la variable «a»")
    .replace(/alert\(/g,"alerter(")
    .replace(/=/g," est ")
    .replace(/outerHTML/g,"HTMLExtérieur")
    .replace(/\.replace\((.+)\,(.+)\)/g," avec $1 remplacé par $2")
    .replace(/\/\*and\*\//g," et")
    .replace(/"(.+?)"/g,"«$1»")
    /*and*/.replace(/currentScript/g,"scriptCourant")
    );
</script>

Output:

<script>
    la variable «a» est document.scriptCourant.HTMLExtérieur;
    alerter(a avec /la variable «a»/g remplacé par «la variable «a»»
     avec /alert\(/g remplacé par «alerter(»
     avec / est /g remplacé par « est »
     avec /HTMLExtérieur/g remplacé par «HTMLExtérieur»
     avec /\.replace\((.+)\,(.+)\)/g remplacé par « avec $1 remplacé par $2»
     avec /\/\*and\*\//g remplacé par « et»
     avec /«(.+?)»/g remplacé par ««$1»»
     et avec /scriptCourant/g remplacé par «scriptCourant»
    );
</script>

SuperJedi224

Posted 2015-06-01T04:47:11.993

Reputation: 11 342

1

I really like how you've reworked the syntax to be more French! But doesn't the French language name actually signify "CoffeeScript"?

– DLosc – 2015-06-02T16:51:40.873

Technically, yes. But that's the best I could think of at the time. Do you have a better suggestion? – SuperJedi224 – 2015-06-02T19:40:28.787

Well, "Java" originally refers to an island, so maybe "Café de Java"? It's pretty wordy, though. I don't know if just "Java" can be used in French to refer to the coffee. – DLosc – 2015-06-02T22:11:06.157

Sure, I'll go with that. – SuperJedi224 – 2015-06-03T01:45:32.887

1

"HTML5 avec le Script au Café de Java" is hilarious :D We have a similar (related ?) argotic word for "coffee" : caoua ("ka-wa").

– Quentin – 2015-06-03T09:00:23.563

3I love the use of guillemets. – TRiG – 2015-06-04T12:01:25.107

1It should be la variable, not le – Léo Lam – 2015-06-04T14:15:52.843

I'm not sure it should be corrected (approximative wording makes it funny), but ".replace <sth> with <sth>" becomes "avec <sth> remplacé par <sth>". – Quentin – 2015-06-06T12:09:54.403

8

JavaScript, French – CauoaScript

var input = prompt('Enter code');

var translations = {
  'alert': 'informe',
  'code': 'le code',
  'else': 'sinon',
  'Enter': 'Entrez',
  'if': 'si',
  'input': 'donnée',
  'function': 'fonction',
  'output': 'résultat',
  'prompt': 'soulève',
  'replace': 'remplace',
  'replacement': 'pièceDeReplacement',
  'return': 'remet',
  'translate': 'traduit',
  'translations': 'traductions',
  'typeof': 'typede',
  'undefined': 'indéterminé',
  'var': 'var',
  'w': 'm', // word
  'word': 'mot'
};

var output = input.replace(/(["'])(.*?[^\\])?\1/g, '« $2 »')
.replace(/\w+/g, function(word) {
  var replacement = translations[word];
  if (typeof replacement != 'undefined') {
    return replacement;
  } else {
    return word;
  }
});

alert(output);

I know there is already a JavaScript + French answer, but mine uses different translations and coding methods.

The code is quite straightforward: it iterates through all words in the input code, and replaces them with their corresponding French word from the translations object. If the word is not listed, it is not changed.

French uses « Guillemets » instead of quotation marks, so it first makes strings uses those. (Yes, it uses regu͘͜l̴͝a͘͜͠r͏͏ ̶̸͢e̵͜x̸͝pr̵͞͞e͘͘s̵ś̸̷i͝o̴ns̴͜ to parse strings, so it doesn't always work perfectly.) Here is the output when run on itself:

var donnée = soulève(« Entrez le code »);

var traductions = {
  « informe »: « informe »,
  « le code »: « le le code »,
  ...
  « mot »: « mot »
};

var résultat = donnée.remplace(/(["« ])(.*?[^\\])?\1/g,  »« $2 »')
.remplace(/\m+/g, fonction(mot) {
  var pièceDeReplacement = traductions[mot];
  si (typede pièceDeReplacement != « indéterminé ») {
    remet pièceDeReplacement;
  } sinon {
    remet mot;
  }
});

informe(résultat);

You can use the Stack Snippet below to easily run the code.

// CaouaScript
var translate = function(input) {
  var input = document.getElementById('input').value;

  var translations = {
    'alert': 'informe',
    'code': 'le code',
    'else': 'sinon',
    'Enter': 'Entrez',
    'if': 'si',
    'input': 'donnée',
    'function': 'fonction',
    'output': 'résultat',
    'prompt': 'soulève',
    'replace': 'remplace',
    'replacement': 'pièceDeReplacement',
    'return': 'remet',
    'translate': 'traduit',
    'translations': 'traductions',
    'typeof': 'typede',
    'undefined': 'indéterminé',
    'var': 'var',
    'w': 'm', // word
    'word': 'mot'
  };
  
  var output = input.replace(/(["'])(.*?[^\\])?\1/g, '« $2 »')
  .replace(/\w+/g, function(word) {
    var replacement = translations[word];
    if (typeof replacement != 'undefined') {
      return replacement;
    } else {
      return word;
    }
  });

  return output;
}

document.getElementById('go').onclick = function(){
  var input = document.getElementById('input').value;
  var output = translate(input);
  document.getElementById('output').innerHTML = output;
};
<textarea id="input" rows="20" cols="70">
var input = prompt('Enter code');

var translations = {
  'alert': 'informe',
  'code': 'le code',
  'else': 'sinon',
  'Enter': 'Entrez',
  'if': 'si',
  'input': 'donnée',
  'function': 'fonction',
  'output': 'résultat',
  'prompt': 'soulève',
  'replace': 'remplace',
  'replacement': 'pièceDeReplacement',
  'return': 'remet',
  'translate': 'traduit',
  'translations': 'traductions',
  'typeof': 'typede',
  'undefined': 'indéterminé',
  'var': 'var',
  'w': 'm', // word
  'word': 'mot'
};

var output = input.replace(/(["'])(.*?[^\\])?\1/g, '« $2 »')
.replace(/\w+/g, function(word) {
  var replacement = translations[word];
  if (typeof replacement != 'undefined') {
    return replacement;
  } else {
    return word;
  }
});

alert(output);</textarea>
<button id="go">Go</button>
<pre><samp id="output"></samp></pre>

NinjaBearMonkey

Posted 2015-06-01T04:47:11.993

Reputation: 9 925

3Oui, tres bien. – Alex A. – 2015-06-02T14:26:17.813

You should add spaces after punctuation - it looks nicer XD – Conor O'Brien – 2015-12-03T22:51:35.297

8

Ruby, Japanese - AkaDama

Ruby in Japanese is rubii (ルビー), which is boring, so I named it literally red gem.

In ruby, variables and methods are not restricted to ASCII, so something like

def フロートの文字化(フロート)
    甲 = フロート.to_s.split(?.)
    甲[0] = 整数の文字化(甲[0])
    甲[1] = 甲[1].chars.map{|乙|R数字行列[乙]}.join
    甲.join(?点)
end

is valid ruby. I'm using this as much as possible for obfuscation for all your bases.

I hope it's okay to use the gems for parsing ruby, it still required some ugly monkey-patching.

You can expand on the TRANS_TABLE to add translation for more methods. Everything that's not in the table is "translated" into Japanese loosely based upon its pronunciation (or more like spelling), so eat becomes えあと ("a-ah-toe").

Converts integers to a "very" practical notation.

# encoding:utf-8

require 'parser/current'

# super hack, don't try this at home!!
class Array
    def freeze
        self
    end
end
class Hash
    def freeze
        self
    end
end
class Parser::AST::Node
    def freeze
        self
    end
end
require 'unparser'
class Parser::Source::Comment
    def freeze
        self
    end
end

# translation memory
R翻訳メモリー = {}

# keyword translation
R鍵文字 = {
    :BEGIN => [:K_PREEXE, :"コンパイル時に最初に登録"],
    :END => [:K_POSTEXE, :"コンパイル時に最後に登録"],
    :__ENCODING__ => [:K_ENCODING, :"__エンコーディング__"],
    :__END__ => [:K_EEND, :"__終__"],
    :__FILE__ => [:K_FILE, :"__ソースファイル名__"],
    :alias => [:K_ALIAS, :"別名"],
    :and => [:K_AND, :"且つ"],
    :begin => [:K_BEGIN, :"開始"],
    :break => [:K_BREAK, :"抜ける"],
    :case => [:K_CASE, :"条件分岐"],
    :class => [:K_CLASS, :"クラス"],
    :def => [:K_DEF, :"定義"],
    :define => [:K_DEFINE, :""],
    :defined? => [:K_DEFINED, :"若し定義されたら"],
    :do => [:K_DO, :"実行"],
    :else => [:K_ELSE, :"違えば"],
    :elsif => [:K_ELSIF, :"それとも"],
    :end => [:K_END, :"此処迄"],
    :ensure => [:K_ENSURE, :"必ず実行"],
    :false => [:K_FALSE, :"偽"],
    :for => [:K_FOR, :"変数"],
    :if => [:K_IF, :"若し"],
    :in => [:K_IN, :"の次の値ごとに"],
    :module => [:K_MODULE, :"モジュール"],
    :next => [:K_NEXT, :"次"],
    :nil => [:K_NIL, :"無"],
    :not => [:K_NOT, :"ノット"],
    :or => [:K_OR, :"又は"],
    :redo => [:K_REDO, :"遣り直す"],
    :rescue => [:K_RESCUE, :"救出"],
    :retry => [:K_RETRY, :"再び試みる"],
    :return => [:K_RETURN, :"戻る"],
    :self => [:K_SELF, :"自身"],
    :super => [:K_SUPER, :"スーパー"],
    :then => [:K_THEN, :"成らば"],
    :true => [:K_TRUE, :"真"],
    :undef => [:K_UNDEF, :"定義を取消す"],
    :unless => [:K_UNLESS, :"若し違えば"],
    :until => [:K_UNTIL, :"次の通りである限り"],
    :when => [:K_WHEN, :"場合"],
    :while => [:K_WHILE, :"次の通りで無い限り"],
    :yield => [:K_YIELD, :"ブロックを呼び出す"],
}

R数字行列 = {
"0" => "零",
"1" => "壹",
"2" => "貮",
"3" => "參",
"4" => "肆",
"5" => "伍",
"6" => "陸",
"7" => "漆",
"8" => "捌",
"9" => "玖",
}

R翻訳行列 = {
# Symbols
:+ => :+,
:- => :-,
:/ => :/,
:* => :*,
:** => :**,
:! => :!,
:^ => :^,
:& => :&,
:| => :|,
:~ => :~,
:> => :>,
:< => :<,
:<< => :<<,
:% => :%,
:"!=" => :"!=",
:"=~" => :"=~",
:"~=" => :"~=",
:">=" => :">=",
:"<=" => :"<=",
:"=" => :"=",
:"==" => :"==",
:"===" => :"===",
:"<=>" => :"<=>",
:"[]" => :"[]",
:"[]=" => :"[]=",
:"!~" => :"!~",
# Errors
:ArgumentError => :引数エラー,
:EncodingError => :文字コードエラー,
:FiberError => :ファイバーエラー,
:IOError => :入出エラー,
:IndexError => :添字エラー,
:LoadError => :読込エラー,
:LocalJumpError => :エラー,
:NameError => :未定義エラー,
:NoMemoryError => :メモリー不足エラー,
:NotImplementedError => :未実装エラー,
:RangeError => :範囲エラー,
:RegexpError => :正規表現エラー,
:RuntimeError => :実行時エラー,
:ScriptError => :スクリプトエラー,
:SecurityError => :セキュリティエラー,
:StandardError => :通常エラー,
:SyntaxError => :シンタクスエラー,
:ThreadError => :スレッドエラー,
:TypeError => :タイプエラー,
:ZeroDivisionError => :零除算エラー,
# Constants
:Array => :配列,
:BasicObject => :基本オブジェクト,
:Bignum => :多倍長整数,
:Class => :クラス,
:Complex => :複素数,
:Exception => :例外,
:FalseClass => :偽クラス,
:File => :ファイル,
:Fiber => :ファイバー,
:Fixnum => :固定長整数,
:Float => :浮動小数点数,
:Hash => :ハッシュ表,
:Integer => :整数,
:IO => :入出,
:Kernel => :中核,
:Marshal => :元帥,
:Math => :数学,
:Module => :モジュール,
:NilClass => :無クラス,
:Numeric => :数値,
:Object => :オブジェクト,
:Prime => :素数,
:Proc => :プロック,
:Process => :プロセス,
:Random => :乱数,
:Range => :範囲,
:Rational => :有理数,
:Regexp => :正規表現,
:Set => :集合,
:Socket => :ソケット,
:String => :文字列,
:Symbol => :シンボル,
:Time => :時刻,
:Thread => :スレッド,
:TrueClass => :真クラス,
# Kernel
:inspect => :検査,
:p => :表示,
:print => :書く,
:puts => :言う,
:require => :取り込む,
# Object
:freeze => :凍結,
# String
:gsub => :全文字列置換,
:gsub! => :全文字列置換せよ,
}


INT_TABLE = [
    [7, "倶胝"],
    [14, "阿庾多"],
    [28, "那由他"],
    [56, "頻波羅"],
    [112, "矜羯羅"],
    [224, "阿伽羅"],
    [448, "最勝"],
    [896, "摩婆羅"],
    [1792, "阿婆羅"],
    [3584, "多婆羅"],
    [7168, "界分"],
    [14336, "普摩"],
    [28672, "禰摩"],
    [57344, "阿婆鈐"],
    [114688, "弥伽婆"],
    [229376, "毘攞伽"],
    [458752, "毘伽婆"],
    [917504, "僧羯邏摩"],
    [1835008, "毘薩羅"],
    [3670016, "毘贍婆"],
    [7340032, "毘盛伽"],
    [14680064, "毘素陀"],
    [29360128, "毘婆訶"],
    [58720256, "毘薄底"],
    [117440512, "毘佉擔"],
    [234881024, "称量"],
    [469762048, "一持"],
    [939524096, "異路"],
    [1879048192, "顛倒"],
    [3758096384, "三末耶"],
    [7516192768, "毘睹羅"],
    [15032385536, "奚婆羅"],
    [30064771072, "伺察"],
    [60129542144, "周広"],
    [120259084288, "高出"],
    [240518168576, "最妙"],
    [481036337152, "泥羅婆"],
    [962072674304, "訶理婆"],
    [1924145348608, "一動"],
    [3848290697216, "訶理蒲"],
    [7696581394432, "訶理三"],
    [15393162788864, "奚魯伽"],
    [30786325577728, "達攞歩陀"],
    [61572651155456, "訶魯那"],
    [123145302310912, "摩魯陀"],
    [246290604621824, "懺慕陀"],
    [492581209243648, "瑿攞陀"],
    [985162418487296, "摩魯摩"],
    [1970324836974592, "調伏"],
    [3940649673949184, "離憍慢"],
    [7881299347898368, "不動"],
    [15762598695796736, "極量"],
    [31525197391593472, "阿麼怛羅"],
    [63050394783186944, "勃麼怛羅"],
    [126100789566373888, "伽麼怛羅"],
    [252201579132747776, "那麼怛羅"],
    [504403158265495552, "奚麼怛羅"],
    [1008806316530991104, "鞞麼怛羅"],
    [2017612633061982208, "鉢羅麼怛羅"],
    [4035225266123964416, "尸婆麼怛羅"],
    [8070450532247928832, "翳羅"],
    [16140901064495857664, "薜羅"],
    [32281802128991715328, "諦羅"],
    [64563604257983430656, "偈羅"],
    [129127208515966861312, "窣歩羅"],
    [258254417031933722624, "泥羅"],
    [516508834063867445248, "計羅"],
    [1033017668127734890496, "細羅"],
    [2066035336255469780992, "睥羅"],
    [4132070672510939561984, "謎羅"],
    [8264141345021879123968, "娑攞荼"],
    [16528282690043758247936, "謎魯陀"],
    [33056565380087516495872, "契魯陀"],
    [66113130760175032991744, "摩睹羅"],
    [132226261520350065983488, "娑母羅"],
    [264452523040700131966976, "阿野娑"],
    [528905046081400263933952, "迦麼羅"],
    [1057810092162800527867904, "摩伽婆"],
    [2115620184325601055735808, "阿怛羅"],
    [4231240368651202111471616, "醯魯耶"],
    [8462480737302404222943232, "薜魯婆"],
    [16924961474604808445886464, "羯羅波"],
    [33849922949209616891772928, "訶婆婆"],
    [67699845898419233783545856, "毘婆羅"],
    [135399691796838467567091712, "那婆羅"],
    [270799383593676935134183424, "摩攞羅"],
    [541598767187353870268366848, "娑婆羅"],
    [1083197534374707740536733696, "迷攞普"],
    [2166395068749415481073467392, "者麼羅"],
    [4332790137498830962146934784, "駄麼羅"],
    [8665580274997661924293869568, "鉢攞麼陀"],
    [17331160549995323848587739136, "毘迦摩"],
    [34662321099990647697175478272, "烏波跋多"],
    [69324642199981295394350956544, "演説"],
    [138649284399962590788701913088, "無尽"],
    [277298568799925181577403826176, "出生"],
    [554597137599850363154807652352, "無我"],
    [1109194275199700726309615304704, "阿畔多"],
    [2218388550399401452619230609408, "青蓮華"],
    [4436777100798802905238461218816, "鉢頭摩"],
    [8873554201597605810476922437632, "僧祇"],
    [17747108403195211620953844875264, "趣"],
    [35494216806390423241907689750528, "至"],
    [70988433612780846483815379501056, "阿僧祇"],
    [141976867225561692967630759002112, "阿僧祇転"],
    [283953734451123385935261518004224, "無量"],
    [567907468902246771870523036008448, "無量転"],
    [1135814937804493543741046072016896, "無辺"],
    [2271629875608987087482092144033792, "無辺転"],
    [4543259751217974174964184288067584, "無等"],
    [9086519502435948349928368576135168, "無等転"],
    [18173039004871896699856737152270336, "不可数"],
    [36346078009743793399713474304540672, "不可数転"],
    [72692156019487586799426948609081344, "不可称"],
    [145384312038975173598853897218162688, "不可称転"],
    [290768624077950347197707794436325376, "不可思"],
    [581537248155900694395415588872650752, "不可思転"],
    [1163074496311801388790831177745301504, "不可量"],
    [2326148992623602777581662355490603008, "不可量転"],
    [4652297985247205555163324710981206016, "不可説"],
    [9304595970494411110326649421962412032, "不可説転"],
    [18609191940988822220653298843924824064, "不可説不可説"],
    [37218383881977644441306597687849648128, "不可説不可説転"],
].reverse

Rしヴぁう = {
    :b => :u,
    :c => :u,
    :d => :o,
    :f => :u,
    :g => :u,
    :h => :u,
    :j => :u,
    :k => :u,
    :l => :u,
    :m => :u,
    :n => :u,
    :p => :u,
    :q => :u,
    :r => :u,
    :s => :u,
    :t => :o,
    :v => :u,
    :w => :u,
    :x => :u,
    :y => :u,
    :z => :u,
}

R平 = {
    :a  => :あ, :i  => :い, :u  => :う, :e  => :え, :o  => :お,
    :ba => :ば, :bi => :び, :bu => :ぶ, :be => :べ, :bo => :ぼ,
    :ca => :か, :ci => :き, :cu => :く, :ce => :け, :co => :こ,
    :da => :だ, :di => :どぃ, :du => :どぅ, :de => :で, :do => :ど,
    :fa => :ふぁ, :fi => :ふぃ, :fu => :ふ, :fe => :ふぇ, :fo => :ふぉ,
    :ga => :が, :gi => :ぎ, :gu => :ぐ, :ge => :げ, :go => :ご,
    :ha => :は, :hi => :ひ, :hu => :ふ, :he => :へ, :ho => :ほ,
    :ja => :じぁ, :ji => :じ, :ju => :じぅ, :je => :じぇ, :jo => :じぉ,
    :ka => :か, :ki => :き, :ku => :く, :ke => :け, :ko => :こ,
    :la => :ら, :li => :り, :lu => :る, :le => :れ, :lo => :ろ,
    :ma => :ま, :mi => :み, :mu => :む, :me => :め, :mo => :も,
    :na => :な, :ni => :に, :nu => :ぬ, :ne => :ね, :no => :の,
    :pa => :ぱ, :pi => :ぴ, :pu => :ぷ, :pe => :ぺ, :po => :ぽ,
    :qa => :か, :qi => :き, :qu => :く, :qe => :け, :qo => :こ,
    :ra => :ら, :ri => :り, :ru => :る, :re => :れ, :ro => :ろ,
    :sa => :さ, :si => :すぃ, :su => :す, :se => :せ, :so => :そ,
    :ta => :た, :ti => :てぃ, :tu => :とぅ, :te => :て, :to => :と,
    :va => :ヴぁ, :vi => :ヴぃ, :vu => :ヴぅ, :ve => :ヴぇ, :vo => :ヴぉ,
    :wa => :わ, :wi => :ゐ, :wu => :ゐぅ, :we => :ゑ, :wo => :を,
    :xa => :くさ, :xi => :くすぃ, :xu => :くす, :xe => :くせ, :xo => :くそ,
    :ya => :いぁ, :yi => :いぃ, :yu => :いぅ, :ye => :いぇ, :yo => :いぉ,
    :za => :ざ, :zi => :ずぃ, :zu => :ず, :ze => :ぜ, :zo => :ぞ,
}

R片 = {
:が => :ガ,:ぎ => :ギ,:ぐ => :グ,:げ => :ゲ,:ご => :ゴ,
:ざ => :ザ,:じ => :ジ,:ず => :ズ,:ぜ => :ゼ,:ぞ => :ゾ,
:だ => :ダ,:ぢ => :ヂ,:づ => :ヅ,:で => :デ,:ど => :ド,
:ば => :バ,:び => :ビ,:ぶ => :ブ,:べ => :ベ,:ぼ => :ボ,
:ぱ => :パ,:ぴ => :ピ,:ぷ => :プ,:ぺ => :ペ,:ぽ => :ポ,
:あ => :ア,:い => :イ,:う => :ウ,:え => :エ,:お => :オ,
:か => :カ,:き => :キ,:く => :ク,:け => :ケ,:こ => :コ,
:さ => :サ,:し => :シ,:す => :ス,:せ => :セ,:そ => :ソ,
:た => :タ,:ち => :チ,:つ => :ツ,:て => :テ,:と => :ト,
:な => :ナ,:に => :ニ,:ぬ => :ヌ,:ね => :ネ,:の => :ノ,
:は => :ハ,:ひ => :ヒ,:ふ => :フ,:へ => :ヘ,:ほ => :ホ,
:ま => :マ,:み => :ミ,:む => :ム,:め => :メ,:も => :モ,
:ら => :ラ,:り => :リ,:る => :ル,:れ => :レ,:ろ => :ロ,
:わ => :ワ,:を => :ヲ,:ゑ => :ヱ,:ゐ => :ヰ,:ヴ => :ヴ,
:ぁ => :ァ,:ぃ => :ィ,:ぅ => :ゥ,:ぇ => :ェ,:ぉ => :ォ,
:ゃ => :ャ,:ゅ => :ュ,:ょ => :ョ,
:や => :ヤ,:ゆ => :ユ,:よ => :ヨ,
:ん => :ン,:っ => :ッ,:ゎ => :ヮ,
}


def 鍵文字を登録
    R鍵文字.each_pair do |甲,乙|
        Unparser::Constants.const_set 乙[0], 乙[1].to_s
        Unparser::Emitter::REGISTRY[乙[1].to_sym] = Unparser::Emitter::REGISTRY[甲.to_sym]
    end
    Unparser::Emitter::Repetition::MAP[:while] = R鍵文字[:while][1].to_s
    Unparser::Emitter::Repetition::MAP[:until] = R鍵文字[:until][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:return] = R鍵文字[:return][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:next] = R鍵文字[:next][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:break] = R鍵文字[:break][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:or] = R鍵文字[:or][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:and] = R鍵文字[:and][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:BEGIN] = R鍵文字[:BEGIN][1].to_s
    Unparser::Emitter::FlowModifier::MAP[:END] = R鍵文字[:END][1].to_s
end

class Float
    def inspect
        フロートの文字化(self)
    end
end
class BigDecimal
    def inspect
        フロートの文字化(self.to_s('F'))
    end
end
class Integer
    def inspect
        整数の文字化(self)
    end
end
class Fixnum
    def inspect
        整数の文字化(self)
    end
end
class Bignum
    def inspect
        整数の文字化(self)
    end
end

def 整数の文字化(整数)
    数字 = 整数.to_s
    if 数字.size <= 7
        return 数字.chars.map{|甲|R数字行列[甲]}.join
    else
        乙 = INT_TABLE.find{|甲|甲[0] < 数字.size}
        整数の文字化(数字[0...-乙[0]]) + 乙[1] +  整数の文字化(数字[(-乙[0])..-1])
    end
end
def フロートの文字化(フロート)
    甲 = フロート.to_s.split(?.)
    甲[0] = 整数の文字化(甲[0])
    甲[1] = 甲[1].chars.map{|乙|R数字行列[乙]}.join
    甲.join(?点)
end

def 文字を翻訳(文字)
    平片 = :hira
    文字.scan(/([^aeiou])?(\1)?([yj])?([aeiou])?/i).map do |子音甲,子音乙,子音丙,母音|
        母音 = 母音.to_s
        if 子音甲.nil? && 母音.empty?
            nil
        else
            平片 = :kata if (子音甲||母音).downcase!=(子音甲||母音)
            子音甲,子音乙,子音丙,母音 = [子音甲,子音乙,子音丙,母音].map{|x| x ? x.downcase : x }
            if 母音.empty?
                母音 = Rしヴぁう[子音甲.to_sym].to_s
            end
            # hu => ひゅ, qu => きゅ
            if 母音=="u" && (子音甲=="h"||子音甲=="q")
                子音丙 = "y"
            end
            # ja,ju,jo => じゃ、じゅ,じょ
            if (母音=="a"||母音=="u"||母音=="o") && 子音甲 == "j"
                子音丙 = "y"
            end
            # 拗音
            if 子音丙
                if [:a,:u,:o].include?(母音)
                    子音丙 = case 母音
                    when :a ; :ゃ
                    when :u ; :ゅ
                    when :o ; :ょ
                    end
                    母音 = :i
                else
                    子音丙 = nil
                end
            end
            # basic syllable
            仮名 = R平[(子音甲.to_s+母音).to_sym].to_s
            # 促音
            if 子音乙
                if %w[ま み む め も な に ぬ ね の].include?(子音乙)
                    仮名 = "ん" + 仮名
                else
                    仮名 = "っ" + 仮名
                end
            end
            # 拗音
            if 子音丙
                仮名 = 仮名 + 子音丙
            end
            # lowercase => hiragana, uppercase => katakana
            if 平片==:kata
                仮名 = 仮名.gsub(/./){|丁|R片[丁.to_sym]}.to_s
            end
            仮名
        end
    end.compact.join
end

def 文を翻訳(文)
    文.scan(/(([a-z]+|[0-9]+|[^a-z0-9]+))/i).map do |文字,_|
        if 文字.index(/[a-z]/i)
            文字を翻訳(文字)
        elsif 文字.index(/[0-9]/)
            整数の文字化(文字)
        else
            文字
        end
    end.compact.join
end

def 翻訳(文章=nil)
    if 文章.empty? || 文章.nil?
        文章
    else
        if 甲 = R翻訳行列[文章.to_sym]
            甲 
        elsif 甲 = R翻訳メモリー[文章]
            甲
        else   
            甲 = 文を翻訳(文章.to_s)        
            R翻訳メモリー[文章] = 甲
        end
    end
end

def ノード毎に(幹,&塊)
    if 幹.is_a? Parser::AST::Node
        子供 = 幹.children
        yield 幹.type,子供
        幹.children.each{|甲|ノード毎に(甲,&塊)}
        if 甲 = R鍵文字[幹.type] 
            幹.instance_variable_set(:@type,甲[1]) if [:self,:true,:false,:nil].include?(幹.type)
        end
    end
end

def 幹を翻訳(幹)
    ノード毎に(幹) do |類,子|
        case 類
        when :arg
            子[0] = 翻訳(子[0]).to_sym
        when :blockarg
            子[0] = 翻訳(子[0]).to_sym
        when :casgn
            子[1] = ('C_'+翻訳(子[1]).to_s).to_sym
        when :const
            子[1] = 翻訳(子[1]).to_sym
        when :def
            子[0] = 翻訳(子[0]).to_sym      
        when :int
        when :kwoptarg
            子[0] = 翻訳(子[0]).to_sym
        when :lvar
            子[0] = 翻訳(子[0]).to_sym
        when :lvasgn
            子[0] = 翻訳(子[0]).to_sym
        when :optarg
            子[0] = 翻訳(子[0]).to_sym
        when :restarg
            子[0] = 翻訳(子[0]).to_sym
        when :send
            子[1] = 翻訳(子[1]).to_sym
        when :str
            子[0] = 翻訳(子[0]).to_s
        when :sym
            子[0] = 翻訳(子[0]).to_sym
        end
    end
end

def ノートを翻訳(ノート)
    ノート.each do |子|
        テキスト = 子.text
        if テキスト[0] == '#'
            子.instance_variable_set(:@text,"#" + 翻訳(テキスト[1..-1]))
        else
            子.instance_variable_set(:@text,"=開始\n" + 翻訳(テキスト[6..-6]) + "\n=此処迄\n")
        end
    end
end

########
# main #
########

# register keywords
鍵文字を登録
# read input, translate, and print result
コード = STDIN.read
コード.encode(Encoding::UTF_8)
コード = "#encoding:utf-8\n" + コード
幹, ノート = Parser::CurrentRuby.parse_with_comments(コード)
幹を翻訳(幹)
ノートを翻訳(ノート)
STDOUT.write Unparser.unparse(幹,ノート)

Run on itself, omitting some translation tables etc:

#えぬこどぃぬぐ:うとふ-捌
# えぬこどぃぬぐ:うとふ-捌
取り込む("ぱるせる/くっれぬと")
# すぺる はくく, どぬ'と とる とひす あと ほめ!!
クラス 配列
  定義 凍結
    自身
  此処迄
此処迄
クラス ハッシュ表
  定義 凍結
    自身
  此処迄
此処迄
クラス パルセル::アスト::ノデ
  定義 凍結
    自身
  此処迄
此処迄
取り込む("うぬぱるせる")
クラス パルセル::ソウルケ::コッメヌト
  定義 凍結
    自身
  此処迄
此処迄
定義 鍵文字を登録
  ル鍵文字.えあくふ_ぱいる 実行 |甲, 乙|
    ウヌパルセル::コヌスタヌトス.こぬすと_せと(乙[零], 乙[壹].と_す)
    ウヌパルセル::エミッテル::レギストル[乙[壹].と_すむ] = ウヌパルセル::エミッテル::レギストル[甲.と_すむ]
  此処迄
  ウヌパルセル::エミッテル::レペティティオヌ::マプ[:ゐぅひれ] = ル鍵文字[:ゐぅひれ][壹].と_す
  ウヌパルセル::エミッテル::レペティティオヌ::マプ[:うぬてぃる] = ル鍵文字[:うぬてぃる][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:れとぅるぬ] = ル鍵文字[:れとぅるぬ][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:ねくすと] = ル鍵文字[:ねくすと][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:ぶれあく] = ル鍵文字[:ぶれあく][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:おる] = ル鍵文字[:おる][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:あぬど] = ル鍵文字[:あぬど][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:ベギヌ] = ル鍵文字[:ベギヌ][壹].と_す
  ウヌパルセル::エミッテル::フロヰゥモドィフィエル::マプ[:エヌド] = ル鍵文字[:エヌド][壹].と_す
此処迄
クラス 浮動小数点数
  定義 検査
    フロートの文字化(自身)
  此処迄
此処迄
クラス ビグデキマル
  定義 検査
    フロートの文字化(自身.と_す("フ"))
  此処迄
此処迄
クラス 整数
  定義 検査
    整数の文字化(自身)
  此処迄
此処迄
クラス 固定長整数
  定義 検査
    整数の文字化(自身)
  此処迄
此処迄
クラス 多倍長整数
  定義 検査
    整数の文字化(自身)
  此処迄
此処迄
定義 整数の文字化(整数)
  数字 = 整数.と_す
  若し (数字.すぃぜ <= 漆)
    戻る 数字.くはるす.まぷ 実行 |甲|
      ル数字行列[甲]
    此処迄.じぉいぬ
  違えば
    乙 = イヌト_タブレ.ふぃぬど 実行 |甲|
      甲[零] < 数字.すぃぜ
    此処迄
    (整数の文字化(数字[零...(-乙[零])]) + 乙[壹]) + 整数の文字化(数字[(-乙[零])..壹])
  此処迄
此処迄
定義 フロートの文字化(フロート)
  甲 = フロート.と_す.すぷりと(".")
  甲[零] = 整数の文字化(甲[零])
  甲[壹] = 甲[壹].くはるす.まぷ 実行 |乙|
    ル数字行列[乙]
  此処迄.じぉいぬ
  甲.じぉいぬ("点")
此処迄
定義 文字を翻訳(文字)
  平片 = :ひら
  文字.すかぬ(/([^あえいおう])?(\壹)?([いぅ])?([あえいおう])?/i).まぷ 実行 |子音甲, 子音乙, 子音丙, 母音|
    母音 = 母音.と_す
    若し (子音甲.にる? && 母音.えむぷと?)
      無
    違えば
      若し ((子音甲 || 母音).どゐぅぬかせ != (子音甲 || 母音))
        平片 = :かた
      此処迄
      子音甲, 子音乙, 子音丙, 母音 = [子音甲, 子音乙, 子音丙, 母音].まぷ 実行 |くす|
        若し くす
          くす.どゐぅぬかせ
        違えば
          くす
        此処迄
      此処迄
      若し 母音.えむぷと?
        母音 = ルしヴぁう[子音甲.と_すむ].と_す
      此処迄
      # ふ => ひゅ, く => きゅ
      若し ((母音 == "う") && ((子音甲 == "ふ") || (子音甲 == "く")))
        子音丙 = "いぅ"
      此処迄
      # じぁ,じぅ,じぉ => じゃ、じゅ,じょ
      若し ((((母音 == "あ") || (母音 == "う")) || (母音 == "お")) && (子音甲 == "じぅ"))
        子音丙 = "いぅ"
      此処迄
      # 拗音
      若し 子音丙
        若し [:あ, :う, :お].いぬくるで?(母音)
          子音丙 = 条件分岐 母音
          場合 :あ
            :ゃ
          場合 :う
            :ゅ
          場合 :お
            :ょ
          此処迄
          母音 = :い
        違えば
          子音丙 = 無
        此処迄
      此処迄
      # ばすぃく すっらぶれ
      仮名 = ル平[(子音甲.と_す + 母音).と_すむ].と_す
      # 促音
      若し 子音乙
        若し ["ま", "み", "む", "め", "も", "な", "に", "ぬ", "ね", "の"].いぬくるで?(子音乙)
          仮名 = ("ん" + 仮名)
        違えば
          仮名 = ("っ" + 仮名)
        此処迄
      此処迄
      # 拗音
      若し 子音丙
        仮名 = (仮名 + 子音丙)
      此処迄
      # ろゑるかせ => ひらがな, うっぺるかせ => かたかな
      若し (平片 == :かた)
        仮名 = 仮名.全文字列置換(/./) 実行 |丁|
          ル片[丁.と_すむ]
        此処迄.と_す
      此処迄
      仮名
    此処迄
  此処迄.こむぱくと.じぉいぬ
此処迄
定義 文を翻訳(文)
  文.すかぬ(/(([あ-ず]+|[零-玖]+|[^あ-ず零-玖]+))/i).まぷ 実行 |文字, _|
    若し 文字.いぬでくす(/[あ-ず]/i)
      文字を翻訳(文字)
    違えば
      若し 文字.いぬでくす(/[零-玖]/)
        整数の文字化(文字)
      違えば
        文字
      此処迄
    此処迄
  此処迄.こむぱくと.じぉいぬ
此処迄
定義 翻訳(文章 = 無)
  若し (文章.えむぷと? || 文章.にる?)
    文章
  違えば
    若し (甲 = ル翻訳行列[文章.と_すむ])
      甲
    違えば
      若し (甲 = ル翻訳メモリー[文章])
        甲
      違えば
        甲 = 文を翻訳(文章.と_す)
        ル翻訳メモリー[文章] = 甲
      此処迄
    此処迄
  此処迄
此処迄
定義 ノード毎に(幹, &塊)
  若し 幹.いす_あ?(パルセル::アスト::ノデ)
    子供 = 幹.くひるどれぬ
    ブロックを呼び出す(幹.とぺ, 子供)
    幹.くひるどれぬ.えあくふ 実行 |甲|
      ノード毎に(甲, &塊)
    此処迄
    若し (甲 = ル鍵文字[幹.とぺ])
      若し [:せるふ, :とるえ, :ふぁるせ, :にる].いぬくるで?(幹.とぺ)
        幹.いぬすたぬけ_ヴぁりあぶれ_せと(:@とぺ, 甲[壹])
      此処迄
    此処迄
  此処迄
此処迄
定義 幹を翻訳(幹)
  ノード毎に(幹) 実行 |類, 子|
    条件分岐 類
    場合 :あるぐ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :ぶろくかるぐ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :かすぐぬ
      子[壹] = ("ク_" + 翻訳(子[壹]).と_す).と_すむ
    場合 :こぬすと
      子[壹] = 翻訳(子[壹]).と_すむ
    場合 :でふ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :いぬと
    場合 :くをぷたるぐ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :るヴぁる
      子[零] = 翻訳(子[零]).と_すむ
    場合 :るヴぁすぐぬ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :おぷたるぐ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :れすたるぐ
      子[零] = 翻訳(子[零]).と_すむ
    場合 :せぬど
      子[壹] = 翻訳(子[壹]).と_すむ
    場合 :すとる
      子[零] = 翻訳(子[零]).と_す
    場合 :すむ
      子[零] = 翻訳(子[零]).と_すむ
    此処迄
  此処迄
此処迄
定義 ノートを翻訳(ノート)
  ノート.えあくふ 実行 |子|
    テキスト = 子.てくすと
    若し (テキスト[零] == "#")
      子.いぬすたぬけ_ヴぁりあぶれ_せと(:@てくすと, "#" + 翻訳(テキスト[壹..壹]))
    違えば
      子.いぬすたぬけ_ヴぁりあぶれ_せと(:@てくすと, ("=開始\n" + 翻訳(テキスト[陸..陸])) + "\n=此処迄\n")
    此処迄
  此処迄
此処迄
########
# まいぬ #
########
# れぎすてる けいぅをるどす
鍵文字を登録
# れあど いぬぷと, とらぬすらて, あぬど ぷりぬと れすると
コード = ストドィヌ.れあど
コード.えぬこで(エヌコドィヌグ::ウトフ_捌)
コード = ("#えぬこどぃぬぐ:うとふ-捌\n" + コード)
幹, ノート = パルセル::クッレヌトルブ.ぱるせ_ゐとふ_こっめぬとす(コード)
幹を翻訳(幹)
ノートを翻訳(ノート)
ストドウト.ゐぅりて(ウヌパルセル.うぬぱるせ(幹, ノート))

or

# Output "I love Ruby"
say = "I love Ruby"
puts say

# Output "I *LOVE* RUBY"
say['love'] = "*love*"
puts say.upcase

# Output "I *love* Ruby"
# five times
5.times { puts say }

becomes

#えぬこどぃぬぐ:うとふ-捌
# オウトプト "イ ろヴぇ ルブ"
さいぅ = "イ ろヴぇ ルブ"
言う(さいぅ)
# オウトプト "イ *ロヴェ* ルブ"
さいぅ["ろヴぇ"] = "*ろヴぇ*"
言う(さいぅ.うぷかせ)
# オウトプト "イ *ろヴぇ* ルブ"
# ふぃヴぇ てぃめす
伍.てぃめす 実行
  言う(さいぅ)
此処迄

blutorange

Posted 2015-06-01T04:47:11.993

Reputation: 1 205

8It seems very unnatural to approximate English using hiragana rather than katakana (regardless of how loosely it is mapped). – Stephan – 2015-06-04T08:12:39.027

7

Commodore 64 BASIC - Bosnian/Croatian/Serbian

10 FOR I=40960 TO 49151:POKE I,PEEK(I):NEXT
20 DATA "KRAJ","ZA","OPET","PODACI","UZM#","UZMI","DIM","CITAJ","DE"
30 DATA "HAJD","TRCI","AKO","VRATI","IDIU","NAZAD","KOM","STOJ","NA"
40 DATA "CEKAJ","UCITAJ","SPASI","VIDI","DEF","GURNI","PIS#","PISI"
50 DATA "NAST","POPIS","BRIS","KOM","SIS","OTVORI","ZATVORI","UZMI"
60 DATA "NOV","TAB(","DO","FU","RAZ(","ONDA","NE","KORAK","+","-"
70 DATA "*","/","↑","I","ILI",">","=","<","ZN","C","ABS","KOR"
80 DATA "SLO","POZ","KOR","SLU","LOG","EKS","KOS","SIN","TAN","ATN"
90 DATA "VIRI","DUZ","NIZ$","VRI","ASK","KAR$","LEVO$","DESNO$","SRE$"
100 DATA "ID",""
110 D=41118
120 READ A$
130 IF A$="" THEN 210
140 L=LEN(A$)
150 IF L=1 THEN 190
160 FOR I=1 TO L-1
170 POKE D,ASC(MID$(A$,I,1)):D=D+1
180 NEXT
190 POKE D,ASC(MID$(A$,L,1))+128:D=D+1
200 GOTO 120
210 POKE 1, PEEK(1) AND 254

This actually replaces BASIC keywords with the translated ones, so you can must use them when you write new code.

Bosnian BASIC

How it works?

FOR I=40960 TO 49151:POKE I,PEEK(I):NEXT

Though it appears that this line does not do much, it in fact copies bytes from BASIC ROM to RAM. Data written to a ROM location is stored in the RAM at the same address.

The last line in the program switches to the RAM copy of BASIC:

POKE 1,PEEK(1) AND 254

Memory adresses 41118-41373 contain a complete list of the reserved BASIC keywords. The ASCII characters of these words are stored in token number order. Bit #7 of the last letter of each word is set to indicate the end of the word (ASCII value + 128).

Lines 20-100 contain the translated keywords. Lines 110-200 read the keywords in the memory as described above.

Danko Durbić

Posted 2015-06-01T04:47:11.993

Reputation: 10 241

5You might be the first person whose code works after the transformation! – CJ Dennis – 2015-06-05T11:02:01.493

When the creator of C64 BASIC completed his work, he stood and proclaimed "I long for the day that people can program the C64 in Bosnian".
    (shame he wasn't such a visionary regarding >640k of RAM)
– Mark K Cowan – 2015-06-08T10:35:46.167

But the translation is made into the RAM and a reboot will cause RAM to be cleared, yes? – cat – 2015-11-24T13:55:29.513

5

PHP - Portuguese (pt-PT/semi pt-BR)

This turned out quite complex, and giant!

<?

    echo preg_replace_callback(
        '@\b([\wâêçãáú]+)\b|(?:[\$\>]|[=\.]=|=\>?|&&)@i',
        function($match){

            $word = $match[0];

            if($word == '_')
            {
                return '_';
            }

            $list = array(
                'echo' => 'ecoar',
                'match' => 'equivalência',
                'array' => 'conjunto',
                'file' => 'ficheiro',
                'replace' => 'substitui',
                'callback' => 'executável',
                'function' => 'função',
                'list' => 'lista',
                'if' => 'se',
                'else' => 'senão',
                'word' => 'palavra',
                'piece' => 'pedaço',
                'pieces' => 'pedaços',
                'explode' => 'explosão',
                'implode' => 'implosão',
                'count' => 'conta',
                'tmp' => 'temporário',
                'k' => 'chave',
                'get' => 'busca',
                'contents' => 'conteúdos',
                'preg' => 'expressão_regular',
                'as' => 'como',
                'return' => 'retorna',
                'use' => 'utiliza',
                'strtoupper' => 'corda_para_maiúscula',
                'strtolower' => 'corda_para_minúscula',
                'unset' => 'remover_definição',
                'isset' => 'está_definido',
                'str' => 'corda',
                '$' => '€',
                '.=' => '.=',
                '=>' => 'recebe',
                '==' => 'igual',
                '=' => 'atribuí',
                '>' => 'maior_que',
                '&&' => 'e'
            );

            if($word[0] == '_' && $word[1] == '_')
            {
                return preg_replace_callback(
                    '@([A-Z]+)@',
                    function($word) use (&$list){
                        return strtoupper($list[strtolower($word[1])]);
                    },
                    $word
                );
            }
            else
            {
                $word = explode('_', $word);
                $pieces = count($word);
                if( $pieces > 1 )
                {
                    $tmp = $word[0];
                    $word[0] = $word[1];
                    $word[1] = $tmp;
                    unset($tmp);
                }

                foreach($word as $k => $piece)
                {
                    $word[$k] = isset($list[$piece])?$list[$piece]:$piece;
                    if( $k == 0 && $pieces > 1 )
                    {
                        $word[$k] .= 'r';
                    }
                }

                return implode('_', $word);
            }
        },
        file_get_contents(__FILE__)
    );

Remember that this code was made to match with itself! It may work partially with other codes.


Output, translated:

<?

    ecoar substituir_expressão_regular_executável(
        '@\b([\wâêçãáú]+)\b|(?:[\€\maior_que]|[atribuí\.]atribuí|atribuí\maior_que?|e)@i',
        função(€equivalência){

            €palavra atribuí €equivalência[0];

            se(€palavra igual '_')
            {
                retorna '_';
            }

            €lista atribuí conjunto(
                'ecoar' recebe 'ecoar',
                'equivalência' recebe 'equivalência',
                'conjunto' recebe 'conjunto',
                'ficheiro' recebe 'ficheiro',
                'substitui' recebe 'substitui',
                'executável' recebe 'executável',
                'função' recebe 'função',
                'lista' recebe 'lista',
                'se' recebe 'se',
                'senão' recebe 'senão',
                'palavra' recebe 'palavra',
                'pedaço' recebe 'pedaço',
                'pedaços' recebe 'pedaços',
                'explosão' recebe 'explosão',
                'implosão' recebe 'implosão',
                'conta' recebe 'conta',
                'temporário' recebe 'temporário',
                'chave' recebe 'chave',
                'busca' recebe 'busca',
                'conteúdos' recebe 'conteúdos',
                'expressão_regular' recebe 'regularr_expressão',
                'como' recebe 'como',
                'retorna' recebe 'retorna',
                'utiliza' recebe 'utiliza',
                'corda_para_maiúscula' recebe 'parar_corda_maiúscula',
                'corda_para_minúscula' recebe 'parar_corda_minúscula',
                'remover_definição' recebe 'definiçãor_remover',
                'está_definido' recebe 'definidor_está',
                'corda' recebe 'corda',
                '€' recebe '€',
                '.=' recebe '.=',
                'recebe' recebe 'recebe',
                'igual' recebe 'igual',
                'atribuí' recebe 'atribuí',
                'maior_que' recebe 'quer_maior',
                'e' recebe 'e'
            );

            se(€palavra[0] igual '_' e €palavra[1] igual '_')
            {
                retorna substituir_expressão_regular_executável(
                    '@([A-Z]+)@',
                    função(€palavra) utiliza (&€lista){
                        retorna corda_para_maiúscula(€lista[corda_para_minúscula(€palavra[1])]);
                    },
                    €palavra
                );
            }
            senão
            {
                €palavra atribuí explosão('_', €palavra);
                €pedaços atribuí conta(€palavra);
                se( €pedaços maior_que 1 )
                {
                    €temporário atribuí €palavra[0];
                    €palavra[0] atribuí €palavra[1];
                    €palavra[1] atribuí €temporário;
                    remover_definição(€temporário);
                }

                foreach(€palavra como €chave recebe €pedaço)
                {
                    €palavra[€chave] atribuí está_definido(€lista[€pedaço])?€lista[€pedaço]:€pedaço;
                    se( €chave igual 0 e €pedaços maior_que 1 )
                    {
                        €palavra[€chave] .= 'r';
                    }
                }

                retorna implosão('_', €palavra);
            }
        },
        buscar_ficheiro_conteúdos(__FICHEIRO__)
    );

I've tried to respect the grammar as much as possible.

An example is right in the first line:

echo preg_replace_callback

Echo is an action, and actions are verbs. All verbs in portuguese end with r.
Translating echo without context would be eco, while in the context it has to be ecoar ('making an echo').

Also, the function preg_replace_callback has a unique thing.
The action must be the first word.
Translated literally, it would be expressão_regular_substitui_executável, which is terribly translated!(It means replace the callback using a regular expression)
Therefore, special care must be taken and swap the first and second words, so it is substituir_expressão_regular_executável, which is a little better.

Other functions, like count, are left without r to detonate an order (like if you were being bossy).

Some words turned out weird...
string means corda, but if I translated it correctly, it would be cadeia contínua/ininterrupta de caracteres.

To add on all that, I've also translated some symbols and operators ($, =, =>).
Thank you @DLosc for the idea of translating $ into .

Ismael Miguel

Posted 2015-06-01T04:47:11.993

Reputation: 6 797

2

You could use a Portuguese monetary symbol instead of $, similar to what this language did.

– DLosc – 2015-06-02T16:55:53.710

@DLosc Thanks a lot for the idea. I went ahead and also translated other operators and symbols. – Ismael Miguel – 2015-06-02T17:54:49.370

4

Fondamentale Visuale .RETE - Visual Basic .NET, translated to ITALIAN

The program is much simple (aimed at translating itself).

Some points:

  • I/O : this is a module with a obvious function to be called

  • grammar is mostly correct (feels almost natural)

  • english and italian word position is different so i could not (easily) write some function to fix that, and preferred static translation pairs

  • i have conjugated imperative verbs to the 2nd person, as in a literal italian translation they would sound and feel wrong (as wrong as windows 8+ talking in 1d person)

  • the translation pairs are obfuscated so the english ones don't get also translated. thus, if there was an interpreter, the translated program would work i only left some "+" to avoid overtranslation (many english words are contained in italian ones, so it would end up translating italian to italian with duplication of suffixes)

Module Italian

    Dim Tokens As New List(Of Tuple(Of String, String))

    Sub AddPair(a As String, b As String)
        Tokens.Add(Tuple.Create(a, b))
    End Sub

    Sub init()
        AddPair(" Italian", " Italia" + "no") : AddPair("Module", "Modulo")
        AddPair("lacks", "non ha") : AddPair("AddPair", "AggiungiCoppia")
        AddPair(" italian", " l'italiano")
        AddPair("Next", "Appresso") : AddPair("Tokens", "Frammenti")
        AddPair("init", "iniz") : AddPair(" As ", " Come ")
        AddPair("Tuple", "Coppia") : AddPair("For Each", "Per Ogni")
        AddPair("Of", "Di") : AddPair(" only", " e basta")
        AddPair("Sub", "Proc") : AddPair("so i will add", "quindi aggiungerò")
        AddPair("Function", "Funzione") : AddPair("Dim", "Def")
        AddPair(" a ", " una ") : AddPair("support", "il s" + "upporto")
        AddPair("used types", "i tipi utilizzati")
        REM italian lacks a gender-indipendent form for adjectives
        REM so i will add support for used types only
        AddPair(" New List", " una Nuova Lista")
        AddPair("Create", "Crea") : AddPair("End", "Fine")
        AddPair("REM", "RIC") : AddPair(" for ", " per ")
        AddPair("gender-indipendent form", "forma indipendente dal genere")
        AddPair("String", "Sequenza") : AddPair("adjectives", "gli aggettivi")
        AddPair(" TranslateToItalian", " TraduciInItaliano")
    End Sub

    Function TranslateToItalian(o As String) As String
        Dim ret As String = o : init()
        For Each t As Tuple(Of String, String) In Tokens
            ret = ret.Replace(t.Item1, t.Item2)
        Next
        Return ret
    End Function

End Module

Italian, here we go!

The result on itself:

Modulo Italiano

    Def Frammenti Come una Nuova Lista(Di Coppia(Di Sequenza, Sequenza))

    Proc AggiungiCoppia(a Come Sequenza, b Come Sequenza)
        Frammenti.Add(Coppia.Crea(a, b))
    Fine Proc

    Proc iniz()
        AggiungiCoppia(" Italiano", " Italia" + "no") : AggiungiCoppia("Modulo", "Modulo")
        AggiungiCoppia("non ha", "non ha") : AggiungiCoppia("AggiungiCoppia", "AggiungiCoppia")
        AggiungiCoppia(" l'italiano", " l'italiano")
        AggiungiCoppia("Appresso", "Appresso") : AggiungiCoppia("Frammenti", "Frammenti")
        AggiungiCoppia("iniz", "iniz") : AggiungiCoppia(" Come ", " Come ")
        AggiungiCoppia("Coppia", "Coppia") : AggiungiCoppia("Per Ogni", "Per Ogni")
        AggiungiCoppia("Di", "Di") : AggiungiCoppia(" e basta", " e basta")
        AggiungiCoppia("Proc", "Proc") : AggiungiCoppia("quindi aggiungerò", "quindi aggiungerò")
        AggiungiCoppia("Funzione", "Funzione") : AggiungiCoppia("Def", "Def")
        AggiungiCoppia(" una ", " una ") : AggiungiCoppia("il supporto", "il s" + "upporto")
        AggiungiCoppia("i tipi utilizzati", "i tipi utilizzati")
        RIC l'italiano non ha una forma indipendente dal genere per gli aggettivi
        RIC quindi aggiungerò il supporto per i tipi utilizzati e basta
        AggiungiCoppia(" una Nuova Lista", " una Nuova Lista")
        AggiungiCoppia("Crea", "Crea") : AggiungiCoppia("Fine", "Fine")
        AggiungiCoppia("RIC", "RIC") : AggiungiCoppia(" per ", " per ")
        AggiungiCoppia("forma indipendente dal genere", "forma indipendente dal genere")
        AggiungiCoppia("Sequenza", "Sequenza") : AggiungiCoppia("gli aggettivi", "gli aggettivi")
        AggiungiCoppia(" TraduciInItaliano", " TraduciInItaliano")
    Fine Proc

    Funzione TraduciInItaliano(o Come Sequenza) Come Sequenza
        Def ret Come Sequenza = o : iniz()
        Per Ogni t Come Coppia(Di Sequenza, Sequenza) In Frammenti
            ret = ret.Replace(t.Item1, t.Item2)
        Appresso
        Return ret
    Fine Funzione

Fine Modulo

beppe9000

Posted 2015-06-01T04:47:11.993

Reputation: 151

Thank you for your answer! Just a couple of points: you are supposed to translate English text in comments too and I can still see many English words in the form of "Mod" + "ule". Try aiming more for the spirit of the challenge rather than the letter. – CJ Dennis – 2015-06-04T05:57:35.550

@CJDennis i fixed that! – beppe9000 – 2015-06-04T11:09:31.500

3

C, Spanish - C

Input/Output via STDIN/STDOUT (use ./c-spanish < c-spanish.c).

If extra = 0 is changed to extra = 1, then the output of this program is essentially a mutual quine. Otherwise, the output is a compilable C program that works like cat.

Extra spaces in the source are necessary (as they are replaced with characters in the Spanish version).

#define B(_, __) __ ## _
#define C(_, __) B(_,__)
#define char C(C(r, ha), c)
#define gets  C(ets, g)
#define if C(f, i)
#define int C(C(ed, n), s##ig)
#define is ==
#define main      C(C(n, ai), m)
#define puts C(C(s, t), C(u, p))
#define void C(id, C(o, v))
#define    while(x) C(r, C(o, f))(;x;)

int x, y, extra = 0;
void count (char *sheep);
void try_replace        (char *cake  , char *bacon , char *sheep);
void translate(char *sheep){
    char *array [] = {
        "array ", "matriz",         "bacon ", "tocino",
        "cake  ", "pastel",         "char", "car ",
        "count ", "cuenta",         "gets ", "traec",
        "if", "si",                 "int ", "ent ",
        "is", "es",                 "main     ", "principal",
        "peace", "paz  ",           "puts", "ponc",
        "sheep", "oveja",           "translate", "traduce  ",
        "truth ", "verdad",         "try_replace        ", "trata_de_reemplazar",
        "void", "nada",             "war   ", "guerra",
        "   while", "mientras",
    };
    int war    = 19, peace = -1;
       while(!(--war    is peace)){
        count (sheep);
        int truth  = x, cake   = 0;
           while(!(cake   is truth )){
            try_replace        (&sheep[cake  ], array [2 * war   ], array [1 + 2 * war   ]);
            if(extra && !y)
                try_replace        (&sheep[cake  ], array [1 + 2 * war   ], array [2 * war   ]);
            ++cake  ;
        }
    }
}

int main     (){
    char bacon [9999];
       while(gets (bacon )){
        translate(bacon );
        puts(bacon );
    }
}

void count (char *sheep){
    x = 0;
       while(*sheep++ && ++x);
}
void try_replace        (char *cake  , char *bacon , char *sheep){
    y = 0;
    char *truth  = bacon ;
       while(*cake   && *truth  && *sheep && *cake   is *truth )
        ++cake  , ++truth , ++sheep;
    if(!*truth ){
           while(!(bacon  is truth )) *--cake   = *(--truth , --sheep);
           y = 1;
    }
}

Words translated:

array               -> matriz
bacon               -> tocino
cake                -> pastel
char                -> car (short for carácter)
count               -> cuenta
gets                -> traec (TRAE la Cadena)
if                  -> si
int                 -> ent (short for entero)
is                  -> es
main                -> principal
peace               -> paz
puts                -> ponc (PON la Cadena)
sheep               -> oveja
translate           -> traduce
truth               -> verdad
try_replace         -> trata_de_reemplazar
void                -> nada
war                 -> guerra
while               -> mientras

Output

With extra = 0:

#define B(_, __) __ ## _
#define C(_, __) B(_,__)
#define car  C(C(r, ha), c)
#define traec C(ets, g)
#define si C(f, i)
#define ent C(C(ed, n), s##ig)
#define es ==
#define principal C(C(n, ai), m)
#define ponc C(C(s, t), C(u, p))
#define nada C(id, C(o, v))
#define mientras(x) C(r, C(o, f))(;x;)

ent x, y, extra = 0;
nada cuenta(car  *oveja);
nada trata_de_reemplazar(car  *pastel, car  *tocino, car  *oveja);
nada traduce  (car  *oveja){
    car  *matriz[] = {
        "matriz", "matriz",         "tocino", "tocino",
        "pastel", "pastel",         "car ", "car ",
        "cuenta", "cuenta",         "traec", "traec",
        "si", "si",                 "ent ", "ent ",
        "es", "es",                 "principal", "principal",
        "paz  ", "paz  ",           "ponc", "ponc",
        "oveja", "oveja",           "traduce  ", "traduce  ",
        "verdad", "verdad",         "trata_de_reemplazar", "trata_de_reemplazar",
        "nada", "nada",             "guerra", "guerra",
        "mientras", "mientras",
    };
    ent guerra = 19, paz   = -1;
    mientras(!(--guerra es paz  )){
        cuenta(oveja);
        ent verdad = x, pastel = 0;
        mientras(!(pastel es verdad)){
            trata_de_reemplazar(&oveja[pastel], matriz[2 * guerra], matriz[1 + 2 * guerra]);
            si(extra && !y)
                trata_de_reemplazar(&oveja[pastel], matriz[1 + 2 * guerra], matriz[2 * guerra]);
            ++pastel;
        }
    }
}

ent principal(){
    car  tocino[9999];
    mientras(traec(tocino)){
        traduce  (tocino);
        ponc(tocino);
    }
}

nada cuenta(car  *oveja){
    x = 0;
    mientras(*oveja++ && ++x);
}
nada trata_de_reemplazar(car  *pastel, car  *tocino, car  *oveja){
    y = 0;
    car  *verdad = tocino;
    mientras(*pastel && *verdad && *oveja && *pastel es *verdad)
        ++pastel, ++verdad, ++oveja;
    si(!*verdad){
        mientras(!(tocino es verdad)) *--pastel = *(--verdad, --oveja);
           y = 1;
    }
}

With extra = 1:

#define B(_, __) __ ## _
#define C(_, __) B(_,__)
#define car  C(C(r, ha), c)
#define traec C(ets, g)
#define si C(f, i)
#define ent C(C(ed, n), s##ig)
#define es ==
#define principal C(C(n, ai), m)
#define ponc C(C(s, t), C(u, p))
#define nada C(id, C(o, v))
#define mientras(x) C(r, C(o, f))(;x;)

ent x, y, extra = 1;
nada cuenta(car  *oveja);
nada trata_de_reemplazar(car  *pastel, car  *tocino, car  *oveja);
nada traduce  (car  *oveja){
    car  *matriz[] = {
        "matriz", "array ",         "tocino", "bacon ",
        "pastel", "cake  ",         "car ", "char",
        "cuenta", "count ",         "traec", "gets ",
        "si", "if",                 "ent ", "int ",
        "es", "is",                 "principal", "main     ",
        "paz  ", "peace",           "ponc", "puts",
        "oveja", "sheep",           "traduce  ", "translate",
        "verdad", "truth ",         "trata_de_reemplazar", "try_replace        ",
        "nada", "void",             "guerra", "war   ",
        "mientras", "   while",
    };
    ent guerra = 19, paz   = -1;
    mientras(!(--guerra es paz  )){
        cuenta(oveja);
        ent verdad = x, pastel = 0;
        mientras(!(pastel es verdad)){
            trata_de_reemplazar(&oveja[pastel], matriz[2 * guerra], matriz[1 + 2 * guerra]);
            si(extra && !y)
                trata_de_reemplazar(&oveja[pastel], matriz[1 + 2 * guerra], matriz[2 * guerra]);
            ++pastel;
        }
    }
}

ent principal(){
    car  tocino[9999];
    mientras(traec(tocino)){
        traduce  (tocino);
        ponc(tocino);
    }
}

nada cuenta(car  *oveja){
    x = 0;
    mientras(*oveja++ && ++x);
}
nada trata_de_reemplazar(car  *pastel, car  *tocino, car  *oveja){
    y = 0;
    car  *verdad = tocino;
    mientras(*pastel && *verdad && *oveja && *pastel es *verdad)
        ++pastel, ++verdad, ++oveja;
    si(!*verdad){
        mientras(!(tocino es verdad)) *--pastel = *(--verdad, --oveja);
           y = 1;
    }
}

es1024

Posted 2015-06-01T04:47:11.993

Reputation: 8 953

Is define a Spanish word? Remember your code doesn't have to work in its original language after being translated, only in a hypothetical translated version of the interpreter/complier. – CJ Dennis – 2015-06-04T05:24:55.217

3@CJDennis define is indeed a word in Spanish (second person command for definir) – es1024 – 2015-06-04T05:42:07.503

3

Ruby, Catalan - Rubí

It's quite a short code in ruby, so it's not that representative, but I've been a bit more verbose in the function names to show a bit more. This exercise remembered me too much of university classes where we used similar pseudocode to "program".

words = {
    while: "mentre",
    words: "paraules",
    end: "fi",
    nil: "res",
    gets: "obtingues_cadena",
    line: "línia",
    each: "per_cada_una",
    do: "fes",
    original: "original",
    replacement: "intercanvi",
    gsub: "substitueix_globalment",
    puts: "posa_cadena"
}

while (line = gets) != nil
    words.each do |original,replacement|
        line.gsub! original.to_s,replacement
    end
    puts line
end

Applied to itself becomes:

paraules = {
    # Eliminat per simplificar codi
}

mentre (línia = obtingues_cadena) != res
    paraules.per_cada_una fes |original,intercanvi|
        línia.substitueix_globalment! original.to_s,intercanvi
    fi
    posa_cadena línia
fi

rorlork

Posted 2015-06-01T04:47:11.993

Reputation: 1 421

1I bet I can guess what Eliminat per simplificar codi means! – CJ Dennis – 2015-06-05T10:29:15.780

I'm also sure you can! – rorlork – 2015-06-05T10:54:20.280

3

Python 3, Lojban

Where I needed to reorder sumti places, I enclosed the words in brackets, e.g (te tcidu fe)

Code:

dictionary = [
    ('basti fa', 'with'),
    ('ro', 'for'),
    ("vidnyja'o", 'print'),
    ('nenri', 'in'),
    ('lujvo', 'word'),
    ('jbovlaste', 'dictionary'),
    ('basygau', 'replace'),
    ('(te tcidu fe)', 'read'),
    ('datnyvei','file'),
    ('vlamei', 'text'),
    ('kargau', 'open'),
    ('la .lojban.', 'lojban'),
    ('no', '0'),
    ('pa', '1'),
    ('as', ''),
    ('with', 'basti fa'),
    ('for', 'ro'),
    ('print', "vidnyja'o"),
    ('in', 'nenri'),
    ('word', 'lujvo'),
    ('dictionary', 'jbovlaste'),
    ('replace', 'basygau'),
    ('read', '(te tcidu fe)'),
    ('file', 'datnyvei'),
    ('text', 'vlamei'),
    ('open', 'kargau'),
    ('lojban', 'la .lojban.'),
    ('0', 'no'),
    ('1', 'pa')
]

with open('lojban.py', 'r') as file:
    text = file.read()

for word in dictionary:
    text = text.replace(word[0], word[1])

print(text)

And its output:

jbovlaste = [
    ('basti fa', 'basti fa'),
    ('ro', 'ro'),
    ("vidnyja'o", 'vidnyja'o'),
    ('nenri', 'nenri'),
    ('lujvo', 'lujvo'),
    ('jbovlaste', 'jbovlaste'),
    ('basygau', 'basygau'),
    ('(te tcidu fe)', '(te tcidu fe)'),
    ('datnyvei','datnyvei'),
    ('vlamei', 'vlamei'),
    ('kargau', 'kargau'),
    ('la .lojban.', 'la .lojban.'),
    ('no', 'no'),
    ('pa', 'pa'),
    ('', ''),
    ('basti fa', 'basti fa'),
    ('ro', 'ro'),
    ('vidnyja'o', "vidnyja'o"),
    ('nenri', 'nenri'),
    ('lujvo', 'lujvo'),
    ('jbovlaste', 'jbovlaste'),
    ('basygau', 'basygau'),
    ('(te tcidu fe)', '(te tcidu fe)'),
    ('datnyvei', 'datnyvei'),
    ('vlamei', 'vlamei'),
    ('kargau', 'kargau'),
    ('la .lojban.', 'la .lojban.'),
    ('no', 'no'),
    ('pa', 'pa')
]

basti fa kargau('la .lojban..py', 'r')  datnyvei:
    vlamei = datnyvei.(te tcidu fe)()

ro lujvo nenri jbovlaste:
    vlamei = vlamei.basygau(lujvo[no], lujvo[pa])

vidnyja'o(vlamei)

Tuomas Laakkonen

Posted 2015-06-01T04:47:11.993

Reputation: 341

read just becomes (te tcidu fe). Is it supposed to do something else? – CJ Dennis – 2015-06-07T05:52:21.823

@CJDennis No, although I suppose I could have used underscores instead of spaces and ditched the brackets. – Tuomas Laakkonen – 2015-06-07T10:28:35.533

OK. From the comment above the code I thought it was supposed to rearrange something! – CJ Dennis – 2015-06-07T13:29:45.747

1

Javascript ES6, Esperanto, Ĝavoskripto

f=_=>f.toString().replace(/toString/g,'konvertiLaĉi').replace(/replace/g,'anstataŭigi');f()

I took some liberties with camelcasing and wording (I translated 'convert to string' instead of 'to string'). I'll complicate things later when I have more time.

Mama Fun Roll

Posted 2015-06-01T04:47:11.993

Reputation: 7 234