waseefakhtar / dose-android

💊⏰ Dose is a medication reminder app for Android, built entirely using Kotlin and Jetpack Compose with MVVM + Clean Architecture
https://play.google.com/store/apps/details?id=com.waseefakhtar.doseapp
MIT License
509 stars 80 forks source link

Fix translations #126

Closed Angelk90 closed 8 months ago

Angelk90 commented 9 months ago

@waseefakhtar : The following part is missing to translate, the texts are there but I don't know how to put them in there, I tried with stringResource but I couldn't.

https://github.com/waseefakhtar/dose-android/blob/788cf54ae911dea8f9d9b436aa4cacab32a2496d/app/src/main/java/com/waseefakhtar/doseapp/feature/addmedication/viewmodel/AddMedicationViewModel.kt#L21-L26

There is a problem:

%2 === 1 <string name="all_set">I tuoi promemoria per %1$s sono pronti, con %2$s avviso %3$s fino a %4$s.</string>

%2 !== 1

<string name="all_set">I tuoi promemoria per %1$s sono pronti, con %2$s avvisi %3$s fino a %4$s.</string>

I tried like this, but it's not working:

MedicationConfirmRoute.kt

        Text(
            text = stringResource(
                R.plurals.all_set,
                medications.size
            ).format(
                medication.name,
                medications.size,
                medication.recurrence.lowercase(),
                medication.endDate.toFormattedDateString()
            ),
            style = MaterialTheme.typography.titleMedium
        )

en:

    <plurals name="all_set">
        <item quantity="one">Your %1$s reminders are ready, with %2$s alert %3$s until %4$s.</item>
        <item quantity="other">Your %1$s reminders are ready, with %2$s alerts %3$s until %4$s.</item>
    </plurals>

it

    <plurals name="all_set">
        <item quantity="one">I tuoi promemoria per %1$s sono pronti, con %2$s avviso %3$s fino a %4$s.</item>
        <item quantity="other">I tuoi promemoria per %1$s sono pronti, con %2$s avvisi %3$s fino a %4$s.</item>
    </plurals>
waseefakhtar commented 8 months ago

Good points!

I think we need a mechanism to map "Daily", "Weekly" and "Monthly" when we need to show them in UI and then pick a localized version, possibly with an extension function. What do you think?

Regarding all_set, can't we go with with the existing phrase where it satisfies both singular and plural values in English, i.e. "Your %1$s reminders are ready, with %2$s alert(s) %3$s until %4$s"?

Angelk90 commented 8 months ago

@waseefakhtar : If it works it's fine. It would be more correct to use the right phrase rather than do as you say. In English you could use it, but there are other languages that would not be correct in form.

waseefakhtar commented 8 months ago

@waseefakhtar : If it works it's fine. It would be more correct to use the right phrase rather than do as you say. In English you could use it, but there are other languages that would not be correct in form.

Wouldn't it make sense to go with avviso/i? If not, we can go with your suggestion, i.e.:

<plurals name="all_set">
    <item quantity="one">Your %1$s reminders are ready, with %2$s alert %3$s until %4$s.</item>
    <item quantity="other">Your %1$s reminders are ready, with %2$s alerts %3$s until %4$s.</item>
</plurals>
Angelk90 commented 8 months ago

@waseefakhtar : It's better to use the plural, but first you need to understand how to make it work.

Then try to solve the following problems:

You can work on this same fork editable by the maintainers

waseefakhtar commented 8 months ago

@waseefakhtar : It's better to use the plural, but first you need to understand how to make it work.

Then try to solve the following problems:

  • Use of plural modify MedicationConfirmRoute.kt file
  • Fix the AddMedicationViewModel.kt issue

You can work on this same fork editable by the maintainers

Looks like I don't have write access to your branch, but here's how you can make the change:

Text(
            text = pluralStringResource(
                id = R.plurals.all_set,
                count = medications.size,
                medication.name,
                medications.size,
                medication.recurrence.lowercase(),
                medication.endDate.toFormattedDateString()
            ),
            style = MaterialTheme.typography.titleMedium
        )