File tree 1 file changed +52
-0
lines changed
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 6
6
# and there is no translation for that sentence/paragraph it updates the .po file with the translated text
7
7
# from the .rst file.
8
8
9
+ import glob
10
+ import os
9
11
import polib # fades
12
+
13
+
14
+ PO_DIR = os .path .abspath (
15
+ os .path .join (
16
+ os .path .dirname (__file__ ),
17
+ '..' ,
18
+ ))
19
+
20
+ RST_DIR = os .path .abspath (
21
+ os .path .join (
22
+ os .path .dirname (__file__ ),
23
+ 'tutorialpyar' ,
24
+ ))
25
+
26
+
27
+
28
+ def get_rst_file (pofilename ):
29
+ """Given a .po filename returns the corresponding .rst filename"""
30
+ pass
31
+
32
+
33
+ def get_rst_translation_text (rstfilename , text ):
34
+ """Given an rstfilename an a text returns the corresponding translated text if exists"""
35
+ pass
36
+
37
+
38
+ def update_po_translation (pofilename , english , spanish ):
39
+ """Update the pofilename with the translated spanish text"""
40
+ pass
41
+
42
+
43
+
44
+ for pofilename in glob .glob (PO_DIR + '**/*.po' ):
45
+ rstfilename = get_rst_file (pofilename )
46
+ if rst is None :
47
+ continue
48
+
49
+ po = polib .pofile (pofilename )
50
+ for entry in po :
51
+ english_text = entry .msgid
52
+ spanish_text = entry .msgstr
53
+ if spanish_text :
54
+ # Do not override already translated text
55
+ continue
56
+
57
+ translated_text = get_rst_translation_text (rstfilename , english_text )
58
+ if translated_text is None :
59
+ continue
60
+
61
+ update_po_translation (po , english_text , translated_text )
You can’t perform that action at this time.
0 commit comments