Every Pacem element speaks a language: its culture (the lang attribute), or else the page's <html lang>.
Bind it, and dates, numbers and prices follow, formatted the way each locale expects.
<!-- one element in Italian, whatever the page says -->
<pacem-span culture="it-IT" text="{{ $pacem.currency(49.9, 'EUR', Pacem.Utils.lang($this)) }}"></pacem-span>
<!-- the whole page in German -->
<pacem-html-proxy attr="lang" value="de-DE"></pacem-html-proxy>
Pick a culture per element. culture sets the element's lang attribute, and changing it re-evaluates the element's bindings right away.
Read it in bindings. Pacem.Utils.lang($this) gives the element's own lang, else <html lang>, else the browser's language.
Pass it to the $pacem formatters (date, number, currency, timespan): left alone, they use the browser's language.
<pacem-span culture="{{ #user.model.locale }}"
text="{{ $pacem.date(#order.model.date, 'short', Pacem.Utils.lang($this)) }}"></pacem-span>
langisn't inherited byPacem.Utils.lang(): it reads the element's own attribute, then the page's. Setcultureon the element whose bindings format, not on a container around it.
Switch the whole page. A <pacem-html-proxy> with attr="lang" writes its value onto <html lang>: every element without
its own culture follows, the next time its bindings run. It works for any attribute of <html> (a theme, a layout flag),
and an empty value removes it.
An element's own
culturerefreshes its bindings at once; a page-wide change only shows on the next evaluation (a new value, a tick).
The same total and date, each row formatting with its own culture.
<pacem-html-proxy> sets <html lang>: the clock has no culture of its own, so it follows at its next tick.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.