Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorent <florent@toopy.org>2012-04-22 23:31:35 (GMT)
committer florent <florent@toopy.org>2012-04-22 23:31:35 (GMT)
commitb56b27fd1c4b93505c4f6a0e3584a8793a763d4f (patch)
tree5c9b429714f863a4b991e356b7a297cec622d849
parent8197201134b23eedc0f5e38514325328a8e864ea (diff)
update doc list in scripts + sort po content in po-to-sphinx script
-rw-r--r--utils/po-to-sphinx.py44
-rw-r--r--utils/sphinx-to-po.py18
2 files changed, 60 insertions, 2 deletions
diff --git a/utils/po-to-sphinx.py b/utils/po-to-sphinx.py
index a994460..cf047e0 100644
--- a/utils/po-to-sphinx.py
+++ b/utils/po-to-sphinx.py
@@ -3,8 +3,24 @@ import codecs, os, subprocess
SRC = [
'index',
'credits',
- 'summary',
'prolog',
+ 'intro',
+ 'section_1',
+ 'chapter_1',
+ 'chapter_2',
+ 'chapter_3',
+ 'chapter_4',
+ 'chapter_5',
+ 'chapter_6',
+ 'chapter_7',
+ 'chapter_8',
+ 'section_2',
+ 'chapter_9',
+ 'chapter_10',
+ 'chapter_11',
+ 'chapter_12',
+ 'annex',
+ 'credits_photo',
]
OUT = 'ceibal'
@@ -14,6 +30,32 @@ FILE_SEP = '^-^_^-^_^-^_^-^_^-^_^-^_^-^_^-^_'
path_in_po = os.path.join('tmp', '%s-fr.po' % OUT)
path_in_txt = os.path.join('tmp', '%s.txt' % OUT)
+# split po in blocks to sort them
+block_list = dict()
+with codecs.open(path_in_po, 'rb', 'utf-8') as f:
+ # init block and key
+ block = ''
+ key = 0
+ for r in f.readlines():
+ if r.startswith('#'):
+ if ':' in r:
+ # add new block
+ block_list[key] = block
+ # reset block and key
+ block = ''
+ key = int(r.strip().split(':')[-1])
+ # add current row
+ block += r
+ # add last block
+ block_list[key] = block
+
+# sort blocks and write in po
+with codecs.open(path_in_po, 'wb', 'utf-8') as f:
+ keys = block_list.keys()
+ keys.sort()
+ for k in keys:
+ f.write(block_list[k])
+
subprocess.call('po2txt --encoding utf-8 %s %s' % (path_in_po, path_in_txt),
shell=True)
diff --git a/utils/sphinx-to-po.py b/utils/sphinx-to-po.py
index 77ffac7..2781360 100644
--- a/utils/sphinx-to-po.py
+++ b/utils/sphinx-to-po.py
@@ -3,8 +3,24 @@ import codecs, os, subprocess
SRC = [
'index',
'credits',
- 'summary',
'prolog',
+ 'intro',
+ 'section_1',
+ 'chapter_1',
+ 'chapter_2',
+ 'chapter_3',
+ 'chapter_4',
+ 'chapter_5',
+ 'chapter_6',
+ 'chapter_7',
+ 'chapter_8',
+ 'section_2',
+ 'chapter_9',
+ 'chapter_10',
+ 'chapter_11',
+ 'chapter_12',
+ 'annex',
+ 'credits_photo',
]
OUT = 'ceibal'