Skip to content

Commit

Permalink
Remove i18nLocale from react-i18n
Browse files Browse the repository at this point in the history
The ability to get the locale slug has moved to i18n-utils since it's a
Calypso specific feature.
  • Loading branch information
p-jackson committed Nov 20, 2020
1 parent 3a3d26f commit 65c8422
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/react-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ export default withI18n( MyComponent );
## API

The translation functions `__`, `_n`, `_nx`, and `_x` are exposed from [`@wordpress/i18n`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/i18n). Refer to their documentation there.
`i18nLocale` is a `string` containing the current locale. This is determined from the provided localeData and will fall back to `en`.
3 changes: 0 additions & 3 deletions packages/react-i18n/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface I18nReact {
_nx: I18n[ '_nx' ];
_x: I18n[ '_x' ];
isRTL: I18n[ 'isRTL' ];
i18nLocale: string;
}

const I18nContext = React.createContext< I18nReact >( makeContextValue() );
Expand Down Expand Up @@ -70,13 +69,11 @@ export const withI18n = createHigherOrderComponent< I18nReact >( ( InnerComponen
*/
function makeContextValue( localeData?: LocaleData ): I18nReact {
const i18n = createI18n( localeData );
const i18nLocale = localeData?.[ '' ]?.localeSlug ?? 'en';
return {
__: i18n.__.bind( i18n ),
_n: i18n._n.bind( i18n ),
_nx: i18n._nx.bind( i18n ),
_x: i18n._x.bind( i18n ),
isRTL: i18n.isRTL.bind( i18n ),
i18nLocale,
};
}

0 comments on commit 65c8422

Please sign in to comment.