Skip to content

Commit

Permalink
🐛 Device information details support multiple languages
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyanakuang committed Nov 30, 2023
1 parent e8aef92 commit 2f3f71c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
23 changes: 14 additions & 9 deletions composeApp/src/commonMain/kotlin/com/clipevery/ui/DeviceItemUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.clipevery.LocalKoinApplication
import com.clipevery.i18n.Copywriter
import com.clipevery.i18n.GlobalCopywriter
import com.clipevery.model.DeviceInfo
import com.clipevery.model.DeviceState
import compose.icons.TablerIcons
Expand All @@ -45,6 +48,8 @@ import compose.icons.tablericons.Ghost
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun DeviceItem(deviceInfo: DeviceInfo) {
val current = LocalKoinApplication.current
val copywriter = current.koin.get<GlobalCopywriter>()

val backgroundColor = when (deviceInfo.state) {
DeviceState.ONLINE -> {
Expand Down Expand Up @@ -138,7 +143,7 @@ fun DeviceItem(deviceInfo: DeviceInfo) {
)
}

val detailInfo by remember { mutableStateOf(deviceDetailInfo(deviceInfo)) }
val detailInfo by remember { mutableStateOf(deviceDetailInfo(copywriter, deviceInfo)) }

TooltipArea(
tooltip = {
Expand All @@ -164,14 +169,14 @@ fun DeviceItem(deviceInfo: DeviceInfo) {
}
}

fun deviceDetailInfo(deviceInfo: DeviceInfo): String {
fun deviceDetailInfo(copywriter: Copywriter, deviceInfo: DeviceInfo): String {
return """
|Device ID: ${deviceInfo.deviceId}
|App Version: ${deviceInfo.appInfo.appVersion}
|User Name: ${deviceInfo.appInfo.userName}
|Host Name: ${deviceInfo.appHostInfo.displayName}
|Host Address: ${deviceInfo.appHostInfo.hostAddress}
|Platform: ${deviceInfo.platform.name} ${deviceInfo.platform.version}
|State: ${deviceInfo.state}
|${copywriter.getText("Device_ID")}: ${deviceInfo.deviceId}
|${copywriter.getText("App_Version")}: ${deviceInfo.appInfo.appVersion}
|${copywriter.getText("User_Name")}: ${deviceInfo.appInfo.userName}
|${copywriter.getText("Host_Name")}: ${deviceInfo.appHostInfo.displayName}
|${copywriter.getText("Host_Address")}: ${deviceInfo.appHostInfo.hostAddress}
|${copywriter.getText("Platform")}: ${deviceInfo.platform.name} ${deviceInfo.platform.version}
|${copywriter.getText("State")}: ${deviceInfo.state}
""".trimMargin()
}
9 changes: 8 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ Boot_start_up=Boot start up
AutomaticUpdate=Automatic update
CurrentLanguage=English
Network=Network
Store=Store
Store=Store
Device_ID=Device ID
App_Version=App Version
User_Name=User Name
Host_Name=Host_Name
Host_Address=Host Address
Platform=Platform
State=State
9 changes: 8 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ Boot_start_up=Inicio de arranque
AutomaticUpdate=Actualización automática
CurrentLanguage=Español
Network=Red
Store=Tienda
Store=Tienda
Device_ID=ID del dispositivo
App_Version=Versión de la aplicación
User_Name=Nombre de usuario
Host_Name=Nombre de host
Host_Address=Dirección del host
Platform=Plataforma
State=Estado
9 changes: 8 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/jp.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ Boot_start_up=起動時に開始
AutomaticUpdate=自動更新
CurrentLanguage=日本語
Network=ネットワーク
Store=ストア
Store=ストア
Device_ID=デバイスID
App_Version=アプリバージョン
User_Name=ユーザー名
Host_Name=ホスト名
Host_Address=ホストアドレス
Platform=プラットフォーム
State=状態
9 changes: 8 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ Boot_start_up=开机启动
AutomaticUpdate=自动更新
CurrentLanguage=简体中文
Network=网络
Store=存储
Store=存储
Device_ID=设备ID
App_Version=应用版本
User_Name=用户名
Host_Name=主机名
Host_Address=主机地址
Platform=平台
State=状态

0 comments on commit 2f3f71c

Please sign in to comment.