Repository: strapi/strapi
File: packages/plugins/i18n/admin/src/components/CMHeaderActions.tsx (TypeScript)

Code before:
    return null;
  }

  const displayedLocales = locales.filter((locale) => {
    /**
     * If you can read we allow you to see the locale exists
     * otherwise the locale is hidden.
     */
    return canRead.includes(locale.code);
  });

  return {
    label: formatMessage({
      id: getTranslation('Settings.locales.modal.locales.label'),
      defaultMessage: 'Locales',
    }),
    options: displayedLocales.map((locale, index) => {
      const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);

      const currentLocaleDoc = allCurrentLocales.find((doc) =>
        'locale' in doc ? doc.locale === locale.code : false
      );

      const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;

      if (isAiAvailable) {
        return {
          render: (
            <React.Fragment key={index}>
              <SingleSelectOption
                disabled={!permissionsToCheck.includes(locale.code)}
                key={locale.code}
                startIcon={
                  <LocaleOptionStartIcon
                    entryWithLocaleExists={entryWithLocaleExists}
                    translationStatus={jobData?.data?.status}
                    index={index}
                  />
                }
                value={locale.code}
              >
                <LocaleOption
                  isDraftAndPublishEnabled={!!schema?.options?.draftAndPublish}
                  locale={locale}
                  status={currentLocaleDoc?.status}
                  entryExists={entryWithLocaleExists}
                />
              </SingleSelectOption>
              {index === 0 && (
                <Box paddingRight={4} paddingLeft={4} paddingTop={2} paddingBottom={2}>
                  <Typography variant="sigma">

Review comment (suggestion):
this only checks if AI is globally enabled/available, but you're not checking if i18n AI specifically is enabled. If it's not I don't think we should show this UI. We already have the other document action to push users to enable it

Code after:
  if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
    return null;
  }

  const displayedLocales = locales.filter((locale) => {
    /**
     * If you can read we allow you to see the locale exists
     * otherwise the locale is hidden.
     */
    return canRead.includes(locale.code);
  });

  return {
    label: formatMessage({
      id: getTranslation('Settings.locales.modal.locales.label'),
      defaultMessage: 'Locales',
    }),
    options: displayedLocales.map((locale, index) => {
      const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);

      const currentLocaleDoc = allCurrentLocales.find((doc) =>
        'locale' in doc ? doc.locale === locale.code : false
      );

      const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;

      if (
        window.strapi.future.isEnabled('unstableAILocalizations') &&
        isAiAvailable &&
        settings?.data?.aiLocalizations
      ) {
        return {
          _render: () => (
            <React.Fragment key={index}>
              <SingleSelectOption
                disabled={!permissionsToCheck.includes(locale.code)}
                key={locale.code}
                startIcon={
                  <LocaleOptionStartIcon
                    entryWithLocaleExists={entryWithLocaleExists}
                    translationStatus={jobData?.data?.status}
                    index={index}
                  />
                }
                value={locale.code}
              >
                <LocaleOption
                  isDraftAndPublishEnabled={!!schema?.options?.draftAndPublish}
                  locale={locale}
                  status={currentLocaleDoc?.status}
                  entryExists={entryWithLocaleExists}