fix: resolve translation proxy shadowing name keys

The Proxy's get handler checked `prop in target` before looking up
translations. Since the target is a function, `Function.name` is a
built-in property that shadowed translation keys like `t.common.name`,
causing the raw proxy path to render instead of the translated string.

Move translation lookup before target property checks so i18n keys
always take priority. Also remove unnecessary `|| 'Name'` fallback
in CreateNotebookDialog.
This commit is contained in:
Luis Novo 2026-02-16 14:46:42 -03:00
parent 7badc51339
commit d147994b92
2 changed files with 4 additions and 8 deletions

View file

@ -75,7 +75,7 @@ export function CreateNotebookDialog({ open, onOpenChange }: CreateNotebookDialo
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="notebook-name">{t.common.name || 'Name'} *</Label>
<Label htmlFor="notebook-name">{t.common.name} *</Label>
<Input
id="notebook-name"
{...register('name')}

View file

@ -78,12 +78,6 @@ export function useTranslation() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (target as any)[prop];
}
// Handle function's own properties
if (prop in target) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (target as any)[prop];
}
if (typeof prop !== 'string') return undefined;
@ -94,7 +88,9 @@ export function useTranslation() {
const currentPath = path ? `${path}.${prop}` : prop;
// Try to get the translation
// Try to get the translation first (before checking target properties,
// since target is a function and has built-in properties like 'name'
// that would shadow translation keys)
const result = i18nTranslateCopy(currentPath, { returnObjects: true });
// If it's a leaf string, return it directly