-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from paulbalandan/revamp-testing
Revamp testing for translations
- Loading branch information
Showing
52 changed files
with
1,134 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
error_reporting(-1); | ||
ini_set('display_errors', '1'); | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
use CodeIgniter\Language\AbstractTranslationTestCase; | ||
|
||
$args = $_SERVER['argv']; | ||
|
||
if (! isset($args[1])) | ||
{ | ||
fwrite(STDERR, 'Changed files are not provided. Aborting...'); | ||
exit(1); | ||
} | ||
|
||
$files = $args[1]; | ||
unset($args); | ||
|
||
$files = explode(' ', trim($files)); | ||
|
||
$stagedPhpFiles = []; | ||
|
||
foreach ($files as $file) | ||
{ | ||
if (substr($file, -4) === '.php') | ||
{ | ||
$stagedPhpFiles[] = $file; | ||
} | ||
} | ||
|
||
$locales = []; | ||
|
||
foreach ($stagedPhpFiles as $file) | ||
{ | ||
if (preg_match('/^Language\/(.*)\/.*\.php$/', $file, $matches)) | ||
{ | ||
$locales[] = $matches[1]; | ||
} | ||
} | ||
|
||
$locales = array_unique($locales); | ||
$count = count($locales); | ||
|
||
chdir(__DIR__ . '/../../'); | ||
|
||
if ($count === 0) | ||
{ | ||
fwrite(STDOUT, 'No language files to test.'); | ||
exit(0); | ||
} | ||
|
||
if ($count === count(AbstractTranslationTestCase::$locales)) | ||
{ | ||
$return = 0; | ||
fwrite(STDOUT, "Testing all language files in all locales.\n\n"); | ||
passthru('vendor/bin/phpunit --filter AllLocalesTranslationTest', $return); | ||
|
||
exit($return); | ||
} | ||
|
||
$returns = 0; | ||
$return = 0; | ||
|
||
foreach ($locales as $locale) | ||
{ | ||
$localeMap = array_flip(AbstractTranslationTestCase::$locales); | ||
$class = preg_replace('/^CodeIgniter\\\\Language\\\\(.*)$/u', '$1', $localeMap[$locale]); | ||
|
||
fwrite(STDOUT, 'Executing vendor/bin/phpunit --color=always --filter ' . $class . "\n\n"); | ||
passthru("vendor/bin/phpunit --color=always --filter {$class}", $return); | ||
|
||
$returns += $return; | ||
} | ||
|
||
exit($returns ? 1 : 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- Language/** | ||
- tests/Language/** | ||
- .github/workflows/build.yml | ||
pull_request: | ||
branches: | ||
- develop | ||
paths: | ||
- Language/** | ||
- tests/Language/** | ||
- .github/workflows/build.yml | ||
|
||
jobs: | ||
|
||
main: | ||
name: Build [PHP ${{ matrix.php-versions }}] | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['7.3', '7.4'] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
tools: composer | ||
extensions: intl, mbstring, xdebug | ||
coverage: xdebug | ||
|
||
- name: Validate composer.json | ||
run: composer validate --strict | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Create composer cache directory | ||
run: mkdir -p ${{ steps.composer-cache.outputs.dir }} | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Setup Composer's GitHub OAuth access to prevent rate limiting | ||
run: composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: composer update --ansi --no-scripts --no-interaction | ||
|
||
- name: Get changed files | ||
id: files | ||
uses: jitterbit/get-changed-files@v1 | ||
|
||
- name: Run Translations Test Suite | ||
run: | | ||
php .github/scripts/continuous-integration "${{ steps.files.outputs.all }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,21 @@ Translations for CodeIgniter 4 System Messages | |
############################################## | ||
|
||
This project contains translations for CodeIgniter 4 | ||
localization, eg. **system/Language/en**. | ||
localization, e.g. **system/Language/en/**. | ||
|
||
Copy the folder(s) for the locales you are interested in, | ||
from inside the **Language** folder of this project to your | ||
**application/Language** folder. | ||
**app/Language/** folder. | ||
|
||
You may then use the CodeIgniter Language class to reference the translations | ||
directly ... see the `User Guide <https://codeigniter4.github.io/CodeIgniter4/outgoing/localization.html>`_. | ||
|
||
Localization in CodeIgniter 4 follows the `ISO 639-1 conventions <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`_. | ||
Each translation set would go inside a folder named following the two-letter language code from here. | ||
|
||
Localization variants are provided for, as folders named with the two-letter ISO 639-1 language code in lowercase, | ||
followed by the two-letter `ISO 3166 country code <https://en.wikipedia.org/wiki/ISO_3166-1>`_ capitalized, | ||
and with the two parts separated by a hyphen. | ||
Localization variants are provided for, as folders named with the two-letter ISO 639-1 language code in lowercase, | ||
followed by the two-letter `ISO 3166 country code <https://en.wikipedia.org/wiki/ISO_3166-1>`_ capitalized, | ||
and with the two parts separated by a hyphen. | ||
An example would be "en" for English, and "en-US" for the variations appropriate to the United States. | ||
|
||
********************** | ||
|
@@ -47,7 +47,7 @@ ko Korean 4.0.0* Timothy-Y-H-Lee Timothy-Y-H-Lee | |
lt Lithuanian 4.0.0* dgvirtual Donatas Glodenis | ||
lv Latvian 4.0.0* davislasis Dāvis Lasis | ||
ml Malayalam 4.0.0 rakheshthayyur Rakhesh Thayyur | ||
nl Dutch 4.0.0 JohanSmolders JohanSmolders | ||
nl Dutch 4.0.0 JohanSmolders JohanSmolders | ||
no Norwegian 4.0.0 LA3QMA Kai Günter Brandt | ||
pl Polish 4.0.0 DEVELPL Maciej Jasiewicz | ||
pt Portugese 4.0.0 rbm0407 Rodrigo Borges | ||
|
@@ -72,5 +72,3 @@ License | |
******* | ||
|
||
These translations are licensed under the `MIT license <LICENSE>`_. | ||
|
||
`Jim Parry <[email protected]>`_ |
Oops, something went wrong.