From 8aa84a945480e0f8129cdfbef414f913af1c13db Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Wed, 22 Dec 2010 13:14:50 -0800 Subject: [PATCH] Bug 594017 - Support localization of strings in embedding/android code, r=ted a=blocking-fennec --- embedding/android/Makefile.in | 31 +++++++++--- embedding/android/locales/Makefile.in | 48 +++++++++++++++++++ .../{ => locales/en-US}/android_strings.dtd | 0 embedding/android/locales/jar.mn | 4 ++ embedding/android/locales/l10n.ini | 5 ++ toolkit/mozapps/installer/packager.mk | 5 +- 6 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 embedding/android/locales/Makefile.in rename embedding/android/{ => locales/en-US}/android_strings.dtd (100%) create mode 100644 embedding/android/locales/jar.mn create mode 100644 embedding/android/locales/l10n.ini diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in index 76cfd709174..fdfe966307c 100644 --- a/embedding/android/Makefile.in +++ b/embedding/android/Makefile.in @@ -43,6 +43,8 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/ipc/app/defs.mk +DIRS = locales + JAVAFILES = \ GeckoApp.java \ GeckoAppShell.java \ @@ -102,8 +104,10 @@ RES_LAYOUT = \ JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar -DEFAULT_BRANDPATH = $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/en-US/brand.dtd -DEFAULT_STRINGSPATH = android_strings.dtd +DEFAULT_BRANDPATH = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/locales/en-US/brand.dtd +DEFAULT_STRINGSPATH = locales/en-US/android_strings.dtd +LOCALIZED_BRANDPATH = $(DEPTH)/dist/bin/chrome/$(AB_CD)/locale/branding/brand.dtd +LOCALIZED_STRINGSPATH = $(DEPTH)/dist/bin/chrome/android-res/res/values-$(AB_CD)/android_strings.dtd ifdef MOZ_CRASHREPORTER PROCESSEDJAVAFILES += CrashReporter.java @@ -117,6 +121,10 @@ MOZ_ANDROID_DRAWABLES += $(shell if test -e $(topsrcdir)/$(MOZ_BRANDING_DIRECTOR include $(topsrcdir)/config/rules.mk +ifneq ($(AB_CD),en-US) +LOCALIZED_STRINGS_XML = res/values-$(AB_CD)/strings.xml +endif + # Override the Java settings with some specific android settings include $(topsrcdir)/config/android-common.mk @@ -149,13 +157,13 @@ $(RES_LAYOUT): $(subst res/,$(srcdir)/resources/,$(RES_LAYOUT)) $(NSINSTALL) -D res/layout $(NSINSTALL) $(srcdir)/resources/layout/* res/layout/ -R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) res/values/strings.xml $(LOCALIZED_STRINGS_XML) AndroidManifest.xml +R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml $(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko -gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) res/values/strings.xml $(LOCALIZED_STRINGS_XML) +gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) res/values/strings.xml FORCE $(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -F $@ -res/values/strings.xml: FORCE +res/values/strings.xml: $(DEFAULT_BRANDPATH) $(DEFAULT_STRINGSPATH) mkdir -p res/values $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) \ -DBRANDPATH="$(DEFAULT_BRANDPATH)" \ @@ -163,6 +171,15 @@ res/values/strings.xml: FORCE $(srcdir)/strings.xml.in \ > $@ -libs:: gecko.ap_ classes.dex +res/values-$(AB_CD)/strings.xml: $(LOCALIZED_BRANDPATH) $(LOCALIZED_STRINGSPATH) + mkdir -p res/values-$(AB_CD) + $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) \ + -DBRANDPATH="$(call core_abspath,$(LOCALIZED_BRANDPATH))" \ + -DSTRINGSPATH="$(call core_abspath,$(LOCALIZED_STRINGSPATH))" \ + $(srcdir)/strings.xml.in \ + > $@ + +chrome:: $(LOCALIZED_STRINGS_XML) + +libs:: classes.dex $(INSTALL) classes.dex $(FINAL_TARGET) - $(UNZIP) -o gecko.ap_ -d $(FINAL_TARGET) diff --git a/embedding/android/locales/Makefile.in b/embedding/android/locales/Makefile.in new file mode 100644 index 00000000000..b4ad413e88e --- /dev/null +++ b/embedding/android/locales/Makefile.in @@ -0,0 +1,48 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Android code. +# +# The Initial Developer of the Original Code is +# the Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Michael Wu +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = embedding/android/locales + +include $(DEPTH)/config/autoconf.mk + +DEFINES += -DAB_CD=$(AB_CD) + +include $(topsrcdir)/config/rules.mk diff --git a/embedding/android/android_strings.dtd b/embedding/android/locales/en-US/android_strings.dtd similarity index 100% rename from embedding/android/android_strings.dtd rename to embedding/android/locales/en-US/android_strings.dtd diff --git a/embedding/android/locales/jar.mn b/embedding/android/locales/jar.mn new file mode 100644 index 00000000000..452e9d25154 --- /dev/null +++ b/embedding/android/locales/jar.mn @@ -0,0 +1,4 @@ +#filter substitution + +android-res.jar: + res/values-@AB_CD@/android_strings.dtd (%android_strings.dtd) diff --git a/embedding/android/locales/l10n.ini b/embedding/android/locales/l10n.ini new file mode 100644 index 00000000000..789da5e2419 --- /dev/null +++ b/embedding/android/locales/l10n.ini @@ -0,0 +1,5 @@ +[general] +depth = ../../.. + +[compare] +dirs = embedding/android diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index df4f2a83ebc..850233070ac 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -201,7 +201,8 @@ endif PKG_SUFFIX = .apk INNER_MAKE_PACKAGE = \ - rm -f $(_ABS_DIST)/gecko.ap_ && \ + make -C ../embedding/android gecko.ap_ && \ + cp ../embedding/android/gecko.ap_ $(_ABS_DIST) && \ ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \ rm -rf lib && \ mkdir -p lib/$(ABI_DIR) && \ @@ -212,6 +213,8 @@ INNER_MAKE_PACKAGE = \ do \ printf "`basename $$SOMELIB`:`$(_ABS_DIST)/host/bin/file_id $$SOMELIB`\n" >> lib.id ; \ done && \ + unzip -o $(_ABS_DIST)/gecko.ap_ && \ + rm $(_ABS_DIST)/gecko.ap_ && \ $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) ) && \ rm -f $(_ABS_DIST)/gecko.apk && \ $(APKBUILDER) $(_ABS_DIST)/gecko.apk -v $(APKBUILDER_FLAGS) -z $(_ABS_DIST)/gecko.ap_ -f $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \