externalize strings

git-svn-id: https://osmand.googlecode.com/svn/trunk@186 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-20 11:58:23 +00:00
parent 2b04069320
commit 56427dc8ba
10 changed files with 62 additions and 22 deletions

View file

@ -7,6 +7,7 @@ public class Messages {
private static ResourceBundle bundle = ResourceBundle.getBundle("messages"); //$NON-NLS-1$
public static final String KEY_M = "m"; //$NON-NLS-1$
public static final String KEY_KM = "km"; //$NON-NLS-1$
public static final String KEY_KM_H = "km_h"; //$NON-NLS-1$
public static String getMessage(String key){
return bundle.getString(key);

View file

@ -22,9 +22,6 @@ public class ToDoConstants {
public int DESCRIBE_ABOUT_AUTHORS = 8;
// TODO ANDROID
// 31. Translation.
// DONE : partially olga
// TODO : everywhere put non-nls, check all translated into russian [swing could not be translated]
// 34. Suppport navigation for calculated route (example of get route from internet is in swing app).
// DONE : MiniMap done, Routing settings done, RouteLayer done, RoutingHelper done.
@ -78,6 +75,7 @@ public class ToDoConstants {
// DONE ANDROID :
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
// DONE : add to app settings preference (Refresh indexes).
// 31. Translation.
// DONE SWING

View file

@ -1,5 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="opening_hours">Рабочие часы: </string>
<string name="opening_changeset">Открытие пакета правок</string>
<string name="closing_changeset">Закрытие пакета правок</string>
<string name="commiting_node">Сохранения объекта</string>
<string name="loading_poi_obj">Загрузка poi </string>
<string name="auth_failed">Авторизация не прошла</string>
<string name="failed_op">, ошибка : </string>
<string name="converting_names">Конвертация имен английский/родных...</string>
<string name="loading_streets_buildings">Загружаются дома/улицы...</string>
<string name="loading_postcodes">Загружаются почтовые индексы...</string>
<string name="loading_streets">Загружаются улицы...</string>
<string name="loading_cities">Загружаются города...</string>
<string name="loading">Загрузка</string>
<string name="poi">POI</string>
<string name="error_occurred_saving_gpx">Ошибка во время сохранения пути в gpx</string>
<string name="error_calculating_route">Ошибка прокладки маршрута: </string>
<string name="error_calculating_route_occured">Ошибка во время прокладки маршрута</string>
<string name="empty_route_calculated">Пустой путь рассчитан</string>
<string name="new_route_calculated_dist">Проложен новый путь, расстояние :</string>
<string name="arrived_at_destination">Вы прибыли в пункт назначения</string>
<string name="invalid_locations">Координаты неправильные</string>
<string name="go_back_to_osmand">Вернуться к OsmAnd карте</string>
<string name="close">Закрыть</string>
<string name="loading_data">Загрузка данных</string>
<string name="reading_indexes">Чтение индексов...</string>
<string name="previous_run_crashed">Предыдущий запуск приложения был неудачен. Лог файл в {0}. Пожалуйста откройте баг и присоедините лог файл.</string>
<string name="saving_gpx_tracks">Сохранение gpx путей на SD...</string>
<string name="finished_task">Окончен : </string>
<string name="reload_indexes_descr">Перезагрузить индексы с SD</string>
<string name="reload_indexes">Обновить индексы</string>

View file

@ -1,5 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="opening_hours">Opening hours : </string>
<string name="opening_changeset">Openging changeset</string>
<string name="closing_changeset">Closing changeset</string>
<string name="commiting_node">Commiting node</string>
<string name="loading_poi_obj">Loading poi </string>
<string name="auth_failed"> Authorization failed</string>
<string name="failed_op"> failed : </string>
<string name="converting_names">Converting native/english names...</string>
<string name="loading_streets_buildings">Loading streets/buildings...</string>
<string name="loading_postcodes">Loading postcodes...</string>
<string name="loading_streets">Loading streets...</string>
<string name="loading_cities">Loading cities...</string>
<string name="loading">Loading</string>
<string name="poi">POI</string>
<string name="error_occurred_saving_gpx">Error occurred while saving gpx</string>
<string name="error_calculating_route">Error calculating route : </string>

View file

@ -327,7 +327,7 @@ public class EditingPOIActivity {
}
connection.connect();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
String msg = userOperation + " failed : " + connection.getResponseMessage();
String msg = userOperation + ctx.getString(R.string.failed_op) + connection.getResponseMessage();
log.error(msg);
Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();
} else {
@ -352,14 +352,14 @@ public class EditingPOIActivity {
}
} catch (NullPointerException e) {
// that's tricky case why NPE is thrown to fix that problem httpClient could be used
String msg = "Authorization failed";
String msg = ctx.getString(R.string.auth_failed);
log.error(msg , e);
Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();
} catch (MalformedURLException e) {
log.error(userOperation + " failed" , e);
log.error(userOperation + ctx.getString(R.string.failed_op) , e);
Toast.makeText(ctx, MessageFormat.format(ctx.getResources().getString(R.string.poi_error_unexpected_template), userOperation), Toast.LENGTH_LONG).show();
} catch (IOException e) {
log.error(userOperation + " failed" , e);
log.error(userOperation + ctx.getString(R.string.failed_op) , e);
Toast.makeText(ctx, MessageFormat.format(ctx.getResources().getString(R.string.poi_error_io_error_template), userOperation), Toast.LENGTH_LONG).show();
}
@ -392,7 +392,7 @@ public class EditingPOIActivity {
} catch (IOException e) {
log.error("Unhandled exception", e); //$NON-NLS-1$
}
String response = sendRequest(SITE_API + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), "Opening changeset", true); //$NON-NLS-1$ //$NON-NLS-2$
String response = sendRequest(SITE_API + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
if (response != null && response.length() > 0) {
id = Long.parseLong(response);
}
@ -401,7 +401,7 @@ public class EditingPOIActivity {
}
public void closeChangeSet(long id){
String response = sendRequest(SITE_API+"api/0.6/changeset/"+id+"/close", "PUT", "", "Closing changeset", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String response = sendRequest(SITE_API+"api/0.6/changeset/"+id+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
log.info("Response : " + response); //$NON-NLS-1$
}
@ -481,7 +481,7 @@ public class EditingPOIActivity {
log.error("Unhandled exception", e); //$NON-NLS-1$
}
String res = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.getBuffer().toString(), "Commiting node", true);
writer.getBuffer().toString(), ctx.getString(R.string.commiting_node), true);
log.debug(res+""); //$NON-NLS-1$
if (res != null) {
if (CREATE_ACTION.equals(action)) {
@ -511,7 +511,7 @@ public class EditingPOIActivity {
public Node loadNode(long id) {
try {
String res = sendRequest(SITE_API+"api/0.6/node/"+id, "GET", null, "Loading poi " + id, false); //$NON-NLS-1$ //$NON-NLS-2$
String res = sendRequest(SITE_API+"api/0.6/node/"+id, "GET", null, ctx.getString(R.string.loading_poi_obj) + id, false); //$NON-NLS-1$ //$NON-NLS-2$
if(res != null){
OsmBaseStorage st = new OsmBaseStorage();
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$

View file

@ -289,7 +289,7 @@ public class SearchAddressActivity extends Activity {
}
protected void startLoadDataInThread(String progressMsg){
final ProgressDialog dlg = ProgressDialog.show(this, "Loading", progressMsg, true);
final ProgressDialog dlg = ProgressDialog.show(this, getString(R.string.loading), progressMsg, true);
new Thread("Loader search data") { //$NON-NLS-1$
@Override
public void run() {
@ -322,15 +322,15 @@ public class SearchAddressActivity extends Activity {
Long cityId = OsmandSettings.getLastSearchedCity(this);
String postcode = OsmandSettings.getLastSearchedPostcode(this);
if (!region.areCitiesPreloaded()) {
progressMsg = "Loading cities...";
progressMsg = getString(R.string.loading_cities);
} else if (postcode != null && !region.arePostcodesPreloaded()) {
progressMsg = "Loading postcodes...";
progressMsg = getString(R.string.loading_postcodes);
} else if (cityId != -1 && region.getCityById(cityId) != null && region.getCityById(cityId).isEmptyWithStreets()) {
progressMsg = "Loading streets/buildings...";
progressMsg = getString(R.string.loading_streets_buildings);
} else if (postcode != null && region.getPostcode(postcode) != null && region.getPostcode(postcode).isEmptyWithStreets()) {
progressMsg = "Loading streets/buildings...";
progressMsg = getString(R.string.loading_streets_buildings);
} else if (OsmandSettings.usingEnglishNames(this) != region.useEnglishNames()) {
progressMsg = "Converting native/english names...";
progressMsg = getString(R.string.converting_names);
}
}
postcode = null;

View file

@ -80,7 +80,7 @@ public class SearchPOIActivity extends ListActivity {
Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(pos);
String format = amenity.getSimpleFormat(OsmandSettings.usingEnglishNames(v.getContext()));
if (amenity.getOpeningHours() != null) {
format += "\nOpening hours : " + amenity.getOpeningHours();
format += "\n"+getString(R.id.OpeningHours) + amenity.getOpeningHours(); //$NON-NLS-1$
}
Toast.makeText(v.getContext(), format, Toast.LENGTH_LONG).show();
return true;

View file

@ -37,7 +37,7 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
street1 = region.getStreetByName(city, (OsmandSettings.getLastSearchedStreet(this)));
}
if(city != null){
startLoadDataInThread("Finding streets...");
startLoadDataInThread(getString(R.string.loading_streets));
}
}
@ -47,7 +47,7 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
protected void startLoadDataInThread(String progressMsg){
final ProgressDialog dlg = ProgressDialog.show(this, "Loading", progressMsg, true);
final ProgressDialog dlg = ProgressDialog.show(this, getString(R.string.loading), progressMsg, true);
new Thread("Loader search data") { //$NON-NLS-1$
@Override
public void run() {

View file

@ -9,6 +9,7 @@ import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.location.Location;
import com.osmand.Messages;
import com.osmand.activities.MapActivity;
import com.osmand.osm.MapUtils;
@ -155,7 +156,7 @@ public class MapInfoLayer implements OsmandMapLayer {
if(map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()){
if(Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > .3f){
cachedSpeed = map.getLastKnownLocation().getSpeed();
cachedSpeedString = ((int) (cachedSpeed * 3.6f)) + " km/h";
cachedSpeedString = ((int) (cachedSpeed * 3.6f)) + Messages.getMessage(Messages.KEY_KM_H);
float right = paintBlack.measureText(cachedSpeedString) + 8 + boundsForSpeed.left;
boundsForSpeed.right = boundsForDist.right = Math.max(right, boundsForDist.right);
}

View file

@ -101,7 +101,7 @@ public class POIMapLayer implements OsmandMapLayer {
if(n != null){
String format = n.getSimpleFormat(OsmandSettings.usingEnglishNames(view.getContext()));
if(n.getOpeningHours() != null){
format += "\nOpening hours : " + n.getOpeningHours();
format += "\n" + view.getContext().getString(R.string.opening_hours) + n.getOpeningHours(); //$NON-NLS-1$
}
Toast.makeText(view.getContext(), format, Toast.LENGTH_SHORT).show();
return true;