This little piece of code lets you write python code in any language you deem fit. This is meant as a tool to teach people programming without having to teach them English first.
Python3.x is supported.
The basic python language is translated and ready for offline use. You can add your own languages. Non standard libraries are not yet supported.
This is a simple transliteration program. The idea is as follows.
- Get a mapping for a language from Google translate.
- Store the mapping as a dictionary.
- Get a sample source file.
- Identify what language it is written in.
- Load the required language and translate into normal Python.
- Run the newly generated file.
git clone https://github.com/theSage21/pytongue.git
cd pytongue
git submodule init
git submodule update
In order to train a new language use the Wikipedia list of ISO-codes
The codes must be supported by Google Translate
Get new languages by:
cd languages
python3 map_generator.py
- enter the language code you want to train.
- Write source code in your natural language.
- The first line of the source code must be
# lang_code
- The
lang_code
must be supported by translate.google.com - The
lang_code
must be specified in the source file
- The
- Run with
./pytongue.sh my_code.py
instead ofpython mycode.py
If you were to write a useless example in Hindi it might be something like this.
# HI
छाप('नमस्ते दुनिया!')
के_लिए i में range(10):
छाप(i)
जबकि 1:
छाप('नमस्ते दुनिया!')
This translates to
# HI
print('Hello world!')
for i in range(10):
print(i)
while 1:
print('Hello World!')
To generate examples in other languages:
- Create a mapping for the required language. (we assume ES here)
- Go to root folder and
python3 make_examples.py
- You example is generated in
examples/ES_example.py
To generate a different example edit the examples/example.py
file.
If the translation provided by Google feels wrong there is nothing to worry about. Since the translation is actually implemented using a dictionary, all you have to do is change the key-value pairs.
That is to automate the process of translation mapping. Translating a lot of words gets tiring very quickly.
You can create your own mapping if you want in any language you want.