Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.22 KB

File metadata and controls

50 lines (39 loc) · 1.22 KB

@events-helsinki/common-i18n

build

Intro

One possible way to share locales amongst apps in the monorepo.

Usage

Add the workspace dependency to the consuming app or package.

yarn add @events-helsinki/common-i18n:"workspace:^"

Add an alias in tsconfig.js to enable fast-refresh.

{
  "compilerOptions": {
    "paths": {
      "@events-helsinki/common-i18n": [
        "../../../packages/common-i18n/src/index",
      ],
      "@events-helsinki/common-i18n/locales/*": [
        "../../../packages/common-i18n/src/locales/*",
      ],
    },
  },
}

Optionally create a file named ./types.d/react-i18next.d.ts to enable typechecks and autocompletion of keys.

import "react-i18next";
import type { I18nNamespaces } from "@events-helsinki/common-i18n";

declare module "react-i18next" {
  interface CustomTypeOptions {
    defaultNS: "common";
    resources: I18nNamespaces;
  }
}