M8: localisation groundwork - resource the file-kind labels, pseudo-locale check

This commit is contained in:
2026-10-14 17:12:02 +02:00
parent a79b7eb58e
commit bf909b3485
7 changed files with 109 additions and 6 deletions
+4
View File
@@ -72,6 +72,10 @@ android {
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"
// Pseudo-locale (en-XA): every string from resources is rendered accented and
// wrapped in brackets, so any text that comes out unchanged is text that never
// went through `strings.xml`. Set the device language to English (XA) to see it.
isPseudoLocalesEnabled = true
}
release {
if (hasReleaseSigning) {
@@ -2,6 +2,7 @@ package de.softwareapp_hb.filemanager.text
import androidx.annotation.StringRes
import de.softwareapp_hb.filemanager.R
import de.softwareapp_hb.filemanager.core.FileKind
import de.softwareapp_hb.filemanager.domain.OperationKind
/**
@@ -19,3 +20,22 @@ fun OperationKind.titleRes(): Int = when (this) {
OperationKind.COMPRESS -> R.string.operation_compress_title
OperationKind.EXTRACT -> R.string.operation_extract_title
}
/**
* The human name of a file category, for the "Type" row of the details sheet.
*
* `FileKind.name` is an enum constant, not a label: showing it directly would put
* untranslatable English in front of the user.
*/
@StringRes
fun FileKind.labelRes(): Int = when (this) {
FileKind.DIRECTORY -> R.string.browser_details_folder
FileKind.IMAGE -> R.string.browser_kind_image
FileKind.VIDEO -> R.string.browser_kind_video
FileKind.AUDIO -> R.string.browser_kind_audio
FileKind.DOCUMENT -> R.string.browser_kind_document
FileKind.ARCHIVE -> R.string.browser_kind_archive
FileKind.APK -> R.string.browser_kind_apk
FileKind.TEXT -> R.string.browser_kind_text
FileKind.OTHER -> R.string.browser_kind_other
}
@@ -17,6 +17,7 @@ import de.softwareapp_hb.filemanager.R
import de.softwareapp_hb.filemanager.core.FileEntry
import de.softwareapp_hb.filemanager.core.FileSize
import de.softwareapp_hb.filemanager.core.Timestamps
import de.softwareapp_hb.filemanager.text.labelRes
/** Name, location, size, type and modified date for one entry. */
@OptIn(ExperimentalMaterial3Api::class)
@@ -39,7 +40,7 @@ fun DetailsSheet(entry: FileEntry, onDismiss: () -> Unit) {
FileSize.format(entry.sizeBytes)
},
)
DetailLine(stringResource(R.string.browser_details_kind), entry.kind.name.lowercase())
DetailLine(stringResource(R.string.browser_details_kind), stringResource(entry.kind.labelRes()))
Timestamps.format(entry.lastModifiedMillis).takeIf { it.isNotEmpty() }?.let { modified ->
DetailLine(stringResource(R.string.browser_details_modified), modified)
}
+10
View File
@@ -93,6 +93,16 @@
<string name="browser_details_modified">Modified</string>
<string name="browser_details_folder">Folder</string>
<!-- ===== File categories (the "Type" row of the details sheet) ===== -->
<string name="browser_kind_image">Image</string>
<string name="browser_kind_video">Video</string>
<string name="browser_kind_audio">Audio</string>
<string name="browser_kind_document">Document</string>
<string name="browser_kind_archive">Archive</string>
<string name="browser_kind_apk">App package</string>
<string name="browser_kind_text">Text</string>
<string name="browser_kind_other">File</string>
<!-- ===== Browser: delete + conflict ===== -->
<string name="browser_delete_title">Delete permanently?</string>
<plurals name="browser_delete_body">