Use Bundle to load string resources

This commit is contained in:
Nebojsa Vuksic 2025-07-29 15:47:03 +02:00
parent bafad75cea
commit 2a0daaa806
4 changed files with 45 additions and 19 deletions

View File

@ -71,11 +71,18 @@ private fun LeftColumn(
// TODO Set selected item on initial showing // TODO Set selected item on initial showing
Column(modifier) { Column(modifier) {
GroupHeader("My Locations", modifier = Modifier.wrapContentHeight().fillMaxWidth()) GroupHeader(
ComposeTemplateBundle.message("weather.app.my.locations.header.text"),
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
)
Spacer(modifier = Modifier.height(10.dp)) Spacer(modifier = Modifier.height(10.dp))
val listState = rememberSelectableLazyListState() val listState = rememberSelectableLazyListState()
// TODO Check why preselection isn't working
LaunchedEffect(myLocations) { LaunchedEffect(myLocations) {
listState listState
.selectedKeys = myLocations .selectedKeys = myLocations
@ -95,7 +102,6 @@ private fun LeftColumn(
items( items(
items = myLocations, items = myLocations,
key = { item -> item }, key = { item -> item },
contentType = { item -> item.location },
) { item -> ) { item ->
ContentItemRow( ContentItemRow(
@ -138,7 +144,7 @@ private fun RightColumn(
Column(modifier) { Column(modifier) {
SearchToolbarMenu( SearchToolbarMenu(
searchAutoCompletionItemProvider = searchAutoCompletionItemProvider, searchAutoCompletionItemProvider = searchAutoCompletionItemProvider,
confirmButtonText = "Add", confirmButtonText = ComposeTemplateBundle.message("weather.app.search.toolbar.menu.add.button.text"),
onSearchPerformed = { place -> onSearchPerformed = { place ->
weatherViewModelApi.onLoadWeatherForecast(place) weatherViewModelApi.onLoadWeatherForecast(place)
}, },

View File

@ -54,7 +54,7 @@ internal fun <T> SearchToolbarMenu(
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
Icon( Icon(
AllIconsKeys.Actions.AddList, AllIconsKeys.Actions.AddList,
contentDescription = ComposeTemplateBundle.message("search.toolbar.menu.add.button.content.description") contentDescription = ComposeTemplateBundle.message("weather.app.search.toolbar.menu.add.button.content.description")
) )
Text(confirmButtonText) Text(confirmButtonText)
} }

View File

@ -23,6 +23,7 @@ import org.jetbrains.jewel.ui.component.HorizontallyScrollableContainer
import org.jetbrains.jewel.ui.component.Icon import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.Text import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.icons.AllIconsKeys import org.jetbrains.jewel.ui.icons.AllIconsKeys
import org.jetbrains.plugins.template.ComposeTemplateBundle
import org.jetbrains.plugins.template.weatherApp.WeatherAppColors import org.jetbrains.plugins.template.weatherApp.WeatherAppColors
import org.jetbrains.plugins.template.weatherApp.model.DailyForecast import org.jetbrains.plugins.template.weatherApp.model.DailyForecast
import org.jetbrains.plugins.template.weatherApp.model.WeatherForecastData import org.jetbrains.plugins.template.weatherApp.model.WeatherForecastData
@ -113,7 +114,10 @@ internal fun WeatherDetailsCard(
// Temperature (emphasized) // Temperature (emphasized)
Text( Text(
text = "${currentWeatherForecast.temperature.toInt()}°C", text = ComposeTemplateBundle.message(
"weather.app.temperature.text",
currentWeatherForecast.temperature.toInt()
),
color = textColor, color = textColor,
fontSize = 32.sp, fontSize = 32.sp,
fontWeight = FontWeight.ExtraBold fontWeight = FontWeight.ExtraBold
@ -139,14 +143,21 @@ internal fun WeatherDetailsCard(
) { ) {
// Wind info // Wind info
Text( Text(
text = "Wind: ${currentWeatherForecast.windSpeed.toInt()} km/h ${currentWeatherForecast.windDirection.label}", text = ComposeTemplateBundle.message(
"weather.app.wind.direction.text",
currentWeatherForecast.windSpeed.toInt(),
currentWeatherForecast.windDirection.label
),
color = textColor, color = textColor,
fontSize = 16.sp fontSize = 16.sp
) )
// Humidity info // Humidity info
Text( Text(
text = "Humidity: ${currentWeatherForecast.humidity}%", text = ComposeTemplateBundle.message(
"weather.app.humidity.text",
currentWeatherForecast.humidity
),
color = textColor, color = textColor,
fontSize = 16.sp fontSize = 16.sp
) )
@ -176,7 +187,7 @@ private fun SevenDaysForecastWidget(
if (weatherForecastData.dailyForecasts.isNotEmpty()) { if (weatherForecastData.dailyForecasts.isNotEmpty()) {
Column(modifier) { Column(modifier) {
Text( Text(
text = "7-Day Forecast", text = ComposeTemplateBundle.message("weather.app.7days.forecast.title.text"),
color = textColor, color = textColor,
fontSize = 18.sp, fontSize = 18.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
@ -262,7 +273,10 @@ private fun DayForecastItem(
// Temperature // Temperature
Text( Text(
text = "${forecast.temperature.toInt()}°C", text = ComposeTemplateBundle.message(
"weather.app.temperature.text",
forecast.temperature.toInt()
),
color = textColor, color = textColor,
fontSize = 16.sp, fontSize = 16.sp,
fontWeight = FontWeight.Bold fontWeight = FontWeight.Bold
@ -272,7 +286,10 @@ private fun DayForecastItem(
// Humidity // Humidity
Text( Text(
text = "Humidity: ${forecast.humidity}%", text = ComposeTemplateBundle.message(
"weather.app.humidity.text",
forecast.humidity
),
color = textColor, color = textColor,
fontSize = 12.sp fontSize = 12.sp
) )
@ -281,7 +298,11 @@ private fun DayForecastItem(
// Wind direction // Wind direction
Text( Text(
text = "Wind: ${forecast.windDirection.label}", text = ComposeTemplateBundle.message(
"weather.app.wind.direction.text",
forecast.windSpeed.toInt(),
forecast.windDirection.label
),
color = textColor, color = textColor,
fontSize = 12.sp fontSize = 12.sp
) )

View File

@ -1,8 +1,7 @@
projectService=Project service: {0} weather.app.temperature.text={0}\u00B0C
randomLabel=The random number is: {0} weather.app.humidity.text=Humidity: {0}%
shuffle=Shuffle weather.app.wind.direction.text=Wind: {0} km/h {1}
helloWorld=Hello world #{0} weather.app.my.locations.header.text=My Locations
increment=Moar weather.app.search.toolbar.menu.add.button.text=Add
action.dev.sebastiano.jewel.ijplugin.demo.text=Jewel Demo Dialog weather.app.search.toolbar.menu.add.button.content.description=Add a place to a watch list.
weather.app.7days.forecast.title.text=7-day Forecast
search.toolbar.menu.add.button.content.description=Add a place to a watch list.