72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
1 |
#!/usr/bin/python
|
2 |
||
3 |
import sys |
|
4 |
import os |
|
5 |
import gettext |
|
6 |
import apt |
|
7 |
import re |
|
8 |
||
9 |
from LanguageSelector.LanguageSelector import * |
|
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
10 |
from LanguageSelector.CheckLanguageSupport import * |
72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
11 |
|
12 |
from optparse import OptionParser |
|
13 |
from gettext import gettext as _ |
|
14 |
||
15 |
||
16 |
if __name__ == "__main__": |
|
17 |
parser = OptionParser() |
|
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
18 |
parser.add_option("-l", "--language", default=None, |
72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
19 |
help=_("target language code")) |
20 |
parser.add_option("-d", "--datadir", |
|
21 |
default="/usr/share/language-selector/", |
|
22 |
help=_("alternative datadir")) |
|
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
23 |
parser.add_option("-p", "--package", default=None, help=_("check for the given package(s) only -- separate packagenames by comma")) |
72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
24 |
parser.add_option("-a", "--all", action='store_true', default=False, |
25 |
help=_("check all available languages")) |
|
76
by Colin Watson
* Add --show-installed option to check-language-support, so that ubiquity |
26 |
parser.add_option("--show-installed", |
27 |
action='store_true', default=False, |
|
28 |
help=_("show installed packages as well as missing ones")) |
|
72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
29 |
(options, args) = parser.parse_args() |
30 |
||
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
31 |
# sanity check for language code
|
32 |
if (options.language and |
|
33 |
not re.match('^([a-z]{2,3}(_[A-Z]{2})?(@[a-z]+)?|(zh-han[st]))$', options.language)): |
|
34 |
print ("Error: Unsupported language code format.\n\ |
|
72
by Arne Goetje
* Add openoffice.org-help-* and evolution-documentation-* to the |
35 |
Supported formats: 'll' or 'lll'\n\ |
36 |
'll_CC' or 'lll_CC'\n\ |
|
37 |
'll@variant' or 'lll@variant'\n\ |
|
38 |
'll_CC@variant' or 'lll_CC@variant'\n\ |
|
39 |
Also supported are 'zh-hans' and 'zh-hant'.") |
|
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
40 |
sys.exit(1) |
41 |
||
42 |
cl = CheckLanguageSupport(options.datadir) |
|
43 |
try: |
|
44 |
packages = [] |
|
45 |
if options.package: |
|
46 |
packages = options.package.split(',') |
|
82
by Arne Goetje, Michael Vogt, Arne Goetje
[ Michael Vogt ] |
47 |
missing = cl.getMissingPackages(language=options.language, all=options.all, packages=packages, showInstalled=options.show_installed) |
79
by Arne Goetje
* new UI to allow separate language and locale settings (LP: #40669) |
48 |
if missing: |
49 |
print (' '.join(sorted(missing))) |
|
50 |
except SoftwareIndexBroken: |
|
51 |
print ("%s\n%s" % ( |
|
52 |
_("Software database is broken"), |
|
53 |
_("It is impossible to install or remove any software. " |
|
54 |
"Please use the package manager \"Synaptic\" or run " |
|
55 |
"\"sudo apt-get install -f\" in a terminal to fix " |
|
56 |
"this issue at first."))) |
|
57 |
sys.exit(1) |
|
58 |