[Android] Fix setting a custom locale when it's composed
Nicolas Pomepuy
git at videolan.org
Mon Mar 8 07:47:48 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Mar 4 13:51:23 2021 +0100| [e96b55486c5ef2b709f1425af3c0bf101947caf4] | committer: Nicolas Pomepuy
Fix setting a custom locale when it's composed
> https://code.videolan.org/videolan/vlc-android/commit/e96b55486c5ef2b709f1425af3c0bf101947caf4
---
application/tools/src/main/java/org/videolan/tools/LocaleUtils.kt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/application/tools/src/main/java/org/videolan/tools/LocaleUtils.kt b/application/tools/src/main/java/org/videolan/tools/LocaleUtils.kt
index eb1737681..f477991a5 100644
--- a/application/tools/src/main/java/org/videolan/tools/LocaleUtils.kt
+++ b/application/tools/src/main/java/org/videolan/tools/LocaleUtils.kt
@@ -4,6 +4,7 @@ import android.annotation.TargetApi
import android.content.Context
import android.content.ContextWrapper
import android.os.Build
+import android.util.Log
import java.util.*
import kotlin.collections.ArrayList
@@ -85,7 +86,7 @@ fun ContextWrapper.wrap(language: String): ContextWrapper {
}
if (language.isNotEmpty() && sysLocale.language != language) {
- val locale = Locale(language)
+ val locale = if (language.contains("-")) Locale(language.substringBefore("-"), language.substringAfter("-")) else Locale(language)
Locale.setDefault(locale)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
More information about the Android
mailing list