-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix(UI): Removed Translation from Constant Files #24570
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
Fix(UI): Removed Translation from Constant Files #24570
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes hardcoded translation calls (t() and i18n.t()) from constant files, converting them to store translation keys instead. Components now handle translation at render time using a new translateLabel utility function for nested translations. This improves internationalization by delaying translation until runtime and supporting dynamic language switching.
Key changes:
- Added
translateLabel()utility for nested translation parameter handling - Converted constant files to store translation keys instead of translated strings
- Updated component logic to translate keys at render time
- Extended type definitions to support translation parameters in constants
Reviewed changes
Copilot reviewed 61 out of 62 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
utils/i18next/LocalUtil.ts |
Added translateLabel() function for nested translation support |
constants/service-guide.constant.ts |
Removed i18n.t() calls, added titleData/descriptionData fields |
constants/Services.constant.ts |
Changed servicesDisplayName to store translation keys with entity parameters |
constants/PageHeaders.constant.ts |
Converted headers/subheaders to keys with optional parameter objects |
constants/Widgets.constant.ts |
Converted widget filter options to translation keys |
constants/BulkImport.constant.ts |
Removed i18n.t() and startCase(), store translation keys directly |
constants/Task.constant.ts |
Removed i18n.t() from task type messages |
constants/Query.constant.ts |
Converted sort options to translation keys |
constants/SearchSettings.constant.ts |
Converted settings labels to translation keys |
constants/Alerts.constants.tsx |
Converted contract status options to translation keys |
constants/AdvancedSearch.constants.ts |
Added labelKeyOptions for nested translations |
constants/Applications.constant.ts |
Converted stepper steps to translation keys |
interface/types.d.ts |
Added optional nameData, titleData, descriptionData fields |
components/PageHeader/* |
Updated to use translateLabel() for headers with parameters |
components/SearchDropdown/* |
Added labelKeyOptions prop for nested translations |
components/Explore/* |
Updated to pass translation keys and translate in components |
components/Settings/Services/* |
Updated service name translation logic |
components/SearchSettings/* |
Updated to translate labels at render time |
components/DataInsight/* |
Converted headers to use translation keys |
components/DataQuality/* |
Updated to use translation keys |
components/MyData/Widgets/* |
Updated sort options to translate at render time |
pages/IncidentManager/* |
Updated to translate page headers |
| Test files (multiple) | Added translateLabel to i18n mocks |
| description: 'message.ingestion-pipeline-name-successfully-deployed-entity', | ||
| descriptionData: { entity: 'label.metadata-lowercase' }, |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The descriptionData field is used in the service guide constants (e.g., lines 41, 60, 79, 96, 113) but there's no type definition for it. The service guide objects should have a type that includes both titleData and descriptionData as optional fields to ensure type safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I didn't see this constent being used anywhere I didn't add type for it. Cleaning up was not objective of this PR
| export const translateLabel = ( | ||
| label: string, | ||
| params?: Record<string, string | number | boolean> | ||
| ): string => { | ||
| if (!params) { | ||
| return t(label); | ||
| } | ||
|
|
||
| const translatedParams = Object.entries(params).reduce( | ||
| (acc, [key, value]) => ({ | ||
| ...acc, | ||
| [key]: typeof value === 'string' ? t(value) : value, | ||
| }), | ||
| {} | ||
| ); | ||
|
|
||
| return t(label, translatedParams); | ||
| }; |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The translateLabel function type definition allows string | number | boolean for parameter values, but the implementation only translates string values with t(). Non-string values are passed through directly. Consider documenting this behavior or adding type safety to ensure only translation keys (strings) are translated while numbers/booleans are passed through as-is.
...i/src/main/resources/ui/src/components/DataInsight/DataAssetsTab/DataAssetsTab.component.tsx
Outdated
Show resolved
Hide resolved
openmetadata-ui/src/main/resources/ui/src/components/DataInsight/KPIChart.tsx
Outdated
Show resolved
Hide resolved
| () => | ||
| STEPS_FOR_ADD_INGESTION.map((step) => ({ | ||
| ...step, | ||
| name: translateLabel(step.name, step.nameData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use t from hook here no?
| () => | ||
| STEPS_FOR_IMPORT_ENTITY.map((step) => ({ | ||
| ...step, | ||
| name: startCase(t(step.name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why startCase to step? Must we fix it in thelanguage file no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was part of constant file
|
|
||
| export type StepperStepType = { | ||
| name: string; | ||
| nameData?: Record<string, string | number | boolean>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this?
| import { getServiceLogo } from '../../utils/CommonUtils'; | ||
| import { getEntityFeedLink } from '../../utils/EntityUtils'; | ||
| import { handleEntityCreationError } from '../../utils/formUtils'; | ||
| import { translateLabel } from '../../utils/i18next/LocalUtil'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have this translateLabel? we can use t directly no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For nested Translation we can't directly remove t from constant file. That's why needed to divide translation into two part like name and nameData . Created a util function translateLabel which will accept both the keys and translate them properly.
openmetadata-ui/src/main/resources/ui/src/utils/i18next/LocalUtil.ts
Outdated
Show resolved
Hide resolved
…vjsx/OpenMetadata into remove-translation-constant
|
|
Changes have been cherry-picked to the 1.11.0 branch. |
* removed translation from constant files * fixed missing header params * fixed pageheader translation * fixed search dropdown * fixed datainsightchard * fixed sorting dropdown * fixed data asset tab * fixed data asset tab * fixed ingestion stepper * minor fixes and undo changes from unused file * fixed widget constants * removed unused mocks from tests * removed translation from policy * renamed translateLabel--> translateWithNestedKeys (cherry picked from commit b8eabae)
* removed translation from constant files * fixed missing header params * fixed pageheader translation * fixed search dropdown * fixed datainsightchard * fixed sorting dropdown * fixed data asset tab * fixed data asset tab * fixed ingestion stepper * minor fixes and undo changes from unused file * fixed widget constants * removed unused mocks from tests * removed translation from policy * renamed translateLabel--> translateWithNestedKeys (cherry picked from commit b8eabae)
|
Changes have been cherry-picked to the 1.10.11 branch as well. |



Describe your changes:
Fixes
I worked on ... because ...
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>