97
97
98
98
99
99
100
-
100
+ translatableAttributes = [ "name" , "description" , "tags" ]
101
101
102
102
reposGroup = "/Qgis/plugin-repos"
103
103
settingsGroup = "/Qgis/plugin-installer"
104
104
seenPluginGroup = "/Qgis/plugin-seen"
105
105
106
106
107
107
# 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" )
109
109
depreciatedRepos = [
110
110
("Old QGIS Official Repository" , "http://pyqgis.org/repo/official" ),
111
111
("Old QGIS Contributed Repository" ,"http://pyqgis.org/repo/contributed" ),
@@ -585,7 +585,7 @@ def removeRepository(self, repo):
585
585
# ----------------------------------------- #
586
586
def getInstalledPlugin (self , key , readOnly , testLoad = True ):
587
587
""" get the metadata of an installed plugin """
588
- def pluginMetadata (fct ):
588
+ def metadataParser (fct ):
589
589
""" plugin metadata parser reimplemented from qgis.utils
590
590
for better control on wchich module is examined
591
591
in case there is an installed plugin masking a core one """
@@ -599,6 +599,17 @@ def pluginMetadata(fct):
599
599
except :
600
600
return ""
601
601
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
+
602
613
if readOnly :
603
614
path = QDir .cleanPath ( QgsApplication .pkgDataPath () ) + "/python/plugins/" + key
604
615
else :
@@ -739,13 +750,15 @@ def rebuild(self):
739
750
self .mPlugins [key ] = plugin # just add a new plugin
740
751
else :
741
752
# 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 ]
745
757
# other remote metadata is preffered:
746
758
for attrib in ["name" , "description" , "category" , "tags" , "changelog" , "author_name" , "author_email" , "homepage" ,
747
759
"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 :
749
762
if plugin [attrib ]:
750
763
self .mPlugins [key ][attrib ] = plugin [attrib ]
751
764
# set status
0 commit comments