chore: bump version to 2.23.13 and update dependencies (#450)
* chore: bump version to 2.23.13 and update dependencies - Updated application version from 2.23.12 to 2.23.13 in package.json. - Upgraded several dependencies including @marsidev/react-turnstile to 1.4.2, @next/bundle-analyzer to 16.1.6, @next/eslint-plugin-next to 16.1.6, and others for improved functionality and security. - Adjusted package versions in pnpm-lock.yaml and pnpm-workspace.yaml for consistency across the project. - Removed unused AI translation functionality from translations-comparison component to streamline the codebase. * refactor: clean up code formatting and update Stripe API version - Removed unnecessary blank lines in LineItemDetails component for improved readability. - Enhanced formatting in PricingItem component for better clarity. - Updated Stripe API version from '2025-12-15.clover' to '2026-01-28.clover' for compatibility with the latest features. - Adjusted i18n initialization in email templates for consistency. - Reformatted props in AdminReactivateUserDialog for better structure. - Cleaned up type imports in ImageUploadInput component.
This commit is contained in:
committed by
GitHub
parent
58f08c5f39
commit
68276fda8a
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { ChevronDownIcon, Loader2Icon } from 'lucide-react';
|
||||
import { ChevronDownIcon } from 'lucide-react';
|
||||
import { Subject, debounceTime } from 'rxjs';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
@@ -32,10 +32,7 @@ import {
|
||||
} from '@kit/ui/table';
|
||||
import { cn } from '@kit/ui/utils';
|
||||
|
||||
import {
|
||||
translateWithAIAction,
|
||||
updateTranslationAction,
|
||||
} from '../lib/server-actions';
|
||||
import { updateTranslationAction } from '../lib/server-actions';
|
||||
import type { TranslationData, Translations } from '../lib/translations-loader';
|
||||
|
||||
function flattenTranslations(
|
||||
@@ -64,7 +61,6 @@ export function TranslationsComparison({
|
||||
translations: Translations;
|
||||
}) {
|
||||
const [search, setSearch] = useState('');
|
||||
const [isTranslating, setIsTranslating] = useState(false);
|
||||
|
||||
// Create RxJS Subject for handling translation updates
|
||||
const subject$ = useMemo(
|
||||
@@ -132,60 +128,6 @@ export function TranslationsComparison({
|
||||
setSelectedLocales(newSelectedLocales);
|
||||
};
|
||||
|
||||
const handleTranslateWithAI = useCallback(async () => {
|
||||
try {
|
||||
setIsTranslating(true);
|
||||
|
||||
// Get missing translations for the selected namespace
|
||||
const missingTranslations: Record<string, string> = {};
|
||||
const baseTranslations = flattenedTranslations[baseLocale] ?? {};
|
||||
|
||||
for (const locale of visibleLocales) {
|
||||
if (locale === baseLocale) continue;
|
||||
|
||||
const localeTranslations = flattenedTranslations[locale] ?? {};
|
||||
|
||||
for (const [key, value] of Object.entries(baseTranslations)) {
|
||||
if (!localeTranslations[key]) {
|
||||
missingTranslations[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(missingTranslations).length > 0) {
|
||||
await translateWithAIAction({
|
||||
sourceLocale: baseLocale,
|
||||
targetLocale: locale,
|
||||
namespace: selectedNamespace,
|
||||
translations: missingTranslations,
|
||||
});
|
||||
|
||||
toast.success(`Translated missing strings to ${locale}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error('Failed to translate: ' + (error as Error).message);
|
||||
} finally {
|
||||
setIsTranslating(false);
|
||||
}
|
||||
}, [flattenedTranslations, baseLocale, visibleLocales, selectedNamespace]);
|
||||
|
||||
// Calculate if there are any missing translations
|
||||
const hasMissingTranslations = useMemo(() => {
|
||||
if (!flattenedTranslations || !baseLocale || !visibleLocales) return false;
|
||||
|
||||
const baseTranslations = flattenedTranslations[baseLocale] ?? {};
|
||||
|
||||
return visibleLocales.some((locale) => {
|
||||
if (locale === baseLocale) return false;
|
||||
|
||||
const localeTranslations = flattenedTranslations[locale] ?? {};
|
||||
|
||||
return Object.keys(baseTranslations).some(
|
||||
(key) => !localeTranslations[key],
|
||||
);
|
||||
});
|
||||
}, [flattenedTranslations, baseLocale, visibleLocales]);
|
||||
|
||||
// Set up subscription to handle debounced updates
|
||||
useEffect(() => {
|
||||
const subscription = subject$.pipe(debounceTime(500)).subscribe((props) => {
|
||||
@@ -262,22 +204,6 @@ export function TranslationsComparison({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
onClick={handleTranslateWithAI}
|
||||
disabled={isTranslating || !hasMissingTranslations}
|
||||
>
|
||||
{isTranslating ? (
|
||||
<>
|
||||
<Loader2Icon className="mr-2 h-4 w-4 animate-spin" />
|
||||
Translating...
|
||||
</>
|
||||
) : (
|
||||
'Translate missing with AI'
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user