Skip to main content

Module localizations

Module localizations 

Source
Expand description

The words the framework itself says: localizations::Localizations and localizations::of. The words the framework itself puts on screen, in the reader’s language (material_localizations.dart).

A framework says a certain amount out loud on an application’s behalf. The label a screen reader announces on a back arrow. The word on the cross that dismisses a notification. The initials over a calendar’s columns, and the name of the month above them. None of it comes from the application, so none of it can be translated by the application — and until this module every one of them was an English string constant.

The reference’s answer is MaterialLocalizations, reached from the tree. This is the same idea with this framework’s ambient-scope idiom (the one MediaQuery uses): a table is installed for the thread, and of hands out whatever is in force.

§It always answers

of never fails. With nothing installed it answers English, which is what every one of those constants said anyway — so nothing breaks, and an application that says nothing is exactly where it was.

That has a cost worth naming: a test that forgets to install a table still passes, and so would a shell that forgot to install one. The guard against that is not the default but a_shell_installs_the_application_s_words, which drives the shell and checks the words actually arrive.

§It is not on the theme

A theme is what an interface looks like. What it says is a different question with a different owner — the reference keeps them apart too, and an application that ships one theme in twelve languages would otherwise need twelve themes.

Structs§

English
The English table: every method left as the trait wrote it.
French
The French table.

Traits§

Localizations
What the framework says, for one language.

Functions§

install
Installs table for this thread, from now on.
of
The table in force, or English when nothing has been installed.
scope
Runs f with table in force, and puts back whatever was there before — including when f panics, so one bad frame cannot leave a stale language installed for every frame after it.