Files
Keep/keep-notes/fix_notebooks.py
2026-04-17 21:14:43 +02:00

23 lines
1.1 KiB
Python

import re
with open('components/notebooks-list.tsx', 'r') as f:
content = f.read()
# 1. Add `language` to `useLanguage`
content = content.replace("const { t } = useLanguage()", "const { t, language } = useLanguage()")
# 2. Add `dir=\"auto\"` and logical properties to active notebook (isExpanded section)
# Replace pl-12 pr-4 with ps-12 pe-4, mr-2 with me-2, ml-2 with ms-2, rounded-r-full with rounded-e-full, text-left with text-start
content = content.replace("rounded-r-full", "rounded-e-full")
content = content.replace("pl-12", "ps-12").replace("pr-4", "pe-4")
content = content.replace("mr-2", "me-2").replace("ml-2", "ms-2")
content = content.replace("text-left", "text-start")
content = content.replace("pr-24", "pe-24")
# 3. Format numbers: ((notebook as any).notesCount) -> new Intl.NumberFormat(language).format((notebook as any).notesCount)
# Look for: ({(notebook as any).notesCount})
content = content.replace("({(notebook as any).notesCount})", "({new Intl.NumberFormat(language).format((notebook as any).notesCount)})")
with open('components/notebooks-list.tsx', 'w') as f:
f.write(content)