1.76.3 • Published 1 year ago

@biorate/i18n v1.76.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

I18n

Internationalization library

Example:

import { inject, container, Core, Types } from '@biorate/inversion';
import { Config, IConfig } from '@biorate/config';
import { I18n as I18nCommon, t } from '@biorate/i18n';

class I18n extends I18nCommon {
  protected options = {
    fallbackLng: 'ru',
    lng: 'ru',
    debug: false,
    resources: {
      ru: {
        translation: {
          'Привет мир': 'Привет мир!',
        },
      },
      en: {
        translation: {
          'Привет мир': 'Hello world!',
        },
      },
    },
  };
}

export class Root extends Core() {
  @inject(Types.Config) public config: IConfig;
  @inject(I18n) public i18n: I18n;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<I18n>(I18n).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();
  console.log(t`Привет мир`); // Привет мир!
  console.log(t(`Привет мир`, { lng: 'en' })); // Hello world!
})();

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

1.76.3

1 year ago

1.65.4

1 year ago

1.54.0

2 years ago

1.45.0

2 years ago

1.42.2

2 years ago

1.42.1

2 years ago

1.38.4

2 years ago

1.38.3

2 years ago

1.38.2

2 years ago

1.38.1

2 years ago

1.35.1

2 years ago

1.35.0

2 years ago

1.34.0

2 years ago

1.33.0

2 years ago

1.32.0

2 years ago