Skip to content

Commit

Permalink
Updated language control files for Fennec, Firefox, SeaMonkey, and Th…
Browse files Browse the repository at this point in the history
…underbird
  • Loading branch information
mattbasta committed Jun 29, 2012
1 parent 86d06cf commit e46eedb
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/validator/constants_local.py /validator/constants_local.py
/src /src
/extras/jslibs /extras/jslibs
/extras/language_controls
22 changes: 18 additions & 4 deletions README.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -440,9 +440,23 @@ Language Packs
============== ==============


With every version of every app that's released, the language pack references 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 need to be updated.
packages, though they can likely be obtained elsewhere.


These reference files need to be placed in the ``validator/testcases/langpacks`` We now have an automated tool to ease this tedious process. It is currently
directory. 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.
72 changes: 72 additions & 0 deletions extras/update_langpacks.py
Original file line number Original file line Diff line number Diff line change
@@ -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 modified validator/testcases/langpacks/fennec.xpi
Binary file not shown.
Binary file modified validator/testcases/langpacks/firefox.xpi
Binary file not shown.
Binary file modified validator/testcases/langpacks/seamonkey.xpi
Binary file not shown.
Binary file modified validator/testcases/langpacks/thunderbird.xpi
Binary file not shown.

0 comments on commit e46eedb

Please sign in to comment.