Add strings to translate
This commit is contained in:
parent
ab5d5deeb1
commit
239184861f
5 changed files with 77 additions and 55 deletions
|
@ -11,6 +11,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -43,6 +44,7 @@ public class OsmandRegions {
|
|||
Integer nameLocaleType = null;
|
||||
String locale = "en";
|
||||
Integer suffixType;
|
||||
Integer keyNameType;
|
||||
|
||||
|
||||
public void prepareFile(String fileName) throws IOException {
|
||||
|
@ -113,6 +115,13 @@ public class OsmandRegions {
|
|||
}
|
||||
return o.getNameByType(suffixType);
|
||||
}
|
||||
|
||||
public String getKeyName(BinaryMapDataObject o) {
|
||||
if(keyNameType == null) {
|
||||
return null;
|
||||
}
|
||||
return o.getNameByType(keyNameType);
|
||||
}
|
||||
|
||||
public boolean isInitialized(){
|
||||
return reader != null;
|
||||
|
@ -240,19 +249,27 @@ public class OsmandRegions {
|
|||
|
||||
public void initLocaleNames() throws IOException {
|
||||
// final Collator clt = OsmAndCollator.primaryCollator();
|
||||
final Map<String, BinaryMapDataObject> downloadNamesPrefix = new LinkedHashMap<String, BinaryMapDataObject>();
|
||||
final ResultMatcher<BinaryMapDataObject> resultMatcher = new ResultMatcher<BinaryMapDataObject>() {
|
||||
|
||||
@Override
|
||||
public boolean publish(BinaryMapDataObject object) {
|
||||
initTypes(object);
|
||||
String downloadName = object.getNameByType(downloadNameType).toLowerCase();
|
||||
String prefix = object.getNameByType(prefixType);
|
||||
String prefix = getPrefix(object);
|
||||
String keyName = getKeyName(object);
|
||||
if(prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
String locName = getLocaleName(object);
|
||||
if(locName != null && locName.length() > 0){
|
||||
String kn = keyName.toLowerCase();
|
||||
if(prefix.length() > 0) {
|
||||
downloadNamesPrefix.put(downloadName, object);
|
||||
kn = prefix.toLowerCase() +"_" + keyName;
|
||||
}
|
||||
downloadNamesToLocaleNames.put(downloadName, locName);
|
||||
downloadNamesToLocaleNames.put(kn, locName);
|
||||
}
|
||||
MapIndex mi = object.getMapIndex();
|
||||
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
||||
|
@ -281,6 +298,18 @@ public class OsmandRegions {
|
|||
}
|
||||
};
|
||||
iterateOverAllObjects(resultMatcher);
|
||||
// post process download names
|
||||
for(Map.Entry<String, BinaryMapDataObject> e : downloadNamesPrefix.entrySet()) {
|
||||
String downloadName = e.getKey();
|
||||
BinaryMapDataObject o = e.getValue();
|
||||
String prefix = getPrefix(o).toLowerCase();
|
||||
String locPrefix = downloadNamesToLocaleNames.get(prefix);
|
||||
String locName = downloadNamesToLocaleNames.get(downloadName);
|
||||
downloadNamesToLocaleNames.put(downloadName, locPrefix + " " + locName);
|
||||
String index = downloadNamesToLowercaseIndex.get(downloadName);
|
||||
downloadNamesToLowercaseIndex.put(downloadName, index + " " + prefix + " " + locPrefix.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -354,6 +383,7 @@ public class OsmandRegions {
|
|||
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
|
||||
prefixType = object.getMapIndex().getRule("region_prefix", null);
|
||||
suffixType = object.getMapIndex().getRule("region_suffix", null);
|
||||
keyNameType = object.getMapIndex().getRule("key_name", null);
|
||||
if (downloadNameType == null || nameType == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -379,7 +409,8 @@ public class OsmandRegions {
|
|||
|
||||
public static void main(String[] args) throws IOException {
|
||||
OsmandRegions or = new OsmandRegions();
|
||||
or.prepareFile("/home/victor/projects/osmand/osm-gen/Osmand_regions.obf");
|
||||
or.setLocale("ru");
|
||||
or.prepareFile("/home/victor/projects/osmand/repo/resources/countries-info/regions.ocbf");
|
||||
// or.cacheAllCountries();
|
||||
// long t = System.currentTimeMillis();
|
||||
// or.cacheAllCountries();
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="download_tab_downloads">Downloads</string>
|
||||
<string name="download_tab_updates">Updates</string>
|
||||
<string name="download_tab_local">Local</string>
|
||||
<string name="no_internet_connection">Not possible to download. Please connect to Wi-Fi to proceed.</string>
|
||||
<string name="dismiss">Dismiss</string>
|
||||
<string name="everything_up_to_date">Everything up to date</string>
|
||||
|
|
|
@ -1,37 +1,36 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
import android.widget.*;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Window;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.FavouritesActivity;
|
||||
import net.osmand.plus.activities.LocalIndexInfo;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import com.actionbarsherlock.view.Window;
|
||||
|
||||
/**
|
||||
* Created by Denis on 08.09.2014.
|
||||
|
@ -80,14 +79,14 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false);
|
||||
if (getMyApplication().getAppCustomization().onlyTourDownload()){
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator("Downloads"),
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
|
||||
DownloadIndexFragment.class, null);
|
||||
} else {
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator("Local"),
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
|
||||
LocalIndexesFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator("Downloads"),
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
|
||||
DownloadIndexFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES").setIndicator("Updates"),
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES").setIndicator(getString(R.string.download_tab_updates)),
|
||||
UpdatesIndexFragment.class, null);
|
||||
}
|
||||
|
||||
|
@ -406,20 +405,5 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getFullName(IndexItem e, OsmandApplication app, OsmandRegions osmandRegions) {
|
||||
String eName;
|
||||
List<IndexItem> forCat = new ArrayList<IndexItem>();
|
||||
forCat.add(e);
|
||||
List<IndexItemCategory> category = IndexItemCategory.categorizeIndexItems(app, forCat);
|
||||
if (category.size() != 0){
|
||||
eName = e.getVisibleDescription(app) + "\n"
|
||||
+ category.get(0).name + " "
|
||||
+ e.getVisibleName(app, osmandRegions);
|
||||
} else {
|
||||
eName = e.getVisibleDescription(app) + "\n"
|
||||
+ e.getVisibleName(app, osmandRegions);
|
||||
}
|
||||
return eName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,29 +8,33 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListAdapter;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.actionbarsherlock.view.SubMenu;
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
} else {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
String eName = DownloadActivity.getFullName(e, getMyApplication(), osmandRegions);
|
||||
String eName = e.getVisibleName(getMyApplication(), osmandRegions);
|
||||
|
||||
name.setText(eName.trim()); //$NON-NLS-1$
|
||||
String d = e.getDate(format) + "\n" + e.getSizeDescription(getMyApplication());
|
||||
|
|
Loading…
Reference in a new issue