[gnome-keysign: 2/18] desktop extract: regard the desktop file spec for translatable strings
- From: Tobias Mueller <tobiasmue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keysign: 2/18] desktop extract: regard the desktop file spec for translatable strings
- Date: Fri, 15 Dec 2017 16:29:25 +0000 (UTC)
commit a46c6ee1898d90a312099b08049d276c211d7c43
Author: Tobias Mueller <muelli cryptobitch de>
Date: Fri Oct 6 15:43:11 2017 +0200
desktop extract: regard the desktop file spec for translatable strings
This makes the extractor behave more like xgettext.
babelglade/__init__.py | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/babelglade/__init__.py b/babelglade/__init__.py
index f629024..8825f15 100644
--- a/babelglade/__init__.py
+++ b/babelglade/__init__.py
@@ -116,15 +116,30 @@ def extract_glade(fileobj, keywords, comment_tags, options):
+
+# All localestrings from https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
+TRANSLATABLE = (
+ 'Name',
+ 'GenericName',
+ 'Comment',
+ 'Icon',
+ 'Keywords',
+)
+
def extract_desktop(fileobj, keywords, comment_tags, options):
for lineno, line in enumerate(fileobj, 1):
- comments = []
- if line.strip().startswith('_'):
- l = line.split('=', 1)
- funcname, message = l[0:2]
- funcname = funcname.lstrip('_')
- comments.append(funcname)
- funcname = '' # FIXME: Why can I not assign that name to funcname?
- yield (lineno, funcname, message.strip(), comments)
+ for t in TRANSLATABLE:
+ if not line.startswith(t):
+ continue
+ else:
+ comments = []
+ key_value = line.split('=', 1)
+ key, value = key_value[0:2]
+
+ funcname = key # FIXME: Why can I not assign that name to funcname?
+ funcname = ''
+ message = value
+ comments.append(key)
+ yield (lineno, funcname, message.strip(), comments)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]