Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Latest commit

 

History

History
 
 

common-i18n

@we-make-websites/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 @we-make-websites/common-locales:"workspace:^"

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

{
  "compilerOptions": {
    "paths": {
      "@we-make-websites/common-i18n": [
        "../../../packages/common-i18n/src/index",
      ],
      "@we-make-websites/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 "@we-make-websites/common-i18n";

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