Skip to content

Commit 234241c

Browse files
committed
Laravel 6 compat
1 parent d8a7a0c commit 234241c

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/Service/SourceEditSync.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tio\Laravel\Service;
44

5+
use Illuminate\Support\Str;
56
use Tio\Laravel\SourceSaver;
67
use Carbon\Carbon;
78
use GuzzleHttp\Client;
@@ -137,7 +138,7 @@ private function timestampFromMetadataContent($metadataContent)
137138

138139
private function throwErrorIfConflictInMetadata($metadataContent)
139140
{
140-
if (str_contains($metadataContent, ['>>>>', '<<<<'])) {
141+
if (Str::contains($metadataContent, ['>>>>', '<<<<'])) {
141142
$metadataFilePath = $this->metadataFilePath();
142143
throw new SourceEditSyncException($metadataFilePath . " file is corrupted and seems to have unresolved versioning conflicts. Please resolve them and try again.");
143144
}

src/SourceSaver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tio\Laravel;
44

5+
use Illuminate\Support\Str;
56
use Tio\Laravel\PrettyVarExport;
67
use Illuminate\Contracts\Foundation\Application;
78
use Illuminate\Filesystem\Filesystem;
@@ -40,7 +41,7 @@ public function call($sourceEdit, $sourceLocale)
4041

4142
// Adapt $group and $dir if the key contains subfolders:
4243
// https://laravel.io/forum/02-23-2015-localization-load-files-from-subdirectories-at-resourceslanglocale)
43-
if (str_contains($key, '/')) {
44+
if (Str::contains($key, '/')) {
4445
$subFolders = explode('/', $key);
4546
array_pop($subFolders);
4647
$dir = join(DIRECTORY_SEPARATOR, array_merge([$dir], $subFolders));
@@ -89,7 +90,7 @@ private function group($key)
8990
{
9091
$foldersAndGroup = explode('.', $key)[0];
9192

92-
if (str_contains($foldersAndGroup, '/')) {
93+
if (Str::contains($foldersAndGroup, '/')) {
9394
$parts = explode('/', $foldersAndGroup);
9495
return array_pop($parts);
9596
}

src/TranslationExtractor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Foundation\Application;
66
use Illuminate\Filesystem\Filesystem;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Translation\Translator;
89
use SplFileInfo;
910
use Symfony\Component\Finder\Finder;
@@ -53,7 +54,7 @@ public function call($locale)
5354
$group = $file->getBasename('.' . $file->getExtension());
5455
$relativePath = $file->getRelativePath();
5556

56-
$data = array_dot([
57+
$data = Arr::dot([
5758
$group => $this->translator->getLoader()->load($locale, $relativePath . DIRECTORY_SEPARATOR . $group)
5859
]);
5960

src/TranslationSaver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Tio\Laravel;
44

55
use Illuminate\Contracts\Foundation\Application;
6+
use Illuminate\Support\Arr;
7+
use Illuminate\Support\Str;
68
use Tio\Laravel\PrettyVarExport;
79
use Illuminate\Filesystem\Filesystem;
810
use Illuminate\Translation\Translator;
@@ -43,7 +45,7 @@ public function call($locale, $translationsDotted)
4345

4446
foreach ($translationsDotted as $key => $value) {
4547
if ($value !== '' && ! is_null($value)) {
46-
array_set($translationsWithGroups, $key, $value);
48+
Arr::set($translationsWithGroups, $key, $value);
4749
}
4850
}
4951

@@ -59,7 +61,7 @@ private function save($locale, $group, $translations)
5961

6062
// Adapt $group and $dir if key contains subfolders:
6163
// https://laravel.io/forum/02-23-2015-localization-load-files-from-subdirectories-at-resourceslanglocale)
62-
if (str_contains($group, '/')) {
64+
if (Str::contains($group, '/')) {
6365
$subFolders = explode('/', $group);
6466
$group = array_pop($subFolders);
6567
$dir = join(DIRECTORY_SEPARATOR, array_merge([$dir], $subFolders));

0 commit comments

Comments
 (0)