L10n:Native Android

From MozillaWiki
Jump to: navigation, search

The android docs talk quite a bit of how the source looks, but there's a bit of a mystery of what the generated code does. Androguard is really helpful in digging into the packages.

In the apk, there is:

     392  2011-10-26 18:45   res/layout/main.xml
    1508  2011-10-26 18:45   AndroidManifest.xml
    1440  2011-10-26 18:45   resources.arsc
    3966  2011-10-26 16:45   res/drawable-hdpi/ic_launcher.png
    1537  2011-10-26 16:45   res/drawable-ldpi/ic_launcher.png
    2200  2011-10-26 16:45   res/drawable-mdpi/ic_launcher.png
    2176  2011-10-26 18:45   classes.dex

and more.

The classes.dex contains the Dalvik dex files, which is the bytecode for Android. It does include stub classes for string resources, which are generated, aside to the actual written java code for the app.

The actual strings are all in resources.arsc. That is one bundle for all languages. Pike has no clue yet how that file is composed.

  • the resources might be disambiguated, size/speed impact might vary between current l10n-merge and a fully localized build (needs more checks)

The res/layout/main.xml file is actually a "binary XML" format, what exactly is in there from the original main.xml is to be seen.


slides on android resource manager

android l10n tutorial (make sure to add a memory card to the emulator)

locale mapping

Android apparently only supports two-letter locale codes. The list of OS supported locales per sdk version can be found in the Locales section for each SDK in the list.

xul to android native locale support mapping data from https://l10n-stage-sj.mozilla.org/dashboard/?tree=fennec_beta and http://developer.android.com/reference/java/util/Locale.html

de fennec_beta
  de. android local constant GERMAN
en-US fennec_beta
  en_US. android local constant US
fr fennec_beta
  fr. android local constant FRENCH 
it fennec_beta
  it. android local constant ITALIAN
ja fennec_beta
   ja. android local constant JAPANESE
ko fennec_beta
  ko. android local constant KOREAN
zh-CN fennec_beta
  zh_CN. android local constant SIMPLIFIED_CHINESE
zh-TW fennec_beta
  zh_TW. android local constant TRADITIONAL_CHINESE

Locales we have in XUL not supported by android?

ar fennec_beta
be fennec_beta
ca fennec_beta
cs fennec_beta
da fennec_beta
el fennec_beta
es-AR fennec_beta
es-ES fennec_beta
et fennec_beta
eu fennec_beta
fa fennec_beta
fi fennec_beta
fy-NL fennec_beta
ga-IE fennec_beta
gd fennec_beta
gl fennec_beta
he fennec_beta
hu fennec_beta
id fennec_beta
lt fennec_beta
nb-NO fennec_beta
nl fennec_beta
nn-NO fennec_beta
pa-IN fennec_beta
pl fennec_beta
pt-BR fennec_beta
pt-PT fennec_beta
ro fennec_beta
ru fennec_beta
sk fennec_beta
sl fennec_beta
sq fennec_beta
sr fennec_beta
th fennec_beta
tr fennec_beta
uk fennec_beta
vi fennec_beta

Locales supported in Android that we don't need?

de_DE. android local constant GERMANY
en. android local constant ENGLISH
en_CA. android local constant CANADA
en_GB. android local constant UK
fr_CA. android local constant CANADA_FRENCH
fr_FR. android local constant FRANCE
it_IT. android local constant ITALY
ja-JP-mac fennec_beta
ja_JP. android local constant JAPAN
ko_KR. android local constant KOREA
locale. android local constant ROOT
zh. android local constant CHINESE
zh_CN. android local constant CHINA
zh_CN. android local constant PRC
zh_TW. android local constant TAIWAN



You can find good instructions at Fennec/NativeUI#How_To_Build. Below is what has worked for me (stas) on Linux. This config assumes that the 'pl' central repository is cloned into $HOME/moz/l10n-central.

 hg clone http://hg.mozilla.org/mozilla-central/ src
 cd src
 vim .mozconfig

Edit the .moconfig:

 ac_add_options --enable-application=mobile/android
 # android options
 ac_add_options --target=arm-linux-androideabi
 ac_add_options --enable-debug
 ac_add_options --disable-optimize
 ac_add_options --enable-ccache
 ac_add_options --disable-crashreporter
 ac_add_options --disable-elf-hack
 ac_add_options --with-l10n-base="$HOME/moz/l10n-central"
 # Android SDK/NDK
 ac_add_options --with-android-ndk="/opt/android-ndk"
 ac_add_options --with-android-sdk="/opt/android-sdk/platforms/android-13"
 ac_add_options --with-android-version=8
 # make options
 mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
 mk_add_options MOZ_MAKE_FLAGS="-j4 -s"

Build en-US:

 make -f client.mk
 make -C obj-android/ package
 adb install -r obj-android/dist/fennec-11.0a1.en-US.android-arm.apk

Build pl:

 cd obj-android/mobile/android/locales/
 make merge-pl LOCALE_MERGEDIR=mergedir
 make installers-pl LOCALE_MERGEDIR=mergedir