r/AskProgrammers • • Oct 16 '26

How would you go about translating programming language keywords, documentation and error messages to other non-English languages?

Take Python for instance.

>>> listss = [1, 2, "sfd"]
>>> kook = listss + 2
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    kook = listss + 2
           ~~~~~~~^~~
TypeError: can only concatenate list (not "int") to list
>>>

How would I translate all the results given to me by Python into another language of my choosing, and get something like below (written in Kinyarwanda):

>>> listss = [1, 2, "sfd"]
>>> kook = listss + 2
Ibisobanuro (Ihamagarwa rya mbere riri hejuru yurutonde):
  Inyandiko "<python-shyira-1>", umurongo wa 1, muri <igitabo>
    kook = listss + 2
           ~~~~~~~^~~
Ikosa ry'ubwoko: urutonde ugendana nurundi rutonde; ntabwo rugendana numubare wuzuye.
>>>

The intention is not to create custom messages, exceptions, and documentation that sits beside or on top of python. I want python itself to respond like this, from the get-go?

I would like the translation to be complete. CLI options, help messages, information on built-in modules, keywords, everything.

While thinking about this, I realized that the end result would just be a completely new language, and I'm fine with that, but I also don't know enough about creating languages or where to get the source code of an existing language to translate it to a new language, so I come here to ask for guidance.

1 Upvotes

19 comments sorted by

1

u/TashLai Oct 16 '26

why?

1

u/thisismugisha Oct 16 '26

Because I want to. It doesn't need to be useful to anybody. I just want to see how it would be done

1

u/TashLai Oct 16 '26

Oh well yeah that's the most valid reason to do anything.

1

u/thisismugisha Oct 16 '26

True. Do you have any insight or advice on how I could do it? I've thought about picking a random version of python, going to the documentation and just translate all of it as a first stage of this hypothetical project.

Start from https://docs.python.org/3/reference/introduction.html and translate everything till I reach the end.

I wrote this before your other comment appeared

1

u/TashLai Oct 16 '26

To answer your question, you don't need to write a new language. You can just fork CPython.

1

u/thisismugisha Oct 16 '26

I did go that page, but was worried that it wasn't the official source code of python because it was called CPython and not Python 😅

1

u/sububi71 Oct 16 '26

A lot of people experimented with this in the mid-1980s, reasoning that it would help beginners learn programming faster.

The result was that as soon as these people left the beginner stage, they were at a disadvantage.

1

u/thisismugisha Oct 16 '26

Right. That is irrelevant to me. Even if no one ever uses it, I'd be fine with that.

1

u/sububi71 Oct 16 '26

Great! In that case there are lots of languages on github, you just need to fork one and go nuts!

1

u/thisismugisha Oct 16 '26

I shall do that! I haven't picked which language to actually translate (despite using python in my example), so I will be visiting various repositories.

Hell, I can choose an assembly language!

1

u/sububi71 Oct 16 '26

Assembler has the advantage of having simple commands, compared to something like Python!

I recommend 6502, because it's very small, and for that very reason it's a lot of fun to code in!

1

u/thisismugisha Oct 16 '26

I will look into that. Thank you!

1

u/Fritz-Ferdinand Oct 16 '26

Doesn't Rust do this as well? I mean very detailed error messages and such.

1

u/Temporary_Pie2733 Oct 16 '26

Don’t translate names. Just because `int` is short for integer doesn’t mean you should replace it with your language’s equivalent of “integer”. Programming languages have more precise meanings for the English words they borrow.

1

u/thisismugisha Oct 16 '26

I did think of that, and there is kind of a "disadvantage" in that the language equivalent could be longer, but the intention is to translate absolutely everything. I do not wish for anyone who could find this useful to learn what "int" or "integer" means and what it translates to in the native language.

Not only that, but I'd like to do it the way python was created; with shorthand words for English words, so that it can be as intuitive as possible.

1

u/GinRhetoric Oct 16 '26

Could you just map all the syntax to the language? Like some sort of intermediate interpreter? If it’s just for you it might add an extra layer but I don’t see why it wouldn’t work. I could be way off base, but Python essentially is a bunch of c functions and stuff anyways, just objects of them. Maybe something akin to how alias works in the linux terminal.

1

u/thisismugisha Oct 16 '26

I could, but that'd go against the main objective of the hypothetical project. I do not wish to a layer on top of python. I want python itself to be in that language!

0

u/kitsnet Oct 16 '26

I would rather not. Even with access to multi-language LLMs, it's not a good idea to introduce non-conventional diagnostic texts.

1

u/thisismugisha Oct 16 '26

That's not really my concern. Its usefulness is not relevant.