diff --git a/HACKING.md b/HACKING.md index 815abd4e80a492d7f2a89cc297ca13b48157dac4..6cdd07f57fa47168571862e9ca960972bbccbe1c 100644 --- a/HACKING.md +++ b/HACKING.md @@ -26,7 +26,9 @@ will also run tests on briar core: ## Testing different locales -To test the app with a different locale, add this e.g. in `Main.kt`: +You can simply switch the language in the settings screen of the application. + +To test the app with a different *default* locale, add this e.g. in `Main.kt`: ``` Locale.setDefault(Locale("ar")) @@ -36,7 +38,7 @@ and replace `ar` with a different language you would like to test, such as Arabic in this example. It is also possible to run from the command line using Gradle with a -different language setting: +different *default* language setting: ``` GRADLE_OPTS="-Duser.language=fr -Duser.country=FR" ./gradlew run diff --git a/TRANSLATION.md b/TRANSLATION.md index 4b5bd0f5e85dd7296806a13777e9c5414c62fa28..43ab7bd131a28b081026d813ae153ac35cdd693a 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -14,7 +14,7 @@ _This section is of interest only for developers of Briar Desktop_. To update translations locally, first install `transifex-client`. You can then pull updates with `tx pull -a`. If that command added a language that was previously not supported, -you have to manually insert the language code in [Settings.kt](./src/main/kotlin/org/briarproject/briar/desktop/settings/Settings.kt) +you have to manually insert the language code in [UnencryptedSettings.kt](./src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettings.kt) for it to be shown in the language selection. The Localization Lab has some instructions and advice for diff --git a/src/main/kotlin/androidx/compose/material/ExposedDropDownMenu.kt b/src/main/kotlin/androidx/compose/material/ExposedDropDownMenu.kt index 92450c6cfb65c85c90b92b8508824b12e4ca0d8d..ffbe92e8bdf00dbb2bb7e4d4424edd86eb77cf0a 100644 --- a/src/main/kotlin/androidx/compose/material/ExposedDropDownMenu.kt +++ b/src/main/kotlin/androidx/compose/material/ExposedDropDownMenu.kt @@ -58,6 +58,7 @@ import org.briarproject.briar.desktop.utils.PreviewUtils.preview // Taken from https://stackoverflow.com/a/69042850 and slightly adapted to follow Material theming // See https://github.com/JetBrains/compose-jb/issues/1673 as tracking issue +@Suppress("HardCodedStringLiteral") fun main() = preview { val values = (0..5).map { "Test $it" } var selected by remember { mutableStateOf(-1) } @@ -196,7 +197,7 @@ private fun ExposedDropDownMenuImpl( } Icon( imageVector = Icons.Filled.ArrowDropDown, - contentDescription = "Change", + contentDescription = "Change", // NON-NLS since this will be replaced by a toolkit native version at some point tint = trailingIconColor, modifier = Modifier .align(Alignment.CenterEnd) diff --git a/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettings.kt b/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettings.kt index 8c78db28aebcee4fa2d173df6d4724790149de46..af1d1b9aa67266c3eff5b1f180eda97080d34b90 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettings.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettings.kt @@ -30,12 +30,12 @@ interface UnencryptedSettings { DEFAULT, EN, // languages as present in resources - AR, BG, DE, ES, FA, GL, HU, IS, IT, LT, PL, RO, RU, SK, SQ, SV, TR, ZH_CN; + AR, BG, DE, ES, FA, FR, GL, HE, HU, IS, IT, JA, KO, LT, MY, NL, PL, PT_BR, RO, RU, SK, SQ, SV, TR, ZH_CN; val locale: Locale get() = if (this == DEFAULT) Locale.getDefault() - else Locale.forLanguageTag(this.name.replace('_', '-')) + else Locale.forLanguageTag(name.replace('_', '-')) } var theme: Theme diff --git a/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettingsImpl.kt b/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettingsImpl.kt index 255458ce57445e5891a387ae1d5567f9e279895e..c434459e33e7333ca166e80b57fa1473c1965cc3 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettingsImpl.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/settings/UnencryptedSettingsImpl.kt @@ -27,8 +27,8 @@ import org.briarproject.briar.desktop.viewmodel.SingleStateEvent import java.util.prefs.Preferences import javax.inject.Inject -const val PREF_THEME = "theme" -const val PREF_LANG = "language" +const val PREF_THEME = "theme" // NON-NLS +const val PREF_LANG = "language" // NON-NLS class UnencryptedSettingsImpl @Inject internal constructor() : UnencryptedSettings { @@ -40,6 +40,8 @@ class UnencryptedSettingsImpl @Inject internal constructor() : UnencryptedSettin override var theme: Theme get() = Theme.valueOf(prefs.get(PREF_THEME, AUTO.name)) set(value) { + if (theme == value) return + prefs.put(PREF_THEME, value.name) prefs.flush() // write preferences to disk invalidateScreen.emit(Unit) @@ -48,6 +50,8 @@ class UnencryptedSettingsImpl @Inject internal constructor() : UnencryptedSettin override var language: Language get() = Language.valueOf(prefs.get(PREF_LANG, DEFAULT.name)) set(value) { + if (language == value) return + prefs.put(PREF_LANG, value.name) prefs.flush() // write preferences to disk updateLocale(value)