Skip to content

Commit

Permalink
Laravel 6 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Sep 13, 2019
1 parent d8a7a0c commit 234241c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Service/SourceEditSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tio\Laravel\Service;

use Illuminate\Support\Str;
use Tio\Laravel\SourceSaver;
use Carbon\Carbon;
use GuzzleHttp\Client;
Expand Down Expand Up @@ -137,7 +138,7 @@ private function timestampFromMetadataContent($metadataContent)

private function throwErrorIfConflictInMetadata($metadataContent)
{
if (str_contains($metadataContent, ['>>>>', '<<<<'])) {
if (Str::contains($metadataContent, ['>>>>', '<<<<'])) {
$metadataFilePath = $this->metadataFilePath();
throw new SourceEditSyncException($metadataFilePath . " file is corrupted and seems to have unresolved versioning conflicts. Please resolve them and try again.");
}
Expand Down
5 changes: 3 additions & 2 deletions src/SourceSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tio\Laravel;

use Illuminate\Support\Str;
use Tio\Laravel\PrettyVarExport;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\Filesystem;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function call($sourceEdit, $sourceLocale)

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

if (str_contains($foldersAndGroup, '/')) {
if (Str::contains($foldersAndGroup, '/')) {
$parts = explode('/', $foldersAndGroup);
return array_pop($parts);
}
Expand Down
3 changes: 2 additions & 1 deletion src/TranslationExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Translation\Translator;
use SplFileInfo;
use Symfony\Component\Finder\Finder;
Expand Down Expand Up @@ -53,7 +54,7 @@ public function call($locale)
$group = $file->getBasename('.' . $file->getExtension());
$relativePath = $file->getRelativePath();

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

Expand Down
6 changes: 4 additions & 2 deletions src/TranslationSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Tio\Laravel;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Tio\Laravel\PrettyVarExport;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Translation\Translator;
Expand Down Expand Up @@ -43,7 +45,7 @@ public function call($locale, $translationsDotted)

foreach ($translationsDotted as $key => $value) {
if ($value !== '' && ! is_null($value)) {
array_set($translationsWithGroups, $key, $value);
Arr::set($translationsWithGroups, $key, $value);
}
}

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

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

0 comments on commit 234241c

Please sign in to comment.