Skip to content

Commit b84cb55

Browse files
authored
Merge pull request #2 from webard/feature/tests
Feature: tests
2 parents a9b6f06 + f68b371 commit b84cb55

52 files changed

Lines changed: 2490 additions & 744 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
version: 2
55
updates:
6-
7-
- package-ecosystem: "github-actions"
8-
directory: "/"
6+
- package-ecosystem: 'github-actions'
7+
directory: '/'
98
schedule:
10-
interval: "weekly"
9+
interval: 'weekly'
1110
labels:
12-
- "dependencies"
11+
- 'dependencies'

.github/workflows/dependabot-auto-merge.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Dependabot Auto-Merge"
1+
name: 'Dependabot Auto-Merge'
22

33
on: pull_request_target
44

@@ -11,12 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: ${{ github.actor == 'dependabot[bot]' }}
1313
steps:
14-
1514
- name: Dependabot metadata
1615
id: metadata
1716
uses: dependabot/fetch-metadata@v2.5.0
1817
with:
19-
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
github-token: '${{ secrets.GITHUB_TOKEN }}'
2019

2120
- name: Auto-merge Dependabot PRs for semver-minor updates
2221
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
@@ -30,4 +29,4 @@ jobs:
3029
run: gh pr merge --auto --merge "$PR_URL"
3130
env:
3231
PR_URL: ${{github.event.pull_request.html_url}}
33-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Fix PHP Code Styling"
1+
name: 'Fix PHP Code Styling'
22

33
on:
44
push:
@@ -18,10 +18,20 @@ jobs:
1818
with:
1919
ref: ${{ github.head_ref }}
2020

21+
- name: Set up Node
22+
uses: actions/setup-node@v6
23+
24+
- name: Install dependencies
25+
run: |
26+
npm ci
27+
2128
- name: Fix PHP code style issues
2229
uses: aglipanci/laravel-pint-action@2.6
2330

31+
- name: Run Prettier
32+
run: npm run prettier
33+
2434
- name: Commit changes
2535
uses: stefanzweifel/git-auto-commit-action@v7
2636
with:
27-
commit_message: Fix styling
37+
commit_message: Fix styling

.github/workflows/phpstan.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.2'
19+
php-version: '8.4'
2020
coverage: none
2121

2222
- name: Install composer dependencies
2323
uses: ramsey/composer-install@v3
24+
with:
25+
composer-options: '--dev --optimize-autoloader'
2426

2527
- name: Run PHPStan
26-
run: ./vendor/bin/phpstan --error-format=github
28+
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/rector.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Rector
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'rector.php'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
rector:
15+
name: rector
16+
runs-on: ubuntu-latest
17+
if: github.event.pull_request.draft == false
18+
timeout-minutes: 5
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.4'
26+
coverage: none
27+
28+
- name: Install composer dependencies
29+
uses: ramsey/composer-install@v3
30+
with:
31+
composer-options: '--optimize-autoloader --classmap-authoritative'
32+
33+
- name: Cache Rector
34+
uses: actions/cache@v5
35+
with:
36+
path: ./storage/framework/rector
37+
key: ${{ runner.os }}-rector-${{ hashFiles('**/composer.lock') }}
38+
restore-keys: ${{ runner.os }}-rector-
39+
40+
- name: Run Rector
41+
run: ./vendor/bin/rector process --dry-run --ansi --no-progress-bar

.github/workflows/run-tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches: [v3]
6+
pull_request:
7+
branches: [v3]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: [8.5, 8.4, 8.3]
17+
laravel: [11.*,12.*]
18+
stability: [prefer-lowest, prefer-stable]
19+
include:
20+
- laravel: 10.*
21+
testbench: 8.*
22+
carbon: 2.*
23+
24+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
35+
coverage: none
36+
37+
- name: Setup problem matchers
38+
run: |
39+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
40+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
41+
42+
- name: Install dependencies
43+
run: |
44+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
45+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
46+
47+
- name: List Installed Dependencies
48+
run: composer show -D
49+
50+
- name: Execute tests
51+
run: vendor/bin/pest --ci

.github/workflows/update-changelog.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Update Changelog"
1+
name: 'Update Changelog'
22

33
on:
44
release:
@@ -26,6 +26,6 @@ jobs:
2626
- name: Commit updated CHANGELOG
2727
uses: stefanzweifel/git-auto-commit-action@v7
2828
with:
29-
branch: main
29+
branch: v3
3030
commit_message: Update CHANGELOG
31-
file_pattern: CHANGELOG.md
31+
file_pattern: CHANGELOG.md

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CLAUDE.md
2+
boost.json
3+
.github/copilot-instructions.md
4+
.mcp.json
5+
.vscode/mcp.json
6+
.junie/guidelines.md
7+
CHANGELOG.md
8+
resources/dist

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2+
"plugins": ["prettier-plugin-blade", "prettier-plugin-tailwindcss"],
23
"semi": false,
34
"singleQuote": true,
45
"trailingComma": "all"
5-
}
6+
}

README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/webard/filament-translatable.svg?style=flat-square)](https://packagist.org/packages/webard/filament-translatable)
44
[![Total Downloads](https://img.shields.io/packagist/dt/webard/filament-translatable.svg?style=flat-square)](https://packagist.org/packages/webard/filament-translatable)
5+
![Tests](https://github.com/webard/filament-translatable/actions/workflows/run-tests.yml/badge.svg)
6+
![PHPStan](https://github.com/webard/filament-translatable/actions/workflows/phpstan.yml/badge.svg)
7+
![Rector](https://github.com/webard/filament-translatable/actions/workflows/rector.yml/badge.svg)
58

69
Filament Translatable is a set of tools that help manage translations.
710

@@ -10,11 +13,10 @@ Filament Translatable is a set of tools that help manage translations.
1013
## Installation
1114

1215
| Filament Version | Filament Translate Field Version |
13-
|------------------|---------------------------|
14-
| 3.x | 2.x
15-
| 4.x | 3.x
16-
| 5.x | 3.x
17-
16+
| ---------------- | -------------------------------- |
17+
| 3.x | 2.x |
18+
| 4.x | 3.x |
19+
| 5.x | 3.x |
1820

1921
You can install the package via composer:
2022

@@ -28,7 +30,6 @@ Publish the assets:
2830
php artisan filament:assets
2931
```
3032

31-
3233
## Configuration
3334

3435
## With `spatie/laravel-translatable`
@@ -77,17 +78,16 @@ public function panel(Panel $panel): Panel
7778
->plugin(FilamentTranslatablePlugin::make());
7879
}
7980
```
80-
81+
8182
### Setting translatable locales
82-
83+
8384
To set up the locales that can be used to translate content, pass an array of locales to the `locales()` plugin method:
84-
85+
8586
```php
8687
FilamentTranslatablePlugin::make()
8788
->locales(['en', 'pl', 'fr']),
8889
```
8990

90-
9191
You can set locale labels using key => value array:
9292

9393
```php
@@ -99,6 +99,7 @@ FilamentTranslatablePlugin::make()
9999
```
100100

101101
Also, you can pass a Closure:
102+
102103
```php
103104
FilamentTranslatablePlugin::make()
104105
->locales(fn () => Language::pluck('code', 'name'))
@@ -217,7 +218,6 @@ TextInput::make('price')
217218
> [!CAUTION]
218219
> Be sure to set field-specific methods like `required()` or `requiredDefaultLocale()` **before** calling the `translatable()` method.
219220
220-
221221
### `Translations` component
222222

223223
By using the `Translations` component, you can easily configure your [form fields](https://filamentphp.com/docs/4.x/forms/fields/getting-started) to support multiple languages and provide translations for each locale.
@@ -248,7 +248,6 @@ Translations::make('translations')
248248
->locales(['en', 'es'])
249249
```
250250

251-
252251
#### Setting the translatable label for a particular field
253252

254253
You have the flexibility to customize the translation label for each field in each locale. You can use the `fieldTranslatableLabel()` method to provide custom labels based on the field instance and the current locale.
@@ -310,7 +309,7 @@ Translations::make('translations')
310309

311310
```
312311

313-
#### Adding action
312+
#### Adding action
314313

315314
You may add actions before each container of child components using the `actions()` method:
316315

@@ -344,7 +343,6 @@ Translations::make()
344343
])
345344
```
346345

347-
348346
#### Injecting the locale to form field
349347

350348
If you wish to access the current locale instance for the field, define a `$locale` parameter:
@@ -359,11 +357,12 @@ Translations::make()
359357
```
360358

361359
#### Removing the styled container
360+
362361
By default, the translate component and its content are wrapped in a container styled as a card. You may remove the styled container using `contained()`:
363362

364363
```php
365364
use Webard\FilamentTranslatable\Forms\Component\Translations;
366-
365+
367366
Translations::make()
368367
->contained(false)
369368
```
@@ -374,7 +373,7 @@ You can display translations as vertical tabs:
374373

375374
```php
376375
use Webard\FilamentTranslatable\Forms\Component\Translations;
377-
376+
378377
Translations::make()
379378
->vertical()
380379
```
@@ -385,27 +384,30 @@ You can customize plugin settings directly on the component:
385384

386385
```php
387386
use Webard\FilamentTranslatable\Forms\Component\Translations;
388-
387+
389388
Translations::make()
390389
->displayNamesInLocaleLabels(false)
391390
->displayFlagsInLocaleLabels(true)
392391
->flagWidth('48px')
393392
```
394393

395-
#### Exclude
394+
#### Exclude
395+
396396
The `exclude` feature allows you to specify fields that you don't want to include in the translation process. This can be useful for fields that contain dynamic content or that shouldn't be translated into other languages.
397397

398398
```php
399399
use Webard\FilamentTranslatable\Forms\Component\Translations;
400-
400+
401401
Translations::make('translations')
402402
->schema([
403403
Forms\Components\TextInput::make('title'),
404404
Forms\Components\TextInput::make('description'),
405405
])
406406
->exclude(['description'])
407407
```
408+
408409
Without `exclude`:
410+
409411
```json
410412
{
411413
"title": {
@@ -420,7 +422,9 @@ Without `exclude`:
420422
}
421423
}
422424
```
425+
423426
With `exclude`:
427+
424428
```json
425429
{
426430
"title": {
@@ -431,6 +435,7 @@ With `exclude`:
431435
"description": null
432436
}
433437
```
438+
434439
## Publishing Views
435440

436441
To publish the views, run:
@@ -467,4 +472,3 @@ If you discover any security-related issues, please email code@webard.me instead
467472
## License
468473

469474
Filament Translatable is open-sourced software licensed under the [MIT license](LICENSE.md).
470-

0 commit comments

Comments
 (0)