Skip to content

Conversation

@AndreaBarbasso
Copy link
Contributor

References

Description

Applied lang attribute to HTML tags containing metadata with an explicit language value.

Instructions for Reviewers

The lang attribute has been added via different approaches:

  • If the metadata string value was shown via innerHTML, that property has now been replaced with the new dsMetadata directive, that accepts a MetadataValue and applies the innerHTML property and the lang attribute to its host element. Having a directive for this purpose is useful since we can later add other attributes if necessary and is more feasible than a component.
  • Otherwise, the lang attribute has been applied to the closest available element.

List of changes in this PR:

  • Created and applied the new dsMetadata directive;
  • Applied the lang attribute where using the directive could lead to unwanted behaviors.
image

To test the PR, change any metadata language value and make sure that the value is added to the lang attribute of its containing element, wherever it's reflected (e.g. item pages, search results, ...).

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@AndreaBarbasso AndreaBarbasso changed the title Task/main/cst 19328 Add lang attribute to elements showing metadata values Oct 16, 2025
@AndreaBarbasso
Copy link
Contributor Author

AndreaBarbasso commented Oct 16, 2025

@tdonohue, tests are failing because of invalid values for the lang attribute.

A lot of metadata fields have the language set to en_US, but the correct value is en-US.
I think the best course of action here is avoiding front-end manipulation of those values, and change them on the fixture instead.

EDIT: after further research, I see that the difference is caused by different standards for in web technologies (IETF BCP 47) and Java/POSIX systems.
So, I guess the best course of action is to convert them on the front-end.

@AndreaBarbasso
Copy link
Contributor Author

As discussed today, I am going to open an issue on the REST side to discuss if we need to change the chosen standard for language codes.
Meanwhile, I will add a simple way to make a11y tests pass and to give a valid string to lang attributes, by replacing the _ with a -.

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.

[Accessibility] lang attribute needed for metadata values

1 participant