Skip to content

Commit

Permalink
TIQR-381: Use localicious for localization
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolnai committed Dec 8, 2023
1 parent df2ac6c commit 872dca5
Show file tree
Hide file tree
Showing 71 changed files with 5,733 additions and 1,187 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ git submodule init
git submodule update
```

### Generate translations

The translations are kept in the file localizations.yaml.
For this, you need to install the node package `localicious` via `yarn` (if you do it with `npm`, it won't work correctly).
See [this](https://blog.picnic.nl/localizing-native-apps-made-easy-with-localicious-5063d02d3511) blog post for more info about localicious.

Once you have it installed, execute the following line from the root of the repository to regerenate the Android resource files based on the
contents of `localizations.yaml`:

```shell
localicious render localizations.yaml ./ --languages en,nl --outputTypes android -c SHARED,ANDROID &&\
mv android/nl/strings.xml app/src/main/res/values-nl/strings.xml &&\
mv android/en/strings.xml app/src/main/res/values/strings.xml &&\
rm -rf android/
```
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ private fun AccountFailedLinkContent(
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = TextGreen
),
text = stringResource(R.string.account_linked_title),
text = stringResource(R.string.NameUpdated_Title_YourSchool_COPY),
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
Text(
style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.SemiBold),
text = stringResource(R.string.account_linked_fail_subtitle),
text = stringResource(R.string.NameUpdated_Title_ContactedSuccessfully_COPY),
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
val explanation =
if (result is ResultAccountLinked.FailedExpired) {
stringResource(R.string.account_linked_fail1_description)
stringResource(R.string.NameUpdated_Title_FailReason_SessionExpired_COPY)
} else {
stringResource(R.string.account_linked_fail2_description)
stringResource(R.string.NameUpdated_Title_FailReason_AlreadyLinked_COPY)
}
Text(
text = explanation,
Expand All @@ -106,7 +106,7 @@ private fun AccountFailedLinkContent(
)
}
PrimaryButton(
text = stringResource(R.string.button_continue),
text = stringResource(R.string.NameUpdated_Continue_COPY),
onClick = continueToHome,
modifier = Modifier
.fillMaxWidth(),
Expand Down Expand Up @@ -142,19 +142,19 @@ private fun AccountLinkedContent(
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = TextGreen
),
text = stringResource(R.string.account_linked_title),
text = stringResource(R.string.NameUpdated_Title_YourSchool_COPY),
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
Text(
style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.SemiBold),
text = stringResource(R.string.account_linked_subtitle),
text = stringResource(R.string.NameUpdated_Title_ContactedSuccessfully_COPY),
modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
Text(
style = MaterialTheme.typography.bodyLarge,
text = stringResource(R.string.account_linked_description),
text = stringResource(R.string.NameUpdated_Description_COPY),
modifier = Modifier.fillMaxWidth()
)
if (isLoading) {
Expand All @@ -169,17 +169,17 @@ private fun AccountLinkedContent(
InfoField(
title = personalInfo.name,
subtitle = if (personalInfo.nameProvider == null) {
stringResource(R.string.infotab_providedby_you)
stringResource(R.string.Profile_ProvidedByYou_COPY)
} else {
stringResource(R.string.infotab_providedby, personalInfo.nameProvider)
stringResource(R.string.Profile_ProvidedBy_COPY, personalInfo.nameProvider)
},
endIcon = R.drawable.shield_tick_blue,
label = stringResource(R.string.infotab_fullname)
label = stringResource(R.string.NameOverview_Title_FullName_COPY)
)
Spacer(Modifier.height(16.dp))
if (personalInfo.institutionAccounts.isNotEmpty()) {
Text(
text = stringResource(R.string.infotab_role_institution),
text = stringResource(R.string.Profile_RoleAndInstitution_COPY),
style = MaterialTheme.typography.bodyLarge.copy(
textAlign = TextAlign.Start,
fontWeight = FontWeight.SemiBold,
Expand All @@ -190,13 +190,13 @@ private fun AccountLinkedContent(
personalInfo.institutionAccounts.forEachIndexed { index, account ->
ConnectionCard(
title = account.role,
subtitle = stringResource(R.string.infotab_at, account.roleProvider),
subtitle = stringResource(R.string.Profile_InstitutionAt_COPY, account.roleProvider),
institutionInfo = account,
onRemoveConnection = { removeConnection(index) },
)
}
PrimaryButton(
text = stringResource(R.string.button_continue),
text = stringResource(R.string.NameUpdated_Continue_COPY),
onClick = continueToHome,
modifier = Modifier
.fillMaxWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun AuthenticationCompletedScreen(goHome: () -> Unit = {}) = EduIdTopAppBar(
Text(
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = TextGreen
), text = stringResource(R.string.authorize_title), modifier = Modifier.fillMaxWidth()
), text = stringResource(R.string.PinAndBioMetrics_LoginRequest_COPY), modifier = Modifier.fillMaxWidth()
)
Column(
verticalArrangement = Arrangement.Center,
Expand All @@ -56,7 +56,7 @@ fun AuthenticationCompletedScreen(goHome: () -> Unit = {}) = EduIdTopAppBar(
)

Text(
text = stringResource(R.string.authorize_confirmed_subtitle),
text = stringResource(R.string.Profile_YouAreLoggedIn_COPY),
style = MaterialTheme.typography.titleLarge.copy(
color = TextGreen
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private fun RequestAuthenticationContent(
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = TextGreen
),
text = stringResource(R.string.authorize_title),
text = stringResource(R.string.PinAndBioMetrics_LoginRequest_COPY),
modifier = Modifier.fillMaxWidth()
)
val loginQuestion = buildAnnotatedString {
Expand All @@ -77,19 +77,16 @@ private fun RequestAuthenticationContent(
color = TextGreen
).toSpanStyle()
)
append(stringResource(R.string.authorize_subtitle01))
append(stringResource(R.string.PinAndBioMetrics_DoYouWantToLogInTo_COPY))
pop()
append("\n")
pushStyle(
MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Center
).toSpanStyle()
)
append(
stringResource(
R.string.authorize_subtitle02, loginToService
)
)
append(loginToService)
append("?")
}

Text(
Expand All @@ -114,7 +111,7 @@ private fun RequestAuthenticationContent(
)
PrimaryButton(
modifier = Modifier.widthIn(min = 140.dp),
text = stringResource(R.string.authorize_login_button),
text = stringResource(R.string.PinAndBioMetrics_SignIn_COPY),
onClick = onLogin,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun EnableBiometricContent(
val contentTopSpacing = createGuidelineFromTop(40.dp)
val backgroundAlign = createGuidelineFromEnd(0.3f)
Text(
text = stringResource(R.string.biometric_enable_title),
text = stringResource(R.string.PinAndBioMetrics_BiometricsApproval_COPY),
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Start,
modifier = Modifier
Expand All @@ -112,7 +112,7 @@ fun EnableBiometricContent(
top.linkTo(title.bottom)
})
Text(
text = stringResource(R.string.biometric_enable_description),
text = stringResource(R.string.PinAndBioMetrics_BiometricsExplain_COPY),
style = MaterialTheme.typography.bodyLarge,
textAlign = TextAlign.Start,
modifier = Modifier
Expand Down Expand Up @@ -148,13 +148,13 @@ fun EnableBiometricContent(
bottom.linkTo(parent.bottom)
}) {
PrimaryButton(
text = stringResource(R.string.biometric_enable_allow), onClick = {
text = stringResource(R.string.PinAndBioMetrics_SetupBiometrics_COPY), onClick = {
enable()
}, modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(24.dp))
SecondaryButton(
text = stringResource(R.string.biometric_enable_skip), onClick = {
text = stringResource(R.string.PinAndBioMetrics_Skip_COPY), onClick = {
skip()
}, modifier = Modifier.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SignInWithBiometricsActivity : AppCompatActivity() {
super.onAuthenticationFailed()
setResult(BIOMETRIC_FAILED, Intent().apply {
putExtra(BIOMETRIC_ERRORCODE_KEY, BIOMETRIC_FAILED)
putExtra(BIOMETRIC_ERRORMESSAGE_KEY, getString(R.string.biometric_failed_unknown))
putExtra(BIOMETRIC_ERRORMESSAGE_KEY, getString(R.string.Biometrics_UnknownError_COPY))
})
biometricPrompt.cancelAuthentication()
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fun ContinueInBrowserScreen(
modifier = Modifier.fillMaxSize()
) {
Text(
text = stringResource(R.string.recovery_browser_title),
text = stringResource(R.string.WelcomeToApp_ReturnBrowserTitle_COPY),
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth(),
Expand All @@ -53,7 +53,7 @@ fun ContinueInBrowserScreen(

Text(
style = MaterialTheme.typography.bodyLarge,
text = stringResource(R.string.recovery_browser_explain),
text = stringResource(R.string.WelcomeToApp_ReturnBrowserText_COPY),
modifier = Modifier.padding(start = 8.dp)
)
Spacer(Modifier.height(16.dp))
Expand All @@ -68,7 +68,7 @@ fun ContinueInBrowserScreen(
}

PrimaryButton(
text = stringResource(R.string.start_button),
text = stringResource(R.string.WelcomeToApp_GotItButton_COPY),
onClick = goHome,
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private fun RequestEduIdCreatedContent(
.fillMaxWidth()
) {
Text(
text = stringResource(R.string.request_id_created_title),
text = stringResource(R.string.CreateEduID_Created_MainTitleLabel_COPY),
style = MaterialTheme.typography.titleLarge.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxWidth()
)
Expand All @@ -134,7 +134,7 @@ private fun RequestEduIdCreatedContent(
}

Text(
text = stringResource(R.string.request_id_created_description),
text = stringResource(R.string.CreateEduID_Created_MainText_COPY),
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.fillMaxWidth()
)
Expand All @@ -151,7 +151,7 @@ private fun RequestEduIdCreatedContent(
}

PrimaryButton(
text = stringResource(id = R.string.button_continue),
text = stringResource(id = R.string.NameUpdated_Continue_COPY),
onClick = {
waitingForVmEvent = true
startEnrollment()
Expand All @@ -167,7 +167,7 @@ private fun RequestEduIdFailedCreationContent() =
.fillMaxSize()
) {
Text(
text = stringResource(R.string.request_id_created_fail_title),
text = stringResource(R.string.CreateEduID_ErrorCreateFailed_Title_COPY),
style = MaterialTheme.typography.titleLarge.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxWidth()
)
Expand All @@ -176,7 +176,7 @@ private fun RequestEduIdFailedCreationContent() =
modifier = Modifier.height(16.dp)
)
Text(
text = stringResource(R.string.request_id_created_fail_description),
text = stringResource(R.string.CreateEduID_ErrorCreateFailed_Message_COPY),
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ fun DataAndActivityScreenContent(
Text(
style = MaterialTheme.typography.titleLarge.copy(
textAlign = TextAlign.Start, color = ButtonGreen
), text = stringResource(R.string.data_info_title), modifier = Modifier.fillMaxWidth()
), text = stringResource(R.string.DataActivity_Title_COPY), modifier = Modifier.fillMaxWidth()
)
Spacer(Modifier.height(12.dp))
Text(
style = MaterialTheme.typography.bodyLarge,
textAlign = TextAlign.Start,
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.data_info_subtitle),
text = stringResource(R.string.DataActivity_Info_COPY),
)
Spacer(Modifier.height(12.dp))
if (isLoading) {
Expand All @@ -112,7 +112,7 @@ fun DataAndActivityScreenContent(
title = provider.providerName.orEmpty(),
subtitle = provider.firstLoginStamp?.let {
stringResource(
R.string.data_info_on_date,
R.string.Profile_VerifiedOn_COPY,
it.getDateTimeString()
)
} ?: "-",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class DataAndActivityViewModel @Inject constructor(private val assistant: DataAs
} else {
uiState.copy(
isLoading = false, errorData = ErrorData(
titleId = R.string.err_title_load_fail,
messageId = R.string.err_msg_data_history_fail
titleId = R.string.ResponseErrors_UnauthorizedTitle_COPY,
messageId = R.string.ResponseErrors_ActivityHistoryRetrieveError_COPY
)
)
}
} catch (e: UnauthorizedException) {
uiState = uiState.copy(
isLoading = false, errorData = ErrorData(
titleId = R.string.err_title_load_fail,
messageId = R.string.err_msg_unauthorized_request_fail
titleId = R.string.ResponseErrors_UnauthorizedTitle_COPY,
messageId = R.string.ResponseErrors_UnauthorizedText_COPY
)
)
}
Expand All @@ -65,16 +65,16 @@ class DataAndActivityViewModel @Inject constructor(private val assistant: DataAs
UiState(
isLoading = false,
errorData = ErrorData(
titleId = R.string.err_title_load_fail,
messageId = R.string.err_msg_data_history_fail
titleId = R.string.ResponseErrors_UnauthorizedTitle_COPY,
messageId = R.string.ResponseErrors_ActivityHistoryRetrieveError_COPY
),
)
}
} catch (e: UnauthorizedException) {
uiState = uiState.copy(
isLoading = false, errorData = ErrorData(
titleId = R.string.err_title_generic_fail,
messageId = R.string.err_msg_unauthorized_request_fail
titleId = R.string.Generic_RequestError_Title_COPY,
messageId = R.string.ResponseErrors_UnauthorizedText_COPY
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun DeleteServiceContent(
.fillMaxWidth()
) {
Text(
text = stringResource(R.string.delete_service_confirm_title),
text = stringResource(R.string.DeleteService_Title_COPY),
style = MaterialTheme.typography.titleLarge.copy(
color = TextGreen, textAlign = TextAlign.Start
),
Expand All @@ -82,15 +82,15 @@ fun DeleteServiceContent(
)
Text(
style = MaterialTheme.typography.bodyLarge.copy(fontWeight = FontWeight.SemiBold),
text = stringResource(R.string.delete_no_undo_warning),
text = stringResource(R.string.DeleteService_Disclaimer_COPY),
modifier = Modifier.fillMaxWidth()
)
}

Spacer(Modifier.height(18.dp))
Text(
text = stringResource(
R.string.delete_service_confirm_explanation, providerName
R.string.DeleteService_Description_COPY, providerName
),
style = MaterialTheme.typography.bodyLarge,
textAlign = TextAlign.Start,
Expand All @@ -112,7 +112,7 @@ fun DeleteServiceContent(
modifier = Modifier.widthIn(min = 140.dp),
)
PrimaryButton(
text = stringResource(R.string.button_confirm),
text = stringResource(R.string.ConfirmDelete_Button_Confirm_COPY),
onClick = removeService,
enabled = !inProgress,
modifier = Modifier.widthIn(min = 140.dp),
Expand Down
Loading

0 comments on commit 872dca5

Please sign in to comment.