Moving to assets
Will need to rebase again before this gets approved
This commit is contained in:
parent
fcfc07d712
commit
9919a98023
34 changed files with 17 additions and 112 deletions
1
OsmAnd/.gitignore
vendored
1
OsmAnd/.gitignore
vendored
|
@ -2,6 +2,7 @@ bin/
|
|||
dist/
|
||||
gen/
|
||||
local.properties
|
||||
raw/
|
||||
obj/
|
||||
cpd.xml
|
||||
jni/Local.mk
|
||||
|
|
|
@ -67,7 +67,7 @@ park,Park
|
|||
parking,Parkeren
|
||||
parking,Parking
|
||||
pharmacy,Apotheek
|
||||
place_of_worship,Religieuze samenkomstplaats
|
||||
place_of_worship,Gebedsplaats
|
||||
police,Politie
|
||||
post_box,Brievenbus
|
||||
post_office,Postkantoor
|
|
@ -1,32 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
pages=('AF' 'AR' 'BR' 'CA' 'CS' 'DE' 'EN' 'ES' 'ET' 'EU' 'FA' 'FI' 'FR' 'GL' 'HR' 'HU' 'IA' 'IS' 'IT' 'JA' 'MK' 'NL' 'NO' 'PL' 'PS' 'PT' 'RU' 'SK' 'SV' 'UK' 'VI')
|
||||
|
||||
# declare -a pages=('AF' 'AR' 'BR' 'CA' 'CS' 'DE' 'EN' 'ES' 'ET' 'EU' 'FA' 'FI' 'FR' 'GL' 'HR' 'HU' 'IA' 'IS' 'IT' 'JA' 'MK' 'NL' 'NO' 'PL' 'PS' 'PT' 'RU' 'SK' 'SV' 'UK' 'VI')
|
||||
|
||||
for lang in ${pages[@]}
|
||||
do
|
||||
wget http://wiki.openstreetmap.org/wiki/Special:Export/Nominatim/Special_Phrases/${lang} -O /tmp/automatedJavaGenarationFile.txt
|
||||
|
||||
cat /tmp/automatedJavaGenarationFile.txt | grep " - " | grep " N" > /tmp/automatedJavaGenarationFile2.txt
|
||||
|
||||
sed -e 's/ *|/|/g' -e 's/| */|/g' </tmp/automatedJavaGenarationFile2.txt > /tmp/automatedJavaGenarationFile.txt
|
||||
|
||||
echo "" > specialphrases_${lang,,}.txt
|
||||
|
||||
while read line; do
|
||||
|
||||
IFS="||"
|
||||
arr=( $line )
|
||||
|
||||
|
||||
|
||||
echo ${arr[5]}','${arr[1]} >> specialphrases_${lang,,}.txt
|
||||
|
||||
done < /tmp/automatedJavaGenarationFile.txt
|
||||
|
||||
done
|
||||
|
||||
|
||||
rm /tmp/automatedJavaGenarationFile.txt
|
||||
rm /tmp/automatedJavaGenarationFile2.txt
|
|
@ -9,6 +9,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
public class SpecialPhrases {
|
||||
|
||||
|
@ -46,100 +47,35 @@ public class SpecialPhrases {
|
|||
* @throws IOException when reading the text file failed
|
||||
*/
|
||||
public static void setLanguage(Context ctx, Locale lang) throws IOException {
|
||||
if (lang.getLanguage().equals(new Locale("af").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_af);
|
||||
} else if (lang.getLanguage().equals(new Locale("ar").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ar);
|
||||
} else if (lang.getLanguage().equals(new Locale("br").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_br);
|
||||
} else if (lang.getLanguage().equals(new Locale("ca").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ca);
|
||||
} else if (lang.getLanguage().equals(new Locale("cs").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_cs);
|
||||
} else if (lang.getLanguage().equals(new Locale("de").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_de);
|
||||
} else if (lang.getLanguage().equals(new Locale("en").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_en);
|
||||
} else if (lang.getLanguage().equals(new Locale("es").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_es);
|
||||
} else if (lang.getLanguage().equals(new Locale("et").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_et);
|
||||
} else if (lang.getLanguage().equals(new Locale("eu").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_eu);
|
||||
} else if (lang.getLanguage().equals(new Locale("fa").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_fa);
|
||||
} else if (lang.getLanguage().equals(new Locale("fi").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_fi);
|
||||
} else if (lang.getLanguage().equals(new Locale("fr").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_fr);
|
||||
} else if (lang.getLanguage().equals(new Locale("gl").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_gl);
|
||||
} else if (lang.getLanguage().equals(new Locale("hr").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_hr);
|
||||
} else if (lang.getLanguage().equals(new Locale("hu").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_hu);
|
||||
} else if (lang.getLanguage().equals(new Locale("ia").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ia);
|
||||
} else if (lang.getLanguage().equals(new Locale("is").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_is);
|
||||
} else if (lang.getLanguage().equals(new Locale("it").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_it);
|
||||
} else if (lang.getLanguage().equals(new Locale("ja").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ja);
|
||||
} else if (lang.getLanguage().equals(new Locale("mk").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_mk);
|
||||
} else if (lang.getLanguage().equals(new Locale("nl").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_nl);
|
||||
} else if (lang.getLanguage().equals(new Locale("no").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_no);
|
||||
} else if (lang.getLanguage().equals(new Locale("pl").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_pl);
|
||||
} else if (lang.getLanguage().equals(new Locale("ps").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ps);
|
||||
} else if (lang.getLanguage().equals(new Locale("pt").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_pt);
|
||||
} else if (lang.getLanguage().equals(new Locale("ru").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_ru);
|
||||
} else if (lang.getLanguage().equals(new Locale("sk").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_sk);
|
||||
} else if (lang.getLanguage().equals(new Locale("sv").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_sv);
|
||||
} else if (lang.getLanguage().equals(new Locale("uk").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_uk);
|
||||
} else if (lang.getLanguage().equals(new Locale("vi").getLanguage())) {
|
||||
loadText(ctx, R.raw.specialphrases_vi);
|
||||
} else {
|
||||
// default case
|
||||
loadText(ctx, R.raw.specialphrases_en);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* load text from the specialphrases
|
||||
* @param ctx
|
||||
* @param resourceId resource representing the file to load
|
||||
* @throws IOException when reading the file failed
|
||||
*/
|
||||
private static void loadText(Context ctx, int resourceId) throws IOException {
|
||||
m = new HashMap<String,String>();
|
||||
|
||||
// The InputStream opens the resourceId and sends it to the buffer
|
||||
InputStream is = ctx.getResources().openRawResource(resourceId);
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_"+lang.getLanguage()+".txt");
|
||||
} catch (IOException ex) {
|
||||
// second try: default to English, if this fails, the error is thrown outside
|
||||
is = ctx.getAssets().open("specialphrases/specialphrases_en.txt");
|
||||
}
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
String readLine = null;
|
||||
|
||||
// While the BufferedReader readLine is not null
|
||||
while ((readLine = br.readLine()) != null) {
|
||||
String[] arr = readLine.split(",");
|
||||
if (arr != null && arr.length == 2)
|
||||
if (arr != null && arr.length == 2) {
|
||||
m.put(arr[0], arr[1]);
|
||||
System.out.println(arr[0]+" x "+arr[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Close the InputStream and BufferedReader
|
||||
is.close();
|
||||
br.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue