medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
468 stars 217 forks source link

Use Bikram Sambat dates throughout the webapp when Nepali locale selected #7294

Closed ghost closed 3 years ago

ghost commented 3 years ago

Is your feature request related to a problem? Please describe. In CHT, date-picker is converted in Nepali date (Bikram Sambat) when we change the language into Nepali, but when we try to display the enter data, it shows the gregorian date. I have tried using bikram-sambat tag in appearance, it only translated English to Nepali and does convert the date.

Describe the solution you'd like

So requesting for date conversion function or a tag in app form, so that date can be shown in summary and notes

@lalkunwar @niraj21

derickl commented 3 years ago

Possibly related: https://github.com/medic/cht-core/issues/4681

garethbowen commented 3 years ago

@ashish-medic I think this probably also applies to other places in the app that dates are shown, for example, task due dates (on hover), and dates in the contact summary section. Can you confirm this is the case? Should these be converted to Bikram Sambat as well?

niraj21 commented 3 years ago

This issue must be resolved as soon as possible because the delivery date with NSSD is September 15th, 2021, and the government is planning to deploy immediately after that. It would be a disappointment if we are unable to deliver the product on time. Thank you in advance for your assistance.

@ashish-medic @nnbhandari1 @binokaryg

ghost commented 3 years ago

@garethbowen thanks for bringing task due dates, and the contact summary section in pictures. Yes, we need this functionality in tasks and contact summary.

newtewt commented 3 years ago

Is this what the Date Filter does in app settings?

https://docs.communityhealthtoolkit.org/apps/reference/app-settings/#date-format-filters

garethbowen commented 3 years ago

@newtewt Yes but it's not widely used in the app. I think it's available for translation keys but as far as I can tell not within enketo forms and not throughout the app where dates are shown.

dianabarsan commented 3 years ago

It's unusual for us to release a patch with a feature, but it's happened before (coincidentally, it was related, about supporting a new language). Are we planning to release a patch with this feature, or add it to 3.13?

craig-landry commented 3 years ago

@dianabarsan it's kind of debatable if this is a feature or bug really. It's more that it's weird that it doesn't work. Technically the date picker does function and this is about using a different calendar (where you could call it a feature), but for users of this, they don't all understand the Gregorian calendar and how to convert that to the Bikram Sambat they're looking for - showing the Gregorian calendar just doesn't make sense.

Regarding a release plan for it, the intention is to have it merged into master, where the project (not yet live, but needed for a demo deadline) can run off a branch/hash. Completion of this code will not require its own official CHT release.

dianabarsan commented 3 years ago

Im starting work on this today.

dianabarsan commented 3 years ago

First of all, apologies for the screenshot spam. What I got so far:

  1. new Enketo xpath function to-bikram-sambat which takes a date string parameter and displays the date in Bikram Sambat.

Example (in this screenshot, selected language is en: Screenshot_20210910_125110

The form used: https://gist.github.com/dianabarsan/44fb5231953fd3806c7459fd7d0a9319

  1. When selected language is ne, date displays and relative date tooltips in lists are converted to Bikram Sambat:

Tasks: Screenshot_20210910_125937

Reports: Screenshot_20210910_151015

Contact detail tasks and reports: Screenshot_20210910_151114

Screenshot_20210910_130129

  1. When selected languge is ne, contact summary date filters automatically convert to Bikram Sambat:

Example where the field label is actually the used filter like: contact.<filter> and the displayed date is contact.reported_date: Screenshot_20210910_151158

Contact summary fields config:

  { appliesToType: 'person', label: 'contact.dateOfDeath', value: thisContact.reported_date, width: 4, filter: 'dateOfDeath' },
  { appliesToType: 'person', label: 'contact.age', value: thisContact.reported_date, width: 4, filter: 'age' },
  { appliesToType: 'person', label: 'contact.dayMonth', value: thisContact.reported_date, width: 4, filter: 'dayMonth' },
  { appliesToType: 'person', label: 'contact.relativeDate', value: thisContact.reported_date, width: 4, filter: 'relativeDate' },
  { appliesToType: 'person', label: 'contact.relativeDay', value: thisContact.reported_date, width: 4, filter: 'relativeDay' },
  { appliesToType: 'person', label: 'contact.taskDueDate', value: thisContact.reported_date, width: 4, filter: 'taskDueDate' },
  { appliesToType: 'person', label: 'contact.simpleDate', value: thisContact.reported_date, width: 4, filter: 'simpleDate' },
  { appliesToType: 'person', label: 'contact.simpleDateTime', value: thisContact.reported_date, width: 4, filter: 'simpleDateTime' },
  { appliesToType: 'person', label: 'contact.fullDate', value: thisContact.reported_date, width: 4, filter: 'fullDate' },
dianabarsan commented 3 years ago

Changes are available for testing on 7294-bikram-sambat-dates - it's based off of master and can be installed with Horticulturalist.

Please share if anything seems out of order or is missing. Thanks!

dianabarsan commented 3 years ago

One of the places where dates are not converted, because there is no mechanism to do so, are when displaying dates in XML report details. This does work for JSON form fields, when the type is set to date.

So, for XML forms, if you want a date field displayed in Bikram Sambat in report details, you'd have to use the Enketo calculation described in the above comment.

ghost commented 3 years ago

Hi team, did some testing, and looks good to me. Here are some screenshot Selection_361

Selection_363 Screenshot of online Nepali calendar : Selection_362

ghost commented 3 years ago

But for this part { appliesToType: 'person', label: 'contact.dayMonth', value: thisContact.reported_date, width: 4, filter: 'dayMonth' }, It only translate.

dianabarsan commented 3 years ago

The branch has been updated to fix this. Right now: image

ghost commented 3 years ago

thanks @dianabarsan it's fixed Selection_364

dianabarsan commented 3 years ago

I'm conflicted about somehting in regards to the implementation of this. Does anyone think it's worth adding a configuration flag that can be used to opt-out of formatting and converting all dates across the app in Bikram Sambat whenever Nepali language is used? Or will all Nepali deployments always want Bikram Sambat dates? I'm looking for some feedback on this. Thanks!

garethbowen commented 3 years ago

My understanding is native Nepali users will want BS everywhere, but would love confirmation of that from @ashish-medic !

A compromise option would be to show both dates but with limited screen real estate that doesn't feel like a sacrifice we can afford to make.

dianabarsan commented 3 years ago

It was my understanding as well, with the biggest hint that our current Enketo datepicker switches to Bikram Sambat automatically when Nepali is selected.

ghost commented 3 years ago

@garethbowen I second your understanding, yes Nepali users want to understand.

dianabarsan commented 3 years ago

This is ready for AT on 7294-bikram-sambat-dates

Should include conversion date to Bikram Sambat when selected locale is "ne". Should convert:

Does not convert the date filter on the reports page.

Adds a new Enketo xpath function to-bikram-sambat that converts a gregorian date to Bikram Sambat text. Example form using the new function: https://gist.github.com/dianabarsan/44fb5231953fd3806c7459fd7d0a9319

Adds a new pipe (filter) localizeNumber that localizes digits (so far, only converts to Devanagari script), which is now used in many places where we display numbers:

It's possible I may have missed some, also some numbers are part of messageformat pluralized keys, and passing localized numbers break messageformat matchers.

The new pipe (filter) can also be used for contact-summary fields to localize them: image

Documentation PR pending.

ngaruko commented 3 years ago

Testing on local

  1. Messages : Dates and tooltips image

  2. Tasks : image

  3. Reports : date picker image report dates and tooltips >> image

  4. People /contacts: contact summary image

  5. Analytics/Targets image

Pinging @ashish-medic and @binokaryg to double check as it is quite hard form me to create new contacts and reports and date with zero knowledge of the language.

ghost commented 3 years ago

I will also check from my side.

ngaruko commented 3 years ago

@latin-panda I think we can merge this one. We have covered most areas where dates are used. If @ashish-medic and team picks up any issue we overlooked, we can open another ticket.

latin-panda commented 3 years ago

Thanks Bede! I'll wait for @dianabarsan to come back before merging.

dianabarsan commented 3 years ago

Merged to master.