mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Language String extension
This commit is contained in:
parent
16540059ad
commit
4bf8cffd48
2 changed files with 11 additions and 3 deletions
|
|
@ -40,6 +40,7 @@ import com.habitrpg.android.habitica.ui.views.ClassText
|
|||
import com.habitrpg.android.habitica.ui.views.ComposableAvatarView
|
||||
import com.habitrpg.android.habitica.ui.views.ComposableUsernameLabel
|
||||
import com.habitrpg.android.habitica.ui.views.LoadingButtonState
|
||||
import com.habitrpg.common.habitica.extensions.toLocale
|
||||
import java.util.Locale
|
||||
import kotlin.random.Random
|
||||
|
||||
|
|
@ -125,9 +126,7 @@ fun PartySeekingListItem(
|
|||
color = HabiticaTheme.colors.textPrimary
|
||||
)
|
||||
Text(
|
||||
Locale(
|
||||
user.preferences?.language ?: "en"
|
||||
).getDisplayName(Locale.getDefault()),
|
||||
"Language: ${user.preferences?.language?.toLocale()?.getDisplayLanguage(Locale.getDefault())}",
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 14.sp,
|
||||
color = HabiticaTheme.colors.textPrimary
|
||||
|
|
|
|||
|
|
@ -43,3 +43,12 @@ fun String.localizedCapitalizeWithSpaces(): String {
|
|||
}
|
||||
|
||||
fun CharSequence?.isValidEmail() = !isNullOrEmpty() && Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
||||
|
||||
fun String.toLocale(): Locale {
|
||||
val parts = this.split("_")
|
||||
return when(parts.size) {
|
||||
1 -> Locale(parts[0])
|
||||
2 -> Locale(parts[0], parts[1])
|
||||
else -> Locale("en")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue