Localized AMSAT status screen for Chinese (#245)

Co-authored-by: atsunatsu <atsunatsu@users.noreply.github.com>
This commit is contained in:
atsunatsuandatsunatsu authored and GitHub committed 2026-09-02 09:05:45 +01:00
1 parent 082266e385
commit 9cac33dae7
4 files changed
+54 -5

No files matched your search

@@ -55,6 +55,7 @@ import com.rtbishop.look4sat.core.presentation.InfoDialog
import com.rtbishop.look4sat.core.presentation.R
import com.rtbishop.look4sat.core.presentation.layoutPadding
import java.util.Calendar
import java.util.Locale
/** Fixed width per day tile — tablet-safe; name column absorbs remaining space. */
private val TILE_WIDTH: Dp = 64.dp
@@ -77,6 +78,19 @@ private fun statusColorOf(statusText: String): Color {
}
}
/** Localize AMSAT API status text for the current locale; falls back to the raw text. */
@Composable
private fun statusTextOf(statusText: String): String {
if (Locale.getDefault().language != Locale.CHINESE.language) return statusText
return when (statusText.lowercase()) {
"heard" -> stringResource(R.string.amsat_status_heard)
"telemetry only" -> stringResource(R.string.amsat_status_tlm_only)
"not heard" -> stringResource(R.string.amsat_status_not_heard)
"crew active" -> stringResource(R.string.amsat_status_crew_active)
else -> statusText
}
}
@Composable
fun SatStatusDestination() {
val context = LocalContext.current
@@ -296,7 +310,7 @@ private fun ReportDialog(statusName: String, day: SatDay, reports: Map<String, S
.background(statusColorOf(report.statusText))
)
Spacer(modifier = Modifier.width(6.dp))
Text(text = report.statusText, fontSize = 14.sp, fontWeight = FontWeight.Bold)
Text(text = statusTextOf(report.statusText), fontSize = 14.sp, fontWeight = FontWeight.Bold)
}
Text(
text = "${report.call} ${report.dateUtc} ${report.timeUtc}" +
@@ -318,10 +332,14 @@ private fun formatFetchedAt(utcMs: Long): String {
val cal = Calendar.getInstance()
cal.timeInMillis = utcMs
val day = cal.get(Calendar.DAY_OF_MONTH)
val month = MONTH_ABBR[cal.get(Calendar.MONTH)]
val monthIndex = cal.get(Calendar.MONTH)
val year = cal.get(Calendar.YEAR)
val hh = cal.get(Calendar.HOUR_OF_DAY).toString().padStart(2, '0')
val mm = cal.get(Calendar.MINUTE).toString().padStart(2, '0')
val ss = cal.get(Calendar.SECOND).toString().padStart(2, '0')
return "$day$month $year - $hh:$mm:$ss"
return if (Locale.getDefault().language == Locale.CHINESE.language) {
"${year}年${monthIndex + 1}月${day}日 - $hh:$mm:$ss"
} else {
"$day${MONTH_ABBR[monthIndex]} $year - $hh:$mm:$ss"
}
}