ELOT-743 translator

I had a task to translate a big Greek address book in English.

Due to the fact that Greek Language is full of special characters, a problem occurred when passports where to be created. There should be a fixed way to translate names from Greek to English. So the ELOT-743 standard was created to solve the confusion.

Here you see most of it:

Greek English Greek English Greek English Greek English
α a Ή I Ξ X Ύ Y
ά a θ th ο o Ϋ Y
Α A Θ TH ό o φ f
Ά A ι i Ο O Φ F
β v ί i Ό O χ ch
Β V ϊ i π p Χ CH
γ γ ΐ i Π P ψ ps
Γ G Ι I ρ r Ψ PS
δ d Ί I Ρ R ω o
Δ D Ϊ I σ s ώ o
ε e κ k ς s Ω O
έ e Κ K Σ S Ώ O
Ε E λ l τ t ΟΥ OU
Έ E Λ L Τ T ου ou
ζ z μ m υ y ού ou
Ζ Z Μ M ύ y Ού Ou
η i ν n ϋ y γγ ng
ή i Ν N ΰ y ΓΓ NG
Η I ξ x Υ Y Γγ Ng

So to save my self from the abyss and to avoid the government’s site that had the capability to translate only small text, I wrote a python script myself.

Here is the dictionary to translate the strings:

# -*- coding= utf8 -*-
"""Main source https://www.sete.gr/files/Media/Egkyklioi/040707Latin-Greek.pdf

And here is the actual script:


# -*- coding= utf8 -*-
import sys, getopt
from string import maketrans
from elot743 import *

def replace_all(text, dic):
     for i, j in dic.iteritems():
              if i != j:
                  text = text.replace(i, j)
     text.replace(',' , '\n')
     return text

def readFile(infile):
     print "reading file",infile,"...\n"
     i = open(infile, 'r')
     for line in i:

     return array
     print "\nfinished reading file!\n"

def writeFile(outfile, array):
     print "writing to file",outfile,"...\n"
     print array
     o = open(outfile, 'w')
     for item in array:
           o.write("%s\n" % item)
     print "\nfinished writing to file!\n"

def main(argv):
   inputfile = ''
   outputfile = ''
      opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
   except getopt.GetoptError:
      print 'names.py -i  -o '
   for opt, arg in opts:
      if opt == '-h':
         print 'names.py -i  -o '
      elif opt in ("-i", "--ifile"):
         inputfile = arg
      elif opt in ("-o", "--ofile"):
         outputfile = arg
   if inputfile == '':
      inputfile = raw_input('File where the names to be translated exist (ex. names.txt) : ')
   if outputfile =='':
      outputfile = raw_input('File where the translated names will be written (ex. trnames.txt) : ')
   print 'Input file is "', inputfile
   print 'Output file is "', outputfile


   print 'File is translated!'

if __name__ == "__main__":

To run the script, you can call it from command line by typing:

python names.py -i  -o

Where the text file where the names to be translated exist and the text file where the translated names will be written.


You can run it without the arguments and it will prompt you for the file names.

I believe that it will not be helpful to many but it could be a relatively good example of using dictionaries in Python;)

The project code can be found here on GitHub. Feel free to use it.

Feel free to leave your comment below!

Comment details and information

To make a comment, please send an e-mail using the button below. Your e-mail address won't be shared and will be deleted from my records after the comment is published. If you don't want your real name to be credited alongside your comment, please specify the name you would like to use. If you would like your name to link to a specific URL, please share that as well. Thank you.