summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2022-08-17 22:02:01 +0300
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2022-12-21 16:45:08 +0000
commitfe8eb2c01e6f4c30eb593eb526892829dbba1804 (patch)
treeccbb379d27a36f96f04a484911ff06d2cd59e18e /solenv
parent87e7a2f60ec823aed6738fb081ad358b5d0536e6 (diff)
tdf#140215 Simplify the handling of .ulf files
Now the headings in the ulf files for .desktop files are in the form [filename_Key] Gallery names are also adjusted to fit the new scheme, where there is no longer a need to pass a --key argument to desktop-translate.py Sync comments with .desktop files and the remaining .ulf and remove obsolete Mandriva Linux meta data while at it. Script to mass-replace relevant names in translations will be provided to infra. Change-Id: I87e8028aa5b66f5f5560efa62ddd9b1e5b61c49c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138455 Tested-by: Jenkins Reviewed-by: Sophie Gautier <sophi@libreoffice.org> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/desktop-translate.py31
-rw-r--r--solenv/gbuild/Gallery.mk2
2 files changed, 16 insertions, 17 deletions
diff --git a/solenv/bin/desktop-translate.py b/solenv/bin/desktop-translate.py
index edc377dab15b..7075a51f9d97 100644
--- a/solenv/bin/desktop-translate.py
+++ b/solenv/bin/desktop-translate.py
@@ -54,7 +54,6 @@ def encode_desktop_string(s_value):
parser = argparse.ArgumentParser()
parser.add_argument("-p", dest="productname", default="LibreOffice")
parser.add_argument("-d", dest="workdir", default=".")
-parser.add_argument("--key", dest="key")
parser.add_argument("--prefix", dest="prefix", default="")
parser.add_argument("--ext", dest="ext")
parser.add_argument("--template-dir", dest="template_dir", default=None)
@@ -67,13 +66,6 @@ if o.template_dir is None:
else:
template_dir = o.template_dir
-# hack for unity section
-if o.key == "UnityQuickList":
- OUTKEY = "Name"
-else:
- OUTKEY = o.key
-
-
templates = {}
# open input file
@@ -85,14 +77,18 @@ template = None
for line in source:
if line.strip() == "":
continue
+ # the headings in the ulf files for .desktop files are in the form [filename_Key]
if line[0] == "[":
- template = line.split("]", 1)[0][1:]
+ heading = line.split("]", 1)[0][1:]
+ template = heading.split("_", 1)[0]
+ key = heading.split("_", 1)[1]
entry = {}
# For every section in the specified ulf file there should exist
# a template file in $workdir ..
entry["outfile"] = f"{template_dir}{template}.{o.ext}"
entry["translations"] = {}
- templates[template] = entry
+ entry["key"] = key
+ templates[heading] = entry
else:
# split locale = "value" into 2 strings
if " = " not in line:
@@ -116,7 +112,7 @@ for line in source:
locale = locale.replace("-", "_")
- templates[template]["translations"][locale] = value
+ templates[heading]["translations"][locale] = value
source.close()
@@ -145,15 +141,18 @@ for template, entries in templates.items():
# emit the template to the output file
for line in template_file:
keyline = line
- if keyline.startswith(o.key):
- keyline = OUTKEY + keyline[len(o.key) :]
+ if keyline.startswith(entries["key"]):
+ # hack for Unity section
+ if entries["key"] == "UnityQuickList":
+ OUTKEY = "Name"
+ else:
+ OUTKEY = entries["key"]
+ keyline = OUTKEY + keyline[len(entries["key"]) :]
outfile.write(keyline)
- if o.key in line:
+ if entries["key"] in line:
translations = entries["translations"]
for locale in sorted(translations.keys()):
value = translations.get(locale, None)
- # print "locale is $locale\n";
- # print "value is $value\n";
if value:
if o.ext in ("desktop", "str"):
if o.ext == "desktop":
diff --git a/solenv/gbuild/Gallery.mk b/solenv/gbuild/Gallery.mk
index 78b9e70ae753..3d3fa2092edc 100644
--- a/solenv/gbuild/Gallery.mk
+++ b/solenv/gbuild/Gallery.mk
@@ -37,7 +37,7 @@ define gb_Gallery__command_str
cp -f $(GALLERY_STRFILE) $@ && \
$(call gb_ExternalExecutable_get_command,python) \
$(gb_Gallery_TRANSLATE) \
- --ext "str" --key "name" \
+ --ext "str" \
-d $(GALLERY_WORKDIR) \
$(GALLERY_ULFFILE)
endef