Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-09-20 15:34:02 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-09-25 13:01:37 (GMT)
commit3a30d3f84ea65d4576ada44b70c434bef0a7f667 (patch)
tree6629ac81369595453b9e582f7fa52191a3d76254
parent7eec45f03174dddbfde1d1f10ceed6920a462af6 (diff)
Add management of summary property to the activity.info file
This summary is translatable as the Activity name and will be displayed in the Activity list in the Home View. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/sugar3/activity/bundlebuilder.py9
-rw-r--r--src/sugar3/bundle/activitybundle.py15
2 files changed, 24 insertions, 0 deletions
diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py
index 0e4af59..1450ec2 100644
--- a/src/sugar3/activity/bundlebuilder.py
+++ b/src/sugar3/activity/bundlebuilder.py
@@ -77,6 +77,7 @@ class Config(object):
self.tar_root_dir = None
self.xo_name = None
self.tar_name = None
+ self.summary = None
self.update()
@@ -85,6 +86,7 @@ class Config(object):
self.version = bundle.get_activity_version()
self.activity_name = bundle.get_bundle_name()
self.bundle_id = bundle.get_bundle_id()
+ self.summary = bundle.get_summary()
self.bundle_name = reduce(operator.add, self.activity_name.split())
self.bundle_root_dir = self.bundle_name + '.activity'
self.tar_root_dir = '%s-%s' % (self.bundle_name, self.version)
@@ -136,9 +138,11 @@ class Builder(object):
cat = gettext.GNUTranslations(open(mo_file, 'r'))
translated_name = cat.gettext(self.config.activity_name)
+ translated_summary = cat.gettext(self.config.summary)
linfo_file = os.path.join(localedir, 'activity.linfo')
f = open(linfo_file, 'w')
f.write('[Activity]\nname = %s\n' % translated_name)
+ f.write('summary = %s\n' % translated_summary)
f.close()
def get_files(self):
@@ -356,6 +360,11 @@ def cmd_genpot(config, args):
f.write('#: activity/activity.info:2\n')
f.write('msgid "%s"\n' % escaped_name)
f.write('msgstr ""\n')
+ if config.summary is not None:
+ escaped_summary = re.sub('([\\\\"])', '\\\\\\1', config.summary)
+ f.write('#: activity/activity.info:3\n')
+ f.write('msgid "%s"\n' % escaped_summary)
+ f.write('msgstr ""\n')
f.close()
args = ['xgettext', '--join-existing', '--language=Python',
diff --git a/src/sugar3/bundle/activitybundle.py b/src/sugar3/bundle/activitybundle.py
index 2313f41..3895673 100644
--- a/src/sugar3/bundle/activitybundle.py
+++ b/src/sugar3/bundle/activitybundle.py
@@ -62,6 +62,8 @@ class ActivityBundle(Bundle):
self._tags = None
self._activity_version = '0'
self._installation_time = os.stat(path).st_mtime
+ self._summary = None
+ self._local_summary = None
info_file = self.get_file('activity/activity.info')
if info_file is None:
@@ -75,6 +77,9 @@ class ActivityBundle(Bundle):
if self._local_name == None:
self._local_name = self._name
+ if self._local_summary == None:
+ self._local_summary = self._summary
+
def _parse_info(self, info_file):
cp = ConfigParser()
cp.readfp(info_file)
@@ -126,6 +131,9 @@ class ActivityBundle(Bundle):
(self._path, version))
self._activity_version = version
+ if cp.has_option(section, 'summary'):
+ self._summary = cp.get(section, 'summary')
+
def _get_linfo_file(self):
lang = locale.getdefaultlocale()[0]
if not lang:
@@ -152,6 +160,9 @@ class ActivityBundle(Bundle):
if cp.has_option(section, 'name'):
self._local_name = cp.get(section, 'name')
+ if cp.has_option(section, 'summary'):
+ self._local_summary = cp.get(section, 'summary')
+
if cp.has_option(section, 'tags'):
tag_list = cp.get(section, 'tags').strip(';')
self._tags = [tag.strip() for tag in tag_list.split(';')]
@@ -225,6 +236,10 @@ class ActivityBundle(Bundle):
"""Get the tags that describe the activity"""
return self._tags
+ def get_summary(self):
+ """Get the summary that describe the activity"""
+ return self._local_summary
+
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher