Language Bridge

generate

Generate the .d.ts from previously pulled JSON.

Generates the typed .d.ts from JSON already written by lb pull. Aliased as lb types.

lb generate --project my-app --out src/@types/resources.d.ts
lb types --no-params   # keys only

Example output

From a pulled common.json (welcome: "Welcome", greeting: "Hi {{name}}"), generate writes:

src/@types/resources.d.ts
// Generated by @language-bridge/cli — do not edit.
// Source locale: en. Re-run `lb sync` to update.
/* eslint-disable */

export interface Resources {
  "common": {
    "greeting": string;
    "welcome": string;
  };
}

export type TranslationParams = {
  "common:greeting": { "name": string | number };
  "common:welcome": {};
};

declare module "i18next" {
  interface CustomTypeOptions {
    defaultNS: "common";
    resources: Resources;
  }
}

Options

FlagDefaultNotes
-o, --out <path>src/@types/resources.d.tsOutput .d.ts path.
--no-paramsSkip interpolation-param types (keys only).

Plus the common options. See Typed i18next for wiring the result into i18next.

On this page