Skip to content

Commit

Permalink
Fix various translation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed Oct 23, 2020
1 parent e1d2ca7 commit c181730
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,7 +38,7 @@ const LanguageStep: React.FunctionComponent = () => {
</ActionButtons>
</div>
<LanguagePicker
languageGroups={ LANGUAGE_GROUPS }
languageGroups={ createLanguageGroups( __ ) }
languages={ languages }
onSelectLanguage={ ( language ) => {
changeLocale( language.langSlug );
Expand Down
1 change: 1 addition & 0 deletions packages/language-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
294 changes: 294 additions & 0 deletions packages/language-picker/src/constants.ts
Original file line number Diff line number Diff line change
@@ -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',
],
},
];
1 change: 1 addition & 0 deletions packages/language-picker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './language-picker';
export { default } from './language-picker';
export * from './constants';
7 changes: 5 additions & 2 deletions packages/language-picker/src/language-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,6 +47,7 @@ type Props = {
};

const LanguagePicker = ( { onSelectLanguage, languages, languageGroups }: Props ) => {
const { __ } = useI18n();
const [ filter, setFilter ] = useState( languageGroups[ 0 ].id );

const getFilteredLanguages = () => {
Expand Down Expand Up @@ -87,7 +88,9 @@ const LanguagePicker = ( { onSelectLanguage, languages, languageGroups }: Props

return (
<div className="language-picker-component">
<div className="language-picker-component__regions-label">{ __( 'regions' ) }</div>
<div className="language-picker-component__regions-label">
{ __( 'regions', __i18n_text_domain__ ) }
</div>
<div className="language-picker-component__content">
<div className="language-picker-component__category-filters">
{ renderCategoryButtons() }
Expand Down
1 change: 1 addition & 0 deletions packages/language-picker/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const __i18n_text_domain__: string;

0 comments on commit c181730

Please sign in to comment.