Localize all visible button labels and dialogs via string resources:
values/strings.xml (English default) and values-de/strings.xml cover section headers, hero disk buttons, sound toggle, import button, file picker title, and the replace-disk confirmation dialog
This commit is contained in:
+12
-12
@@ -150,14 +150,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
findViewById<Button>(R.id.btn_help).setOnClickListener { showHelp() }
|
findViewById<Button>(R.id.btn_help).setOnClickListener { showHelp() }
|
||||||
|
|
||||||
findViewById<Button>(R.id.btn_import_disks).setOnClickListener {
|
findViewById<Button>(R.id.btn_import_disks).setOnClickListener {
|
||||||
launchPicker(diskPickerLauncher, "Select SCHWUM disk images", multiSelect = true)
|
launchPicker(diskPickerLauncher, getString(R.string.picker_title), multiSelect = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val btnSound = findViewById<Button>(R.id.btn_sound)
|
val btnSound = findViewById<Button>(R.id.btn_sound)
|
||||||
btnSound.setOnClickListener {
|
btnSound.setOnClickListener {
|
||||||
soundEnabled = !soundEnabled
|
soundEnabled = !soundEnabled
|
||||||
engine.setSoundEnabled(soundEnabled)
|
engine.setSoundEnabled(soundEnabled)
|
||||||
btnSound.text = if (soundEnabled) "Sound: ON" else "Sound: OFF"
|
btnSound.text = getString(if (soundEnabled) R.string.sound_on else R.string.sound_off)
|
||||||
}
|
}
|
||||||
|
|
||||||
val btnReset = findViewById<Button>(R.id.btn_reset)
|
val btnReset = findViewById<Button>(R.id.btn_reset)
|
||||||
@@ -297,7 +297,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private fun loadDiskSlot(slot: DiskSlot) {
|
private fun loadDiskSlot(slot: DiskSlot) {
|
||||||
if (slot.part == 'B' && slot.episode !in loadedADisks) {
|
if (slot.part == 'B' && slot.episode !in loadedADisks) {
|
||||||
val aLabel = diskSlots.first { it.episode == slot.episode && it.part == 'A' }.label
|
val aLabel = diskSlots.first { it.episode == slot.episode && it.part == 'A' }.label
|
||||||
val msg = "Load $aLabel first — ${slot.label} continues from where it left off"
|
val msg = getString(R.string.load_a_first, aLabel, slot.label)
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
|
||||||
appendLog(msg)
|
appendLog(msg)
|
||||||
return
|
return
|
||||||
@@ -361,10 +361,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val dest = File(assetDir, slot.fileName)
|
val dest = File(assetDir, slot.fileName)
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle("Diskette ersetzen?")
|
.setTitle(R.string.replace_disk_title)
|
||||||
.setMessage("${slot.label} existiert bereits. Alle gespeicherten Daten gehen verloren.")
|
.setMessage(getString(R.string.replace_disk_msg, slot.label))
|
||||||
.setPositiveButton("Ersetzen") { _, _ -> writeHeroDisk(slot) }
|
.setPositiveButton(R.string.replace_disk_confirm) { _, _ -> writeHeroDisk(slot) }
|
||||||
.setNegativeButton("Abbrechen", null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
} else {
|
} else {
|
||||||
writeHeroDisk(slot)
|
writeHeroDisk(slot)
|
||||||
@@ -377,9 +377,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
try {
|
try {
|
||||||
dest.writeBytes(createBlankD64(slot.label))
|
dest.writeBytes(createBlankD64(slot.label))
|
||||||
refreshDiskButtons()
|
refreshDiskButtons()
|
||||||
appendLog("Erstellt: ${slot.label}")
|
appendLog(getString(R.string.hero_disk_created, slot.label))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
appendLog("Fehler beim Erstellen: ${slot.label}")
|
appendLog(getString(R.string.hero_disk_create_failed, slot.label))
|
||||||
Log.e(TAG, "createHeroDisk failed", e)
|
Log.e(TAG, "createHeroDisk failed", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,10 +465,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
assets.open(if (german) "help_de.md" else "help_en.md").bufferedReader().readText()
|
assets.open(if (german) "help_de.md" else "help_en.md").bufferedReader().readText()
|
||||||
} catch (e: Exception) { "Help text unavailable." }
|
} catch (e: Exception) { "Help text unavailable." }
|
||||||
|
|
||||||
var german = true
|
var german = java.util.Locale.getDefault().language == "de"
|
||||||
|
|
||||||
val tv = android.widget.TextView(this).apply {
|
val tv = android.widget.TextView(this).apply {
|
||||||
text = load(true)
|
text = load(german)
|
||||||
typeface = android.graphics.Typeface.MONOSPACE
|
typeface = android.graphics.Typeface.MONOSPACE
|
||||||
textSize = 12f
|
textSize = 12f
|
||||||
setTextColor(Color.parseColor("#DDDDDD"))
|
setTextColor(Color.parseColor("#DDDDDD"))
|
||||||
@@ -483,7 +483,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
.setTitle("Schwert und Magie auf Pebble")
|
.setTitle("Schwert und Magie auf Pebble")
|
||||||
.setView(scroll)
|
.setView(scroll)
|
||||||
.setPositiveButton("OK", null)
|
.setPositiveButton("OK", null)
|
||||||
.setNeutralButton("English", null)
|
.setNeutralButton(if (german) "English" else "Deutsch", null)
|
||||||
.show()
|
.show()
|
||||||
|
|
||||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
|
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Disketten"
|
android:text="@string/section_disks"
|
||||||
android:textColor="#AAFFAA"
|
android:textColor="#AAFFAA"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Helden-Disketten"
|
android:text="@string/section_hero_disks"
|
||||||
android:textColor="#AAFFAA"
|
android:textColor="#AAFFAA"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -202,10 +202,10 @@
|
|||||||
<Button android:id="@+id/btn_hero_1" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_1" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="0dp" android:layout_height="wrap_content"
|
android:layout_width="0dp" android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" android:gravity="center_vertical|start"
|
android:layout_weight="1" android:gravity="center_vertical|start"
|
||||||
android:text="Held 1" android:textSize="12sp" android:enabled="false" />
|
android:text="@string/hero_1" android:textSize="12sp" android:enabled="false" />
|
||||||
<Button android:id="@+id/btn_hero_1_new" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_1_new" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp" android:text="Neu" android:textSize="11sp" />
|
android:layout_marginStart="4dp" android:text="@string/btn_new" android:textSize="11sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
|
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||||
@@ -213,10 +213,10 @@
|
|||||||
<Button android:id="@+id/btn_hero_2" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_2" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="0dp" android:layout_height="wrap_content"
|
android:layout_width="0dp" android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" android:gravity="center_vertical|start"
|
android:layout_weight="1" android:gravity="center_vertical|start"
|
||||||
android:text="Held 2" android:textSize="12sp" android:enabled="false" />
|
android:text="@string/hero_2" android:textSize="12sp" android:enabled="false" />
|
||||||
<Button android:id="@+id/btn_hero_2_new" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_2_new" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp" android:text="Neu" android:textSize="11sp" />
|
android:layout_marginStart="4dp" android:text="@string/btn_new" android:textSize="11sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
|
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||||
@@ -224,10 +224,10 @@
|
|||||||
<Button android:id="@+id/btn_hero_3" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_3" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="0dp" android:layout_height="wrap_content"
|
android:layout_width="0dp" android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" android:gravity="center_vertical|start"
|
android:layout_weight="1" android:gravity="center_vertical|start"
|
||||||
android:text="Held 3" android:textSize="12sp" android:enabled="false" />
|
android:text="@string/hero_3" android:textSize="12sp" android:enabled="false" />
|
||||||
<Button android:id="@+id/btn_hero_3_new" style="?attr/materialButtonOutlinedStyle"
|
<Button android:id="@+id/btn_hero_3_new" style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="4dp" android:text="Neu" android:textSize="11sp" />
|
android:layout_marginStart="4dp" android:text="@string/btn_new" android:textSize="11sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -242,7 +242,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:text="Import Disks"
|
android:text="@string/btn_import_disks"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -267,7 +267,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="Sound: OFF"
|
android:text="@string/sound_off"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Drawer section headers -->
|
||||||
|
<string name="section_disks">Disketten</string>
|
||||||
|
<string name="section_hero_disks">Helden-Disketten</string>
|
||||||
|
|
||||||
|
<!-- Hero disk buttons -->
|
||||||
|
<string name="hero_1">Held 1</string>
|
||||||
|
<string name="hero_2">Held 2</string>
|
||||||
|
<string name="hero_3">Held 3</string>
|
||||||
|
<string name="btn_new">Neu</string>
|
||||||
|
|
||||||
|
<!-- Bottom drawer buttons -->
|
||||||
|
<string name="btn_import_disks">Disketten importieren</string>
|
||||||
|
<string name="sound_off">Ton: AUS</string>
|
||||||
|
<string name="sound_on">Ton: AN</string>
|
||||||
|
|
||||||
|
<!-- Disk picker -->
|
||||||
|
<string name="picker_title">SCHWUM-Disketten auswählen</string>
|
||||||
|
|
||||||
|
<!-- Load-order warning toast -->
|
||||||
|
<string name="load_a_first">%1$s zuerst laden — %2$s setzt dort fort</string>
|
||||||
|
|
||||||
|
<!-- Hero disk creation dialog -->
|
||||||
|
<string name="replace_disk_title">Diskette ersetzen?</string>
|
||||||
|
<string name="replace_disk_msg">%1$s existiert bereits. Alle gespeicherten Daten gehen verloren.</string>
|
||||||
|
<string name="replace_disk_confirm">Ersetzen</string>
|
||||||
|
<string name="cancel">Abbrechen</string>
|
||||||
|
|
||||||
|
<!-- Hero disk creation log -->
|
||||||
|
<string name="hero_disk_created">Erstellt: %1$s</string>
|
||||||
|
<string name="hero_disk_create_failed">Fehler beim Erstellen: %1$s</string>
|
||||||
|
</resources>
|
||||||
@@ -1,3 +1,34 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">SchwertUndMagieOnPebbleCompanionApp</string>
|
<string name="app_name">SchwertUndMagieOnPebbleCompanionApp</string>
|
||||||
</resources>
|
|
||||||
|
<!-- Drawer section headers -->
|
||||||
|
<string name="section_disks">Disks</string>
|
||||||
|
<string name="section_hero_disks">Hero Disks</string>
|
||||||
|
|
||||||
|
<!-- Hero disk buttons -->
|
||||||
|
<string name="hero_1">Hero 1</string>
|
||||||
|
<string name="hero_2">Hero 2</string>
|
||||||
|
<string name="hero_3">Hero 3</string>
|
||||||
|
<string name="btn_new">New</string>
|
||||||
|
|
||||||
|
<!-- Bottom drawer buttons -->
|
||||||
|
<string name="btn_import_disks">Import Disks</string>
|
||||||
|
<string name="sound_off">Sound: OFF</string>
|
||||||
|
<string name="sound_on">Sound: ON</string>
|
||||||
|
|
||||||
|
<!-- Disk picker -->
|
||||||
|
<string name="picker_title">Select SCHWUM disk images</string>
|
||||||
|
|
||||||
|
<!-- Load-order warning toast -->
|
||||||
|
<string name="load_a_first">Load %1$s first — %2$s continues from where it left off</string>
|
||||||
|
|
||||||
|
<!-- Hero disk creation dialog -->
|
||||||
|
<string name="replace_disk_title">Replace disk?</string>
|
||||||
|
<string name="replace_disk_msg">%1$s already exists. All saved data will be lost.</string>
|
||||||
|
<string name="replace_disk_confirm">Replace</string>
|
||||||
|
<string name="cancel">Cancel</string>
|
||||||
|
|
||||||
|
<!-- Hero disk creation log -->
|
||||||
|
<string name="hero_disk_created">Created: %1$s</string>
|
||||||
|
<string name="hero_disk_create_failed">Failed to create: %1$s</string>
|
||||||
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user