name, name_ko, name_en, or a locale map like name: { ko: "...", en: "..." }. Sonamu automatically selects the appropriate value for the current locale using the localizedColumn() function.
localizedColumn Function
Priority Order
localizedColumn() looks for values in the following order:
| Current locale | Priority |
|---|---|
ko | name_ko โ name โ name_en |
en | name_en โ name โ name_ko |
"") and null are skipped, and the next priority is checked.
Entity Definition
Example of an Entity with multilingual columns:Using in Models
Processing in Subset
You can uselocalizedColumn in a Subsetโs enhancer to deliver only a single name field to the client:
Using in API Response
Using in Frontend
The same function can be used in the frontend (exported from webโs sd.generated.ts):Supported Value Shapes
localizedColumn() supports two storage shapes:
| Shape | Example | Description |
|---|---|---|
| Suffix columns | name, name_ko, name_en | Store one column per locale. |
| Locale map | { name: { ko: "ํ๊ทธ", en: "Tag" } } | Store locale-specific values in the base column object. |
string or string[]. string[] values are returned as arrays and are not stringified. For suffix columns or base columns, scalar values such as number, boolean, or bigint are stringified for backward compatibility.
Suffix Column Naming Patterns
| Base column | Locale columns | Description |
|---|---|---|
name | name_ko, name_en | Name |
title | title_ko, title_en | Title |
description | description_ko, description_en | Description |
content | content_ko, content_en | Content |
When using suffix columns, use the
{base_column}_{locale} format. When using a locale map, the base column value can store the locale-specific object.Important Notes
localizedColumnis simply a function that selects column values. Query optimization (SELECTing only necessary columns) must be handled separately.- If all locale columns are
nulland the base column is also empty,undefinedis returned. - If locale is not set in Context,
defaultLocaleis used. - If Context locale is unsupported, values are resolved from
defaultLocale.
i18n Setup
Initial i18n configuration
Using the SD Function
Writing and using dictionaries