Skip to content

Commit 2b1959a

Browse files
committed
Update localisation publish folder
1 parent e6b4cd6 commit 2b1959a

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
labels:
12+
- "dependencies"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can publish the translation files using:
3131
php artisan vendor:publish --tag="api-response-translations"
3232
```
3333

34-
This will create a vendor folder (if it doesn't exists) in the `./resources/lang` folder of your project and inside, a `laravel-api-response/en` folder that has two files: `errors.php` and `success.php`. Both files are used for the translation of message strings in the JSON response sent out.
34+
This will create a vendor folder (if it doesn't exists) in the `lang` folder of your project and inside, a `api-response/en` folder that has two files: `errors.php` and `success.php`. Both files are used for the translation of message strings in the JSON response sent out.
3535

3636
Optionally, you can publish the config file using:
3737

src/ApiResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function getTranslatedMessageMeta(string $message, array &$data, bool
141141
return [];
142142
}
143143

144-
$translationPrefix = 'laravel-api-response::'.config("api-response.translation.{$fileKey}");
144+
$translationPrefix = 'api-response::'.config("api-response.translation.{$fileKey}");
145145

146146
$translated = $this->extractTranslationDataFromResponsePayload($data, $message, $translationPrefix);
147147

src/LaravelApiResponseServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function register()
2323
*/
2424
public function boot()
2525
{
26-
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-api-response');
26+
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'api-response');
2727

2828
$this->configurePublishing();
2929
}
@@ -44,7 +44,7 @@ private function configurePublishing()
4444
], 'api-response-config');
4545

4646
$this->publishes([
47-
__DIR__."/../lang" => base_path("lang/vendor/api-response"),
47+
__DIR__.'/../resources/lang' => lang_path('vendor/api-response'),
4848
], 'api-response-translations');
4949
}
5050
}

tests/ApiResponseTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ public function testSuccessfulResponseMessageIsTranslatedCorrectly()
363363

364364
$this->assertTrue($responseDataA['success']);
365365
$this->assertTrue($responseDataB['success']);
366-
$this->assertSame(__('laravel-api-response::success.example_code'), $responseDataA['message']);
367-
$this->assertSame(__('laravel-api-response::success.Example response message'), $responseDataB['message']);
366+
$this->assertSame(__('api-response::success.example_code'), $responseDataA['message']);
367+
$this->assertSame(__('api-response::success.Example response message'), $responseDataB['message']);
368368
}
369369

370370
public function testErrorResponseMessageIsTranslatedCorrectly()
@@ -374,7 +374,7 @@ public function testErrorResponseMessageIsTranslatedCorrectly()
374374
$responseData = ApiResponse::create(400, 'Example Error')->getData(true);
375375

376376
$this->assertFalse($responseData['success']);
377-
$this->assertSame(__('laravel-api-response::errors.Example Error'), $responseData['message']);
377+
$this->assertSame(__('api-response::errors.Example Error'), $responseData['message']);
378378
}
379379

380380
public function testResponseWithErrorCodeAsMessageIsTranslatedCorrectly()
@@ -384,7 +384,7 @@ public function testResponseWithErrorCodeAsMessageIsTranslatedCorrectly()
384384
$responseData = ApiResponse::create(400, 'error_code.error_code_name')->getData(true);
385385

386386
$this->assertFalse($responseData['success']);
387-
$this->assertSame(__('laravel-api-response::errors.error_code.error_code_name'), $responseData['message']);
387+
$this->assertSame(__('api-response::errors.error_code.error_code_name'), $responseData['message']);
388388
$this->assertArrayHasKey('error_code', $responseData);
389389
$this->assertSame('error_code_name', $responseData['error_code']);
390390
}
@@ -399,7 +399,7 @@ public function testResponseMessageWithAttributesIsExpandedCorrectlyForSuccessfu
399399
$this->assertSame('A normal message', $responseDataA['message']);
400400
$this->assertNotSame('example_code:status=hurray!', $responseDataB['message']);
401401

402-
$translation = __('laravel-api-response::success.example_code', ['status' => 'hurray!']);
402+
$translation = __('api-response::success.example_code', ['status' => 'hurray!']);
403403

404404
$this->assertSame($translation, $responseDataB['message']);
405405
}
@@ -410,7 +410,7 @@ public function testResponseMessageWithAttributesIsExpandedCorrectlyForFailedRes
410410

411411
$this->assertNotSame('error_code.error_code_name:attribute=yes', $responseData['message']);
412412

413-
$translation = __('laravel-api-response::errors.error_code.error_code_name', ['attribute' => 'yes']);
413+
$translation = __('api-response::errors.error_code.error_code_name', ['attribute' => 'yes']);
414414

415415
$this->assertSame($translation, $responseData['message']);
416416
$this->assertArrayHasKey('error_code', $responseData);

tests/TranslatableTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getTranslatableArrayProvider()
6464
*/
6565
public function testGetTranslatedStringArray($key, $attributes, $prefix, $output)
6666
{
67-
$prefix = $prefix ? 'laravel-api-response::'.$prefix : $prefix;
67+
$prefix = $prefix ? 'api-response::'.$prefix : $prefix;
6868

6969
$result = $this->class->getTranslatedStringArray($key, $attributes, $prefix);
7070

0 commit comments

Comments
 (0)