]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/webapp/translations.py
8 def __init__(self
, path
, project
):
10 self
.project
= project
12 p
= os
.popen("msgfmt -v --statistics %s 2>&1" % self
.path
)
13 self
.line
= p
.readlines()[0]
15 def __cmp__(self
, other
):
16 return cmp(self
.lang
, other
.lang
)
21 for lang
in tornado
.locale
.LOCALE_NAMES
.keys():
22 ret
[lang
[:2]] = "%(name)s (%(name_en)s)" % tornado
.locale
.LOCALE_NAMES
[lang
]
27 return os
.path
.basename(self
.path
)[:-3]
31 return self
.code2lang
.get(self
.code
, "Unknown (%s)" % self
.code
)
35 return int(self
.line
.split()[0])
38 def untranslated(self
):
55 if not self
.project
.total_strings
:
58 return "%3.1f%%" % (self
.translated
* 100 / self
.project
.total_strings
)
61 class Project(object):
62 def __init__(self
, id, path
, **kwargs
):
65 self
._name
= kwargs
.pop("name")
66 self
.desc
= kwargs
.pop("desc")
68 self
._translations
= []
79 def translations(self
):
80 if not self
._translations
:
81 for path
in os
.listdir(self
.path
):
82 if path
.endswith(".po"):
83 self
._translations
.append(Po(os
.path
.join(self
.path
, path
), self
))
84 self
._translations
.sort()
85 return self
._translations
88 for path
in os
.listdir(self
.path
):
89 if path
.endswith(".pot"):
90 self
.pot
= Po(os
.path
.join(self
.path
, path
), self
)
94 def total_strings(self
):
97 return self
.pot
.untranslated
100 Project("pomona", "/srv/checkout/ipfire-3.x/src/pomona/po",
101 name
="Pomona", desc
="The pomona installer for ipfire."),