Skip to content

Commit

Permalink
Laravel 9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed Apr 20, 2022
1 parent c19366c commit a9f0a6d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-artisan-translations` will be documented in this file

## 2.0.0 - 2022-04-20

- Laravel 9 compatibility

## 1.0.0 - 2017-06-01

- initial release
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,33 @@ Now add the service provider in `config/app.php` file:
### Add translations from a single file

```php
php artisan translations:add vendor/typicms/pages/src/resources/lang/fr.json
php artisan translations:add vendor/typicms/pages/src/lang/fr.json
```

Every translations present in this file will be added to ```/resources/lang/fr.json```.
Every translations present in this file will be added to `/lang/fr.json`.

### Add translations from a directory

```php
php artisan translations:add vendor/typicms/pages/src/resources/lang
php artisan translations:add vendor/typicms/pages/src/lang
```

Every translations found in this directory will be added to ```/resources/lang```
Every translations found in this directory will be added to `/lang`

### Overwrite translations

By default, translation keys will not be overwritten. You can use the ```--force``` option to overwrite existing keys:
By default, translation keys will not be overwritten. You can use the `--force` option to overwrite existing keys:

### Remove translations

```php
php artisan translations:remove vendor/typicms/pages/src/resources/lang[/lg.json]
php artisan translations:remove vendor/typicms/pages/src/lang[/lg.json]
```

Every translations found in this file/directory will be removed from ```/resources/lang```

Every translations found in this file/directory will be removed from `/lang`

```php
php artisan translations:add vendor/typicms/pages/src/resources/lang --force
php artisan translations:add vendor/typicms/pages/src/lang --force
```

## Changelog
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
}
],
"require": {
"php": "^7.0|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"php": "^8.0.2",
"illuminate/console": "^9.0",
"illuminate/filesystem": "^9.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Commands/AddTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class AddTranslations extends AbstractTranslations
public function handle()
{
foreach ($this->getFiles() as $file) {
$targetDirectory = resource_path('lang');
$targetDirectory = lang_path();
$targetPath = $targetDirectory.'/'.$file->getBasename();
if ($this->files->missing($targetDirectory)) {
$this->files->makeDirectory($targetDirectory);
}
if ($this->files->missing($targetPath)) {
$this->files->copy($file->getPathname(), $targetPath);
$this->info($targetPath.' created.');

continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/RemoveTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RemoveTranslations extends AbstractTranslations
public function handle()
{
foreach ($this->getFiles() as $file) {
$mainFile = resource_path('lang/'.basename($file));
$mainFile = lang_path(basename($file));

$existingTranslations = $this->getTranslations($mainFile);
$newTranslations = $this->getTranslations($file);
Expand Down

0 comments on commit a9f0a6d

Please sign in to comment.