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

Adding i18n to records #593

Merged
merged 2 commits into from
Sep 1, 2023
Merged

Adding i18n to records #593

merged 2 commits into from
Sep 1, 2023

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Aug 25, 2023

This PR is intended to get user current locale in records instead of the default one.

If a translation is available in the record for his language, it uses this one.

Issue #556

@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2023

Affected libs: api-metadata-converter, api-repository, feature-catalog, feature-record, feature-router, feature-search, feature-map, feature-dataviz, feature-auth, feature-editor, ui-search, common-fixtures, util-shared, ui-elements, ui-catalog, ui-widgets, ui-inputs, ui-map, util-i18n, util-app-config, ui-dataviz,
Affected apps: metadata-converter, metadata-editor, datafeeder, demo, datahub, webcomponents, search, map-viewer,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@fgravin fgravin linked an issue Aug 25, 2023 that may be closed by this pull request
Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

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

Very nice start !
We have to be careful about what fields are multilingual and what are not.
Also, it depends on the versions of GN... for instance, organizations & contacts have been converted to multilingual very shortly.
It might miss the contacts for the last version of GN 4.2.5.

Also, the hard work, which could be led in another PR, is about the way we run the search.
The index is multilingual, there is a setting to set the language of the catalog (which is more the language of the records of the catalog though). If set to fre the search is led on any.fre instead of any.default (resourceTitleObject.fre and all other multilingual fields). You can also have any.* etc...

We might need to work with Christophe on this cause he studied that for geocat and see how it's handle in geonetwork vanilla as well. It's not an easy task.
🙌

) {}

private readonly lang3 = LANG_2_TO_3_MAPPER[this.translateService.currentLang]
Copy link
Member

Choose a reason for hiding this comment

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

Is it a fixed variable ? With the language switcher, I expect people to dynamically change the language of the UI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know what's the actual behavior when we change locale.Is it reloading the page ? in this case it should work.

If it doesn't reload, I'll get a bigger look on onLangChange to edit this variable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is static for now, changing the shown language dynamically would be a more involved change which is I think outside of the scope of this PR

@@ -1269,6 +1269,8 @@ export const ES_FIXTURE_FULL_RESPONSE = deepFreeze({
{
default: 'Restriction lié à l’exercice du droit moral',
langfre: 'Restriction lié à l’exercice du droit moral',
langger:
'Einschränkung im Zusammenhang mit der Ausübung moralischer Rechte',
Copy link
Member

Choose a reason for hiding this comment

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

😲

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test 😄

@coveralls
Copy link

Coverage Status

coverage: 82.793% (+6.8%) from 75.974% when pulling 7bce7d0 on better-i18n-handling into 30a1e9a on main.

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Great work!!

): T | null => selectField(source, 'default')
source: SourceWithUnknownProps,
lang3: string
): T | null => selectField(source, lang3) || selectField(source, 'default')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
): T | null => selectField(source, lang3) || selectField(source, 'default')
): T | null => selectFallback(selectField(source, lang3), selectField(source, 'default'))

@f-necas
Copy link
Collaborator Author

f-necas commented Sep 1, 2023

Thanks for your reviews !
I've updated the fallback thing and also updated code to get translation of contacts and orgs.

1 similar comment
@f-necas
Copy link
Collaborator Author

f-necas commented Sep 1, 2023

Thanks for your reviews !
I've updated the fallback thing and also updated code to get translation of contacts and orgs.

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Thanks!

@f-necas f-necas merged commit a79eb32 into main Sep 1, 2023
7 checks passed
@jahow jahow deleted the better-i18n-handling branch September 8, 2023 10:03
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.

[Datahub]: Multilingual search
4 participants