fix(translate): chart labels, sheet-refs, sheet-name offset, paid-user Memento
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m19s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m19s
Multiple translation bugs in Word/Excel/PPTX that caused chart elements
to be left untranslated or charts to render as empty series.
Backend
-------
* providers (deepseek/openai/minimax): tighten system prompt so the LLM
actually translates chart titles/axis labels/legend/category labels,
month abbreviations, and clarifies what counts as a 'real' proper noun
(people/place/company/product names) vs. technical labels. Old rule
'keep proper nouns unchanged' was being read too broadly by the model
and caused chart text to be skipped.
* excel_translator.py:
- Sheet reference rewrite: when a sheet is renamed, the chart XML's
c:f refs (e.g. 'Sales 2024'!$D$2:$D$61) are now rewritten to the
new name with proper apostrophe escaping (Chiffre d'affaires ->
'Chiffre d''affaires') and auto-quoting when the new name contains
spaces or special chars. Without this, the chart points at a sheet
that no longer exists and renders 0/empty series.
- Sheet name offset bug: sheet_name_offset was computed after chart
text was appended to text_elements, causing sheet names to receive
chart text translations. Now captured BEFORE sheet names are added.
* New tests:
- test_excel_chart_sheet_refs.py (10 unit tests, synthetic inputs)
- test_chart_translation_prompt.py (3 contract tests on the prompt)
Frontend
--------
* DashboardSidebar / translate/page: hide the Memento promo section
for paying users (tier != 'free').
* constants.ts: temporarily comment out the 'CLES API' nav item.
Update constants.test.ts to match the new state.
All fixes are generic - no file-specific hardcoding, edge cases covered
(empty mapping, missing bang, apostrophe escaping, partial renames,
multi-series).
This commit is contained in:
@@ -18,6 +18,7 @@ export function DashboardSidebar() {
|
||||
const { t } = useI18n();
|
||||
|
||||
const isPro = ['pro', 'business', 'enterprise'].includes(user?.tier ?? '');
|
||||
const isPaid = !!user?.tier && user.tier !== 'free';
|
||||
const navItems = isPro ? baseNavItems : baseNavItems.filter(item => !item.proOnly);
|
||||
|
||||
return (
|
||||
@@ -68,7 +69,8 @@ export function DashboardSidebar() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Memento promo section */}
|
||||
{/* Memento promo section — hidden for paying users */}
|
||||
{!isPaid && (
|
||||
<a
|
||||
href={t('memento.url', { defaultValue: 'https://memento-note.com/' })}
|
||||
target="_blank"
|
||||
@@ -88,6 +90,7 @@ export function DashboardSidebar() {
|
||||
</button>
|
||||
</div>
|
||||
</a>
|
||||
)}
|
||||
|
||||
{/* User section */}
|
||||
<div className="border-t border-black/5 dark:border-white/5">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FileText, Key, BookText, User, type LucideIcon } from 'lucide-react';
|
||||
import { FileText, BookText, User, type LucideIcon } from 'lucide-react';
|
||||
|
||||
export interface NavItem {
|
||||
labelKey: string;
|
||||
@@ -11,5 +11,6 @@ export const baseNavItems: NavItem[] = [
|
||||
{ labelKey: 'dashboard.nav.translate', href: '/dashboard/translate', icon: FileText },
|
||||
{ labelKey: 'dashboard.nav.profile', href: '/dashboard/profile', icon: User },
|
||||
{ labelKey: 'dashboard.nav.glossaries', href: '/dashboard/glossaries', icon: BookText, proOnly: true },
|
||||
{ labelKey: 'dashboard.nav.apiKeys', href: '/dashboard/api-keys', icon: Key, proOnly: true },
|
||||
// API Keys nav item temporarily removed per request — uncomment to restore.
|
||||
// { labelKey: 'dashboard.nav.apiKeys', href: '/dashboard/api-keys', icon: Key, proOnly: true },
|
||||
];
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useNotification } from '@/components/ui/notification';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { API_BASE } from '@/lib/config';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useUser } from '../useUser';
|
||||
|
||||
/* ── helpers ─────────────────────────────────────────────────────── */
|
||||
const FILE_ICONS: Record<string, React.ElementType> = {
|
||||
@@ -74,6 +75,8 @@ export default function TranslatePage() {
|
||||
const submit = useTranslationSubmit();
|
||||
const { error: showError } = useNotification();
|
||||
const { t } = useI18n();
|
||||
const { data: currentUser } = useUser();
|
||||
const isPaid = !!currentUser?.tier && currentUser.tier !== 'free';
|
||||
const lastErrorRef = useRef<string | null>(null);
|
||||
const replaceInputRef = useRef<HTMLInputElement>(null);
|
||||
const dropzoneInputRef = useRef<HTMLInputElement>(null);
|
||||
@@ -742,8 +745,8 @@ export default function TranslatePage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── MEMENTO PROMO BANNER ──────────────────────────────── */}
|
||||
{(showUpload || showConfiguring || showFailed) && (
|
||||
{/* ── MEMENTO PROMO BANNER — hidden for paying users ────── */}
|
||||
{!isPaid && (showUpload || showConfiguring || showFailed) && (
|
||||
<a
|
||||
href={t('memento.url', { defaultValue: 'https://memento-note.com/' })}
|
||||
target="_blank"
|
||||
|
||||
@@ -10,10 +10,15 @@ describe('baseNavItems', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should flag glossaries and apiKeys as proOnly', () => {
|
||||
it('should flag glossaries as proOnly', () => {
|
||||
const glossaries = baseNavItems.find(item => item.href === '/dashboard/glossaries');
|
||||
const apiKeys = baseNavItems.find(item => item.href === '/dashboard/api-keys');
|
||||
expect(glossaries?.proOnly).toBe(true);
|
||||
expect(apiKeys?.proOnly).toBe(true);
|
||||
});
|
||||
|
||||
it('should currently omit apiKeys nav item (temporarily removed)', () => {
|
||||
// The apiKeys nav item is temporarily commented out in constants.ts.
|
||||
// If you re-enable it, update this test to assert its presence.
|
||||
const apiKeys = baseNavItems.find(item => item.href === '/dashboard/api-keys');
|
||||
expect(apiKeys).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user