Skip to content

#5636 - fixing i18n translation problem for date picker labels#5647

Open
kanasznagyzoltan wants to merge 1 commit into
DSpace:mainfrom
qultoltd:QREPO-403-date-picker-label-i18n-issue
Open

#5636 - fixing i18n translation problem for date picker labels#5647
kanasznagyzoltan wants to merge 1 commit into
DSpace:mainfrom
qultoltd:QREPO-403-date-picker-label-i18n-issue

Conversation

@kanasznagyzoltan
Copy link
Copy Markdown
Contributor

References

Description

Fixes a broken double-translation chain in the date picker form labels that caused raw i18n key strings (e.g. form.number-picker.label.Év) to be rendered instead of translated text in non-English languages.

Instructions for Reviewers

Root Cause

date-picker.component.html passed [placeholder]="'form.date-picker.placeholder.year' | translate" to <ds-number-picker>. The number-picker component then used that value to construct a second translation key: 'form.number-picker.label.' + placeholder. This created a two-step chain:

  • English: form.date-picker.placeholder.year"Year"form.number-picker.label.Year
  • German: form.date-picker.placeholder.year"Jahr"form.number-picker.label.Jahr ✗ (key does not exist → raw key string rendered)
  • Hungarian: form.date-picker.placeholder.year"Év"form.number-picker.label.Év

The bug was latent until form.date-picker.placeholder.* keys were properly translated in non-English language files — at which point the dynamically constructed lookup key no longer existed.

List of changes in this PR:

  • date-picker.component.html: Removed | translate pipe from all three [placeholder] bindings. Now passes static English key suffixes ('Year', 'Month', 'Day') directly so that number-picker owns all translation logic internally.
  • number-picker.component.html: Fixed increment/decrement button title and aria-label attributes to resolve ('form.number-picker.label.' + placeholder | translate) as the {{field}} interpolation value, so accessibility strings also display the localized field name correctly.
  • hu.json5: Added Hungarian translations for form.number-picker.label.Year, form.number-picker.label.Month, and form.number-picker.label.Day to allow testing. Full Hungarian translation is covered separately in Fixes #5633 - [i18n] Update and complete Hungarian (hu) translations for DSpace 10 #5634.

How to test:

  1. Start a new submission
  2. Switch language to Hungarian, German, or Spanish
  3. Navigate to a metadata field with a date picker (e.g. "Date of Issue")
  4. Verify labels show the localized names (e.g. Év / Hónap / Nap in Hungarian, Jahr / Monat / Tag in German) instead of raw key strings
  5. Verify the increment/decrement button tooltips also show the localized field name

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • 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.

@lgeggleston lgeggleston added bug i18n / l10n Internationalisation and localisation, related to message catalogs component: submission 1 APPROVAL pull request only requires a single approval to merge labels May 11, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release May 11, 2026
@lgeggleston
Copy link
Copy Markdown

Thanks for your fix for this @kanasznagyzoltan! The bug seemed to occur on sandbox but not the demo site, so this may only affect main/10.0.

Copy link
Copy Markdown
Contributor

@GauravD2t GauravD2t left a comment

Choose a reason for hiding this comment

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

thanks for the contribution!

1.Old keys are now unused: form.date-picker.placeholder.year/month/day exist in all 37 language files (including en.json5 lines 7479-7483) but are no longer referenced in the code.

Recommendation
Either:

Option A: Revert date-picker to use the existing translation keys (form.date-picker.placeholder.year/month/day) which are already translated in all languages
Option B: Complete the translation updates for all 37 language files before merging, ensuring form.number-picker.label.Year/Month/Day are properly translated in every language

Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@kanasznagyzoltan : Thanks for this PR. However, based on a code review only, I think these i18n keys you've created all should be lowercased to match what is in the English file (en.json5). See notes inline below

[value]="year"
[invalid]="showErrorMessages"
[placeholder]="'form.date-picker.placeholder.year' | translate"
[placeholder]="'Year'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kanasznagyzoltan : As @GauravD2t pointed out, I think these placeholders need to be lowercased. In the en.json5 file the i18n keys are as follows:

 "form.date-picker.placeholder.year": "Year",

  "form.date-picker.placeholder.month": "Month",

  "form.date-picker.placeholder.day": "Day",

But, by making this uppercased Year, you are trying to use a non-existent key of form.date-picker.placeholder.Year instead of form.date-picker.placeholder.year.

Comment thread src/assets/i18n/hu.json5
// "form.number-picker.label.Year": "Year",
// TODO New key - Add a translation
"form.number-picker.label.Year": "Year",
"form.number-picker.label.Year": "Év",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These should also be lowercased to match the en.json5 file. So this should be form.number-picker.label.year

@lgeggleston lgeggleston moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 10.0 Release May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug component: submission i18n / l10n Internationalisation and localisation, related to message catalogs

Projects

Status: 👀 Under Review

Development

Successfully merging this pull request may close these issues.

Date picker form label translation problem in some languages

4 participants