@wordpress/react-i18n 4.39.1-next.v.202602111440.0 → 4.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.40.0 (2026-02-18)
6
+
5
7
  ## 4.39.0 (2026-01-29)
6
8
 
7
9
  ## 4.38.0 (2026-01-16)
package/README.md CHANGED
@@ -44,7 +44,7 @@ _Parameters_
44
44
 
45
45
  _Returns_
46
46
 
47
- - `JSX.Element`: Children wrapped in the I18nProvider.
47
+ - Children wrapped in the I18nProvider.
48
48
 
49
49
  ### useI18n
50
50
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type {\n\tComponentType,\n\tFunctionComponent,\n\tPropsWithChildren,\n} from 'react';\nimport type { Subtract } from 'utility-types';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { defaultI18n } from '@wordpress/i18n';\nimport type { I18n } from '@wordpress/i18n';\ninterface I18nContextProps {\n\t__: I18n[ '__' ];\n\t_x: I18n[ '_x' ];\n\t_n: I18n[ '_n' ];\n\t_nx: I18n[ '_nx' ];\n\tisRTL: I18n[ 'isRTL' ];\n\thasTranslation: I18n[ 'hasTranslation' ];\n}\n\n/**\n * Utility to make a new context value\n *\n * @param i18n\n */\nfunction makeContextValue( i18n: I18n ): I18nContextProps {\n\treturn {\n\t\t__: i18n.__.bind( i18n ),\n\t\t_x: i18n._x.bind( i18n ),\n\t\t_n: i18n._n.bind( i18n ),\n\t\t_nx: i18n._nx.bind( i18n ),\n\t\tisRTL: i18n.isRTL.bind( i18n ),\n\t\thasTranslation: i18n.hasTranslation.bind( i18n ),\n\t};\n}\n\nconst I18nContext = createContext( makeContextValue( defaultI18n ) );\nI18nContext.displayName = 'I18nContext';\n\ntype I18nProviderProps = PropsWithChildren< { i18n: I18n } >;\n\n/**\n * The `I18nProvider` should be mounted above any localized components:\n *\n * @example\n * ```js\n * import { createI18n } from '@wordpress/i18n';\n * import { I18nProvider } from '@wordpress/react-i18n';\n * const i18n = createI18n();\n *\n * ReactDom.render(\n * \t<I18nProvider i18n={ i18n }>\n * \t\t<App />\n * \t</I18nProvider>,\n * \tel\n * );\n * ```\n *\n * You can also instantiate the provider without the `i18n` prop. In that case it will use the\n * default `I18n` instance exported from `@wordpress/i18n`.\n *\n * @param props i18n provider props.\n * @return Children wrapped in the I18nProvider.\n */\nexport function I18nProvider( props: I18nProviderProps ): JSX.Element {\n\tconst { children, i18n = defaultI18n } = props;\n\tconst [ update, forceUpdate ] = useReducer( () => [], [] );\n\n\t// Rerender translations whenever the i18n instance fires a change event.\n\tuseEffect( () => i18n.subscribe( forceUpdate ), [ i18n ] );\n\n\tconst value = useMemo( () => makeContextValue( i18n ), [ i18n, update ] );\n\n\treturn (\n\t\t<I18nContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</I18nContext.Provider>\n\t);\n}\n\n/**\n * React hook providing access to i18n functions. It exposes the `__`, `_x`, `_n`, `_nx`,\n * `isRTL` and `hasTranslation` functions from [`@wordpress/i18n`](../i18n).\n * Refer to their documentation there.\n *\n * @example\n * ```js\n * import { useI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent() {\n * \tconst { __ } = useI18n();\n * \treturn __( 'Hello, world!' );\n * }\n * ```\n */\nexport const useI18n = () => useContext( I18nContext );\n\ntype PropsAndI18n< P > = Pick<\n\tP,\n\tExclude< keyof P, '__' | '_x' | '_n' | '_nx' | 'isRTL' | 'hasTranslation' >\n>;\n\n/**\n * React higher-order component that passes the i18n translate functions (the same set\n * as exposed by the `useI18n` hook) to the wrapped component as props.\n *\n * @example\n * ```js\n * import { withI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent( { __ } ) {\n * \treturn __( 'Hello, world!' );\n * }\n *\n * export default withI18n( MyComponent );\n * ```\n *\n * @param InnerComponent React component to be wrapped and receive the i18n functions like `__`\n * @return The wrapped component\n */\nexport function withI18n< P extends I18nContextProps >(\n\tInnerComponent: ComponentType< P >\n): FunctionComponent< PropsAndI18n< P > > {\n\tconst EnhancedComponent: ComponentType<\n\t\tSubtract< P, I18nContextProps >\n\t> = ( props ) => {\n\t\tconst i18nProps = useI18n();\n\t\treturn <InnerComponent { ...( props as P ) } { ...i18nProps } />;\n\t};\n\tconst innerComponentName =\n\t\tInnerComponent.displayName || InnerComponent.name || 'Component';\n\tEnhancedComponent.displayName = `WithI18n(${ innerComponentName })`;\n\treturn EnhancedComponent;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,qBAMO;AACP,kBAA4B;AAiE1B;AAjDF,SAAS,iBAAkB,MAA+B;AACzD,SAAO;AAAA,IACN,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,KAAK,KAAK,IAAI,KAAM,IAAK;AAAA,IACzB,OAAO,KAAK,MAAM,KAAM,IAAK;AAAA,IAC7B,gBAAgB,KAAK,eAAe,KAAM,IAAK;AAAA,EAChD;AACD;AAEA,IAAM,kBAAc,8BAAe,iBAAkB,uBAAY,CAAE;AACnE,YAAY,cAAc;AA2BnB,SAAS,aAAc,OAAwC;AACrE,QAAM,EAAE,UAAU,OAAO,wBAAY,IAAI;AACzC,QAAM,CAAE,QAAQ,WAAY,QAAI,2BAAY,MAAM,CAAC,GAAG,CAAC,CAAE;AAGzD,gCAAW,MAAM,KAAK,UAAW,WAAY,GAAG,CAAE,IAAK,CAAE;AAEzD,QAAM,YAAQ,wBAAS,MAAM,iBAAkB,IAAK,GAAG,CAAE,MAAM,MAAO,CAAE;AAExE,SACC,4CAAC,YAAY,UAAZ,EAAqB,OACnB,UACH;AAEF;AAiBO,IAAM,UAAU,UAAM,2BAAY,WAAY;AAyB9C,SAAS,SACf,gBACyC;AACzC,QAAM,oBAEF,CAAE,UAAW;AAChB,UAAM,YAAY,QAAQ;AAC1B,WAAO,4CAAC,kBAAiB,GAAK,OAAiB,GAAG,WAAY;AAAA,EAC/D;AACA,QAAM,qBACL,eAAe,eAAe,eAAe,QAAQ;AACtD,oBAAkB,cAAc,YAAa,kBAAmB;AAChE,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type {\n\tComponentType,\n\tFunctionComponent,\n\tPropsWithChildren,\n} from 'react';\nimport type { Subtract } from 'utility-types';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { defaultI18n } from '@wordpress/i18n';\nimport type { I18n } from '@wordpress/i18n';\ninterface I18nContextProps {\n\t__: I18n[ '__' ];\n\t_x: I18n[ '_x' ];\n\t_n: I18n[ '_n' ];\n\t_nx: I18n[ '_nx' ];\n\tisRTL: I18n[ 'isRTL' ];\n\thasTranslation: I18n[ 'hasTranslation' ];\n}\n\n/**\n * Utility to make a new context value\n *\n * @param i18n\n */\nfunction makeContextValue( i18n: I18n ): I18nContextProps {\n\treturn {\n\t\t__: i18n.__.bind( i18n ),\n\t\t_x: i18n._x.bind( i18n ),\n\t\t_n: i18n._n.bind( i18n ),\n\t\t_nx: i18n._nx.bind( i18n ),\n\t\tisRTL: i18n.isRTL.bind( i18n ),\n\t\thasTranslation: i18n.hasTranslation.bind( i18n ),\n\t};\n}\n\nconst I18nContext = createContext( makeContextValue( defaultI18n ) );\nI18nContext.displayName = 'I18nContext';\n\ntype I18nProviderProps = PropsWithChildren< { i18n: I18n } >;\n\n/**\n * The `I18nProvider` should be mounted above any localized components:\n *\n * @example\n * ```js\n * import { createI18n } from '@wordpress/i18n';\n * import { I18nProvider } from '@wordpress/react-i18n';\n * const i18n = createI18n();\n *\n * ReactDom.render(\n * \t<I18nProvider i18n={ i18n }>\n * \t\t<App />\n * \t</I18nProvider>,\n * \tel\n * );\n * ```\n *\n * You can also instantiate the provider without the `i18n` prop. In that case it will use the\n * default `I18n` instance exported from `@wordpress/i18n`.\n *\n * @param props i18n provider props.\n * @return Children wrapped in the I18nProvider.\n */\nexport function I18nProvider( props: I18nProviderProps ) {\n\tconst { children, i18n = defaultI18n } = props;\n\tconst [ update, forceUpdate ] = useReducer( () => [], [] );\n\n\t// Rerender translations whenever the i18n instance fires a change event.\n\tuseEffect( () => i18n.subscribe( forceUpdate ), [ i18n ] );\n\n\tconst value = useMemo( () => makeContextValue( i18n ), [ i18n, update ] );\n\n\treturn (\n\t\t<I18nContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</I18nContext.Provider>\n\t);\n}\n\n/**\n * React hook providing access to i18n functions. It exposes the `__`, `_x`, `_n`, `_nx`,\n * `isRTL` and `hasTranslation` functions from [`@wordpress/i18n`](../i18n).\n * Refer to their documentation there.\n *\n * @example\n * ```js\n * import { useI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent() {\n * \tconst { __ } = useI18n();\n * \treturn __( 'Hello, world!' );\n * }\n * ```\n */\nexport const useI18n = () => useContext( I18nContext );\n\ntype PropsAndI18n< P > = Pick<\n\tP,\n\tExclude< keyof P, '__' | '_x' | '_n' | '_nx' | 'isRTL' | 'hasTranslation' >\n>;\n\n/**\n * React higher-order component that passes the i18n translate functions (the same set\n * as exposed by the `useI18n` hook) to the wrapped component as props.\n *\n * @example\n * ```js\n * import { withI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent( { __ } ) {\n * \treturn __( 'Hello, world!' );\n * }\n *\n * export default withI18n( MyComponent );\n * ```\n *\n * @param InnerComponent React component to be wrapped and receive the i18n functions like `__`\n * @return The wrapped component\n */\nexport function withI18n< P extends I18nContextProps >(\n\tInnerComponent: ComponentType< P >\n): FunctionComponent< PropsAndI18n< P > > {\n\tconst EnhancedComponent: ComponentType<\n\t\tSubtract< P, I18nContextProps >\n\t> = ( props ) => {\n\t\tconst i18nProps = useI18n();\n\t\treturn <InnerComponent { ...( props as P ) } { ...i18nProps } />;\n\t};\n\tconst innerComponentName =\n\t\tInnerComponent.displayName || InnerComponent.name || 'Component';\n\tEnhancedComponent.displayName = `WithI18n(${ innerComponentName })`;\n\treturn EnhancedComponent;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,qBAMO;AACP,kBAA4B;AAiE1B;AAjDF,SAAS,iBAAkB,MAA+B;AACzD,SAAO;AAAA,IACN,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,KAAK,KAAK,IAAI,KAAM,IAAK;AAAA,IACzB,OAAO,KAAK,MAAM,KAAM,IAAK;AAAA,IAC7B,gBAAgB,KAAK,eAAe,KAAM,IAAK;AAAA,EAChD;AACD;AAEA,IAAM,kBAAc,8BAAe,iBAAkB,uBAAY,CAAE;AACnE,YAAY,cAAc;AA2BnB,SAAS,aAAc,OAA2B;AACxD,QAAM,EAAE,UAAU,OAAO,wBAAY,IAAI;AACzC,QAAM,CAAE,QAAQ,WAAY,QAAI,2BAAY,MAAM,CAAC,GAAG,CAAC,CAAE;AAGzD,gCAAW,MAAM,KAAK,UAAW,WAAY,GAAG,CAAE,IAAK,CAAE;AAEzD,QAAM,YAAQ,wBAAS,MAAM,iBAAkB,IAAK,GAAG,CAAE,MAAM,MAAO,CAAE;AAExE,SACC,4CAAC,YAAY,UAAZ,EAAqB,OACnB,UACH;AAEF;AAiBO,IAAM,UAAU,UAAM,2BAAY,WAAY;AAyB9C,SAAS,SACf,gBACyC;AACzC,QAAM,oBAEF,CAAE,UAAW;AAChB,UAAM,YAAY,QAAQ;AAC1B,WAAO,4CAAC,kBAAiB,GAAK,OAAiB,GAAG,WAAY;AAAA,EAC/D;AACA,QAAM,qBACL,eAAe,eAAe,eAAe,QAAQ;AACtD,oBAAkB,cAAc,YAAa,kBAAmB;AAChE,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type {\n\tComponentType,\n\tFunctionComponent,\n\tPropsWithChildren,\n} from 'react';\nimport type { Subtract } from 'utility-types';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { defaultI18n } from '@wordpress/i18n';\nimport type { I18n } from '@wordpress/i18n';\ninterface I18nContextProps {\n\t__: I18n[ '__' ];\n\t_x: I18n[ '_x' ];\n\t_n: I18n[ '_n' ];\n\t_nx: I18n[ '_nx' ];\n\tisRTL: I18n[ 'isRTL' ];\n\thasTranslation: I18n[ 'hasTranslation' ];\n}\n\n/**\n * Utility to make a new context value\n *\n * @param i18n\n */\nfunction makeContextValue( i18n: I18n ): I18nContextProps {\n\treturn {\n\t\t__: i18n.__.bind( i18n ),\n\t\t_x: i18n._x.bind( i18n ),\n\t\t_n: i18n._n.bind( i18n ),\n\t\t_nx: i18n._nx.bind( i18n ),\n\t\tisRTL: i18n.isRTL.bind( i18n ),\n\t\thasTranslation: i18n.hasTranslation.bind( i18n ),\n\t};\n}\n\nconst I18nContext = createContext( makeContextValue( defaultI18n ) );\nI18nContext.displayName = 'I18nContext';\n\ntype I18nProviderProps = PropsWithChildren< { i18n: I18n } >;\n\n/**\n * The `I18nProvider` should be mounted above any localized components:\n *\n * @example\n * ```js\n * import { createI18n } from '@wordpress/i18n';\n * import { I18nProvider } from '@wordpress/react-i18n';\n * const i18n = createI18n();\n *\n * ReactDom.render(\n * \t<I18nProvider i18n={ i18n }>\n * \t\t<App />\n * \t</I18nProvider>,\n * \tel\n * );\n * ```\n *\n * You can also instantiate the provider without the `i18n` prop. In that case it will use the\n * default `I18n` instance exported from `@wordpress/i18n`.\n *\n * @param props i18n provider props.\n * @return Children wrapped in the I18nProvider.\n */\nexport function I18nProvider( props: I18nProviderProps ): JSX.Element {\n\tconst { children, i18n = defaultI18n } = props;\n\tconst [ update, forceUpdate ] = useReducer( () => [], [] );\n\n\t// Rerender translations whenever the i18n instance fires a change event.\n\tuseEffect( () => i18n.subscribe( forceUpdate ), [ i18n ] );\n\n\tconst value = useMemo( () => makeContextValue( i18n ), [ i18n, update ] );\n\n\treturn (\n\t\t<I18nContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</I18nContext.Provider>\n\t);\n}\n\n/**\n * React hook providing access to i18n functions. It exposes the `__`, `_x`, `_n`, `_nx`,\n * `isRTL` and `hasTranslation` functions from [`@wordpress/i18n`](../i18n).\n * Refer to their documentation there.\n *\n * @example\n * ```js\n * import { useI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent() {\n * \tconst { __ } = useI18n();\n * \treturn __( 'Hello, world!' );\n * }\n * ```\n */\nexport const useI18n = () => useContext( I18nContext );\n\ntype PropsAndI18n< P > = Pick<\n\tP,\n\tExclude< keyof P, '__' | '_x' | '_n' | '_nx' | 'isRTL' | 'hasTranslation' >\n>;\n\n/**\n * React higher-order component that passes the i18n translate functions (the same set\n * as exposed by the `useI18n` hook) to the wrapped component as props.\n *\n * @example\n * ```js\n * import { withI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent( { __ } ) {\n * \treturn __( 'Hello, world!' );\n * }\n *\n * export default withI18n( MyComponent );\n * ```\n *\n * @param InnerComponent React component to be wrapped and receive the i18n functions like `__`\n * @return The wrapped component\n */\nexport function withI18n< P extends I18nContextProps >(\n\tInnerComponent: ComponentType< P >\n): FunctionComponent< PropsAndI18n< P > > {\n\tconst EnhancedComponent: ComponentType<\n\t\tSubtract< P, I18nContextProps >\n\t> = ( props ) => {\n\t\tconst i18nProps = useI18n();\n\t\treturn <InnerComponent { ...( props as P ) } { ...i18nProps } />;\n\t};\n\tconst innerComponentName =\n\t\tInnerComponent.displayName || InnerComponent.name || 'Component';\n\tEnhancedComponent.displayName = `WithI18n(${ innerComponentName })`;\n\treturn EnhancedComponent;\n}\n"],
5
- "mappings": ";AAaA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAiE1B;AAjDF,SAAS,iBAAkB,MAA+B;AACzD,SAAO;AAAA,IACN,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,KAAK,KAAK,IAAI,KAAM,IAAK;AAAA,IACzB,OAAO,KAAK,MAAM,KAAM,IAAK;AAAA,IAC7B,gBAAgB,KAAK,eAAe,KAAM,IAAK;AAAA,EAChD;AACD;AAEA,IAAM,cAAc,cAAe,iBAAkB,WAAY,CAAE;AACnE,YAAY,cAAc;AA2BnB,SAAS,aAAc,OAAwC;AACrE,QAAM,EAAE,UAAU,OAAO,YAAY,IAAI;AACzC,QAAM,CAAE,QAAQ,WAAY,IAAI,WAAY,MAAM,CAAC,GAAG,CAAC,CAAE;AAGzD,YAAW,MAAM,KAAK,UAAW,WAAY,GAAG,CAAE,IAAK,CAAE;AAEzD,QAAM,QAAQ,QAAS,MAAM,iBAAkB,IAAK,GAAG,CAAE,MAAM,MAAO,CAAE;AAExE,SACC,oBAAC,YAAY,UAAZ,EAAqB,OACnB,UACH;AAEF;AAiBO,IAAM,UAAU,MAAM,WAAY,WAAY;AAyB9C,SAAS,SACf,gBACyC;AACzC,QAAM,oBAEF,CAAE,UAAW;AAChB,UAAM,YAAY,QAAQ;AAC1B,WAAO,oBAAC,kBAAiB,GAAK,OAAiB,GAAG,WAAY;AAAA,EAC/D;AACA,QAAM,qBACL,eAAe,eAAe,eAAe,QAAQ;AACtD,oBAAkB,cAAc,YAAa,kBAAmB;AAChE,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type {\n\tComponentType,\n\tFunctionComponent,\n\tPropsWithChildren,\n} from 'react';\nimport type { Subtract } from 'utility-types';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { defaultI18n } from '@wordpress/i18n';\nimport type { I18n } from '@wordpress/i18n';\ninterface I18nContextProps {\n\t__: I18n[ '__' ];\n\t_x: I18n[ '_x' ];\n\t_n: I18n[ '_n' ];\n\t_nx: I18n[ '_nx' ];\n\tisRTL: I18n[ 'isRTL' ];\n\thasTranslation: I18n[ 'hasTranslation' ];\n}\n\n/**\n * Utility to make a new context value\n *\n * @param i18n\n */\nfunction makeContextValue( i18n: I18n ): I18nContextProps {\n\treturn {\n\t\t__: i18n.__.bind( i18n ),\n\t\t_x: i18n._x.bind( i18n ),\n\t\t_n: i18n._n.bind( i18n ),\n\t\t_nx: i18n._nx.bind( i18n ),\n\t\tisRTL: i18n.isRTL.bind( i18n ),\n\t\thasTranslation: i18n.hasTranslation.bind( i18n ),\n\t};\n}\n\nconst I18nContext = createContext( makeContextValue( defaultI18n ) );\nI18nContext.displayName = 'I18nContext';\n\ntype I18nProviderProps = PropsWithChildren< { i18n: I18n } >;\n\n/**\n * The `I18nProvider` should be mounted above any localized components:\n *\n * @example\n * ```js\n * import { createI18n } from '@wordpress/i18n';\n * import { I18nProvider } from '@wordpress/react-i18n';\n * const i18n = createI18n();\n *\n * ReactDom.render(\n * \t<I18nProvider i18n={ i18n }>\n * \t\t<App />\n * \t</I18nProvider>,\n * \tel\n * );\n * ```\n *\n * You can also instantiate the provider without the `i18n` prop. In that case it will use the\n * default `I18n` instance exported from `@wordpress/i18n`.\n *\n * @param props i18n provider props.\n * @return Children wrapped in the I18nProvider.\n */\nexport function I18nProvider( props: I18nProviderProps ) {\n\tconst { children, i18n = defaultI18n } = props;\n\tconst [ update, forceUpdate ] = useReducer( () => [], [] );\n\n\t// Rerender translations whenever the i18n instance fires a change event.\n\tuseEffect( () => i18n.subscribe( forceUpdate ), [ i18n ] );\n\n\tconst value = useMemo( () => makeContextValue( i18n ), [ i18n, update ] );\n\n\treturn (\n\t\t<I18nContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</I18nContext.Provider>\n\t);\n}\n\n/**\n * React hook providing access to i18n functions. It exposes the `__`, `_x`, `_n`, `_nx`,\n * `isRTL` and `hasTranslation` functions from [`@wordpress/i18n`](../i18n).\n * Refer to their documentation there.\n *\n * @example\n * ```js\n * import { useI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent() {\n * \tconst { __ } = useI18n();\n * \treturn __( 'Hello, world!' );\n * }\n * ```\n */\nexport const useI18n = () => useContext( I18nContext );\n\ntype PropsAndI18n< P > = Pick<\n\tP,\n\tExclude< keyof P, '__' | '_x' | '_n' | '_nx' | 'isRTL' | 'hasTranslation' >\n>;\n\n/**\n * React higher-order component that passes the i18n translate functions (the same set\n * as exposed by the `useI18n` hook) to the wrapped component as props.\n *\n * @example\n * ```js\n * import { withI18n } from '@wordpress/react-i18n';\n *\n * function MyComponent( { __ } ) {\n * \treturn __( 'Hello, world!' );\n * }\n *\n * export default withI18n( MyComponent );\n * ```\n *\n * @param InnerComponent React component to be wrapped and receive the i18n functions like `__`\n * @return The wrapped component\n */\nexport function withI18n< P extends I18nContextProps >(\n\tInnerComponent: ComponentType< P >\n): FunctionComponent< PropsAndI18n< P > > {\n\tconst EnhancedComponent: ComponentType<\n\t\tSubtract< P, I18nContextProps >\n\t> = ( props ) => {\n\t\tconst i18nProps = useI18n();\n\t\treturn <InnerComponent { ...( props as P ) } { ...i18nProps } />;\n\t};\n\tconst innerComponentName =\n\t\tInnerComponent.displayName || InnerComponent.name || 'Component';\n\tEnhancedComponent.displayName = `WithI18n(${ innerComponentName })`;\n\treturn EnhancedComponent;\n}\n"],
5
+ "mappings": ";AAaA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAiE1B;AAjDF,SAAS,iBAAkB,MAA+B;AACzD,SAAO;AAAA,IACN,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,IAAI,KAAK,GAAG,KAAM,IAAK;AAAA,IACvB,KAAK,KAAK,IAAI,KAAM,IAAK;AAAA,IACzB,OAAO,KAAK,MAAM,KAAM,IAAK;AAAA,IAC7B,gBAAgB,KAAK,eAAe,KAAM,IAAK;AAAA,EAChD;AACD;AAEA,IAAM,cAAc,cAAe,iBAAkB,WAAY,CAAE;AACnE,YAAY,cAAc;AA2BnB,SAAS,aAAc,OAA2B;AACxD,QAAM,EAAE,UAAU,OAAO,YAAY,IAAI;AACzC,QAAM,CAAE,QAAQ,WAAY,IAAI,WAAY,MAAM,CAAC,GAAG,CAAC,CAAE;AAGzD,YAAW,MAAM,KAAK,UAAW,WAAY,GAAG,CAAE,IAAK,CAAE;AAEzD,QAAM,QAAQ,QAAS,MAAM,iBAAkB,IAAK,GAAG,CAAE,MAAM,MAAO,CAAE;AAExE,SACC,oBAAC,YAAY,UAAZ,EAAqB,OACnB,UACH;AAEF;AAiBO,IAAM,UAAU,MAAM,WAAY,WAAY;AAyB9C,SAAS,SACf,gBACyC;AACzC,QAAM,oBAEF,CAAE,UAAW;AAChB,UAAM,YAAY,QAAQ;AAC1B,WAAO,oBAAC,kBAAiB,GAAK,OAAiB,GAAG,WAAY;AAAA,EAC/D;AACA,QAAM,qBACL,eAAe,eAAe,eAAe,QAAQ;AACtD,oBAAkB,cAAc,YAAa,kBAAmB;AAChE,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -37,7 +37,7 @@ type I18nProviderProps = PropsWithChildren<{
37
37
  * @param props i18n provider props.
38
38
  * @return Children wrapped in the I18nProvider.
39
39
  */
40
- export declare function I18nProvider(props: I18nProviderProps): JSX.Element;
40
+ export declare function I18nProvider(props: I18nProviderProps): import("react").JSX.Element;
41
41
  /**
42
42
  * React hook providing access to i18n functions. It exposes the `__`, `_x`, `_n`, `_nx`,
43
43
  * `isRTL` and `hasTranslation` functions from [`@wordpress/i18n`](../i18n).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,OAAO,CAAC;AAcf,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,UAAU,gBAAgB;IACzB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,GAAG,EAAE,IAAI,CAAE,KAAK,CAAE,CAAC;IACnB,KAAK,EAAE,IAAI,CAAE,OAAO,CAAE,CAAC;IACvB,cAAc,EAAE,IAAI,CAAE,gBAAgB,CAAE,CAAC;CACzC;AAqBD,KAAK,iBAAiB,GAAG,iBAAiB,CAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAE,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAE,KAAK,EAAE,iBAAiB,GAAI,GAAG,CAAC,OAAO,CAcpE;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,wBAAkC,CAAC;AAEvD,KAAK,YAAY,CAAE,CAAC,IAAK,IAAI,CAC5B,CAAC,EACD,OAAO,CAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,gBAAgB,CAAE,CAC3E,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,gBAAgB,EACnD,cAAc,EAAE,aAAa,CAAE,CAAC,CAAE,GAChC,iBAAiB,CAAE,YAAY,CAAE,CAAC,CAAE,CAAE,CAWxC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,OAAO,CAAC;AAcf,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,UAAU,gBAAgB;IACzB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,EAAE,EAAE,IAAI,CAAE,IAAI,CAAE,CAAC;IACjB,GAAG,EAAE,IAAI,CAAE,KAAK,CAAE,CAAC;IACnB,KAAK,EAAE,IAAI,CAAE,OAAO,CAAE,CAAC;IACvB,cAAc,EAAE,IAAI,CAAE,gBAAgB,CAAE,CAAC;CACzC;AAqBD,KAAK,iBAAiB,GAAG,iBAAiB,CAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAE,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAE,KAAK,EAAE,iBAAiB,+BAcrD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,wBAAkC,CAAC;AAEvD,KAAK,YAAY,CAAE,CAAC,IAAK,IAAI,CAC5B,CAAC,EACD,OAAO,CAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,gBAAgB,CAAE,CAC3E,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,gBAAgB,EACnD,cAAc,EAAE,aAAa,CAAE,CAAC,CAAE,GAChC,iBAAiB,CAAE,YAAY,CAAE,CAAC,CAAE,CAAE,CAWxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/react-i18n",
3
- "version": "4.39.1-next.v.202602111440.0+a307a2e35",
3
+ "version": "4.40.0",
4
4
  "description": "React bindings for @wordpress/i18n.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -44,12 +44,12 @@
44
44
  "types": "build-types",
45
45
  "sideEffects": false,
46
46
  "dependencies": {
47
- "@wordpress/element": "^6.39.1-next.v.202602111440.0+a307a2e35",
48
- "@wordpress/i18n": "^6.12.1-next.v.202602111440.0+a307a2e35",
47
+ "@wordpress/element": "^6.40.0",
48
+ "@wordpress/i18n": "^6.13.0",
49
49
  "utility-types": "^3.10.0"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "e0a2324a9690e55f4101d61113f4bbbf240b55ed"
54
+ "gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
55
55
  }
package/src/index.tsx CHANGED
@@ -73,7 +73,7 @@ type I18nProviderProps = PropsWithChildren< { i18n: I18n } >;
73
73
  * @param props i18n provider props.
74
74
  * @return Children wrapped in the I18nProvider.
75
75
  */
76
- export function I18nProvider( props: I18nProviderProps ): JSX.Element {
76
+ export function I18nProvider( props: I18nProviderProps ) {
77
77
  const { children, i18n = defaultI18n } = props;
78
78
  const [ update, forceUpdate ] = useReducer( () => [], [] );
79
79