Install

@beforesemicolon/intl is designed to work in plain HTML, any framework, and tests.

You have two options:

Both approaches expose the same runtime behavior.

Via package manager

bash
1npm install @beforesemicolon/intl

Then initialize the runtime from your app entrypoint:

ts
1import {2    initIntl,3    intlMsg,4    intlNumber,5} from '@beforesemicolon/intl'

Use any exported helpers directly from your bundler or ESM loader.

Via CDN (browser build)

html
1<script src="https://unpkg.com/@beforesemicolon/web-component/dist/client.js"></script>2<script src="https://unpkg.com/@beforesemicolon/intl/dist/client.js"></script>

When loaded this way, helper functions are available on window.BFS.INTL:

html
1<script>2  const { initIntl, intlMsg, intlNumber } = window.BFS.INTL3</script>

Minimal runtime setup

html
1<intl-locale locale="en-US" fallback-locale="en" src-dir="/locales">2    <intl-msg key="hello">Hello</intl-msg>3    <intl-number type="currency" currency="USD">1200</intl-number>4</intl-locale>

src-dir loads /locales/{locale}.json by default (/locales/en-US.json).

How to choose a setup

ScenarioSetup
Static pagesUse CDN scripts and intl-* tags
SPA or app frameworkUse module imports and initIntl()
Tests and snapshotsUse initIntl() with messages

Common installation notes

Troubleshooting

If formatting is not updating:

edit this doc