You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well-structured translation feature with comprehensive test coverage, clean implementation, and excellent documentation including Storybook examples.
🚨 Critical Issues
None found.
⚠️ Important Issues
[File: src/utils/helpers.ts Line: L14-L39] The translate function creates a new localTranslations object on every invocation, which is inefficient. This object should be defined as a constant outside the function to avoid unnecessary memory allocations on each call. Move the DEFAULT_TRANSLATIONS object outside the function scope for better performance.
[File: src/utils/helpers.ts Line: L12] Missing translation keys in the default translations object. The function should include all keys defined in the Translations type for consistency. Missing keys: "from", "to", "Add to Cart". These keys are defined in the Translations type (src/types.ts:L84-L88) but not in the default translations, which could cause unexpected fallbacks to the raw key string.
💡 Suggestions
[File: src/utils/helpers.ts Line: L42-L43] The type casting as keyof Translations and as string could be avoided with better typing. Consider using a stricter type guard or a type-safe lookup approach to eliminate the need for assertions.
[File: src/constants.ts Line: L7-L46] The translationsDescription constant appears unused in the codebase (based on the diff). If this is intended for documentation purposes, consider adding a JSDoc comment explaining where it should be used, or remove it if not needed.
[File: spec/utils/helpers.test.ts Line: L87-L94] Good edge case test for undefined values. Consider adding a similar test for empty string values (results: empty string) to ensure the behavior is well-defined when a translation is explicitly set to an empty string.
[General] The translations are passed through context and retrieved in each component. For components that use multiple translation keys (like CioPlpGrid), consider memoizing the context value to prevent unnecessary re-renders when unrelated context values change.
[File: src/stories/components/CioPlp/Translations.stories.tsx Line: L40-L42] The gridKey increment logic has a potential issue - it references gridKey in the dependency array which is intentionally omitted, making the increment unreliable. Consider using a functional state update: setGridKey(prev => prev + 1).
Overall Assessment: ✅ Pass
The translation feature is well-implemented with strong test coverage and good documentation. The important issues identified are primarily performance optimizations and consistency improvements that should be addressed to ensure optimal performance at scale. The code is production-ready once the missing default translations are added.
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR adds i18n/translations support to the PLP component library, introducing a Translations type, a translate() helper, and wiring the new translations prop through the context to all UI strings.
esezen
changed the title
Add support for translations
[CDX-303] Add support for translations
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Before you submit a pull request, please make sure you have to following:
PR Type
What kind of change does this PR introduce?