Skip to content

{{format-list}}

Uses Intl.ListFormat to join an array of strings.

gts
import type { TOC } from '@ember/component/template-only';
import { formatList } from 'ember-intl';

interface ExampleSignature {
  Args: {};
}

const letters = ['A', 'B', 'C'];

const Example: TOC<ExampleSignature> = <template>
  {{formatList letters}}
</template>;

export default Example;

options.locale

You can display the text in another locale (i.e. independently from the user's preferred locale). Pass the name of the locale to locale.

gts
import type { TOC } from '@ember/component/template-only';
import { formatList } from 'ember-intl';

interface ExampleSignature {
  Args: {};
}

const letters = ['A', 'B', 'C'];

const Example: TOC<ExampleSignature> = <template>
  <div lang="en-us">
    {{formatList letters locale="en-us"}}
  </div>

  <div lang="de-de">
    {{formatList letters locale="de-de"}}
  </div>
</template>;

export default Example;

Additional options

You can use named arguments to pass the options that Intl.ListFormat supports. Some of these options are listed below.

  • localeMatcher
  • style
  • type
gts
import type { TOC } from '@ember/component/template-only';
import { formatList } from 'ember-intl';

interface ExampleSignature {
  Args: {};
}

const letters = ['A', 'B', 'C'];

const Example: TOC<ExampleSignature> = <template>
  {{formatList letters type="disjunction"}}
</template>;

export default Example;