~webapps/unity-firefox-extension/quantal

« back to all changes in this revision

Viewing changes to po/update_template.py

  • Committer: Ken VanDine
  • Date: 2012-10-01 19:26:03 UTC
  • mfrom: (83.37.53)
  • Revision ID: ken.vandine@canonical.com-20121001192603-y07phsf5gugx7s2t
Tags: 2.3.3-0ubuntu1
releasing version 2.3.3-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
import polib
3
 
import sys
4
 
import optparse
5
 
 
6
 
parser = optparse.OptionParser(usage="usage: %prog path_to_eng_file")
7
 
 
8
 
(options, args) = parser.parse_args()
9
 
 
10
 
if args == None or len(args) != 1:
11
 
        print("ERROR: not enough arguments");
12
 
        sys.exit(1)
13
 
 
14
 
path = args[0]
15
 
 
16
 
po = polib.POFile()
17
 
po.metadata = {
18
 
    'Project-Id-Version': 'PACKAGE VERSION',
19
 
    'Report-Msgid-Bugs-To': 'you@example.com',
20
 
 
21
 
    'POT-Creation-Date': '2007-10-18 14:00+0100',
22
 
 
23
 
    'PO-Revision-Date': 'YEAR-MO-DA HO:MI+ZONE',
24
 
    'Last-Translator': 'FULL NAME <EMAIL@ADDRESS>',
25
 
    'Language-Team': 'LANGUAGE <LL@li.org>',
26
 
    'Language': '',
27
 
    'MIME-Version': '1.0',
28
 
    'Content-Type': 'text/plain; charset=utf-8',
29
 
    'Content-Transfer-Encoding': '8bit',
30
 
}
31
 
 
32
 
lines = open(path, 'r').readlines()
33
 
 
34
 
for i in range(len(lines)):
35
 
    line = lines[i]
36
 
    msg = line[line.find('=') + 1:].strip()
37
 
    entry = polib.POEntry(msgid=msg,
38
 
                          msgstr=u'',
39
 
                          occurrences=[('unity_webapps.properties', str(i))]
40
 
        )
41
 
    po.append(entry)
42
 
 
43
 
po.save('unity_firefox_extension.pot')