Bug 1395457 - De-hardcode product name when producing webext-langpack. r=kmag draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 07 Sep 2017 13:16:20 -0700
changeset 660893 31b74722e4188c18191f0370fc09a327b7b4b9f6
parent 660738 37b95547f0d27565452136d16b2df2857be840f6
child 730421 c093582e35afdccddb54feb9e546a826454319ad
push id78597
push userbmo:gandalf@aviary.pl
push dateThu, 07 Sep 2017 20:16:32 +0000
reviewerskmag
bugs1395457
milestone57.0a1
Bug 1395457 - De-hardcode product name when producing webext-langpack. r=kmag MozReview-Commit-ID: D6TbDR7dkY6
python/mozbuild/mozbuild/action/langpack_manifest.py
toolkit/locales/l10n.mk
--- a/python/mozbuild/mozbuild/action/langpack_manifest.py
+++ b/python/mozbuild/mozbuild/action/langpack_manifest.py
@@ -218,28 +218,31 @@ def parse_chrome_manifest(path, base_pat
 # Args:
 #    locstr         (str)  - A string with a comma separated list of locales
 #                            for which resources are embedded in the
 #                            language pack
 #    min_app_ver    (str)  - A minimum version of the application the language
 #                            resources are for
 #    max_app_ver    (str)  - A maximum version of the application the language
 #                            resources are for
+#    app_name       (str)  - The name of the application the language
+#                            resources are for
 #    defines        (dict) - A dictionary of defines entries
 #    chrome_entries (dict) - A dictionary of chrome registry entries
 #
 # Returns:
 #    (dict) - a web manifest
 #
 # Example:
 #    manifest = create_webmanifest(
 #      ['pl'],
 #      '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}',
 #      '57.0',
 #      '57.0.*',
+#      'Firefox',
 #      {'MOZ_LANG_TITLE': 'Polski'},
 #      chrome_entries
 #    )
 #    manifest == {
 #        'languages': {
 #            'pl': {
 #                'version': '201709121481',
 #                'chrome_resources': {
@@ -268,17 +271,18 @@ def parse_chrome_manifest(path, base_pat
 #                'id': 'langpack-pl@mozilla.org',
 #            }
 #        },
 #        'version': '57.0',
 #        'name': 'Polski Language Pack',
 #        ...
 #    }
 ###
-def create_webmanifest(locstr, min_app_ver, max_app_ver, defines, chrome_entries):
+def create_webmanifest(locstr, min_app_ver, max_app_ver, app_name,
+                       defines, chrome_entries):
     locales = map(lambda loc: loc.strip(), locstr.split(','))
     main_locale = locales[0]
 
     author = build_author_string(
         defines['MOZ_LANGPACK_CREATOR'],
         defines['MOZ_LANGPACK_CONTRIBUTORS']
     )
 
@@ -288,17 +292,17 @@ def create_webmanifest(locstr, min_app_v
         'applications': {
             'gecko': {
                 'id': 'langpack-{0}@firefox.mozilla.org'.format(main_locale),
                 'strict_min_version': min_app_ver,
                 'strict_max_version': max_app_ver,
             }
         },
         'name': '{0} Language Pack'.format(defines['MOZ_LANG_TITLE']),
-        'description': 'Language pack for Firefox for {0}'.format(main_locale),
+        'description': 'Language pack for {0} for {1}'.format(app_name, main_locale),
         'version': min_app_ver,
         'languages': {},
         'sources': {
             'browser': {
                 'base_path': 'browser/'
             }
         },
         'author': author
@@ -331,16 +335,18 @@ def create_webmanifest(locstr, min_app_v
 def main(args):
     parser = argparse.ArgumentParser()
     parser.add_argument('--locales',
                         help='List of language codes provided by the langpack')
     parser.add_argument('--min-app-ver',
                         help='Min version of the application the langpack is for')
     parser.add_argument('--max-app-ver',
                         help='Max version of the application the langpack is for')
+    parser.add_argument('--app-name',
+                        help='Name of the application the langpack is for')
     parser.add_argument('--defines', default=[], nargs='+',
                         help='List of defines files to load data from')
     parser.add_argument('--input',
                         help='Langpack directory.')
 
     args = parser.parse_args(args)
 
     chrome_entries = []
@@ -348,16 +354,17 @@ def main(args):
         os.path.join(args.input, 'chrome.manifest'), args.input, chrome_entries)
 
     defines = parse_defines(args.defines)
 
     res = create_webmanifest(
         args.locales,
         args.min_app_ver,
         args.max_app_ver,
+        args.app_name,
         defines,
         chrome_entries
     )
     write_file(os.path.join(args.input, 'manifest.json'), res)
 
 
 if __name__ == '__main__':
     main(sys.argv[1:])
--- a/toolkit/locales/l10n.mk
+++ b/toolkit/locales/l10n.mk
@@ -202,17 +202,17 @@ langpack-%:
 	@$(MAKE) package-langpack-$(AB_CD)
 
 package-langpack-%: LANGPACK_FILE=$(ABS_DIST)/$(PKG_LANGPACK_PATH)$(PKG_LANGPACK_BASENAME).xpi
 package-langpack-%: XPI_NAME=locale-$*
 package-langpack-%: AB_CD=$*
 package-langpack-%:
 	$(NSINSTALL) -D $(DIST)/$(PKG_LANGPACK_PATH)
 ifdef WEBEXT_LANGPACKS
-	$(call py_action,langpack_manifest,--locales $(AB_CD) --min-app-ver $(MOZ_APP_VERSION) --max-app-ver $(MOZ_APP_MAXVERSION) --defines $(NEW_APP_DEFINES) --input $(DIST)/xpi-stage/locale-$(AB_CD))
+	$(call py_action,langpack_manifest,--locales $(AB_CD) --min-app-ver $(MOZ_APP_VERSION) --max-app-ver $(MOZ_APP_MAXVERSION) --app-name "$(MOZ_APP_DISPLAYNAME)" --defines $(NEW_APP_DEFINES) --input $(DIST)/xpi-stage/locale-$(AB_CD))
 	$(call py_action,zip,-C $(DIST)/xpi-stage/locale-$(AB_CD) -x **/*.manifest -x **/*.js -x **/*.ini $(LANGPACK_FILE) $(PKG_ZIP_DIRS) manifest.json)
 else
 	$(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) \
 	  -DTK_DEFINES=$(TK_DEFINES) -DAPP_DEFINES=$(APP_DEFINES) $(MOZILLA_DIR)/toolkit/locales/generic/install.rdf -o $(DIST)/xpi-stage/$(XPI_NAME)/install.rdf)
 	$(call py_action,zip,-C $(DIST)/xpi-stage/locale-$(AB_CD) $(LANGPACK_FILE) install.rdf $(PKG_ZIP_DIRS) chrome.manifest)
 endif
 
 # This variable is to allow the wget-en-US target to know which ftp server to download from