Copilot commented on code in PR #3689:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3689#discussion_r3774497040


##########
packages/import-java-classes-component/src/components/ImportJavaClasses/ImportJavaClasses.tsx:
##########
@@ -42,20 +42,25 @@ interface ImportJavaClassesProps {
   loadJavaClassesInDataTypeEditor?: (javaClasses: JavaClass[]) => void;
 }
 
-const ImportJavaClassesI18nDictionariesProvider = (
-  props: Omit<
-    React.ComponentProps<typeof I18nDictionariesProvider>,
-    "defaults" | "dictionaries" | "initialLocale" | "ctx"
-  >
-) => (
-  <I18nDictionariesProvider
-    defaults={importJavaClassesWizardI18nDefaults}
-    dictionaries={importJavaClassesWizardI18nDictionaries}
-    initialLocale={navigator.language}
-    ctx={ImportJavaClassesWizardI18nContext}
-    {...props}
-  />
-);
+export type ImportJavaClassesI18nDictionariesProviderProps = Omit<
+  React.ComponentProps<typeof I18nDictionariesProvider>,
+  "defaults" | "dictionaries" | "initialLocale" | "ctx"
+> & {
+  locale?: string;
+};
+
+const ImportJavaClassesI18nDictionariesProvider = (props: 
ImportJavaClassesI18nDictionariesProviderProps) => {
+  const { locale, ...i18nProviderProps } = props;
+  return (
+    <I18nDictionariesProvider
+      defaults={importJavaClassesWizardI18nDefaults}
+      dictionaries={importJavaClassesWizardI18nDictionaries}
+      initialLocale={locale ?? navigator.language}

Review Comment:
   `navigator.language` will throw in non-browser environments (SSR, some test 
runners, Node-based tooling). Use a safe lookup (e.g., 
`globalThis.navigator?.language`) and provide a sensible fallback locale string 
when `navigator` is unavailable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to