Skip to content

Commit 50bf791

Browse files
committed
[Plugin Manager] Translateable name and description in metadata.txt.
1 parent 74f08c5 commit 50bf791

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

python/pyplugin_installer/installer_data.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@
9797

9898

9999

100-
100+
translatableAttributes = ["name", "description", "tags"]
101101

102102
reposGroup = "/Qgis/plugin-repos"
103103
settingsGroup = "/Qgis/plugin-installer"
104104
seenPluginGroup = "/Qgis/plugin-seen"
105105

106106

107107
# Repositories: (name, url, possible depreciated url)
108-
officialRepo = ("QGIS Official Repository", "http://plugins.qgis.org/plugins/plugins.xml","http://plugins.qgis.org/plugins")
108+
officialRepo = ( QCoreApplication.translate("QgsPluginInstaller", "QGIS Official Plugin Repository"), "http://plugins.qgis.org/plugins/plugins.xml","http://plugins.qgis.org/plugins")
109109
depreciatedRepos = [
110110
("Old QGIS Official Repository", "http://pyqgis.org/repo/official"),
111111
("Old QGIS Contributed Repository","http://pyqgis.org/repo/contributed"),
@@ -585,7 +585,7 @@ def removeRepository(self, repo):
585585
# ----------------------------------------- #
586586
def getInstalledPlugin(self, key, readOnly, testLoad=True):
587587
""" get the metadata of an installed plugin """
588-
def pluginMetadata(fct):
588+
def metadataParser(fct):
589589
""" plugin metadata parser reimplemented from qgis.utils
590590
for better control on wchich module is examined
591591
in case there is an installed plugin masking a core one """
@@ -599,6 +599,17 @@ def pluginMetadata(fct):
599599
except:
600600
return ""
601601

602+
def pluginMetadata(fct):
603+
""" calls metadataParser for current l10n.
604+
If failed, fallbacks to the standard metadata """
605+
locale = QLocale.system().name()
606+
if locale and fct in translatableAttributes:
607+
value = metadataParser( "%s[%s]" % (fct, locale ) )
608+
if value: return value
609+
value = metadataParser( "%s[%s]" % (fct, locale.split("_")[0] ) )
610+
if value: return value
611+
return metadataParser( fct )
612+
602613
if readOnly:
603614
path = QDir.cleanPath( QgsApplication.pkgDataPath() ) + "/python/plugins/" + key
604615
else:
@@ -739,13 +750,15 @@ def rebuild(self):
739750
self.mPlugins[key] = plugin # just add a new plugin
740751
else:
741752
# update local plugin with remote metadata
742-
# only use remote icon if local one is not available
743-
if self.mPlugins[key]["icon"] == key and plugin["icon"]:
744-
self.mPlugins[key]["icon"] = plugin["icon"]
753+
# name, description, icon: only use remote data if local one is not available (because of i18n and to not download the icon)
754+
for attrib in translatableAttributes + ["icon"]:
755+
if not self.mPlugins[key][attrib] and plugin[attrib]:
756+
self.mPlugins[key][attrib] = plugin[attrib]
745757
# other remote metadata is preffered:
746758
for attrib in ["name", "description", "category", "tags", "changelog", "author_name", "author_email", "homepage",
747759
"tracker", "code_repository", "experimental", "version_available", "zip_repository",
748-
"download_url", "filename", "downloads", "average_vote", "rating_votes"]:
760+
"download_url", "filename", "downloads", "average_vote", "rating_votes"]
761+
and not attrib in translatableAttributes:
749762
if plugin[attrib]:
750763
self.mPlugins[key][attrib] = plugin[attrib]
751764
# set status

0 commit comments

Comments
 (0)