Skip to content

Conversation

@dhruvjsx
Copy link
Contributor

Describe your changes:

Fixes

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@github-actions
Copy link
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@dhruvjsx dhruvjsx changed the title Fix(UI): Removed Translastion from Constant Files Fix(UI): Removed Translation from Constant Files Nov 27, 2025
@Ashish8689 Ashish8689 added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch labels Nov 27, 2025
@Ashish8689 Ashish8689 requested a review from Copilot November 27, 2025 07:51
Copy link
Contributor

Copilot AI left a 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

Comment on lines 40 to 41
description: 'message.ingestion-pipeline-name-successfully-deployed-entity',
descriptionData: { entity: 'label.metadata-lowercase' },
Copy link

Copilot AI Nov 27, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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

Comment on lines 63 to 80
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);
};
Copy link

Copilot AI Nov 27, 2025

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 27, 2025

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.45% (49766/78429) 40.61% (23801/58615) 44.32% (7568/17074)

() =>
STEPS_FOR_ADD_INGESTION.map((step) => ({
...step,
name: translateLabel(step.name, step.nameData),
Copy link
Collaborator

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)),
Copy link
Collaborator

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?

Copy link
Contributor Author

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>;
Copy link
Collaborator

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';
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@sonarqubecloud
Copy link

@chirag-madlani chirag-madlani merged commit b8eabae into open-metadata:main Dec 1, 2025
17 of 19 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Changes have been cherry-picked to the 1.11.0 branch.

github-actions bot pushed a commit that referenced this pull request Dec 1, 2025
* 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)
Ashish8689 pushed a commit that referenced this pull request Dec 1, 2025
* 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)
@Ashish8689
Copy link
Contributor

Changes have been cherry-picked to the 1.10.11 branch as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants