summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2012-10-16 11:51:09 +0900
committerDaiki Ueno <ueno@unixuser.org>2012-10-18 09:59:37 +0900
commit2f03ff63b8f429a5bb368ce55122961e1271a434 (patch)
tree970b18ef624af707251ea756aa53475f5c43fcad /tools
parent0a643fd9e6e87d5e74da7cc00bb0c63ee79d1330 (diff)
downloadcaribou-2f03ff63b8f429a5bb368ce55122961e1271a434.tar.gz
make_schema: don't translate strings in schema files
Prevent summary and description fields in gschema files from being translated. Also embed gettext-domain in schemas. https://bugzilla.gnome.org/show_bug.cgi?id=686200
Diffstat (limited to 'tools')
-rwxr-xr-xtools/make_schema.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/tools/make_schema.py b/tools/make_schema.py
index 7237ac4..f8386dc 100755
--- a/tools/make_schema.py
+++ b/tools/make_schema.py
@@ -9,18 +9,20 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from caribou.settings import caribou_settings
class SchemasMaker:
- def __init__(self, settings):
+ def __init__(self, settings, domain):
self.settings = settings
+ self.domain = domain
- def create_schemas(self):
+ def create_schemas(self, output):
doc = xml.dom.minidom.Document()
schemafile = doc.createElement('schemalist')
schema = doc.createElement('schema')
schema.setAttribute("id", self.settings.schema_id)
+ schema.setAttribute("gettext-domain", self.domain)
schemafile.appendChild(schema)
self._create_schema(self.settings, doc, schema)
- fp = open("%s.gschema.xml.in" % self.settings.schema_id, 'w')
+ fp = open(output, 'w')
self._pretty_xml(fp, schemafile)
fp.close()
@@ -77,15 +79,27 @@ class SchemasMaker:
if __name__ == "__main__":
from caribou.settings import AllSettings
+ from locale import setlocale, LC_ALL
+ import argparse
- if (len(sys.argv) != 2):
- print "usage: %s <schema id>" % sys.argv[0]
- sys.exit(1)
+ parser = argparse.ArgumentParser(description='make_schema')
- modulename, settings_obj = sys.argv[-1].rsplit('.', 1)
+ parser.add_argument('settings_object', type=str,
+ help='Settings object')
+ parser.add_argument('-o', '--output', type=str, required=True,
+ help='Output file name')
+ parser.add_argument('-d', '--domain', type=str, default='caribou',
+ help='Translation domain')
+
+ args = parser.parse_args()
+
+ # prevent _summary and _description from being translated
+ setlocale(LC_ALL, "C")
+
+ modulename, settings_obj = args.settings_object.rsplit('.', 1)
module = __import__(modulename, locals(), globals(), [settings_obj])
settings = getattr(module, settings_obj)
- maker = SchemasMaker(settings)
- maker.create_schemas()
+ maker = SchemasMaker(settings, args.domain)
+ maker.create_schemas(args.output)