Skip to main content
HydroGo
Multi-languageContent locales

Content locales

Publish your site in several languages: the i18n configuration, per-locale pages and news, localized content type fields and the ?locale= parameter.

HydroGo has two independent language concepts. Content locales (this page) are the languages of your site's content. The admin interface language is what editors see in the panel; see Admin interface language.

Enable locales

config.yaml
i18n:
  enabled: true
  default_locale: en
  locales: [en, tr, de]
BASH
HYDRO_I18N_ENABLED=true HYDRO_DEFAULT_LOCALE=en HYDRO_LOCALES=en,tr,de hydro serve --config config.yaml
  • default_locale must not be empty and must be one of locales.
  • locales holds 1 to 64 codes such as en, tr, pt-BR or zh-Hans.
  • Restart the server after changing locales.

Pages and news

Pages and news articles are per-locale documents: each has a locale, and the slug is unique within that locale. Create the English about page and a Turkish hakkimizda page as two documents (the page editor also offers a Translate action to start from an existing page).

BASH
curl 'https://cms.example.com/api/v1/pages/by-slug?locale=en&slug=about'
curl 'https://cms.example.com/api/v1/pages/by-slug?locale=tr&slug=hakkimizda'
curl 'https://cms.example.com/api/v1/news?locale=tr&limit=10'

Always pass locale to the pages and news endpoints. They do not fall back to another locale's document.

Localized fields in content types

In a content type, mark the fields whose text differs per language with localized: true. Storage keeps one value per locale.

content-types/team.yaml
id: team
label: Team
revisions: true          # required when any field is localized
public: true
fields:
  - {id: name, label: Name, kind: text, required: true, list: true}
  - {id: role, label: Role, kind: text, list: true, localized: true}
  - {id: bio,  label: Bio,  kind: textarea, localized: true}
  - {id: photo, label: Photo, kind: media, localized: true}
RuleDetail
Allowed kindstext, textarea, richtext, media.
Not combinable withunique, searchable, filterable.
Requiresrevisions: true on the type.
Default localeThe record itself holds the default locale's value; other locales are stored beside it.
ActivationOnly when i18n.enabled is true and more than one locale is configured. Otherwise the flag changes nothing.

In the admin

Records of types with localized fields show locale tabs. Edit the default locale first, then switch tabs to fill the others. A copy from action seeds a locale from another one.

In the API

BASH
# default locale
curl 'https://cms.example.com/api/v1/content/team'
# Turkish values; any missing field falls back to the default locale per field
curl 'https://cms.example.com/api/v1/content/team?locale=tr'

With ?locale= the response is flagged with metadata.locale and each record gets a locale field. Fallback happens field by field: if only role is translated, bio still comes back in the default language. An unknown locale answers 400.

Search, filters and sorting always use the default locale's values, even when ?locale= asks for another.

From your frontend

TS
const locale = params.lang ?? 'en';

const page = await hydro.getPage(locale, params.slug);
const news = await hydro.listNews(locale, 10);
const team = await hydro.listContent('team', { locale });
Link translations to each other in your frontend by convention (for example the same page id in your own mapping, or a shared tag). HydroGo does not enforce that a translation exists for every locale.

Site-level text

Navigation menus and translation strings are stored per locale too: Site > Navigation and Site > Translations in the admin, and GET /api/v1/site/navigation/{locale} in the API.