chore: Localize all ui strings
This commit is contained in:
parent
16c7640fcd
commit
bec3ab3ad1
|
@ -11,7 +11,6 @@ import androidx.activity.enableEdgeToEdge
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.p_vacho.neat_calendar.R
|
||||
import com.p_vacho.neat_calendar.api.RetrofitClient
|
||||
import com.p_vacho.neat_calendar.util.ExceptionSerializer
|
||||
|
|
|
@ -183,7 +183,8 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
val defaultDateTime = endDateTime ?: startDateTime ?: defaultDate.atTime(12, 0)
|
||||
showDateTimePicker(defaultDateTime) { selectedDateTime ->
|
||||
if (!selectedDateTime.isAfter(startDateTime)) {
|
||||
Toast.makeText(this, "End time must be after start time", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this,
|
||||
getString(R.string.end_time_must_be_after_start_time), Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
endDateTime = selectedDateTime
|
||||
txtEndTime.setText(formatDateTime(selectedDateTime))
|
||||
|
@ -201,7 +202,8 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
val userId = (application as MyApplication).tokenManager.userId
|
||||
|
||||
if (userId.isNullOrEmpty()) {
|
||||
Toast.makeText(this, "User not authenticated. Unable to fetch categories.", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this,
|
||||
getString(R.string.user_not_authenticated_unable_to_fetch_categories), Toast.LENGTH_SHORT).show()
|
||||
finish() // Close the activity if no user is authenticated
|
||||
return
|
||||
}
|
||||
|
@ -245,14 +247,14 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
if (selectableCategories.isEmpty()) {
|
||||
Toast.makeText(this, "No more categories to add", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, getString(R.string.no_more_categories_to_add), Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
val categoryNames = selectableCategories.map { it.name }.toTypedArray()
|
||||
|
||||
val builder = android.app.AlertDialog.Builder(this)
|
||||
.setTitle("Add Category")
|
||||
.setTitle(getString(R.string.add_category))
|
||||
.setItems(categoryNames) { dialog, which ->
|
||||
val selectedCategory = selectableCategories[which]
|
||||
eventCategories.add(selectedCategory)
|
||||
|
@ -260,7 +262,7 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
updateCategoryView()
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("Cancel") { dialog, _ ->
|
||||
.setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
|
@ -291,12 +293,14 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
val description = etEventDescription.text.toString()
|
||||
|
||||
if (title.isEmpty() || startDateTime == null) {
|
||||
Toast.makeText(this, "Please provide a title and start time", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this,
|
||||
getString(R.string.please_provide_a_title_and_start_time), Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
if (!instantEvent && endDateTime == null) {
|
||||
Toast.makeText(this, "Please provide an end time or use an instant event", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this,
|
||||
getString(R.string.please_provide_an_end_time_or_use_an_instant_event), Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -343,7 +347,7 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(
|
||||
this@CreateEventActivity,
|
||||
"Failed to save event: $errMsg",
|
||||
getString(R.string.failed_to_save_event, errMsg),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -352,7 +356,7 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun handleEventSaved(createdEvent: EventResponse) {
|
||||
Toast.makeText(this, "Event Saved: ${createdEvent.title}", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, getString(R.string.event_saved, createdEvent.title), Toast.LENGTH_SHORT).show()
|
||||
|
||||
if (existingEvent == null) {
|
||||
val intent = Intent().apply {
|
||||
|
@ -388,7 +392,7 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
private fun openColorPickerDialog() {
|
||||
ColorPickerDialog
|
||||
.Builder(this)
|
||||
.setTitle("Choose Event Color") // TODO: Localize
|
||||
.setTitle(getString(R.string.choose_event_color))
|
||||
// setDefaultColor expects an int coming from a color resource
|
||||
// we're instead passing the current color as Int, so it's not
|
||||
// from a resource, which the linter doesn't like, so suppress it
|
||||
|
@ -402,7 +406,9 @@ class CreateEventActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun formatDateTime(dateTime: LocalDateTime?): String {
|
||||
return dateTime?.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) ?: "Select Time"
|
||||
return dateTime?.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) ?: getString(
|
||||
R.string.select_time
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateCategoryView() {
|
||||
|
|
|
@ -177,7 +177,7 @@ class DayViewActivity : AppCompatActivity() {
|
|||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(
|
||||
this@DayViewActivity,
|
||||
"Invitation sent to ${user.username}",
|
||||
getString(R.string.invitation_sent_to, user.username),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class DayViewActivity : AppCompatActivity() {
|
|||
val userNames = users.map { it.username }.toTypedArray()
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Select a user to invite")
|
||||
.setTitle(getString(R.string.select_a_user_to_invite))
|
||||
.setItems(userNames) { dialog, which ->
|
||||
// Pass the selected user back
|
||||
onUserSelected(users[which])
|
||||
|
|
|
@ -50,7 +50,7 @@ class LoginActivity : AppCompatActivity() {
|
|||
val password = passwordInput.text.toString().trim()
|
||||
|
||||
if (username.isEmpty() || password.isEmpty()) {
|
||||
Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, getString(R.string.please_fill_in_all_fields), Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
performLogin(username, password)
|
||||
}
|
||||
|
@ -72,16 +72,16 @@ class LoginActivity : AppCompatActivity() {
|
|||
|
||||
// Show the errors in a dialog
|
||||
AlertDialog.Builder(this@LoginActivity)
|
||||
.setTitle("Validation Errors")
|
||||
.setTitle(getString(R.string.validation_errors))
|
||||
.setMessage(errorMessages)
|
||||
.setPositiveButton("OK", null)
|
||||
.setPositiveButton(getString(R.string.ok), null)
|
||||
.show()
|
||||
}
|
||||
|
||||
is LoginResult.UnknownError -> {
|
||||
Toast.makeText(
|
||||
this@LoginActivity,
|
||||
"Login failed. Please try again.",
|
||||
getString(R.string.login_failed_please_try_again),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
|
|
|
@ -65,7 +65,8 @@ class RegisterActivity : AppCompatActivity() {
|
|||
val result = authRepository.register(username, password, email)
|
||||
when (result) {
|
||||
is RegisterResult.Success -> {
|
||||
Toast.makeText(this@RegisterActivity, "User registered, you may now log in", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this@RegisterActivity,
|
||||
getString(R.string.user_registered_you_may_now_log_in), Toast.LENGTH_SHORT).show()
|
||||
navigateToLoginActivity()
|
||||
}
|
||||
is RegisterResult.ValidationError -> {
|
||||
|
@ -76,16 +77,18 @@ class RegisterActivity : AppCompatActivity() {
|
|||
|
||||
// Show the errors in a dialog
|
||||
AlertDialog.Builder(this@RegisterActivity)
|
||||
.setTitle("Validation Errors")
|
||||
.setTitle(getString(R.string.validation_errors))
|
||||
.setMessage(errorMessages)
|
||||
.setPositiveButton("OK", null)
|
||||
.show()
|
||||
}
|
||||
is RegisterResult.UserAlreadyExists -> {
|
||||
Toast.makeText(this@RegisterActivity, "User already exists. Please log in.", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this@RegisterActivity,
|
||||
getString(R.string.user_already_exists_please_log_in), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
is RegisterResult.UnknownError -> {
|
||||
Toast.makeText(this@RegisterActivity, "Registration failed. Try again later.", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(this@RegisterActivity,
|
||||
getString(R.string.registration_failed_try_again_later), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,19 +111,22 @@ class SettingsActivity : AppCompatActivity() {
|
|||
throw e
|
||||
}
|
||||
|
||||
Toast.makeText(this@SettingsActivity, "This username or email is already taken", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this@SettingsActivity,
|
||||
getString(R.string.username_or_email_is_already_taken), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
Toast.makeText(this@SettingsActivity, "Changes saved", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this@SettingsActivity,
|
||||
getString(R.string.changes_saved), Toast.LENGTH_SHORT).show()
|
||||
// Make a ping request, to re-check api connectivity
|
||||
// TODO: Ping isn't a good enough check here, we should also validate tokens
|
||||
withContext(Dispatchers.IO) {
|
||||
RetrofitClient.ping()
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this@SettingsActivity, "No changes made", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this@SettingsActivity,
|
||||
getString(R.string.no_changes_made), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,4 +53,25 @@
|
|||
<string name="delete_account">Delete Account</string>
|
||||
<string name="controls">Controls</string>
|
||||
<string name="logout">Log out</string>
|
||||
<string name="invitation_sent_to">Invitation sent to %1$s</string>
|
||||
<string name="select_a_user_to_invite">Select a user to invite</string>
|
||||
<string name="username_or_email_is_already_taken">This username or email is already taken</string>
|
||||
<string name="changes_saved">Changes saved</string>
|
||||
<string name="no_changes_made">No changes made</string>
|
||||
<string name="user_registered_you_may_now_log_in">User registered, you may now log in</string>
|
||||
<string name="validation_errors">Validation Errors</string>
|
||||
<string name="user_already_exists_please_log_in">User already exists. Please log in.</string>
|
||||
<string name="registration_failed_try_again_later">Registration failed. Try again later.</string>
|
||||
<string name="please_fill_in_all_fields">Please fill in all fields</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="login_failed_please_try_again">Login failed. Please try again.</string>
|
||||
<string name="end_time_must_be_after_start_time">End time must be after start time</string>
|
||||
<string name="user_not_authenticated_unable_to_fetch_categories">User not authenticated. Unable to fetch categories.</string>
|
||||
<string name="no_more_categories_to_add">No more categories to add</string>
|
||||
<string name="please_provide_a_title_and_start_time">Please provide a title and start time</string>
|
||||
<string name="please_provide_an_end_time_or_use_an_instant_event">Please provide an end time or use an instant event</string>
|
||||
<string name="failed_to_save_event">Failed to save event: %1$s</string>
|
||||
<string name="event_saved">Event Saved: %1$s</string>
|
||||
<string name="choose_event_color">Choose Event Color</string>
|
||||
<string name="select_time">Select Time</string>
|
||||
</resources>
|
Loading…
Reference in a new issue