forked from capocchi/DEVSimPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslation.py
More file actions
33 lines (23 loc) · 1.01 KB
/
Translation.py
File metadata and controls
33 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
import os
import sys
# make the template
os.system("xgettext -k_ -kN_ --msgid-bugs-address=capocchi@univ-corse.fr -o ./locale/DEVSimPy.pot *.py")
# what language you want trnaslate
language = input("What po file do you want changed ? (fr or en):")
if language =='en':
# make po file
os.system("msginit -i ./locale/DEVSimPy.pot -o ./locale/en/LC_MESSAGES/DEVSimPy.po")
# compile it
os.system("msgfmt ./locale/en/LC_MESSAGES/DEVSimPy.po -o ./locale/en/LC_MESSAGES/DEVSimPy.mo")
else:
# for french, you can only update or rewrite the .po
update = input("Do you want to update the fr .po ? (y,n):")
if update == 'y':
os.system("msgmerge -U ./locale/fr/LC_MESSAGES/DEVSimPy.po ./locale/DEVSimPy.pot")
else:
os.system("msginit -i ./locale/DEVSimPy.pot -o ./locale/fr/LC_MESSAGES/DEVSimPy.po")
# edit the .po file for update or write
os.system("kwrite ./locale/fr/LC_MESSAGES/DEVSimPy.po")
#compile
os.system("msgfmt ./locale/fr/LC_MESSAGES/DEVSimPy.po -o ./locale/fr/LC_MESSAGES/DEVSimPy.mo")