Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#248] Support for loading-time L10n of metadata names and descriptions based on Context's locale. #249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mseaton
Copy link
Collaborator

@mseaton mseaton commented Oct 5, 2023

Note, if this approach is approved, then there are likely additional changes to expand this beyond the encounter type domain, by changing other metadata loaders to extend the BaseMetadataLineProcessor rather than the BaseLineProcessor and then update the way the set the name and description properties.

For now, this works and is tested against the EncounterType domain.

We'll also need to update the README and Release Notes. I can add that in if this is agreed on as a general approach. I expect there may be alternative ideas for what the constant is named (currently "_translate_", but I assume others may have better ideas here).

…ta from translations in the context locale
@mseaton mseaton requested review from rbuisson, mks-d and Ruhanga October 5, 2023 16:57
Copy link
Member

@mks-d mks-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseaton I'm surely a bit out of context but is this for metadata entities that do not support a display string (for which we would use the display:xy header, like for example here)?

Copy link
Member

@mks-d mks-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry, just read the issue description...

So, at Iniz-time, the metadata name and description are localised as per the system's locale, correct?

This should not have any impact in the UX (in theory), but is useful in the local context? As you describe when flattening data directly out of the database, etc?

If that's right then this really a metadata regionalization/localization feature so that the database looks "local" to consumers in country. Then maybe, rather than the _translate_ directive, we could use _localize_ (or _L10n_)?

@mseaton
Copy link
Collaborator Author

mseaton commented Oct 6, 2023

If that's right then this really a metadata regionalization/localization feature so that the database looks "local" to consumers in country. Then maybe, rather than the _translate_ directive, we could use _localize_ (or _L10n_)?

Sure, we can have this named whatever we want. I'll take direction from you on this, and make it so.

@mks-d mks-d changed the title #248 - Support setting names and descriptions of metadata from transl… [#248] Support setting names and descriptions of metadata from transl… Oct 6, 2023
String name = line.getName(true);
if (TRANSLATE.equals(name)) {
String code = "ui.i18n." + metadata.getClass().getSimpleName() + ".name." + metadata.getUuid();
name = messageSourceService.getMessage(code);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What locale is going to be used here? My question is at a functional level, OpenMRS' default locale I would assume?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the functioning of the unit tests, it is whatever is returned from Context.getLocale(), which will end up as LocaleUtility.getDefaultLocale(). This will ultimately be whatever is in the GP named "default_locale", and if this is either unset or can't be retrieved, will fall back to "en_GB"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that describe the feature appropriately:

Support for loading-time L10n of metadata names and descriptions based on Context's locale.

?
It would need to be documented well of course, but is that functional intent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it raises a good point. We might want to change this and also be more explicit in the code. Because if someone were to decide to re-run an initializer load themselves (eg. we have an admin feature to allow this for development), then this will pick up their locale, rather than a standard system locale. So maybe the translation here should explicitly pass in the locale that is returned from LocaleUtility.getDefaultLocale(), so that this will always behave consistently in the same system. Then, the documentation can describe this as "...based on the system default locale (default_locale global property)" or something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseaton we all left this PR and thread hanging, what's your take? Should we resume reviewing it, or should be close it for now?

@mks-d mks-d changed the title [#248] Support setting names and descriptions of metadata from transl… [#248] Support for loading-time L10n of metadata names and descriptions based on Context's locale. Jul 1, 2024
@mks-d mks-d removed request for rbuisson and Ruhanga July 1, 2024 06:11
@mks-d mks-d removed the enhancement label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants