> ## Documentation Index
> Fetch the complete documentation index at: https://sonamu.cartanova.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto-extracted Entity Labels

> i18n labels automatically extracted from Entity definitions

Sonamu automatically extracts labels from Entity definitions and includes them in `sd.generated.ts`. This eliminates the need to manually write Entity-related text in the dictionary.

## Auto-extracted Items

### 1. Entity Title

The Entity's `title` property is extracted as the `entity.{EntityId}` key:

```json theme={null}
// entity.json
{
  "id": "User",
  "title": "사용자",
  "table": "users",
  "props": [...]
}
```

```typescript theme={null}
// sd.generated.ts (auto-generated)
const entityLabels = {
  "entity.User": "사용자",
  // ...
};

// Usage
SD("entity.User"); // "사용자"
```

### 2. Prop Labels

Each prop's `desc` property is extracted as the `entity.{EntityId}.{propName}` key:

```json theme={null}
// entity.json
{
  "id": "User",
  "props": [
    { "name": "id", "type": "integer", "desc": "ID" },
    { "name": "email", "type": "string", "desc": "이메일" },
    { "name": "username", "type": "string", "desc": "이름" },
    { "name": "created_at", "type": "datetime", "desc": "등록일시" }
  ]
}
```

```typescript theme={null}
// sd.generated.ts (auto-generated)
const entityLabels = {
  "entity.User": "USER",
  "entity.User.id": "ID",
  "entity.User.email": "이메일",
  "entity.User.username": "이름",
  "entity.User.created_at": "등록일시",
  // ...
};

// Usage
SD("entity.User.email"); // "이메일"
```

### 3. Enum Labels

`enumLabels` defined in the Entity are extracted as `enum.{EnumId}.{value}` keys:

```json theme={null}
// entity.json
{
  "id": "User",
  "enums": {
    "UserRole": ["admin", "normal"]
  },
  "enumLabels": {
    "UserRole": {
      "admin": "관리자",
      "normal": "일반"
    }
  }
}
```

```typescript theme={null}
// sd.generated.ts (auto-generated)
const entityLabels = {
  "enum.UserRole.admin": "관리자",
  "enum.UserRole.normal": "일반",
  // ...
};

// Usage
SD("enum.UserRole.admin"); // "관리자"
SD.enumLabels("UserRole")["admin"]; // "관리자"
```

### 4. OrderBy / SearchField Labels

Enums used in ListParams are also automatically extracted:

```typescript theme={null}
// sd.generated.ts (auto-generated)
const entityLabels = {
  "enum.UserOrderBy.id-desc": "ID최신순",
  "enum.UserSearchField.id": "ID",
  "enum.UserSearchField.email": "이메일",
  // ...
};
```

## Editing Labels in Sonamu UI

You can directly edit labels in Sonamu UI's Entity edit screen:

1. **Entity Title**: Edit on the Entity detail page
2. **Prop Labels**: Edit each prop's `desc` field
3. **Enum Labels**: Edit in the Enum edit modal

After saving, `entity.json` is updated, and it will be reflected in `sd.generated.ts` upon `pnpm sync`.

## Multilingual Entity Labels

Entity labels are stored only in `defaultLocale`. Translations for other locales should be written directly in the respective locale's dictionary file:

```typescript theme={null}
// en.ts
import { defineLocale } from "./sd.generated";

export default defineLocale({
  // Entity label translations
  "entity.User": "User",
  "entity.User.email": "Email",
  "entity.User.username": "Username",

  // Enum label translations
  "enum.UserRole.admin": "Administrator",
  "enum.UserRole.normal": "Normal User",

  // Rest of project dictionary
  "common.save": "Save",
  // ...
});
```

## Bulk Translation via Excel

You can export all keys including Entity labels as Excel from Sonamu UI's i18n management page, translate them, and import back.

<CardGroup cols={2}>
  <Card title="Excel Import/Export" icon="file-excel" href="/en/advanced-features/i18n/excel-import">
    Bulk translation file management
  </Card>

  <Card title="Using the SD Function" icon="code" href="/en/advanced-features/i18n/dictionary">
    Writing and using dictionaries
  </Card>
</CardGroup>
