Skip to content

Commit

Permalink
Renames most String resources and let translations of array values po…
Browse files Browse the repository at this point in the history
…int to strings.xml

This prepares translation via Weblate to supply more detailed names of String resources and one single source of translatable text from within the app.
  • Loading branch information
meikpiep committed Mar 2, 2024
1 parent a94a2bf commit fbdd644
Show file tree
Hide file tree
Showing 32 changed files with 356 additions and 339 deletions.
2 changes: 1 addition & 1 deletion gauguin-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<activity android:name=".ui.LoadGameListActivity" />
<activity
android:name=".ui.statistics.StatisticsActivity"
android:label="@string/stats_group_title" />
android:label="@string/statistics_title" />
<activity
android:name=".ui.SettingsActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ class LoadGameListActivity : AppCompatActivity() {

fun deleteGameDialog(filename: File?) {
MaterialAlertDialogBuilder(this)
.setTitle(resources.getString(R.string.dialog_delete_title))
.setMessage(resources.getString(R.string.dialog_delete_msg))
.setNegativeButton(resources.getString(R.string.dialog_cancel)) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(resources.getString(R.string.dialog_ok)) { _: DialogInterface?, _: Int ->
.setTitle(resources.getString(R.string.dialog_delete_game_title))
.setMessage(resources.getString(R.string.dialog_delete_game_message))
.setNegativeButton(
resources.getString(R.string.dialog_delete_game_cancel_button),
) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(resources.getString(R.string.dialog_delete_game_ok_button)) { _: DialogInterface?, _: Int ->
deleteSaveGame(
filename,
)
Expand All @@ -115,10 +117,10 @@ class LoadGameListActivity : AppCompatActivity() {

private fun deleteAllGamesDialog() {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.dialog_delete_all_title)
.setMessage(R.string.dialog_delete_all_msg)
.setNegativeButton(R.string.dialog_cancel) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.dialog_ok) { _: DialogInterface?, _: Int -> deleteAllSaveGames() }
.setTitle(R.string.dialog_delete_all_games_title)
.setMessage(R.string.dialog_delete_all_games_message)
.setNegativeButton(R.string.dialog_delete_all_games_cancel_button) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.dialog_delete_all_games_ok_button) { _: DialogInterface?, _: Int -> deleteAllSaveGames() }
.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class LoadGameListAdapter(context: LoadGameListActivity) :
}
holder.duration.text = Utils.displayableGameDuration(grid.playTime)
holder.gametitle.text =
mContext.getString(R.string.gridSizeInfo, grid.gridSize.width, grid.gridSize.height)
mContext.getString(R.string.game_grid_size_info, grid.gridSize.width, grid.gridSize.height)
holder.date.text =
DateFormat.getDateInstance(DateFormat.MEDIUM).format(
grid.creationDate,
Expand Down
20 changes: 10 additions & 10 deletions gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/MainDialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class MainDialogs(private val mainActivity: MainActivity) : KoinComponent {
MaterialAlertDialogBuilder(
mainActivity,
)
builder.setTitle(R.string.dialog_restart_title)
.setMessage(R.string.dialog_restart_msg)
.setNegativeButton(R.string.dialog_cancel) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.dialog_ok) { _: DialogInterface?, _: Int ->
builder.setTitle(R.string.dialog_restart_current_game_title)
.setMessage(R.string.dialog_restart_current_game_message)
.setNegativeButton(R.string.dialog_restart_current_game_cancel_button) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.dialog_restart_current_game_ok_button) { _: DialogInterface?, _: Int ->
game.restartGame()
mainActivity.startFreshGrid(true)
}
Expand All @@ -55,13 +55,13 @@ class MainDialogs(private val mainActivity: MainActivity) : KoinComponent {
R.layout.dialog_help,
mainActivity.findViewById(R.id.help_layout),
)
builder.setTitle(R.string.help_section_title)
builder.setTitle(R.string.help_overall_title)
.setView(layout)
.setNeutralButton(R.string.about_section_title) { _: DialogInterface?, _: Int ->
.setNeutralButton(R.string.about_overall_title) { _: DialogInterface?, _: Int ->
openAboutDialog()
if (deactivateNewUserFlag) applicationPreferences.deactivateNewUserCheck()
}
.setPositiveButton(R.string.dialog_ok) { dialog: DialogInterface, _: Int ->
.setPositiveButton(R.string.help_dismiss_dialog_button) { dialog: DialogInterface, _: Int ->
dialog.cancel()
if (deactivateNewUserFlag) applicationPreferences.deactivateNewUserCheck()
}
Expand All @@ -85,10 +85,10 @@ class MainDialogs(private val mainActivity: MainActivity) : KoinComponent {
R.layout.dialog_about,
mainActivity.findViewById(R.id.about_layout),
)
builder.setTitle(R.string.about_section_title)
builder.setTitle(R.string.about_overall_title)
.setView(layout)
.setNeutralButton(R.string.help_section_title) { _: DialogInterface?, _: Int -> openHelpDialog() }
.setPositiveButton(R.string.dialog_ok) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setNeutralButton(R.string.help_overall_title) { _: DialogInterface?, _: Int -> openHelpDialog() }
.setPositiveButton(R.string.about_dismiss_dialog_button) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BalloonHintPopup(
private val mistakes = game.grid.numberOfMistakes()
private val text =
resources.getQuantityString(
R.plurals.toast_mistakes,
R.plurals.game_info_popup_mistakes,
mistakes,
mistakes,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class MainActivity : AppCompatActivity(), GridCreationListener, GameSolvedListen
}

fun gameSaved() {
Snackbar.make(binding.root, resources.getText(R.string.main_activity_current_game_saved), Snackbar.LENGTH_LONG)
Snackbar.make(binding.root, resources.getText(R.string.main_activity_application_bar_item_current_game_saved), Snackbar.LENGTH_LONG)
.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,49 +39,49 @@ class MainNavigationViewService(

val newGameItem =
PrimaryDrawerItem().apply {
nameRes = R.string.menu_new
nameRes = R.string.main_menu_item_new
identifier = 1
iconRes = R.drawable.outline_add_24
}
val restartGameItem =
PrimaryDrawerItem().apply {
nameRes = R.string.menu_restart_game
nameRes = R.string.main_menu_item_restart_game
identifier = 2
iconRes = R.drawable.outline_replay_24
}
val loadGameItem =
PrimaryDrawerItem().apply {
nameRes = R.string.menu_load
nameRes = R.string.main_menu_item_load_game
identifier = 3
iconRes = R.drawable.outline_open_in_new_24
}
val saveGameItem =
PrimaryDrawerItem().apply {
nameRes = R.string.menu_save
nameRes = R.string.main_menu_item_save_game
identifier = 4
iconRes = R.drawable.outline_save_24
}
val statisticsItem =
SecondaryDrawerItem().apply {
nameRes = R.string.menu_stats
nameRes = R.string.main_menu_item_show_statistics
identifier = 5
iconRes = R.drawable.outline_leaderboard_24
}
val settingsItem =
SecondaryDrawerItem().apply {
nameRes = R.string.menu_settings
nameRes = R.string.main_menu_item_open_settings
identifier = 6
iconRes = R.drawable.outline_settings_24
}
val helpItem =
SecondaryDrawerItem().apply {
nameRes = R.string.menu_help
nameRes = R.string.main_menu_item_show_help
identifier = 7
iconRes = R.drawable.outline_help_24
}
val bugsAndFeaturesItem =
SecondaryDrawerItem().apply {
nameRes = R.string.menu_issues
nameRes = R.string.main_menu_item_open_github_issues
identifier = 8
iconRes = R.drawable.outline_bug_report_24
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ class GridShapeOptionsFragment : Fragment(R.layout.fragment_new_game_grid_shape_
binding.newGridPreview.invalidate()
binding.newGameGridSize.text =
if (squareOnlyMode) {
resources.getString(R.string.new_grid_shape_size_square, grid.gridSize.width)
resources.getString(R.string.game_setting_new_grid_shape_size_square, grid.gridSize.width)
} else {
resources.getString(R.string.new_grid_shape_size_rectangular, grid.gridSize.width, grid.gridSize.height)
resources.getString(R.string.game_setting_new_grid_shape_size_rectangular, grid.gridSize.width, grid.gridSize.height)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ class StatisticsActivity : AppCompatActivity() {

private fun resetStatisticsDialog() {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.dialog_reset_statistics_title)
.setMessage(R.string.dialog_reset_statistics_msg)
.setNegativeButton(R.string.dialog_cancel) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.dialog_ok) { _: DialogInterface?, _: Int ->
.setTitle(R.string.statistics_dialog_reset_statistics_title)
.setMessage(R.string.statistics_dialog_reset_statistics_message)
.setNegativeButton(
R.string.statistics_dialog_reset_statistics_cancel_button,
) { dialog: DialogInterface, _: Int -> dialog.cancel() }
.setPositiveButton(R.string.statistics_dialog_reset_statistics_ok_button) { _: DialogInterface?, _: Int ->
run {
statisticsManager.clearStatistics()
updateViews()
Expand Down
4 changes: 2 additions & 2 deletions gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
style="@style/TextAppearance.Material3.HeadlineMedium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/new_grid_game_options"/>
android:text="@string/game_setting_new_grid_game_options"/>

<FrameLayout
android:id="@+id/newGameOptions"
Expand All @@ -53,7 +53,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion gauguin-app/src/main/res/layout-land/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
android:id="@+id/squareButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_grid_shape_square"
android:text="@string/game_setting_new_grid_shape_square"
app:icon="@drawable/outline_square_20"
/>
<Button
style="?attr/materialButtonOutlinedStyle"
android:id="@+id/rectangularButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_grid_shape_rectangular"
android:text="@string/game_setting_new_grid_shape_rectangular"
app:icon="@drawable/outline_rectangle_20"
/>
</com.google.android.material.button.MaterialButtonToggleGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
14 changes: 7 additions & 7 deletions gauguin-app/src/main/res/layout-w600dp/activity_statistics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/stats_puzzles_title"
android:text="@string/statistics_puzzles_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down Expand Up @@ -113,7 +113,7 @@
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stats_puzzles_started" />
android:text="@string/statistics_puzzles_started" />

<TextView
android:id="@+id/startedstat"
Expand All @@ -128,7 +128,7 @@
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stats_puzzles_hinted" />
android:text="@string/statistics_puzzles_hinted" />

<TextView
android:id="@+id/hintedstat"
Expand All @@ -143,7 +143,7 @@
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stats_puzzles_solved" />
android:text="@string/statistics_puzzles_solved" />

<TextView
android:id="@+id/solvedstat"
Expand All @@ -157,7 +157,7 @@
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stats_puzzles_solved_streak" />
android:text="@string/statistics_puzzles_solved_current_streak" />

<TextView
android:id="@+id/solvedstreak"
Expand All @@ -171,7 +171,7 @@
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/stats_puzzles_longest_streak" />
android:text="@string/statistics_puzzles_longest_streak" />

<TextView
android:id="@+id/longeststreak"
Expand All @@ -186,7 +186,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/stats_clear"
android:text="@string/statistics_reset_statistics_button"
app:layout_constraintStart_toStartOf="@id/statsOverallBox"
app:layout_constraintEnd_toEndOf="@id/statsOverallBox"
app:layout_constraintTop_toBottomOf="@id/statsOverallBox" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
style="@style/TextAppearance.Material3.HeadlineMedium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/new_grid_game_options"/>
android:text="@string/game_setting_new_grid_game_options"/>

<FrameLayout
android:id="@+id/newGameOptions"
Expand All @@ -53,7 +53,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion gauguin-app/src/main/res/layout/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/new_game_activity_start_new_game"
android:text="@string/game_setting_new_game_activity_start_new_game"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/newGameOptions"
Expand Down
4 changes: 2 additions & 2 deletions gauguin-app/src/main/res/layout/activity_savegame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:id="@+id/saveGameAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="@string/dialog_title_load"
app:title="@string/load_game_screen_title"
app:menu="@menu/save_game_app_bar"
app:navigationIcon="@drawable/outline_arrow_back_24"
style="@style/Widget.MaterialComponents.Toolbar.PrimarySurface"
Expand All @@ -39,7 +39,7 @@
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:padding="10dp"
android:text="@string/save_games_empty" />
android:text="@string/load_game_screen_no_saved_games_found" />
</RelativeLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading

0 comments on commit fbdd644

Please sign in to comment.