Configuration and time · rule
type.temporal_locales_required
Formatting needs declared locales.
Area 10, Configuration and time; not declinable; the next step is usually the agent's.
A project that formats text for people declares the locales it supports:
use shop/types { OrderedAt, PlacedText }/// The placing, in the customer's language.action show_placed(ordered_at: OrderedAt, reader_locale: Locale) -> PlacedText { return PlacedText { placed: text.format( ordered_at, zone: Zone.utc, locale: reader_locale, format: TimeFormat.date_long ) }}
error: `text.format` needs the application's locales --> domains/shop/actions/show_placed.jadpo:6:17 |6 | placed: text.format( | ^^^^^^^^^^^ no locales declared reason: Text for a person is written in one of the locales the application supports. None is declared, so there is nothing to check `locale:` against, and nothing for a request with no usable `Accept-Language` to fall back to. next: Declare them in `app.jadpo`, for instance `locales { default: Locale.en_gb supported: [Locale.en_gb] }` (agent) rule: type.temporal_locales_required help: https://jadpo.dev/docs/errors/type.temporal_locales_requiredcheck failed: 1 error, 4 files
The same rule covers choosing a locale from a request, since there is nothing to choose among and nothing to fall back to:
use shop/types { BrowserLanguages }/// The language the customer's browser asks for.action locale_for_reader(languages_header: BrowserLanguages?) -> Locale { return locale.from_accept_language(languages_header)}
error: `locale.from_accept_language` needs the application's locales --> domains/shop/actions/locale_for_reader.jadpo:5:12 |5 | return locale.from_accept_language(languages_header) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no locales declared reason: `locale.from_accept_language` chooses among the locales the application supports and falls back to its `default:`. None is declared, so there is nothing to choose among and nothing to fall back to. next: Declare them in `app.jadpo`, for instance `locales { default: Locale.en_gb supported: [Locale.en_gb] }` (agent) rule: type.temporal_locales_required help: https://jadpo.dev/docs/errors/type.temporal_locales_requiredcheck failed: 1 error, 3 files
And sorting by a locale's alphabet, since a deployable carries collation for the declared locales only:
use shop/types { LoafName }/// The loaves in the order the shopper's alphabet puts them.action in_name_order(loaves: List<LoafName>, shopper: Locale) -> List<LoafName> { return list.sort_by(loaves, loaf -> loaf, locale: shopper)}
error: `list.sort_by` needs the application's locales --> domains/shop/actions/in_name_order.jadpo:5:12 |5 | return list.sort_by(loaves, loaf -> loaf, locale: shopper) | ^^^^^^^^^^^^ no locales declared reason: `locale:` orders text by the alphabet of one of the locales the application supports, and a deployable carries only those locales' collation. None is declared, so there is no alphabet to sort by. next: Declare them in `app.jadpo`, for instance `locales { default: Locale.en_gb supported: [Locale.en_gb] }` (agent) rule: type.temporal_locales_required help: https://jadpo.dev/docs/errors/type.temporal_locales_requiredcheck failed: 1 error, 3 files
Markdown for agents: /docs/errors/type.temporal_locales_required.md.Built from Jadpo main at a707efb.