Untranslated Travel guides (wikivoyage) file names

https://github.com/osmandapp/OsmAnd/issues/11398
This commit is contained in:
androiddevkotlin 2021-04-19 17:33:40 +03:00
parent 2d2a951dde
commit ed8b9973a9
2 changed files with 52 additions and 7 deletions

View file

@ -361,6 +361,9 @@ public class DownloadActivityType {
if (basename.endsWith(FileNameTranslationHelper.WIKI_NAME)) {
return FileNameTranslationHelper.getWikiName(ctx, basename);
}
if (basename.endsWith(FileNameTranslationHelper.WIKIVOYAGE_NAME)) {
return FileNameTranslationHelper.getWikivoyageName(ctx, basename);
}
// if (this == HILLSHADE_FILE){
// return FileNameTranslationHelper.getHillShadeName(ctx, osmandRegions, bn);
// }

View file

@ -1,9 +1,11 @@
package net.osmand.plus.helpers;
import android.content.Context;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.map.OsmandRegions;
import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.download.DownloadResources;
@ -19,6 +21,7 @@ import java.lang.reflect.Field;
public class FileNameTranslationHelper {
private static final Log LOG = PlatformUtil.getLog(FileNameTranslationHelper.class);
public static final String WIKI_NAME = "_wiki";
public static final String WIKIVOYAGE_NAME = "_wikivoyage";
public static final String HILL_SHADE = "Hillshade";
public static final String SLOPE = "Slope";
public static final String SEA_DEPTH = "Depth_";
@ -31,6 +34,8 @@ public class FileNameTranslationHelper {
String basename = getBasename(fileName);
if (basename.endsWith(WIKI_NAME)) { //wiki files
return getWikiName(ctx, basename);
} else if (basename.endsWith(WIKIVOYAGE_NAME)) {
return getWikivoyageName(ctx, basename);
} else if (fileName.endsWith("tts")) { //tts files
return getVoiceName(ctx, fileName);
} else if (fileName.endsWith(IndexConstants.FONT_INDEX_EXT)) { //otf files
@ -75,10 +80,10 @@ public class FileNameTranslationHelper {
return ctx.getString(R.string.ltr_or_rtl_combine_via_space, locName, "(" + terrain + ")");
}
public static String getWikiName(Context ctx, String basename){
public static String getWikiName(Context ctx, String basename) {
String cutted = basename.substring(0, basename.indexOf("_wiki"));
String wikiName = getStandardLangName(ctx, cutted);
if (wikiName == null){
if (wikiName == null) {
wikiName = cutted;
}
String wikiWord = ctx.getString(R.string.amenity_type_osmwiki);
@ -87,7 +92,21 @@ public class FileNameTranslationHelper {
//removing word in "()" from recourse file
return wikiName + " " + wikiWord.substring(0, index).trim();
}
return wikiName + " " + ctx.getString(R.string.amenity_type_osmwiki);
return wikiName + " " + ctx.getString(R.string.amenity_type_osmwiki);
}
public static String getWikivoyageName(Context ctx, String basename) {
String formattedName = basename.substring(0, basename.indexOf(WIKIVOYAGE_NAME)).replaceAll("-", "").replaceAll("all", "");
String wikiVoyageName = getSuggestedWikivoyageMaps(ctx, formattedName);
if (wikiVoyageName == null) {
wikiVoyageName = formattedName;
}
String wikiVoyageWord = ctx.getString(R.string.shared_string_wikivoyage);
int index = wikiVoyageWord.indexOf("(");
if (index >= 0) {
return ctx.getString(R.string.ltr_or_rtl_combine_via_space, wikiVoyageName, wikiVoyageWord.substring(0, index).trim());
}
return ctx.getString(R.string.ltr_or_rtl_combine_via_space, wikiVoyageName, wikiVoyageWord);
}
public static String getVoiceName(Context ctx, String fileName) {
@ -196,8 +215,8 @@ public class FileNameTranslationHelper {
return ctx.getString(R.string.lang_pl);
} else if (filename.equalsIgnoreCase("Portuguese")) {
return ctx.getString(R.string.lang_pt);
//} else if (filename.equalsIgnoreCase("Portuguese")) {
// return ctx.getString(R.string.lang_pt_br);
//} else if (filename.equalsIgnoreCase("Portuguese")) {
// return ctx.getString(R.string.lang_pt_br);
} else if (filename.equalsIgnoreCase("Romanian")) {
return ctx.getString(R.string.lang_ro);
} else if (filename.equalsIgnoreCase("Russian")) {
@ -227,7 +246,7 @@ public class FileNameTranslationHelper {
return ctx.getString(R.string.index_item_world_altitude_correction);
} else if (basename.equals("world_basemap")) {
return ctx.getString(R.string.index_item_world_basemap);
} else if (basename.equals("world_basemap_detailed")){
} else if (basename.equals("world_basemap_detailed")) {
return ctx.getString(R.string.index_item_world_basemap_detailed);
} else if (basename.equals("world_bitcoin_payments")) {
return ctx.getString(R.string.index_item_world_bitcoin_payments);
@ -245,4 +264,27 @@ public class FileNameTranslationHelper {
}
return null;
}
private static String getSuggestedWikivoyageMaps(Context ctx, String filename) {
if (WorldRegion.AFRICA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_africa);
} else if (WorldRegion.AUSTRALIA_AND_OCEANIA_REGION_ID.replaceAll("-", "").equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_oceania);
} else if (WorldRegion.ASIA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_asia);
} else if (WorldRegion.CENTRAL_AMERICA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_central_america);
} else if (WorldRegion.EUROPE_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_europe);
} else if (WorldRegion.RUSSIA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_russia);
} else if (WorldRegion.NORTH_AMERICA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_north_america);
} else if (WorldRegion.SOUTH_AMERICA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_south_america);
} else if (WorldRegion.ANTARCTICA_REGION_ID.equalsIgnoreCase(filename)) {
return ctx.getString(R.string.index_name_antarctica);
}
return null;
}
}