Add intl auto-id tool

This commit is contained in:
dominik-zeglen 2019-08-21 14:14:41 +02:00
parent b3720a6361
commit 337f14b327
4 changed files with 83 additions and 30 deletions

View file

@ -14,6 +14,7 @@
}
],
"@babel/plugin-proposal-object-rest-spread",
"react-intl-auto",
[
"react-intl",
{

57
package-lock.json generated
View file

@ -4900,6 +4900,16 @@
}
}
},
"babel-plugin-react-intl-auto": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/babel-plugin-react-intl-auto/-/babel-plugin-react-intl-auto-2.1.0.tgz",
"integrity": "sha512-nhh509nyNVKXg2By1X1v/u1m+liWzF8XWC/RWeHXbhDskC1deH3rkWIYkVfvCabEbDBVZ/cpV5JAYRbutFUQgw==",
"dev": true,
"requires": {
"@babel/types": "^7.5.5",
"murmurhash3js": "^3.0.1"
}
},
"babel-plugin-syntax-async-functions": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz",
@ -9397,8 +9407,7 @@
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"optional": true
"bundled": true
},
"aproba": {
"version": "1.2.0",
@ -9416,13 +9425,11 @@
},
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"optional": true
"bundled": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -9435,18 +9442,15 @@
},
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"optional": true
"bundled": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"optional": true
"bundled": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"optional": true
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
@ -9549,8 +9553,7 @@
},
"inherits": {
"version": "2.0.3",
"bundled": true,
"optional": true
"bundled": true
},
"ini": {
"version": "1.3.5",
@ -9560,7 +9563,6 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -9573,20 +9575,17 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true,
"optional": true
"bundled": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -9603,7 +9602,6 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -9676,8 +9674,7 @@
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"optional": true
"bundled": true
},
"object-assign": {
"version": "4.1.1",
@ -9687,7 +9684,6 @@
"once": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -9763,8 +9759,7 @@
},
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"optional": true
"bundled": true
},
"safer-buffer": {
"version": "2.1.2",
@ -9794,7 +9789,6 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -9812,7 +9806,6 @@
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -9851,13 +9844,11 @@
},
"wrappy": {
"version": "1.0.2",
"bundled": true,
"optional": true
"bundled": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"optional": true
"bundled": true
}
}
},
@ -13937,6 +13928,12 @@
"integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=",
"dev": true
},
"murmurhash3js": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/murmurhash3js/-/murmurhash3js-3.0.1.tgz",
"integrity": "sha1-Ppg+W0fCoG9DpxMXTn5DXKBEuZg=",
"dev": true
},
"mustache": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.2.tgz",

View file

@ -109,6 +109,7 @@
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.6",
"babel-plugin-react-intl": "^4.1.12",
"babel-plugin-react-intl-auto": "^2.1.0",
"codecov": "^3.5.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",

54
react-intl.d.ts vendored Normal file
View file

@ -0,0 +1,54 @@
declare module "react-intl" {
import * as ReactIntl from "node_modules/react-intl";
export * from "node_modules/react-intl";
export interface MessageDescriptor {
id?: string;
description?: string;
defaultMessage: string;
}
type Messages<Names extends keyof any = string> = Record<
Names,
MessageDescriptor
>;
type PrimitiveType = string | number | boolean | null | undefined | Date;
type FormatXMLElementFn = (...args: any[]) => string | object;
export interface IntlFormatters
extends Omit<ReactIntl.IntlFormatters, "formatMessage"> {
formatMessage(
descriptor: MessageDescriptor,
values?: Record<string, PrimitiveType>
): string;
formatMessage(
descriptor: MessageDescriptor,
values?: Record<
string,
PrimitiveType | React.ReactElement | FormatXMLElementFn
>
): string | React.ReactNodeArray;
}
export interface FormattedMessageProps<
V extends Record<string, any> = Record<string, React.ReactNode>
> extends MessageDescriptor {
values?: V;
tagName?: React.ElementType<any>;
children?(...nodes: React.ReactNodeArray): React.ReactNode;
}
export function defineMessages<Names extends keyof any>(
messageDescriptors: Messages<Names>
): Messages<Names>;
export interface IntlShape extends ReactIntl.IntlConfig, IntlFormatters {
formatters: ReactIntl.Formatters;
}
export class FormattedMessage<
TValues extends Record<string, any> = Record<
string,
PrimitiveType | React.ReactElement | FormatXMLElementFn
>
> extends React.Component<FormattedMessageProps<TValues>> {}
export function useIntl(): IntlShape;
}