How to use the relative-time-format.addLocale function in relative-time-format

To help you get started, we’ve selected a few relative-time-format examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / __e2e__ / src / startup.ts View on Github external
import { I18nConfiguration } from '@aurelia/i18n';
import { JitHtmlBrowserConfiguration } from '@aurelia/jit-html-browser';
import { Aurelia } from '@aurelia/runtime';
import Fetch from 'i18next-fetch-backend';
import * as intervalPlural from 'i18next-intervalplural-postprocessor';
import { App as component } from './app';
import { CustomMessage } from './plugins/custom-message';
import { SutI18N } from './plugins/sut-i18n';
import { resources } from './plugins/translation-resources';

// Intl.RelativeTimeFormat polyfill is needed as Cypress uses electron and does not seems to work with puppeteer
import RelativeTimeFormat from 'relative-time-format';
import * as deRt from 'relative-time-format/locale/de.json';
import * as enRt from 'relative-time-format/locale/en.json';
RelativeTimeFormat.addLocale(enRt['default']);
RelativeTimeFormat.addLocale(deRt['default']);
Intl['RelativeTimeFormat'] = Intl['RelativeTimeFormat'] || RelativeTimeFormat;

(async function () {
  const host = document.querySelector('app');
  const searchParams = new URL(location.href).searchParams;
  const fetchResource = !!searchParams.get('fetchResource');

  const au = new Aurelia()
    .register(
      JitHtmlBrowserConfiguration,
      DebugConfiguration,
      I18nConfiguration.customize((options) => {
        options.translationAttributeAliases = ['t', 'i18n'];
        const plugins = [intervalPlural.default];
        if (fetchResource) {
          plugins.push(Fetch);
github catamphetamine / javascript-time-ago / source / JavascriptTimeAgo.js View on Github external
JavascriptTimeAgo.addLocale = function(localeData) {
	addLocaleData(localeData)
	RelativeTimeFormat.addLocale(localeData)
}