Repository navigation
Expand file tree
/
Copy pathDemoLocalization.kt
More file actions
30 lines (25 loc) · 1.8 KB
/
Copy pathDemoLocalization.kt
File metadata and controls
30 lines (25 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.omarshehe.forminputs
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
import com.omarshehe.forminput.compose.ui.FormInputStrings
import com.omarshehe.forminput.compose.ui.model.FormInputTextFieldState
internal val LocalFrench = compositionLocalOf { false }
/** The app's own wording for a field name: the French text while the switch is on. */
@Composable
internal fun tr(en: String, fr: String): String = if (LocalFrench.current) fr else en
/** This state with its label and placeholder set to the English or French wording, whichever the switch is on. */
@Composable
internal fun FormInputTextFieldState.withLabel(en: String, fr: String): FormInputTextFieldState =
copy(label = tr(en, fr), placeholder = tr(en, fr))
/** An app's own wording: any text left null keeps the library's default. */
internal val frenchStrings = FormInputStrings(
ok = "D'accord", cancel = "Annuler", next = "Suivant", back = "Retour", delete = "Supprimer",
selectDate = "Choisir une date", selectTime = "Choisir une heure", selectDateTime = "Choisir date et heure",
searchHint = "Rechercher...", clearSearch = "Effacer", browseFiles = "Parcourir les fichiers",
clickToUpload = "Touchez pour choisir un fichier", uploadedDocuments = "Documents",
showPassword = "Afficher le mot de passe", hidePassword = "Masquer le mot de passe",
passwordRulesTitle = "Votre mot de passe doit :", passwordRuleUpperCase = "Contenir une majuscule",
passwordRuleSpecial = "Contenir un caractère spécial", passwordRuleDigit = "Contenir un chiffre",
passwordRuleMinLength = { "Avoir au moins $it caractères" }, passwordMismatch = "Les mots de passe ne correspondent pas",
strengthWeak = "Faible", strengthMedium = "Moyen", strengthStrong = "Fort", strengthVeryStrong = "Très fort",
)