Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locale not working #70

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fun TextRowWithIconPreviewFromMain() {
@Composable
fun TextRowWithIconPreviewFromMainJustMultiPreview() {
TextRowWithIcon(
titleText = "Title",
subtitleText = "Subtitle"
titleText = stringResource(com.emergetools.snapshots.sample.R.string.sample_title),
subtitleText = stringResource(com.emergetools.snapshots.sample.R.string.sample_subtitle)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.res.Configuration
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig
Expand All @@ -19,11 +20,12 @@ fun SnapshotVariantProvider(

val localConfiguration = Configuration(LocalConfiguration.current).apply {
config.uiMode?.let { uiMode = it }
config.locale?.let { setLocale(Locale(it)) }
val locale = config.locale?.let { Locale(it) } ?: Locale.getDefault()
setLocale(locale)
}

val providedValues = arrayOf(
LocalConfiguration provides localConfiguration,
LocalContext provides LocalContext.current.createConfigurationContext(localConfiguration),
config.fontScale?.let { LocalDensity provides fontScaleDensity }
)
CompositionLocalProvider(
Expand Down
Loading