include appinfo metadata file in translation

This commit is contained in:
Juergen E. Fischer 2018-09-25 01:26:30 +02:00 committed by Jürgen Fischer
parent 8e845b9a96
commit 52a80d895c
11 changed files with 230 additions and 99 deletions

View File

@ -20,22 +20,36 @@ MACRO(ADD_TRANSLATION_FILES _sources )
ENDMACRO(ADD_TRANSLATION_FILES)
# make sure the output directory exists
file(MAKE_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/i18n)
FILE(MAKE_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/i18n)
SET(TS_FILES qgis_ar.ts qgis_bg.ts qgis_bs.ts qgis_ca.ts qgis_cs.ts qgis_da.ts qgis_de.ts qgis_el.ts qgis_eo.ts qgis_es.ts qgis_et.ts qgis_eu.ts qgis_fi.ts qgis_fr.ts qgis_gl.ts qgis_hi.ts qgis_hu.ts qgis_id.ts qgis_is.ts qgis_it.ts qgis_ja.ts qgis_km.ts qgis_ko.ts qgis_ky.ts qgis_lt.ts qgis_lv.ts qgis_nb.ts qgis_nl.ts qgis_pl.ts qgis_pt_BR.ts qgis_pt_PT.ts qgis_ro.ts qgis_ru.ts qgis_sl.ts qgis_sv.ts qgis_tr.ts qgis_uk.ts qgis_vi.ts qgis_zh-Hans.ts qgis_zh-Hant.ts)
ADD_TRANSLATION_FILES (QM_FILES ${TS_FILES})
IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/org.qgis.qgis.desktop ${CMAKE_BINARY_DIR}/org.qgis.qgis.appdata.xml
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${CMAKE_SOURCE_DIR}/scripts/ts2appinfo.py "${CMAKE_BINARY_DIR}"
COMMENT "Updating appinfo files..."
DEPENDS ${QM_FILES}
)
SET(MD_FILES ${CMAKE_BINARY_DIR}/org.qgis.qgis.desktop ${CMAKE_BINARY_DIR}/org.qgis.qgis.appdata.xml)
INSTALL(FILES ${CMAKE_BINARY_DIR}/org.qgis.qgis.desktop DESTINATION share/applications)
INSTALL(FILES ${CMAKE_BINARY_DIR}/org.qgis.qgis.appdata.xml DESTINATION share/metainfo)
ENDIF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# creating a custom target is needed to make the files build
# "ALL" means that it will be run by default
ADD_CUSTOM_TARGET (translations ALL
DEPENDS ${QM_FILES})
ADD_CUSTOM_TARGET (translations ALL DEPENDS ${QM_FILES} ${MD_FILES})
# first compile sources, then compile translations
IF (WITH_DESKTOP)
ADD_DEPENDENCIES (translations ${QGIS_APP_NAME})
ENDIF (WITH_DESKTOP)
INSTALL (FILES ${QM_FILES}
DESTINATION ${QGIS_DATA_DIR}/i18n)

View File

@ -1,7 +1,3 @@
#metadata
install(FILES org.qgis.qgis.desktop DESTINATION share/applications)
install(FILES org.qgis.qgis.appdata.xml DESTINATION share/metainfo)
#icons
## application icon
install(FILES ${CMAKE_SOURCE_DIR}/images/icons/qgis_icon.svg RENAME qgis.svg DESTINATION share/icons/hicolor/scalable/apps)

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.qgis.qgis.desktop</id>
<name>QGIS Desktop</name>
<summary>A Free and Open Source Geographic Information System</summary>
<summary xml:lang="pt_BR">Um Sistema de Informação Geográfica livre e aberto </summary>
<summary xml:lang="es">Un Sistema de Información Geográfica libre y de Código Abierto</summary>
<summary xml:lang="id">Sistem Informasi Geografis yang Gratis dan Terbuka</summary>
<screenshots>
<screenshot><image type="source">https://qgis.org/en/_static/images/about-screenshot.png</image></screenshot>
</screenshots>
<description><p>QGIS is a user friendly Open Source Geographic Information System (GIS) licensed under the GNU General Public License. QGIS is an official project of the Open Source Geospatial Foundation (OSGeo). It runs on Linux, Unix, Mac OSX, Windows and Android and supports numerous vector, raster, and database formats and functionalities.</p></description>
<description xml:lang="pt_BR"><p>O QGIS é um Sistema de Informação Geográfica (SIG) de Código Aberto licenciado segundo a Licença Pública Geral GNU. O QGIS é um projeto oficial da Open Source Geospatial Foundation (OSGeo). Funciona em Linux, Unix, Mac OSX, Windows e Android e suporta inúmeros formatos de vetores, rasters e bases de dados e funcionalidades.</p></description>
<description xml:lang="es"><p>QGIS es un Sistema de Información Geográfica (SIG) de Código Abierto licenciado bajo GNU - General Public License . QGIS es un proyecto oficial de Open Source Geospatial Foundation (OSGeo). Corre sobre Linux, Unix, Mac OSX, Windows y Android y soporta numerosos formatos y funcionalidades de datos vector, datos ráster y bases de datos.</p></description>
<description xml:lang="id"><p>QGIS adalah perangkat Sistem Informasi Geografis (SIG) Open Source yang user friendly dengan lisensi di bawah GNU General Public License. QGIS merupakan proyek tidak resmi dari Open Source Geospatial Foundation (OSGeo). QGIS dapat dijalankan pada Linux, Unix, Mac OSX, Windows dan Android, serta mendukung banyak format dan fungsionalitas data vektor, raster, dan basisdata.</p></description>
<metadata_license>MIT</metadata_license>
<project_license>GPL-2.0+</project_license>
<url type="bugtracker">https://issues.qgis.org/projects/qgis/issues/</url>
<url type="donation">https://qgis.org/en/site/getinvolved/donations.html</url>
<url type="faq">https://qgis.org/en/site/getinvolved/faq/index.html</url>
<url type="help">https://qgis.org/en/docs/index.html</url>
<url type="homepage">https://qgis.org</url>
<project_group>QGIS</project_group>
<releases>
<release version="3.2.0" date="2018-06-22" />
</releases>
<launchable type="desktop-id">org.qgis.qgis.desktop</launchable>
<provides>
<binary>qgis</binary>
</provides>
</component>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.qgis.qgis.desktop</id>
<name>QGIS Desktop</name>
<summary>A Free and Open Source Geographic Information System</summary>
<screenshots>
<screenshot><image type="source">https://qgis.org/en/_static/images/about-screenshot.png</image></screenshot>
</screenshots>
<description><p>QGIS is a user friendly Open Source Geographic Information System (GIS) licensed under the GNU General Public License. QGIS is an official project of the Open Source Geospatial Foundation (OSGeo). It runs on Linux, Unix, Mac OSX, Windows and Android and supports numerous vector, raster, and database formats and functionalities.</p></description>
<metadata_license>MIT</metadata_license>
<project_license>GPL-2.0+</project_license>
<url type="bugtracker">https://issues.qgis.org/projects/qgis/issues/</url>
<url type="donation">https://qgis.org/en/site/getinvolved/donations.html</url>
<url type="faq">https://qgis.org/en/site/getinvolved/faq/index.html</url>
<url type="help">https://qgis.org/en/docs/index.html</url>
<url type="homepage">https://qgis.org</url>
<project_group>QGIS</project_group>
<releases>
<release version="3.2.0" date="2018-06-22" />
</releases>
<launchable type="desktop-id">org.qgis.qgis.desktop</launchable>
<provides>
<binary>qgis</binary>
</provides>
</component>

View File

@ -1,56 +0,0 @@
[Desktop Entry]
Type=Application
Name=QGIS Desktop
GenericName=Geographic Information System
GenericName[ar]=نظام المعلومات الجغرافي
GenericName[az]=Coğrafi informasiya sistemi
GenericName[bg]=Географска информационна система
GenericName[bs]=Geografski informacioni sistem
GenericName[ca]=Sistema d'informació geogràfica
GenericName[cs]=Geografický Informační Systém
GenericName[de]=Geographisches Informationssystem
GenericName[el]=Σύστημα Γεωγραφικών Πληροφοριών
GenericName[es]=Sistema de Información Geográfica
GenericName[et]=Geoinfosüsteem
GenericName[eu]=Geografia-informazioko sistemen
GenericName[fa]=سامانه اطلاعات مکانی
GenericName[fi]=Maantieteellinen Tietojärjestelmä
GenericName[fr]=Système d'Information Géographique
GenericName[gl]=Sistema de información xeográfica
GenericName[he]=מערכת מידע גאוגרפית
GenericName[hi]=__
GenericName[hr]=Geografski informacijski sustav
GenericName[hu]=Földrajzi információs rendszer
GenericName[hy]=Աշխարհագրական տեղեկատվական համակարգ
GenericName[id]=Sistem informasi geografis
GenericName[is]=Landfræðilegt upplýsingakerfi
GenericName[it]=Sistema Informativo Geografico
GenericName[ka]=
GenericName[lt]=Geografinė informacinė sistema
GenericName[lv]=Ģeogrāfiskā informācijas sistēma
GenericName[mk]=Географски информационен систем
GenericName[ml]=ി...
GenericName[nl]=Geografisch informatiesysteem
GenericName[nn]=Geografiske informasjonssystem
GenericName[no]=Geografiske informasjonssystemer
GenericName[pl]=System Informacji Geograficznej
GenericName[pt]=Sistema de Informação Geográfica
GenericName[ro]=Sistem Informatic Geografic
GenericName[ru]=Геоинформационная система
GenericName[sh]=Geografski informacijski sistem
GenericName[sk]=Geografický informačný systém
GenericName[sl]=Geografski informacijski sistem
GenericName[sr]=Географски информациони систем
GenericName[sv]=Geografiskt Informationssystem
GenericName[th]=
GenericName[tr]=Coğrafi bilgi sistemi
GenericName[uk]=Геоінформаційна система
GenericName[uz]=Geografik axborot tizimi
Icon=qgis
TryExec=qgis
Exec=qgis %F
Terminal=false
StartupNotify=false
Categories=Qt;Education;Science;Geography;
MimeType=application/x-qgis-project;application/x-qgis-layer-settings;application/x-qgis-layer-definition;application/x-qgis-composer-template;image/tiff;image/jpeg;image/jp2;application/x-raster-aig;application/x-raster-ecw;application/x-raster-mrsid;application/x-mapinfo-mif;application/x-esri-shape;
Keywords=map;globe;postgis;wms;wfs;ogc;osgeo;

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Name=QGIS Desktop
GenericName=Geographic Information System
Icon=qgis
TryExec=qgis
Exec=qgis %F
Terminal=false
StartupNotify=false
Categories=Qt;Education;Science;Geography;
MimeType=application/x-qgis-project;application/x-qgis-layer-settings;application/x-qgis-layer-definition;application/x-qgis-composer-template;image/tiff;image/jpeg;image/jp2;application/x-raster-aig;application/x-raster-ecw;application/x-raster-mrsid;application/x-mapinfo-mif;application/x-esri-shape;
Keywords=map;globe;postgis;wms;wfs;ogc;osgeo;

59
scripts/appinfo2cpp.py Normal file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
/***************************************************************************
appinfo2cpp.py
-------------------
begin : 2018-09-24
copyright : (C) 2018 by Jürgen E. Fischer
email : jef at norbit dot de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import sys
from xml.etree import ElementTree as et
strings = {}
d = et.parse('linux/org.qgis.qgis.appdata.xml.in')
r = d.getroot()
for elem in ['name', 'summary', 'description']:
for c in r.iter(elem):
if not c.attrib:
l = list(c)
t = c.text if not l else "".join([et.tostring(x).decode("utf-8") for x in l])
strings[t] = 1
f = open("linux/org.qgis.qgis.desktop.in", "r")
for r in f.readlines():
r = r.strip()
if r.startswith("Name="):
strings[r[5:]] = 1
elif r.startswith("GenericName="):
strings[r[12:]] = 1
f.close()
print("""
/*
This is NOT a proper c++ source code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by pylupdate5.
*/
""")
for k in strings:
k = k.replace('"', '\\"')
k = k.replace('\n', '\\n')
print("translate( \"appinfo\", \"{}\" )".format(k))

View File

@ -163,7 +163,7 @@ unless( $dopoint ) {
print "Updating changelog...\n";
run( "scripts/create_changelog.sh", "create_changelog.sh failed" );
run( "perl -i -pe 's#<releases>#<releases>\n <release version=\"$newmajor.$newminor.$newpatch\" date=\"" . strftime("%Y-%m-%d", localtime) . "\" />#' linux/org.qgis.qgis.appdata.xml", "appdata update failed" );
run( "perl -i -pe 's#<releases>#<releases>\n <release version=\"$newmajor.$newminor.$newpatch\" date=\"" . strftime("%Y-%m-%d", localtime) . "\" />#' linux/org.qgis.qgis.appdata.xml.in", "appdata update failed" );
unless( $dopoint ) {
run( "scripts/update-news.pl $newmajor $newminor '$newreleasename'", "could not update news" ) if $major>2 || ($major==2 && $minor>14);

View File

@ -42,7 +42,7 @@ images/themes/default/mIconJoinHasNotUpsertOnEdit.svg
images/themes/default/mIconJoinNotEditable.svg
images/themes/default/mIconJoinedLayerNotEditable.svg
LexerR.py
linux/org.qgis.qgis.appdata.xml
linux/org.qgis.qgis.appdata.xml.in
python/plugins/MetaSearch/resources/connections-default.xml
python/plugins/processing/algs/grass7/description/i.landsat.toar.txt
python/plugins/processing/gui/algnames.txt

108
scripts/ts2appinfo.py Normal file
View File

@ -0,0 +1,108 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
/***************************************************************************
ts2appinfo.py
-------------------
begin : 2018-09-24
copyright : (C) 2018 by Jürgen E. Fischer
email : jef at norbit dot de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import sys
import os
from glob import glob
from xml.etree import ElementTree as et
from PyQt5.QtCore import QCoreApplication, QTranslator
strings = {}
d = et.parse('linux/org.qgis.qgis.appdata.xml.in')
r = d.getroot()
for elem in ['name', 'summary', 'description']:
for c in r.iter(elem):
if not c.attrib:
l = list(c)
t = c.text if not l else "".join([et.tostring(x).decode("utf-8") for x in l])
strings[t] = {}
else:
r.remove(c)
f = open("linux/org.qgis.qgis.desktop.in", "r")
lines = f.readlines()
for line in lines:
line = line.strip()
for prefix in ['Name', 'GenericName']:
if line.startswith(prefix + "="):
strings[line[len(prefix) + 1:]] = {}
f.close()
try:
argvb = list(map(os.fsencode, sys.argv))
except AttributeError:
argvb = sys.argv
app = QCoreApplication(argvb)
for qm in glob(sys.argv[1] + "/output/i18n/qgis_*.qm"):
translator = QTranslator()
translator.load(qm)
lang = qm[len(sys.argv[1] + "/output/i18n/qgis_"):-3]
for s in strings:
translation = translator.translate("appinfo", s, "")
if translation in [s, '']:
continue
strings[s][lang] = translation
for elem in ['name', 'summary', 'description']:
for c in r.iter(elem):
if c.attrib:
continue
l = list(c)
s = c.text if not l else "".join([et.tostring(x).decode("utf-8") for x in l])
for lang in strings[s]:
e = et.Element(elem, attrib={"xml:lang": lang})
e.text = strings[s][lang]
e.tail = c.tail
r.append(e)
d.write(sys.argv[1] + "/org.qgis.qgis.appdata.xml", encoding="UTF-8", xml_declaration=True)
f = open(sys.argv[1] + "/org.qgis.qgis.desktop", "w")
for line in lines:
skip = False
for prefix in ['Name', 'GenericName']:
if line.startswith(prefix + "="):
skip = True
f.write(line)
t = line.strip()[len(prefix) + 1:]
for lang in strings[t]:
f.write("{}[{}]={}\n".format(prefix, lang, strings[t][lang]))
elif line.startswith(prefix + "["):
skip = True
continue
if not skip:
f.write(line)
f.close()

View File

@ -39,6 +39,7 @@ cleanup() {
python/plugins/*/python-i18n.{ts,cpp} \
python/plugins/processing/processing-i18n.{ts,cpp} \
src/plugins/grass/grasslabels-i18n.cpp \
src/app/appinfo-i18n.cpp \
i18n/backup.tar \
qgis_ts.pro
do
@ -165,6 +166,9 @@ perl scripts/qgm2cpp.pl >src/plugins/grass/grasslabels-i18n.cpp
echo Updating processing translations
perl scripts/processing2cpp.pl python/plugins/processing/processing-i18n.cpp
echo Updating appinfo files
python scripts/appinfo2cpp.py >src/app/appinfo-i18n.cpp
echo Creating qmake project file
$QMAKE -project -o qgis_ts.pro -nopwd $PWD/src $PWD/python $PWD/i18n $textcpp