From 04cbce74127d52545ee8b7ff481a7fe0f6031f19 Mon Sep 17 00:00:00 2001 From: Salem Code Date: Tue, 15 Oct 2024 00:51:54 +0300 Subject: [PATCH 1/2] Fix Change the wrong part of the translation file --- src/Actions/SyncPhrasesAction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Actions/SyncPhrasesAction.php b/src/Actions/SyncPhrasesAction.php index 68c1b47..a0379d6 100644 --- a/src/Actions/SyncPhrasesAction.php +++ b/src/Actions/SyncPhrasesAction.php @@ -27,7 +27,7 @@ public static function execute(Translation $source, $key, $value, $locale, $file $isRoot = $file === $locale.'.json' || $file === $locale.'.php'; $extension = pathinfo($file, PATHINFO_EXTENSION); - $filePath = str_replace('.'.$extension, '', str_replace($locale.DIRECTORY_SEPARATOR, '', $file)); + $filePath = str_replace('.'.$extension, '', preg_replace('/^'.$locale.DIRECTORY_SEPARATOR, '', $file)); $translationFile = TranslationFile::firstOrCreate([ 'name' => $filePath, From c81fc9940bc083686d20d6afcb7a947dd71c1ecf Mon Sep 17 00:00:00 2001 From: Salem Code Date: Tue, 15 Oct 2024 01:03:55 +0300 Subject: [PATCH 2/2] Fix the regex --- src/Actions/SyncPhrasesAction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Actions/SyncPhrasesAction.php b/src/Actions/SyncPhrasesAction.php index a0379d6..cb44eb9 100644 --- a/src/Actions/SyncPhrasesAction.php +++ b/src/Actions/SyncPhrasesAction.php @@ -27,7 +27,7 @@ public static function execute(Translation $source, $key, $value, $locale, $file $isRoot = $file === $locale.'.json' || $file === $locale.'.php'; $extension = pathinfo($file, PATHINFO_EXTENSION); - $filePath = str_replace('.'.$extension, '', preg_replace('/^'.$locale.DIRECTORY_SEPARATOR, '', $file)); + $filePath = str_replace('.'.$extension, '', preg_replace('/^' . preg_quote($locale . DIRECTORY_SEPARATOR, '/') . '/', '', $file)); $translationFile = TranslationFile::firstOrCreate([ 'name' => $filePath,