Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.01 KB

translations.md

File metadata and controls

45 lines (29 loc) · 1.01 KB

Translations

Table of Contents

How to add a new translation

  1. Copy the en folder and rename it to the language you are adding.
  2. Translate files in the new folder.

How to use translations on frontend

  1. Add header x-custom-lang to the request with the language you want to use.

How to use translations in code

import { I18nContext } from 'nestjs-i18n';

// code ...

@Injectable()
export class SomeService {
  // code ...

  async someMethod(): Promise<void> {
    const i18n = I18nContext.current();

    if (!i18n) {
      throw new Error('I18nContext is not available');
    }

    const emailConfirmTitle = await i18n.t('common.confirmEmail');

    // code ...
  }
}

Previous: Automatic update of dependencies