Merge pull request #11468 from osmandapp/Untranslated-travel

Untranslated Travel guides (wikivoyage) file names
This commit is contained in:
Vitaliy 2021-04-19 20:20:37 +03:00 committed by GitHub
commit a657d71e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 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
@ -90,6 +95,17 @@ public class FileNameTranslationHelper {
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);
return ctx.getString(R.string.ltr_or_rtl_combine_via_space, wikiVoyageName, wikiVoyageWord);
}
public static String getVoiceName(Context ctx, String fileName) {
try {
String nm = fileName.replace('-', '_').replace(' ', '_');
@ -245,4 +261,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;
}
}