language fix

This commit is contained in:
Phillip Thelen 2024-07-24 10:24:34 +02:00
parent cca45639c6
commit 975b409023
2 changed files with 7 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.extensions
import android.content.res.Resources
import com.habitrpg.android.habitica.R
import com.habitrpg.common.habitica.helpers.LanguageHelper
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Calendar
@ -173,7 +174,7 @@ fun Duration.getMinuteOrSeconds(): DurationUnit {
}
fun Date.formatForLocale(): String {
val locale = Locale.getDefault()
val locale = LanguageHelper.systemLocale
val dateFormatter: DateFormat =
if (locale == Locale.US || locale == Locale.ENGLISH) {
SimpleDateFormat("M/d/yy", locale)

View file

@ -43,6 +43,10 @@ class LanguageHelper(languageSharedPref: String?) {
companion object {
// Intentional, we want the system locale, not the app locale
@SuppressLint("ConstantLocale")
val systemLocale = Locale.getAvailableLocales().firstOrNull() ?: Locale.getDefault()
val systemLocale: Locale
init {
systemLocale = Locale.getDefault()
}
}
}