0

I would like to deploy multilingual documents in my Android app directly inside my apk in order to access them offline.

Documents placed in the raw directory can do that but I can't keep any folder structure, I would prefer to avoid this. In addition I wouldn't be able to integrate (non single file) html file.

I saw some workarounds using the assets folder:

Localizable assets in Android

localization of assets files

What's the best practice? It seems like a basic feature, it's strange that Google didn't foresee a solution for this. I couldn't find any guideline in http://developer.android.com.

Community
  • 1
  • 1
L. G.
  • 9,642
  • 7
  • 56
  • 78

1 Answers1

3

As you know, Android supports localization on some folders with folder names(ex: drawable-en, values-br)

in my opinion using the values-[XX] to use strings xml as a control mechanism to reach in assets folder is best practice

for example :

use your assets subfolders to do it so like :

assets--> images-en,images-fr,html-gr...

then get your files like this

context.getAssets().open("images"+Locale.getDefault().getDisplayLanguage()+"/whatetever.png");
Ercan
  • 3,705
  • 1
  • 22
  • 37
  • I ended up implementing this solution (also mentioned in the links of my questions) as there was no answer relating to Google guidelines. As I consider it a workaround I let the question open for a while to see if some better solution comes up. – L. G. Apr 05 '13 at 07:23
  • yeah, it is a work arround, yet it is pretty :) – Ercan Apr 05 '13 at 13:08
  • As no solution was proposed better than this nice workaround I finally accept it. – L. G. May 29 '13 at 07:06