diff --git a/client/landing/gutenboarding/onboarding-block/language/index.tsx b/client/landing/gutenboarding/onboarding-block/language/index.tsx index 071befa5ded3b..c7c233b144f86 100644 --- a/client/landing/gutenboarding/onboarding-block/language/index.tsx +++ b/client/landing/gutenboarding/onboarding-block/language/index.tsx @@ -5,14 +5,13 @@ import * as React from 'react'; import { useHistory } from 'react-router-dom'; import { useI18n } from '@automattic/react-i18n'; import { ActionButtons, BackButton, Title } from '@automattic/onboarding'; -import LanguagePicker from '@automattic/language-picker'; +import LanguagePicker, { createLanguageGroups } from '@automattic/language-picker'; /** * Internal dependencies */ import { ChangeLocaleContextConsumer } from '../../components/locale-context'; import { languages } from '../../../../languages'; -import { LANGUAGE_GROUPS } from '../../../../components/language-picker/constants'; /** * Style dependencies @@ -39,7 +38,7 @@ const LanguageStep: React.FunctionComponent = () => { { changeLocale( language.langSlug ); diff --git a/packages/language-picker/package.json b/packages/language-picker/package.json index 073ac8ed57a0b..c1bba3a97b44a 100644 --- a/packages/language-picker/package.json +++ b/packages/language-picker/package.json @@ -28,6 +28,7 @@ ], "types": "dist/types", "dependencies": { + "@automattic/react-i18n": "^1.0.0-alpha.0", "@babel/runtime": "^7.11.1", "@wordpress/base-styles": "^2.0.1", "@wordpress/components": "^10.0.5", diff --git a/packages/language-picker/src/constants.ts b/packages/language-picker/src/constants.ts new file mode 100644 index 0000000000000..755fb213873fc --- /dev/null +++ b/packages/language-picker/src/constants.ts @@ -0,0 +1,294 @@ +/** + * Internal dependencies + */ +import { LanguageGroup } from './language-picker'; +import { I18nReact } from '@automattic/react-i18n'; + +export const createLanguageGroups = ( __: I18nReact[ '__' ] ): LanguageGroup[] => [ + { + id: 'popular', + name: () => __( 'Popular languages' ), + }, + { + id: 'africa-middle-east', + name: () => __( 'Africa and Middle East' ), + subTerritories: [ '145', '002' ], + countries: [ + 'AE', + 'AM', + 'AO', + 'AZ', + 'BF', + 'BH', + 'BI', + 'BJ', + 'BW', + 'CD', + 'CF', + 'CG', + 'CI', + 'CM', + 'CV', + 'CY', + 'DJ', + 'DZ', + 'EA', + 'EG', + 'EH', + 'ER', + 'ET', + 'GA', + 'GE', + 'GH', + 'GM', + 'GN', + 'GQ', + 'GW', + 'IC', + 'IL', + 'IQ', + 'JO', + 'KE', + 'KM', + 'KW', + 'LB', + 'LR', + 'LS', + 'LY', + 'MA', + 'MG', + 'ML', + 'MR', + 'MU', + 'MW', + 'MZ', + 'NA', + 'NE', + 'NG', + 'OM', + 'PS', + 'QA', + 'RE', + 'RW', + 'SA', + 'SC', + 'SD', + 'SH', + 'SL', + 'SN', + 'SO', + 'SS', + 'ST', + 'SY', + 'SZ', + 'TD', + 'TG', + 'TN', + 'TR', + 'TZ', + 'UG', + 'YE', + 'YT', + 'ZA', + 'ZM', + 'ZW', + ], + }, + { + id: 'americas', + name: () => __( 'Americas' ), + subTerritories: [ '019' ], + countries: [ + 'AG', + 'AI', + 'AR', + 'AW', + 'BB', + 'BL', + 'BM', + 'BO', + 'BQ', + 'BR', + 'BS', + 'BZ', + 'CA', + 'CL', + 'CO', + 'CR', + 'CU', + 'CW', + 'DM', + 'DO', + 'EC', + 'FK', + 'GD', + 'GF', + 'GL', + 'GP', + 'GT', + 'GY', + 'HN', + 'HT', + 'JM', + 'KN', + 'KY', + 'LC', + 'MF', + 'MQ', + 'MS', + 'MX', + 'NI', + 'PA', + 'PE', + 'PM', + 'PR', + 'PY', + 'SR', + 'SV', + 'SX', + 'TC', + 'TT', + 'US', + 'UY', + 'VC', + 'VE', + 'VG', + 'VI', + ], + }, + { + id: 'asia-pacific', + default: true, + name: () => __( 'Asia-Pacific' ), + subTerritories: [ '143', '009', '030', '034', '035' ], + countries: [ + 'AC', + 'AF', + 'AQ', + 'AS', + 'AU', + 'BD', + 'BN', + 'BT', + 'BV', + 'CC', + 'CK', + 'CN', + 'CP', + 'CX', + 'DG', + 'FJ', + 'FM', + 'GS', + 'GU', + 'HK', + 'HM', + 'ID', + 'IN', + 'IO', + 'IR', + 'JP', + 'KG', + 'KH', + 'KI', + 'KP', + 'KR', + 'KZ', + 'LA', + 'LK', + 'MH', + 'MM', + 'MN', + 'MO', + 'MP', + 'MV', + 'MY', + 'NC', + 'NF', + 'NP', + 'NR', + 'NU', + 'NZ', + 'PF', + 'PG', + 'PH', + 'PK', + 'PN', + 'PW', + 'QO', + 'SB', + 'SG', + 'TA', + 'TF', + 'TH', + 'TJ', + 'TK', + 'TL', + 'TM', + 'TO', + 'TV', + 'TW', + 'UM', + 'UZ', + 'VN', + 'VU', + 'WF', + 'WS', + ], + }, + { + id: 'eastern-europe', + name: () => __( 'Eastern Europe' ), + subTerritories: [ '151' ], + countries: [ 'BG', 'BY', 'CZ', 'HU', 'MD', 'PL', 'RO', 'RU', 'SK', 'UA' ], + }, + { + id: 'western-europe', + name: () => __( 'Western Europe' ), + subTerritories: [ '154', '155', '039' ], + countries: [ + 'AD', + 'AL', + 'AT', + 'AX', + 'BA', + 'BE', + 'CH', + 'DE', + 'DK', + 'EE', + 'ES', + 'FI', + 'FO', + 'FR', + 'GB', + 'GG', + 'GI', + 'GR', + 'HR', + 'IE', + 'IM', + 'IS', + 'IT', + 'JE', + 'LI', + 'LT', + 'LU', + 'LV', + 'MC', + 'ME', + 'MK', + 'MT', + 'NL', + 'NO', + 'PT', + 'RS', + 'SE', + 'SI', + 'SJ', + 'SM', + 'VA', + 'XK', + ], + }, +]; diff --git a/packages/language-picker/src/index.ts b/packages/language-picker/src/index.ts index f16eecca2ec25..83019881af6e3 100644 --- a/packages/language-picker/src/index.ts +++ b/packages/language-picker/src/index.ts @@ -1,2 +1,3 @@ export * from './language-picker'; export { default } from './language-picker'; +export * from './constants'; diff --git a/packages/language-picker/src/language-picker.tsx b/packages/language-picker/src/language-picker.tsx index bd1dd8ac2f181..467cd3fe94a59 100644 --- a/packages/language-picker/src/language-picker.tsx +++ b/packages/language-picker/src/language-picker.tsx @@ -3,12 +3,12 @@ * External dependencies */ import React, { useState } from 'react'; +import { useI18n } from '@automattic/react-i18n'; /** * WordPress dependencies */ import { Button } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; /** * Style dependencies @@ -47,6 +47,7 @@ type Props = { }; const LanguagePicker = ( { onSelectLanguage, languages, languageGroups }: Props ) => { + const { __ } = useI18n(); const [ filter, setFilter ] = useState( languageGroups[ 0 ].id ); const getFilteredLanguages = () => { @@ -87,7 +88,9 @@ const LanguagePicker = ( { onSelectLanguage, languages, languageGroups }: Props return (
-
{ __( 'regions' ) }
+
+ { __( 'regions', __i18n_text_domain__ ) } +
{ renderCategoryButtons() } diff --git a/packages/language-picker/src/types.d.ts b/packages/language-picker/src/types.d.ts new file mode 100644 index 0000000000000..e4d38b2ca9e4e --- /dev/null +++ b/packages/language-picker/src/types.d.ts @@ -0,0 +1 @@ +declare const __i18n_text_domain__: string;