python - Folder organization for easy translation -
i'm making application in python released in different languages.
so i'm wondering best way organize project don't have literal strings in source code , replace them hand.
here's have far thinking , information gather:
first have module each language contain every strings application:
english.py:
greeting = 'hello world!'
french.py:
greeting = 'bonjour le monde!'
then code written mymodule.py:
if lang == 'eng': #how mimick 'preprocessor' in python? import english str elif lang == 'fr': import french str if __name__ == '__main__': print(str.greeting)
- does make sense way?
- should every language have it's own module?
- how achieve preprocessing conditionals of c in pythonesque way?
i'm thinking there's no way hasn't been asked before maybe it's cuz english isn't first language , i'm doing wrong can't find info on best practices this.
my system fu** try this:
import os lang = os.getenv('lang') if lang == 'en_us,': import english str elif lang == 'fr_ch': import french str if __name__ == '__main__': print(str.greeting)
i none, give try.
Comments
Post a Comment