Skip to content

Commit

Permalink
fix: string translation for PHP and JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Oct 9, 2024
1 parent 03f4d8f commit 7d84a72
Show file tree
Hide file tree
Showing 41 changed files with 7,228 additions and 5,392 deletions.
6 changes: 0 additions & 6 deletions .babelrc.json

This file was deleted.

7 changes: 3 additions & 4 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Browsers that we support

last 1 version
> 1%
maintained node versions
not dead
last 4 Chrome versions
last 4 Safari versions
last 4 Firefox versions
9 changes: 5 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"indent": ["error", "tab", { "SwitchCase": 1 }],
"linebreak-style": [
"error",
"unix"
Expand All @@ -23,7 +21,7 @@
"always"
],
"no-unused-vars": [
"error", {
"warn", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
Expand All @@ -32,7 +30,10 @@
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"no-alert": 0,
"no-nested-ternary": 0
"no-nested-ternary": 0,
"prettier/prettier": "off",
"no-shadow": "warn",
"camelcase": "warn"
},
"ignorePatterns": ["**/vendor/**"]
}
27 changes: 3 additions & 24 deletions .github/workflows/build-dev-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
types: [opened, synchronize, ready_for_review]
branches-ignore:
- 'update_dependencies'
- "update_dependencies"
jobs:
dev-zip:
name: Build ZIP and upload to s3
Expand All @@ -19,32 +19,11 @@ jobs:
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}
steps:
- name: Check out source files
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/gallium # 16.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
node-version: lts/hydrogen # 18.x
- name: Install composer deps
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Install yarn deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/gallium # 16.x
node-version: lts/hydrogen # 18.x
- name: Build
run: |
yarn install --frozen-lockfile
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ jobs:
name: E2E Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/gallium # 16.x
node-version: lts/hydrogen # 18.x
- name: Build
run: |
yarn install --frozen-lockfile
composer install --no-dev --prefer-dist --no-progress --no-suggest
yarn run build
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install testing env
run: bash ./bin/e2e-env.sh
- name: Run Cypress tests
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: PHP Tests
on:
push:
branches-ignore:
- 'master'
- "master"
# Cancel previous workflow run groups that have not completed.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
Expand All @@ -16,30 +16,19 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
php-version: "7.4"
extensions: simplexml
tools: composer:v2.1
- name: Checkout source code
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
uses: actions/checkout@v4
- name: Install composer
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run PHPCS
run: composer run lint

phpunit:
name: PHPUnit
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:5.7
Expand All @@ -52,25 +41,14 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"
extensions: simplexml, mysql
tools: phpunit-polyfills
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install WordPress Test Suite
run: |
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
- name: Run phpunit
Expand All @@ -84,10 +62,10 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"
extensions: simplexml, mysql
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
Expand All @@ -103,4 +81,3 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest
- name: PHPStan Static Analysis
run: composer phpstan

16 changes: 8 additions & 8 deletions beaver/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ const Header = ( { closeModal, getOrder, getSearchQuery } ) => {
window.tiTpc.postType
) &&
parseInt( window.tiTpc.tier ) === 3 && (
<Button
label={ window.tiTpc.library.actions.save }
icon={ cloudUpload }
onClick={ () =>
updateCurrentTab( 'export' )
}
/>
) }
<Button
label={ window.tiTpc.library.actions.save }
icon={ cloudUpload }
onClick={ () =>
updateCurrentTab( 'export' )
}
/>
) }
</ButtonGroup>
) }

Expand Down
4 changes: 2 additions & 2 deletions beaver/src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ if ( parseInt( window.tiTpc.tier ) === 3 ) {
const text = contextMenu.textContent;
contextMenu.textContent = text.replace(
// eslint-disable-next-line prettier/prettier
'<li><a class=\"fl-block-row-reset\" href=\"javascript:void(0);\">Reset Row Width</a></li>',
'<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li>',
// eslint-disable-next-line prettier/prettier
'<li><a class=\"fl-block-row-reset\" href=\"javascript:void(0);\">Reset Row Width</a></li><li><a class=\"fl-block-row-tpc-export\" onclick="window.tiTpc.tpcExport(this)" href=\"javascript:void(0);\">Save to Templates Cloud</a></li>'
'<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li><li><a class="fl-block-row-tpc-export" onclick="window.tiTpc.tpcExport(this)" href="javascript:void(0);">Save to Templates Cloud</a></li>'
);
}

Expand Down
9 changes: 1 addition & 8 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,5 @@
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"visual:test": "percy exec -- cypress run --config baseUrl=https://qa-neve.themeisle.com,video=false --spec 'cypress/integration/visual-regression/**/*.spec.js' --headless"
},
"browserslist": [
"> 0.5%",
"last 2 versions",
"Firefox ESR",
"not dead",
"not IE 9-11"
]
}
}
5 changes: 2 additions & 3 deletions editor/src/components/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const Content = ( {
};

export default withSelect( ( select ) => {
const { isPreview, isFetching, getCurrentTab } = select(
'tpc/block-editor'
);
const { isPreview, isFetching, getCurrentTab } =
select( 'tpc/block-editor' );
return {
isPreview: isPreview(),
isFetching: isFetching(),
Expand Down
8 changes: 6 additions & 2 deletions editor/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ const Header = ( { closeModal, getOrder, getSearchQuery } ) => {
await fetchTemplates( {
search: getSearchQuery(),
...order,
showFSE: tiTpc.isFSETheme ? window?.localStorage?.tpcShowFse === 'true' : false,
showFSE: tiTpc.isFSETheme
? window?.localStorage?.tpcShowFse === 'true'
: false,
} );

await fetchLibrary( {
search: getSearchQuery(),
...order,
showFSE: tiTpc.isFSETheme ? window?.localStorage?.tpcShowFse === 'true' : false,
showFSE: tiTpc.isFSETheme
? window?.localStorage?.tpcShowFse === 'true'
: false,
} );

setFetching( false );
Expand Down
15 changes: 5 additions & 10 deletions editor/src/components/import-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { importTemplate } from '../data/templates-cloud';
const ImportModal = ( {
clientId,
autoLoad = true,
isFse = false,
isFse = false,
modalOpen,
setModalOpen,
} ) => {
Expand All @@ -25,12 +25,8 @@ const ImportModal = ( {
previewData: select( 'tpc/block-editor' ).getPreview(),
} ) );

const {
removeBlock,
replaceBlocks,
insertBlocks,
resetBlocks,
} = useDispatch( 'core/block-editor' );
const { removeBlock, replaceBlocks, insertBlocks, resetBlocks } =
useDispatch( 'core/block-editor' );

const { togglePreview } = useDispatch( 'tpc/block-editor' );

Expand All @@ -44,9 +40,8 @@ const ImportModal = ( {

const { editPost } = useDispatch( 'core/editor' );

const { updateLibrary, updateTemplates } = useDispatch(
'tpc/block-editor'
);
const { updateLibrary, updateTemplates } =
useDispatch( 'tpc/block-editor' );

const [ importing, setImporting ] = useState( false );

Expand Down
28 changes: 17 additions & 11 deletions editor/src/data/templates-cloud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ export const fetchTemplates = async ( additionalParams = {} ) => {
params.type = [ 'gutenberg', 'fse' ];
}

const url = stringifyUrl( {
url: tiTpc.endpoint + 'page-templates',
query: params,
}, { arrayFormat: 'bracket' } );
const url = stringifyUrl(
{
url: tiTpc.endpoint + 'page-templates',
query: params,
},
{ arrayFormat: 'bracket' }
);

try {
const response = await apiFetch( {
Expand Down Expand Up @@ -73,14 +76,17 @@ export const fetchLibrary = async ( additionalParams = {} ) => {
params.type = [ 'gutenberg', 'fse' ];
}

const url = stringifyUrl( {
url: tiTpc.endpoint + 'templates',
query: {
cache: localStorage.getItem( 'tpcCacheBuster' ),
...filteredParams,
...params,
const url = stringifyUrl(
{
url: tiTpc.endpoint + 'templates',
query: {
cache: localStorage.getItem( 'tpcCacheBuster' ),
...filteredParams,
...params,
},
},
}, { arrayFormat: 'bracket' } );
{ arrayFormat: 'bracket' }
);

try {
const response = await apiFetch( {
Expand Down
4 changes: 2 additions & 2 deletions editor/src/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const icon = () => {
);
};

export const iconBlack = ({className}) => {
export const iconBlack = ( { className } ) => {
return (
<SVG
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={classnames(['tpc-icon', className])}
className={ classnames( [ 'tpc-icon', className ] ) }
>
<Path
d="M22.8063 24H1.19365C0.534714 24 0 23.4653 0 22.8063V1.19365C0 0.534714 0.534714 0 1.19365 0H22.8063C23.4653 0 24 0.534714 24 1.19365V22.8063C24 23.4653 23.4653 24 22.8063 24Z"
Expand Down
Loading

0 comments on commit 7d84a72

Please sign in to comment.