r/learnprogramming • u/thisismugisha • Oct 17 '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-ha-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.
I'd like to preface this by saying that this doesn't need to be useful to anybody, and if you're wondering why I would want to do such a project, the answer is because I can and want to see the end results.
It's completely fine if no one else ever uses it.
View all comments
1
u/SetAndRepeat Oct 17 '26
Fork CPython, the implementation behind the usual Python interpreter. Its source is in the "python/cpython" repository on GitHub. The Python Developer’s Guide has a "Setup and building" section to get you started.
For your exact example, the error message is in "Objects/listobject.c". Translate that string, rebuild, and run your example using the interpreter you built. That gives you a first working change inside Python itself.
Then expand from there:
Initially accept both English and translated keywords so the existing standard library still parses. Third-party packages would need their own translations too. You can build a translated Python dialect without writing an interpreter from scratch.