pierrejeambrun commented on code in PR #55604:
URL: https://github.com/apache/airflow/pull/55604#discussion_r2355681999
##########
dev/i18n/check_translations_completeness.py:
##########
@@ -454,20 +454,31 @@ def print_translation_progress(console, locale_files,
missing_counts, summary):
"--add-missing",
is_flag=True,
default=False,
- help="Add missing translations for the selected language, prefixed with
'TODO: translate:'.",
+ help="Add missing translations for all languages except English, prefixed
with 'TODO: translate:'.",
)
def cli(language: str | None = None, add_missing: bool = False):
- if add_missing:
- if not language:
- raise ValueError("--language is required when passing
--add_missing")
- locale_path = LOCALES_DIR / language
- locale_path.mkdir(exist_ok=True)
locale_files = get_locale_files()
console = Console(force_terminal=True, color_system="auto")
print_locale_file_table(locale_files, console, language)
found_difference = print_file_set_differences(locale_files, console,
language)
summary, missing_counts = compare_keys(locale_files, console)
console.print("\n[bold underline]Summary of differences by language:[/bold
underline]", style="cyan")
+ if add_missing and language != "en":
+ # Loop through all languages except 'en' and add missing translations
+ if language:
+ language_files = [lf for lf in locale_files if lf.locale ==
language]
+ else:
+ language_files = [lf for lf in locale_files if lf.locale != "en"]
+ for lf in language_files:
+ filtered_summary = {}
+ for filename, diff in summary.items():
+ filtered_summary[filename] = LocaleSummary(
+ missing_keys={lf.locale: diff.missing_keys.get(lf.locale,
[])},
+ extra_keys={lf.locale: diff.extra_keys.get(lf.locale, [])},
+ )
+ add_missing_translations(lf.locale, filtered_summary, console)
+ # After adding, re-run the summary for all languages
+ summary, missing_counts = compare_keys(get_locale_files(), console)
Review Comment:
That's not related to the issue, can you please split that into a different
PR. (Also I'm not sure why we need that)
##########
airflow-core/src/airflow/ui/src/components/LimitedItemsList.tsx:
##########
@@ -16,67 +16,174 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Box, Text, HStack, StackSeparator } from "@chakra-ui/react";
+import { Box, Text, HStack, useDisclosure, Heading, Stack } from
"@chakra-ui/react";
import React, { type ReactNode } from "react";
import { useTranslation } from "react-i18next";
-import { Tooltip } from "./ui";
+import { Tooltip, Dialog, Button } from "./ui";
type ListProps = {
readonly icon?: ReactNode;
readonly interactive?: boolean;
readonly items: Array<ReactNode | string>;
readonly maxItems?: number;
+ readonly modalTitle?: string;
readonly separator?: string;
+ readonly showModal?: boolean;
};
export const LimitedItemsList = ({
icon,
interactive = false,
items,
maxItems,
+ modalTitle = "All Items",
separator = ", ",
+ showModal = false,
}: ListProps) => {
const { t: translate } = useTranslation("components");
+ const { onClose, onOpen, open } = useDisclosure();
const shouldTruncate = maxItems !== undefined && items.length > maxItems;
const displayItems = shouldTruncate ? items.slice(0, maxItems) : items;
const remainingItems = shouldTruncate ? items.slice(maxItems) : [];
const remainingItemsList = interactive ? (
- <HStack separator={<StackSeparator />}>{remainingItems}</HStack>
+ <Box maxH="200px" overflowY="auto" p={2}>
+ <Text fontSize="sm" fontWeight="bold" mb={2}>
+ {translate("limitedList.allItems", { count: items.length })}
+ </Text>
+ <Stack gap={1}>
+ {items.map((item, index) => (
+ <Box fontSize="sm" key={typeof item === "string" ? item : index}>
+ {item}
+ </Box>
+ ))}
+ </Stack>
+ <Text color="gray.500" fontSize="xs" mt={2}>
+ {translate("limitedList.clickToOpenFull", { count:
remainingItems.length })}
+ </Text>
+ </Box>
) : (
- `More items: ${remainingItems.map((item) => (typeof item === "string" ?
item : "item")).join(", ")}`
+ <Box maxH="200px" overflowY="auto" p={2}>
+ <Text fontSize="sm" fontWeight="bold" mb={2}>
+ {translate("limitedList.allItems", { count: items.length })}
+ </Text>
+ <Stack gap={1}>
+ {items.map((item, index) => (
+ <Text fontSize="sm" key={typeof item === "string" ? item : index}>
+ {item}
+ </Text>
+ ))}
+ </Stack>
+ {showModal ? (
+ <Text color="gray.500" fontSize="xs" mt={2}>
+ {translate("limitedList.clickToOpenFull", { count:
remainingItems.length })}
+ </Text>
+ ) : undefined}
+ </Box>
Review Comment:
That seems like a lot of duplicated code.
--
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]