[android-developers] Re: Localizing example somewhere?

2010-11-13 Thread Hal
You may want want to get some ideas from the MVC Struts framework
(internationalization/Errors handling).
I realize that Struts doesn't run on Android. Perhaps you can use some
of their ideas and/or components. The latter
is probably more difficult ... Just a thought 

BTW, Struts uses Resource Bundles (key/value pairs for specific
language)

They also use standard Java mechanism

On Nov 12, 1:21 pm, Rutton rut...@web.de wrote:
 Thanks for your kind explanation.
 The describing text is easy to realize, but what I wanted to really
 know is, how to deal with (custom formatted) exception messages. So,
 is it good practice to use the Exception e.getLocalizedMessage() and
 use the Java-mechanism to deal with that, perhaps in conjunction with
 the Android-string localization features.

 What I have is exception throwing code (that creates custom
 formatted / not just text values that can be retrieved from the res/*
 files). And I ask myself, what to do here the best. At somepoint an
 exception *may* bubble up to a error message to the user, and how to
 localize these the best way.

 Cheers,
 R.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Localizing example somewhere?

2010-11-13 Thread Gergely Juhász
I think localized error messages are not supported on Android:
http://developer.android.com/reference/java/lang/Throwable.html#getLocalizedMessage%28%29

But your custom formatted error messages could be a good idea.

On 12 November 2010 19:21, Rutton rut...@web.de wrote:
 Thanks for your kind explanation.
 The describing text is easy to realize, but what I wanted to really
 know is, how to deal with (custom formatted) exception messages. So,
 is it good practice to use the Exception e.getLocalizedMessage() and
 use the Java-mechanism to deal with that, perhaps in conjunction with
 the Android-string localization features.

 What I have is exception throwing code (that creates custom
 formatted / not just text values that can be retrieved from the res/*
 files). And I ask myself, what to do here the best. At somepoint an
 exception *may* bubble up to a error message to the user, and how to
 localize these the best way.

 Cheers,
 R.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Localizing example somewhere?

2010-11-13 Thread letlite
You can catch and format whatever exception you are concerned about.
Use android.content.res.Resource.getString to format messages:
http://developer.android.com/reference/android/content/res/Resources.html#getString(int,
java.lang.Object...)

On Nov 12, 10:21 am, Rutton rut...@web.de wrote:
 Thanks for your kind explanation.
 The describing text is easy to realize, but what I wanted to really
 know is, how to deal with (custom formatted) exception messages. So,
 is it good practice to use the Exception e.getLocalizedMessage() and
 use the Java-mechanism to deal with that, perhaps in conjunction with
 the Android-string localization features.

 What I have is exception throwing code (that creates custom
 formatted / not just text values that can be retrieved from the res/*
 files). And I ask myself, what to do here the best. At somepoint an
 exception *may* bubble up to a error message to the user, and how to
 localize these the best way.

 Cheers,
 R.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Localizing example somewhere?

2010-11-13 Thread Rutton
Thanks for all your help. I worked it out my way. Here is the code for
a getLocalizedMessage in a custom exception:

public String getLocalizedMessage() {
Context c = LearningWordsApplication.getContext();

int id = R.string.error_unknown;
switch (error) {
case ERROR_CANNOT_CREATE_DIR:
id = R.string.error_directory_cannot_be_created;
break;
case ERROR_CANNOT_CREATE_FILE:
id = R.string.error_file_cannot_be_created;
break;
case ERROR_WEIRD_WRITING:
id = R.string.error_weird_writing;
break;
case ERROR_CANNOT_READ:
id = R.string.error_cannot_read_file;
break;
case ERROR_NO_CHARSET_FOR_READER:
id = R.string.error_no_charset_for_reader;
break;
case ERROR_CANNOT_FIND_EXTERNAL_STORAGE:
id = R.string.error_cannot_find_external_storage;
break;
default:
id = R.string.error_unknown;
}

String msg = c.getResources().getString(id);
String result = null;
if (paramTwo != null  paramOne != null) {
Object[] args = { paramOne, paramTwo };
result = MessageFormat.format(msg, args);
}
else if (paramOne != null) {
Object[] args = { paramOne };
result = MessageFormat.format(msg, args);
}

return result;
 }

As you see, a R.string.* Messages uses localized files, the android
localizing method and those contain the MessageFormat for the creation
of preformatted messages.
Cheers,
R.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Localizing example somewhere?

2010-11-12 Thread Rutton
Thanks for your kind explanation.
The describing text is easy to realize, but what I wanted to really
know is, how to deal with (custom formatted) exception messages. So,
is it good practice to use the Exception e.getLocalizedMessage() and
use the Java-mechanism to deal with that, perhaps in conjunction with
the Android-string localization features.

What I have is exception throwing code (that creates custom
formatted / not just text values that can be retrieved from the res/*
files). And I ask myself, what to do here the best. At somepoint an
exception *may* bubble up to a error message to the user, and how to
localize these the best way.

Cheers,
R.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en