Folder organization for easy translation
Question: I'm making an application in Python that will be released in different
languages.

So I'm wondering what is the best way to organize a project so you don't have
to look for literal strings in the source code and replace them by hand.

Here's what I have so far from some thinking and the information I could
gather:

First we have a module for each language to contain every strings for the
application:

english.py:

    
    
    greeting = 'Hello world!'
    

french.py:

    
    
    greeting = 'Bonjour le monde!'
    

then the code would be written so myModule.py:

    
    
    if lang == 'eng': #How do you mimick a 'preprocessor' in Python?
        import english as str
    elif lang == 'fr':
        import french as str
    
    if __name__ == '__main__':
        print(str.greeting)
    

  * Does it make sense to do it this way? 
  * Should every language have it's own module?
  * How do you achieve the preprocessing conditionals of C in a pythonesque way?

I'm thinking there's no way it hasn't been asked before but maybe it's cuz
English isn't my first language and I'm doing it wrong but I can't find any
good info on the best practices to do this.


Answer: My system is fu*_*_ up but try this:

    
    
     import os
     lang = os.getenv('LANG')
    
     if lang == 'en_US,': 
        import english as str
     elif lang == 'fr_CH':
        import french as str
    
     if __name__ == '__main__':
        print(str.greeting)
    

I get None, but give it a try.

