diff --git a/FIX_PROPOSAL.md b/FIX_PROPOSAL.md new file mode 100644 index 0000000..03d6d6a --- /dev/null +++ b/FIX_PROPOSAL.md @@ -0,0 +1,78 @@ +To fix the issue of hardcoded English strings in the `CortexChangesPanel` component, we need to integrate it with the IDE's i18n mechanism. We can achieve this by using the `I18nContext` from `src/i18n/index.ts` to translate the strings. + +Here's the exact code fix: + +```tsx +// src/components/cortex/CortexChangesPanel.tsx +import React from 'react'; +import { useI18n } from 'src/i18n/index'; + +const CortexChangesPanel = () => { + const { t } = useI18n(); + + return ( + // ... +
+
{t('cortex.changesPanel.tabLabels.changes')}
+
{t('cortex.changesPanel.tabLabels.allFiles')}
+
{t('cortex.changesPanel.emptyState')}
+
{t('cortex.changesPanel.diffLoadingFallback')}
+
+ // ... + ); +}; + +export default CortexChangesPanel; +``` + +Then, in your `src/i18n/index.ts` file, add the necessary translation keys: + +```typescript +// src/i18n/index.ts +import { createI18n } from 'i18n'; + +const i18n = createI18n({ + // ... + resources: { + en: { + translation: { + cortex: { + changesPanel: { + tabLabels: { + changes: 'Changes', + allFiles: 'All Files', + }, + emptyState: 'No changes yet', + diffLoadingFallback: 'Unable to load diff', + }, + }, + }, + }, + // Add translations for other languages here + fr: { + translation: { + cortex: { + changesPanel: { + tabLabels: { + changes: 'Changements', + allFiles: 'Tous les fichiers', + }, + emptyState: 'Aucun changement pour le moment', + diffLoadingFallback: 'Impossible de charger la différence', + }, + }, + }, + }, + // ... + }, +}); + +export const useI18n = () => { + const { t } = i18n.useTranslation(); + return { t }; +}; +``` + +This code uses the `useI18n` hook to get the `t` function, which is used to translate the strings. The `t` function takes a key as an argument and returns the translated string for the current locale. + +Make sure to add translations for all the languages you want to support in the `resources` object. \ No newline at end of file