Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added i18n for interval validation #33 #34

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ private String formatTime(long seconds){
*/
private int parseTime(String stringTime) throws NumberFormatException {
if (stringTime == null)
throw new NumberFormatException("parseTimeString null str");
throw new NumberFormatException(getString(R.string.main_text_interval_exception_null));
if (stringTime.isEmpty())
throw new NumberFormatException("parseTimeString empty str");
throw new NumberFormatException(getString(R.string.main_text_interval_exception_empty));

int minutes, seconds;

Expand All @@ -447,15 +447,15 @@ private int parseTime(String stringTime) throws NumberFormatException {

// Throw an exception if the string the wrong length
if (units.length != 2)
throw new NumberFormatException("parseTimeString too many sections");
throw new NumberFormatException(getString(R.string.main_text_interval_exception_sections));

// Get the sections from the string
minutes = Integer.parseInt(units[0].trim());
seconds = Integer.parseInt(units[1].trim());

// Check that the sections are within the correct range
if ((minutes < 0) || (minutes > 60) || (seconds < 0) || (seconds > 60))
throw new NumberFormatException("parseTimeString range error. The values for minutes and seconds must be within [0,60]");
throw new NumberFormatException(getString(R.string.main_text_interval_exception_range));

// Return the result
return (minutes * 60) + seconds;
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<string name="main_button_disabled_text">Inaktiver Button</string>
<string name="main_text_work_interval">Trainingsintervall</string>
<string name="main_text_rest_interval">Pausenintervall</string>
<string name="main_text_interval_exception_null">Null ist kein erlaubter Wert</string>
<string name="main_text_interval_exception_empty">Der Wert darf nicht leer sein</string>
<string name="main_text_interval_exception_sections">Der Wert hat zu viele Abschnitte</string>
<string name="main_text_interval_exception_range">Die Werte für Minuten und Sekunden müssen zwischen 0 und 60 liegen</string>
<string name="main_text_sets">Sätze</string>
<string name="main_text_start">START ></string>
<string name="main_text_title">Bitte wählen:</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<string name="main_button_disabled_text">Inactive Button</string>
<string name="main_text_work_interval">Workout Interval</string>
<string name="main_text_rest_interval">Rest Interval</string>
<string name="main_text_interval_exception_null">Null values are not allowed</string>
<string name="main_text_interval_exception_empty">Empty values are not allowed</string>
<string name="main_text_interval_exception_sections">The value has too many sections</string>
<string name="main_text_interval_exception_range">The values for minutes and seconds must be between 0 and 60</string>
<string name="main_text_sets">Sets</string>
<string name="main_text_start">START ></string>
<string name="main_text_title">Please choose:</string>
Expand Down