将您的英语源代码翻译成外语[关闭]


66

我注意到,基于英语的计算机语言数量不成比例。我建议通过将现有的计算机语言翻译成外语来解决此问题!

  • 选择一种使用英语关键字/功能的计算机语言
  • 选择英语以外的任何自然*语言
  • 编写一个程序,将其自身的源代码或使用相同关键字/函数子集编写的任何其他程序翻译成其他语言
  • 发布源代码和输出(翻译后的代码)

用以下内容开始您的帖子:

法语BASIC

要么

BASIC,法语-FONDAMENTAL

如果不想,您不必翻译语言名称,这只是为了好玩!

您不必翻译所选语言中的所有关键字/功能,只需翻译您在源代码中实际使用的关键字/功能即可。例如,PHP有成千上万,因此您绝对不需要全部翻译!另外,如果您有任何意见,也请尽力翻译!程序完成后,除非适用于外语的英语单词不应该被识别。字符串中的单词也应该翻译(这意味着翻译后的程序即使可以运行,也不再能在英语源代码上运行!)。希望您的程序对说另一种语言的程序员有某种意义!

例如,if () {} elseif () {} else {}可能会变成si () {} sinonsi () {} sinon {}法文!如果您将Perl的翻译elsif成法文,也许您会ne用英语将第二个单词放在第二个单词一样丢弃第二个单词sinosi。在法国其他更可能是他者,但替代兴农或者否则)感觉更好的给我!

有创造力!尝试捕捉计算机和自然语言的感觉!没有英语标记的语言如Brainfuck,CJam等将无法使用。像BASIC或COBOL之类的语言更合适。除非您的语言不支持可以是英语单词的变量名,否则请使用有意义的变量名并进行翻译。

您可以发布多个答案,每个答案对应一种计算机/自然语言。您不得使用库或外部工具进行翻译!您的代码应自行翻译,而不要调用其他可以翻译的内容!这不是Code Golf!如果您的程序接受任何输入,则只能是其自己的源代码,如果它是从光盘中读取的,则只能是源文件,等等。

*就此挑战而言,我将世界语,洛伊班语,Volapük,Interlingua等视为自然语言。您可能没有为这项挑战发明自己的语言!

我添加了一条规则来防止显眼的提篮。您可以选择关键字/功能的任何子集(甚至全部)进行翻译。您的程序必须至少能够翻译自己,即,如果您的原始来源中包含单词,print那么print(42)在输入代码中添加任何位置(而不是您的程序本身)仍将产生正确的结果。

例如:

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

可能成为

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

如果输入更改为

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

输出则应该成为

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

4
“打印”将成为“ imprimer”(如在“打印机”中),而不是“ empreinte”(如在“脚印”中:)
昆汀

4
@Quentin我从来没有说过它是很好的法语!
CJ Dennis

13
我认为Excel具有本机语言支持已经很糟糕了.. :(。使调试公式变得如此困难
Mave

1
@Quentin我现在想知道法语动词是否应该使用命令式而不是不定式。唯一的问题是我的法语还不够好!
CJ丹尼斯

3
@CJDennis在法国的伪代码中,我总是见过不定式,但如有需要,我可以伸出援手:p
Quentin

Answers:


67

Python,Koine希腊文 -Πύθων

我最喜欢的编程语言和我最喜欢的外语-完美!这个名字已经是希腊语了,这也没有什么坏处。

Python 3中的翻译器程序(感谢提供本机Unicode支持):

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)

在其自身上运行代码的结果(删除了大的翻译列表):

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

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

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

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

Koine Greek已有2000年的历史,因此翻译编程术语很有趣。这是我的最爱:

  • βιβλίον =“滚动”(file
  • γραψάτω =“写”(print
  • λαβέτω =“服用”(input
  • εἰσενεγκάτω =“带来”(import
  • τύπος =“样式,类型”(encoding
  • λόγοι / νεόλογοι =“单词” /“新单词”(code/ replacements
  • ἕκαστον...ἐκ =“每个...来自”(for ... in
  • εἰ...εἰδὲ...εἰδὲμή =“如果...但如果...但不是”(if ... elif ... else
  • ἐντῷ的字面意思是“在……中”,但在某些情况下,它可能是“何时,何时”的成语。
  • “正则表达式”成为ῥήμαλογικόν,“理性/合理的说法”; 因此,缩写reῥλ

大多数单词也可以通过在Wiktionary上搜索找到。

其他一些重要功能:

  • 英语编程使用一堆势在必行动词(的printreadreplace)。我怀疑古希腊人对这样的计算机讲话会感到有些愚蠢,因此我使他们成为所有第三人称命令:“必须打印”,“必须阅读”,“必须替换”。
  • 希腊标点符号与英语略有不同。我并没有因此而过度,因为我不确定用什么来代替方括号和下划线,但是我确实将冒号换成了ano teleia或“句号”(·)。
  • 对于不在列表中的单词,我也确保将所有小写字母都音译。并不总是存在直接的一对一对应关系。因此,例如,utf变成-- ουτφ如果您尝试发音的话听起来像“ ootf”。

这在语法上仍然有很多不足之处。与英语相比,希腊语是一种更加易用的语言,而且我的代码还不够完善,无法正确使用所有大小写和数字。例如,ἕκαστονπαλαιγν,νέονἐκνεόλογοι应当以ἐ格为宾语,以gen格为例。但是,我不会花那么多时间!外观足够希腊化(至少对于未经训练的眼睛而言),高高的时期增加了不错的触感。总而言之,我对结果非常满意。


4
在我看来就像希腊人!我不懂希腊语,但是您似乎在语法上遇到了麻烦,做得很好!您介意从翻译列表中添加几行内容吗?
CJ Dennis

我仍然只看到νεόλογοι = [...]。您可以在其中放几行吗?无需整个列表!
CJ Dennis

没错,这并不是很有趣,但是它确实表明了整个输出!
CJ Dennis

翻译不应该只保留字符串常量而仅翻译关键字(可能还有变量名)吗?
kasperd 2015年

@kasperd Au矛盾Words in strings should be translated too
DLosc

65

,中文-鸡

鸡肉比我想象的难用得多。

没有尾随换行符。但是最后chicken只是标记该程序的结束,可以用空行代替。

我正在使用此解释器该解释器将打印额外的换行符,并且无法取消显示。因此,输出比原始输出多一行,这可能会使Chicken程序损坏。我希望这不会使它无效。

它使用了一些技巧,例如从输入的索引-1获取空字符串,并通过与空字符串进行比较来检测EOF。我还使用该compare命令丢弃堆栈中未使用的项目,而无需关心类型。他们可能无法在其他口译员中工作。它将字符串打印为UTF-8字节,其他解释器可能会支持直接打印Unicode字符。

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

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

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

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

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

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

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


chicken

使用此命令运行以下代码:

bin/chicken "`<file`" <file

奇怪的是,第一个file用于输入,第二个用于代码。

输出(中文在单词之间不使用空格):

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

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

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

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

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

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

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


鸡

该程序替换h,换行符不受影响,并忽略其他所有内容。

如您所见,它可以翻译每个有效的Chicken程序。


3
你知道这是什么让我觉得〜的youtu.be/vExjnn_3ep4
DLosc

5
嗯!中国鸡!我认为输出比原始程序更容易理解!现在还有其他人想要外卖吗?
CJ Dennis

2
干得好,吉米
Alex A.

18
@AlexA。然后更改了我的用户名。
jimmy23013 2015年


36

C ++,拉丁文-C Plus 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;
}

笔记:

  • 在命令行上获取输入和输出文件
  • 翻译所有关键字
  • 我没有编写完整的罗马数字解析器,但是我认为至少要翻译源代码中出现的数字(nihiliii)会很好。
  • 我没有走C ++中使用的符号翻译之路,这似乎是一大堆蠕虫
  • 关键字constenumint,并operator不会改变。现在,它们代表常量枚举整数运算符
  • 我不认为罗马人会成为_分词师,所以我使用了interpuncts
  • 翻译非常笨拙且效率低下,忽略了单词边界等。

输出:

#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;
}

难道不应该像现代罗曼语那样将“字符串”翻译为“ catena”吗?
200_success 2015年

取决于您的感受。
路加福音

6
更确切地说,您感觉如何浪漫。
Alex A.

1
我认为您错过了“空”。
Pakk 2015年

1
谢谢。我从@ Vioz-的书中拿出一片叶子,并用'inane'表示空白,这样我就可以用'vacuum'表示空白。
路加福音

25

JavaScript(NodeJS)-希伯来语

我的编码方法与DLosc的Python程序非常相似:它读取源代码,具有令牌列表,并运行查找和替换。

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

这给出以下输出:

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

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

不幸的是,SE似乎不喜欢RTL文本。我试图将上述代码块手动包装到中<pre dir="rtl">,但是它被剥离了。:(该代码实际上应该看起来像这样:(gedit的屏幕截图)

code properly displayed with RTL formatting

有关希伯来文字的一些注意事项:

  • 希伯来语缩写方法(在此代码中多次使用)是在末尾使用单引号来缩写一个单词,如果最后一个字母是多个单词,则在最后一个字母之前使用双引号。对于单个单词,我们将var其翻译为מש',是“משתנה”(变量)的缩写。fs,“文件系统”的缩写,翻译为מ"ק,如上所示,“מערכתקבצים”的首字母。
  • 希伯来语没有大写/小写字母。几个字母具有正常/最终形式(分别为כמנפצ和ךםןףץ),仅此而已。因此,在第二个单词的末尾以最后一个字母结尾的情况下,我也用“ readFile”和“ filename”之类的混搭单词将希伯来语“קראקובץ”和“שםקובץ”混在一起。
  • 以上不适用于toString。在希伯来语中,介词是单个字母,位于该词之前。因此,如果“ string”为“מחרוזת”,则“ to string”为“למחרוזת”。这就是为什么在代码for..in块中,in令牌包含空格,以便将其附加到下一个单词(word in words变为מילה במילים)的原因。
  • 我无法从计算机上重现此内容,但是当我从iPad 转到translate.google.com并放入时regex,它又带给我ביטויסדיר的字面意思,即“有序表达”。哇!我把它缩写为ביטס"ד,就像JS一样RegExp
  • g正则表达式标志我译为ע”,它代表עולמי,全球性的。
  • 注意用于替换的复杂正则表达式形式new。这是因为在希伯来语中,形容词(例如“ new”-“חדש”)紧跟在名词(例如regex)之后。因此,代替的new RegExp()是“ RegExp [即] new()`。
  • 我删除了引号,因为它们在经典的希伯来语中不存在。这无疑使语法变得更加困难!我仍然不确定这是否是个好决定。
  • 看来我正在用冒号替换所有终止的分号。它实际上是U + 05C3 SOF PASUQ,是标点符号,以圣经中的诗句结尾。

此代码当然不会翻译每个有效的JS程序。实际上,它可能仅翻译了这一篇。但这对于这个挑战已经足够了。;)

顺便说一句,如果您对希伯来语感兴趣,请遵循希伯来语.SE提案(并对分数小于10的问题进行投票)!(来源:stackexchange.com
Stack Exchange Q&A site proposal: Hebrew Language


9
应该随PHP一起使用-它们已经T_PAAMAYIM_NEKUDOTAYIM涵盖了
wchargin

2
RTL源代码的最后一行看起来像一个满脸胡子的男人。:)
马特·里昂斯2015年

(无论哪种情况,出于某种原因,我都没有在LTR来源上注意到它)
Matt Lyons 2015年

@MattLyons您可能没有注意到英语,因为它看起来并不像它。
Scimonster

1
来自@proudhaskeller
sagiksp

22

Perl,PigLatin-erlPay

首先,实际程序非常简短,因此为了演示它在较长文本段中的行为,我提供了一些Perl诗歌作为输入/输出的另一个示例。由于诗歌包含在END行之后,因此实际上并不会执行。

实际的算法非常简单:

  • 将输入分成单词边界上的标记
  • 对于至少具有两个字母字符的任何单词,请翻译成Pig Latin
    • 在单词中找到主要的辅音
    • 将其移至末尾并在其上加上“ ay”后缀
  • 打印所有内容。非字母输入(和单字符)不翻译

#!/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)

自行运行程序的输出:

#!/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)

2
拉丁猪被认为是一种语言游戏,而不是自然语言。参见Pig Pig Wikipedia页面
Alex A.15年

5
我想您可以这样说,尽管就不确定性而言,我不确定这一挑战是否已经上升到联邦RFP的水平。
拉尔夫·马歇尔

3
翻译的语言名称应该是erlPay,如果它也输出的话我会喜欢的__DENAY__。不宜openayacceptayenopayceptacay
CJ丹尼斯

1
挑战指定“外语”。拉丁猪不算在内。
mbomb007

6
我想我建议大家都放松一下PigLatin作为外语的接受度。如果您不喜欢我的解决方案,请不要投票。我相信CJ对此很满意,并且因为这只是一个有趣的小练习,所以我会坚持自己的意见。
拉尔夫·马歇尔

17

Visual Basic .Net,波斯语

我选择了一种冗长的语言,所以会更难。事实证明,我不必更改语法。代码的波斯语形式也很冗长。

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

结果需要从右到左的文本编辑器。我无法在此处正确显示。但是,如果我必须显示它,就在这里。这是一张图片:

码

注意:它从名为Persian.txt的文件中读取并输出到code.txt。如果没有变成问号,我将无法获得控制台窗口来编写或阅读波斯语。(例如,四个字母的单词会变成????)

注意:如果您用波斯语将单词彼此连接,则几乎是不可读的,因为字母彼此连接并获得了不同的形式。因此,我不得不用空格分隔它们,从而导致单词中包含空格。像Imports这样的单词变成了واردکردن,这是两个单词。


在我的希伯来语文章中,我包括了它的屏幕快照,该屏幕快照在支持RTL的编辑器中正确显示。
Scimonster 2015年

@Scimonster好主意。我马上就做。谢谢。
JNV

2
您可以使用无空格的“درستکردن”,而不必使用Unicode零宽度非连接符(U + 200C)将其转换为“درستکردن”:“ درست‌کردن”-这会强制字母并排没有间隙,没有将它们连接在一起-尽管效果是否好看取决于字体!
psmears 2015年

@psmears你是对的;我忘了 谢谢!
JNV 2015年

14

Java,德语-Java

这个程序真的很简单。
它仅读取作为第一个参数给出的文件,并用相应的德语翻译替换所有出现的英语单词。

我正在使用带有两个组(([^a-zA-Z\\d:])*)的正则表达式来匹配以非字母数字字符开头/后跟的单个项目。这样就解决了重叠翻译的问题(英语List->英语,Liste但是后来Liste变成了Listee)。使用$1/ $2向后添加这些字符,并为我们提供翻译后的源代码。

更新1:

使用类似缩写eanbea等等遵循Java的命名约定的德国。

更新2:

现在使用数组中的第三个组件在第一次替换后中断。这是我作弊的偏斜/共轭方法所必需的。class/ Klasse在德语中是女性,void/ nichts是中性的,所以我只是跳过了后者的替换,后来又替换了。另一个编辑是new的翻译,neue因为我只在上使用它String,它是女性的。

更新3:

通过添加区分大小写的正则表达式来正确处理大小写。

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

这将输出以下内容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);
        }
    }

如果您对代码或翻译有任何改进,请告诉我,看看是否可以实现。


/󠀠 而且-标识符可能不好。
六。

6
我喜欢这两种语言之间的对应关系-两者都使用庞大的复合词。;)但是我确实怀疑德国人仍会Eingabe/Ausgabe以某种方式缩写-也许Einaus吗?
DLosc

1
@DLosc I / O(输入/输出)通常用E / A(Eingabe / Ausgabe)缩写。Einaus我想也有可能,但是感觉不对。Rein/Raus似乎也有可能,但再次感觉不太好。
GiantTree 2015年

@Vi。您的意思是替换字符串中的字符(左侧)?不需要那些,因为Java不允许这样的字符成为名称/标识符的一部分。我认为您的意思是因为我要一遍又一遍地检查整个字符串,并且您可能认为E/A或类似原因可能会导致问题,但是它们不会被解释为正则表达式,它们只是匹配而不会影响正则表达式。(我可能是错的,但这是我使用正则表达式所经历的)
GiantTree 2015年

@GiantTree,我的意思是假设的德语Java编译器很难解析代码。
六。

14

朱莉娅,鞑靼 -朱莉娅

它使用了非官方的拉丁字母Zamanälif字母(用于建立于2001年的İdel-Ural塔塔尔语)。但是,在2002年,俄罗斯联邦否决了tar斯坦共和国的议案,要求将Zamanälif用作塔塔尔语的官方字母,将任何形式的官方使用定为犯罪。西里尔字母以外的其他字母。

在过去的一个世纪中,塔塔尔语言有5个字母:

  • İskeimlâ,阿拉伯字母的变体,1870-1920年代
  • Yañaimlâ,另一个阿拉伯语变体,1920年代和30年代
  • Jaᶇalif,1930年代拉丁字母的一种变体
  • 西里尔字母,由约瑟夫·斯大林(Joseph Stalin)委托,1940年代至今
  • Zamanälif,非官方,2001年至今

我之所以选择Zamanälif,是因为我认为如果我使用Cyrillic,我的祖父会感到失望。他的第一语言是塔塔尔语,他出生于1920年代,学会了使用iskeimlâ字母进行读写。

英语:

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

塔塔尔族:

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

我采取了一些自由措施,以使翻译更加简洁。例如,for变为saen,将其从字面上翻译为“每个”。我也没有缩写Süzlek,意思是“字典”。ukırgaböten,我对的翻译readallukırga(阅读)+ böten(所有/每个)。başägär,我对的翻译elseifbaş(的缩写başkaça,表示“其他/否则”)+ ägär(如果)。

如果PPCG上的任何人都了解塔塔尔语,那么您可能比我了解的更多。欢迎大家提出意见。


13

鲁斯特白俄罗斯(Ржа)

程序:

#![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!("{}", зьмест);
}

输出:

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

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

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

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

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


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

No.󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠󠀠
六。

俄语和C ++?
GamrCorps,2015年

@IonLee,没有提示:第一次猜测就更近了。
六。

@IonLee:自然语言是白俄罗斯语。
Alex

1
锈和白俄罗斯语?
ProgramFOX

12

DogeScript,西班牙语 Perro

DogeScript被解释为JavaScript,因此任何有效的JS都是有效的DogeScript。我在这里给出的翻译实际上包含了整个关键字说明(还有更多内容可以覆盖程序中使用的单词)。

“英语”:

 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

西班牙语:

 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

您可能会注意到,我在翻译中享有一些自由。部分原因是我的西班牙语水平很差,部分原因是我缺乏西班牙语模因知识。

在此处输入图片说明


11

C#,拉丁文-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);
        }
    }
}

从命令行参数读取文件,写入output.txt。

例:

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

达恩,刚刚看到了C ++拉丁版本。


s/ToLatin/AdLatinam/...而且,不应该argsargumenta(中性复数)?
DLosc

@DLosc我不知道是否应该,我不知道拉丁语,但是我会信服。
卡德2015年

好东西,我正在比较通用术语的翻译。“或”应为“ aut”。
路加福音

为什么System Ratio用拉丁语?那拉丁文的比率是多少?
phuclv 2015年

@LưuVĩnhPhúc- ratio>ratione/proportio
Kade

8

Ruby,日语-AkaDama

日语中的Ruby是rubiiruビー),它很无聊,所以我将其命名为红色宝石

在ruby中,变量和方法不限于ASCII,所以类似

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

是有效的红宝石。我尽可能地使用它进行混淆您的所有基地。

我希望可以使用宝石来解析红宝石,但仍然需要进行一些丑陋的猴子修补。

您可以在上扩展TRANS_TABLE以添加翻译以使用更多方法。表中未包含的所有内容都会根据其发音(或更像是拼写)轻松地“翻译”为日语,因此eat变成えあと(“ a-ah-toe”)。

将整数转换为“非常”实用的表示法

# 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(幹,ノート)

自行运行,省略一些翻译表等:

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

要么

# 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 }

变成

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

8
用平假名而不是片假名来近似英语似乎是很不自然的(不管它的映射程度如何)。
Stephan

8

HTML5 / Javascript到法文(HTML5 Script au Caoua)

<脚本>
    var a = document.currentScript.outerHTML;
    警报(a.replace(/ var a / g,“ la变量«a»”))
    .replace(/ alert \(/ g,“ alerter(”)
    .replace(/ = / g,“ est”)
    .replace(/ outerHTML / g,“HTMLExtérieur”)
    .replace(/ \。replace \((。+)\,(。+)\)/ g,“ avec $ 1复制$ 2”]
    .replace(/ \ / \ *和\ * \ // g,“ et”)
    .replace(/"(.+?)"/ g,“«$ 1»”)
    /*and*/.replace(/currentScript/g,"scriptCourant“)
    );
</ script>

输出:

<脚本>
    变量«a»estdocument.scriptCourant.HTMLExtérieur;
    Alerter(a avec / la变量«a»/ g复制«la变量«a»»
     avec / alert \(/ g复制«alerter(»
     avec / est / g复制«est»
     avec /HTMLExtérieur/ g«HTMLExtérieur»
     avec /\.replace\((.+)\,(.+)\)/g复制副本«avec $ 1复制副本$ 2»
     avec / \ / \ *和\ * \ // g复制«et»
     avec/«(.+?)»/g复制««$ 1»»
     et avec / scriptCourant / g«scriptCourant»
    );
</ script>

1
我真的很喜欢您如何将语法重新设计为更法语!但是法语名称实际上不是表示“ CoffeeScript ”吗?
DLosc

从技术上讲,是的。但这是我当时能想到的最好的方法。您有更好的建议吗?
SuperJedi224 2015年

1
“HTML5 AVEC乐脚本AU咖啡厅去的Java”是热闹:d我们有一个类似的argotic词为“咖啡”(相关的):caoua(“かわ”)。
2015年

3
我喜欢使用海贝。
TRiG 2015年

1
应该是la变量,而不是le
Lao Lam 2015年

8

JavaScript,法语– 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);

我知道已经有一个JavaScript +法语答案,但是我的使用不同的翻译和编码方法。

该代码非常简单:遍历输入代码中的所有单词,并将其替换为translations对象中对应的法语单词。如果未列出该单词,则不会更改。

法语使用« Guillemets »代替引号,因此首先使字符串使用那些。(是的,它使用regu͘͜l̴͝a͘͜͠r͏͏e̶̸͢x̸͝pr̵͞͞e̵͞͞s̵ś̸̷i͝o̴ns̴͜来解析字符串,因此它并不总是能正常工作。)这是在自身上运行时的输出:

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

您可以使用下面的堆栈片段轻松运行代码。


3
Oui,tres bien。
Alex A.

您应在标点符号后添加空格-XD看起来更好
Conor O'Brien 2015年

7

Commodore 64 BASIC-波斯尼亚/克罗地亚/塞尔维亚语

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

这实际上将BASIC关键字替换为翻译后的关键字,因此您 能够 编写新代码时必须使用它们。

波斯尼亚语的BASIC

这个怎么运作?

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

尽管看起来这行没有多大作用,但实际上它会将字节从BASIC ROM复制到RAM。写入ROM位置的数据存储在RAM中的同一地址。

程序的最后一行切换到BASIC的RAM副本:

POKE 1,PEEK(1) AND 254

内存地址41118-41373包含保留的BASIC关键字的完整列表。这些单词的ASCII字符以令牌编号顺序存储。每个单词的最后一个字母的位#7设置为指示单词的结尾(ASCII值+ 128)。

第20-100行包含翻译后的关键字。行110-200如上所述读取了存储器中的关键字。


5
你可能会的第一人,其代码工作的蜕变!
CJ Dennis

当C64 BASIC的创建者完成他的工作时,他站起来并宣称“我渴望人们可以在波斯尼亚语中对C64进行编程的一天”。(可耻的是,他对640k以上的RAM并不是那么有远见)
Mark K Cowan 2015年

但是转换已转换为RAM,重新启动将导致RAM被清除,是吗?
2015年

5

PHP-葡萄牙语(pt-PT /半pt-BR)

事实证明这很复杂,而且巨大!

<?

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

请记住,此代码是与自身匹配的!它可能与其他代码部分兼容。


输出,翻译:

<?

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

我试图尽可能地尊重语法。

第一行就是一个例子:

echo preg_replace_callback

回声是一个动作,动作是动词。葡萄牙语中的所有动词均以结尾r。没有上下文的
翻译echo将是eco,而在上下文中则必须是ecoar(进行回显)。

而且,该功能preg_replace_callback具有独特之处。
动作必须是第一个单词。
从字面上翻译,它应该是expressão_regular_substitui_executável,这是经过可怕翻译的!(这意味着replace the callback using a regular expression
因此,必须格外小心并交换第一个和第二个单词,所以它是substituir_expressão_regular_executável,这要好一些。

count剩下的其他功能(如)无需r引爆命令即可(例如,如果您是专横的)。

有些单词看起来很奇怪...
string是什么意思corda,但如果我正确翻译了,那就是cadeia contínua/ininterrupta de caracteres

要在所有的添加,我也翻译了一些符号和运算符($==>)。
感谢您@DLosc对翻译的想法$进入


2
您可以使用葡萄牙语的货币符号代替$,类似于该语言
DLosc 2015年

@DLosc非常感谢您的想法。我继续并翻译了其他运算符和符号。
Ismael Miguel

4

Fondamentale Visuale .RETE- Visual Basic .NET,翻译成意大利文

该程序非常简单(旨在翻译自身)。

一些要点:

  • I / O:这是一个具有明显功能的模块,可以调用

  • 语法大部分是正确的(感觉几乎是自然的)

  • 英文和意大利文的单词位置不同,因此我无法(轻松地)编写一些函数来解决该问题,并且首选静态翻译对

  • 我将命令式动词与第二人称共轭,如按义大利语意大利语翻译,它们听起来和感觉是错误的(就像Windows 8+在第一人称中说话一样错误)

  • 翻译对模糊不清,所以英语的翻译对也不会翻译。因此,如果有口译员,翻译后的程序将可以正常工作,而 我只剩下一些"+"以避免过度翻译(许多英语单词包含在意大利语中,因此最终将意大利语翻译成意大利语并带有后缀)

意大利语模块

    昏暗令牌作为新列表(元组(字符串,字符串))

    Sub AddPair(a作为字符串,b作为字符串)
        Tokens.Add(元组。创建(a,b))
    结束子

    子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”,“ quindiaggiungerò”)
        AddPair(“ Function”,“ Funzione”):AddPair(“ Dim”,“ Def”)
        AddPair(“ a”,“ una”):AddPair(“ support”,“ il s” +“ upporto”)
        AddPair(“二手类型”,“ i tipi utilizzati”)
        REM意大利人缺乏形容词的性别倾向形式
        REM,所以我将仅添加对二手类型的支持
        AddPair(“ New List”,“ una Nuova Lista”)
        AddPair(“ Create”,“ Crea”):AddPair(“ End”,“ Fine”)
        AddPair(“ REM”,“ RIC”):AddPair(“表示”,“ per”)
        AddPair(“性别独立形式”,“独立形式”)
        AddPair(“ String”,“ Sequenza”):AddPair(“形容词”,“ gli aggettivi”)
        AddPair(“ TranslateToItalian”,“ TraduciInItaliano”)
    结束子

    函数TranslateToItalian(o作为字符串)作为字符串
        Dim ret As String = o:init()
        对于每个t作为标记中的元组(字符串,字符串)
            ret = ret.Replace(t.Item1,t.Item2)
        下一个
        返回ret
    结束功能

终端模块

意大利语,我们开始!

结果本身:

意大利语模块

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

    Proc AggiungiCoppia(a接续序列,b接续序列)
        Frammenti.Add(Coppia.Crea(a,b))
    精细加工

    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(“ quindiaggiungerò”,“ quindiaggiungerò”)
        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 hauna forma indipendente dalgenere)
        RIC quindiaggiungerò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(“正式独立形式”,“独立独立形式”)
        AggiungiCoppia(“ Sequenza”,“ Sequenza”):AggiungiCoppia(“ gli aggettivi”,“ gli aggettivi”)
        AggiungiCoppia(“ TraduciInItaliano”,“ TraduciInItaliano”)
    精细加工

    Funzione TraduciInItaliano(o Come Sequenza)Come Sequenza
        Def ret Come Sequenza = o:iniz()
        每位到来的科隆(Di Sequenza,Sequenza)在Frammenti
            ret = ret.Replace(t.Item1,t.Item2)
        Appresso
        返回ret
    精美的Funzione

精细模

谢谢您的回答!请注意以下几点:您也应该在评论中翻译英文文本,我仍然可以看到许多英文单词,形式为"Mod" + "ule"。尝试将更多目标对准挑战的精神,而非挑战。
CJ丹尼斯

@CJDennis我已经解决了!
beppe9000

3

C,西班牙文-C

通过STDIN / STDOUT输入/输出(使用./c-spanish < c-spanish.c)。

如果extra = 0将更改为extra = 1,则该程序的输出本质上是一个互斥。否则,输出是一个可编译的C程序,其工作方式类似于cat

源文件中必须有多余的空格(因为它们已替换为西班牙语版本中的字符)。

#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;
    }
}

单词翻译:

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

输出量

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

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

define西班牙语单词吗?请记住,您的代码在翻译后不必以其原始语言工作,而仅可以在解释器/编译器的假设翻译版本中使用。
CJ丹尼斯2015年

3
@CJDennis define确实是西班牙语中的一个单词(第二人称命令definir
es1024

3

Ruby,加泰罗尼亚语-鲁比

这是用ruby编写的很短的代码,所以它不是代表性的代码,但是我在函数名称上有些冗长,以示更多内容。这项练习使我想起了太多的大学课程,在这些课程中,我们使用类似的伪代码来“编程”。

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

应用于自身成为:

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

1
我敢打赌,我猜猜是什么Eliminat per simplificar codi意思!
CJ丹尼斯

我也确定可以!
rorlork 2015年

3

Python 3,Lojban

在需要重新排序汇总位置的地方,我将单词括在方括号中,例如(te tcidu fe)

码:

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)

及其输出:

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)

read变成(te tcidu fe)。它应该做其他事情吗?
CJ丹尼斯

@CJDennis不,尽管我想我可以使用下划线代替空格并抛开括号。
Tuomas Laakkonen 2015年

好。从上面的代码注释中,我认为应该重新排列一些内容!
CJ Dennis

1

Javascript ES6,世界语,Ĝavoskripto

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

我自由选择了驼背和措辞(我翻译了“转换为字符串”而不是“转换为字符串”)。等更多时间后,我会把事情复杂化。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.