chore: snapshot before performance optimization

This commit is contained in:
Sepehr Ramezani
2026-04-17 21:14:43 +02:00
parent b6a548acd8
commit 2eceb32fd4
95 changed files with 4357 additions and 1942 deletions

View File

@@ -0,0 +1,41 @@
import re
files_to_fix = [
'components/note-inline-editor.tsx',
'components/notes-tabs-view.tsx',
'components/note-card.tsx'
]
replacement_func = """import { faIR } from 'date-fns/locale'
function getDateLocale(language: string) {
if (language === 'fr') return fr
if (language === 'fa') return faIR
return enUS
}"""
for file in files_to_fix:
with open(file, 'r') as f:
content = f.read()
# 1. Replace the getDateLocale function
content = re.sub(
r'function getDateLocale\(language: string\) \{\s*if \(language === \'fr\'\) return fr\s*return enUS\s*\}',
"function getDateLocale(language: string) {\n if (language === 'fr') return fr;\n if (language === 'fa') return require('date-fns/locale').faIR;\n return enUS;\n}",
content
)
# Also fix translations for "Modifiée" and "Créée" in inline editor (they are currently hardcoded)
if 'note-inline-editor.tsx' in file:
content = content.replace(
"<span>Modifiée {formatDistanceToNow(new Date(note.updatedAt), { addSuffix: true, locale: dateLocale })}</span>",
"<span>{t('notes.modified') || 'Modifiée'} {formatDistanceToNow(new Date(note.updatedAt), { addSuffix: true, locale: dateLocale })}</span>"
)
content = content.replace(
"<span>Créée {formatDistanceToNow(new Date(note.createdAt), { addSuffix: true, locale: dateLocale })}</span>",
"<span>{t('notes.created') || 'Créée'} {formatDistanceToNow(new Date(note.createdAt), { addSuffix: true, locale: dateLocale })}</span>"
)
with open(file, 'w') as f:
f.write(content)