Permalink
Browse files

Updated language control files for Fennec, Firefox, SeaMonkey, and Th…

…underbird
  • Loading branch information...
1 parent 86d06cf commit e46eedb07debe9256f0c5c5b414096b954b39118 @mattbasta committed Jun 18, 2012
View
@@ -8,3 +8,4 @@
/validator/constants_local.py
/src
/extras/jslibs
+/extras/language_controls
View
@@ -440,9 +440,23 @@ Language Packs
==============
With every version of every app that's released, the language pack references
-need to be updated. It is usually easiest to extract them from the OS X .app
-packages, though they can likely be obtained elsewhere.
+need to be updated.
-These reference files need to be placed in the ``validator/testcases/langpacks``
-directory.
+We now have an automated tool to ease this tedious process. It is currently
+designed to work on OS X with the OS X versions of Mozilla applications, though
+it could conceivably run on any \*NIX platform against the OS X application
+packages.
+To run the tool, first create a new directory: ``extras/language_controls/``
+
+Put the ``.app`` packages for each updated product into this directory. Once
+this is ready, simply run: ::
+
+ cd extras
+ python update_langpacks.py
+
+That should be it. Note that this tool will fail horribly if any of the teams
+change the locations that the various language files are stored in.
+
+Also note that this tool should only be run against the en-US versions of these
+applications.
View
@@ -0,0 +1,72 @@
+import os
+from fnmatch import fnmatch
+from tempfile import NamedTemporaryFile
+from zipfile import ZipFile
+
+
+PACKAGE_MAPPINGS = {"Fennec.app": "fennec",
+ "Firefox.app": "firefox",
+ "SeaMonkey.app": "seamonkey",
+ "Thunderbird.app": "thunderbird",}
+
+
+def copy_to_zip(read_zip, write_zip, pattern, prefix=""):
+ for member in read_zip.namelist():
+ if fnmatch(member, pattern):
+ filename = member.split("/")[-1]
+ write_zip.writestr("%s%s" % (prefix, filename),
+ read_zip.read(member))
+
+
+def copy_to_new_zip(callback, read_zip, pattern, prefix=""):
+ with NamedTemporaryFile("w") as temp:
+ with ZipFile(temp.name, "w") as write_zip:
+ copy_to_zip(read_zip, write_zip, pattern, prefix)
+
+ callback(temp.name)
+
+
+def main():
+ for package in os.listdir("language_controls/"):
+ if package.startswith(".") or package not in PACKAGE_MAPPINGS:
+ continue
+
+ platform = PACKAGE_MAPPINGS[package]
+ path = "language_controls/%s" % package
+ jar = ZipFile("../validator/testcases/langpacks/%s.xpi" % platform, "w")
+
+ if platform == "firefox":
+ # Firefox puts this stuff in omni.ja.
+ with ZipFile("%s/Contents/MacOS/omni.ja" % path, "r") as omni_ja:
+ #print list(x for x in omni_ja.namelist() if x.startswith("chrome/"))
+ jar.writestr("chrome.manifest",
+ omni_ja.read("chrome/localized.manifest"))
+
+ # Copy the chrome/en-US/ directory to /en-US.jar in the new zip.
+ def callback(name):
+ jar.write(name, "en-US.jar")
+ copy_to_new_zip(callback, omni_ja, "chrome/en-US/*")
+
+ elif platform in ("thunderbird", "seamonkey", ):
+ # Thunderbird puts stuff in omni.ja, too,
+ with ZipFile("%s/Contents/MacOS/omni.ja" % path, "r") as omni_ja:
+ jar.writestr("chrome.manifest",
+ omni_ja.read("chrome/localized.manifest"))
+
+ # Copy the chrome/en-US/ directory to /en-US.jar in the new zip.
+ def callback(name):
+ jar.write(name, "en-US.jar")
+ copy_to_new_zip(callback, omni_ja, "chrome/en-US/*")
+
+ else:
+ jar.write("%s/Contents/MacOS/chrome/localized.manifest" % path,
+ "chrome.manifest")
+ jar.write("%s/Contents/MacOS/chrome/en-US.jar" % path,
+ "en-US.jar")
+
+ jar.close()
+
+
+if __name__ == "__main__":
+ main()
+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e46eedb

Please sign in to comment.