Skip to content

Commit

Permalink
add missing phrases related to issues MohmmedAshraf#111
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalcraftlabs committed Jan 13, 2025
1 parent 779348a commit 72ce93e
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 67 deletions.
2 changes: 1 addition & 1 deletion config/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@
|
*/
'exclude_files' => [
//'validation.php', // Exclude default validation for example.
// 'validation.php', // Exclude default validation for example.
],
];
2 changes: 1 addition & 1 deletion database/migrations/create_phrases_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function up(): void
{
Schema::create('ltu_phrases', function (Blueprint $table) {
$table->id();
$table->char('uuid', 36);;
$table->char('uuid', 36);
$table->foreignIdFor(Translation::class)->constrained('ltu_translations')->cascadeOnDelete();
$table->foreignIdFor(TranslationFile::class)->constrained('ltu_translation_files')->cascadeOnDelete();
$table->foreignIdFor(Phrase::class)->nullable()->constrained('ltu_phrases')->cascadeOnDelete();
Expand Down
8 changes: 5 additions & 3 deletions src/Actions/SyncPhrasesAction.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Outhebox\TranslationsUI\Actions;
namespace App\Actions;

use Outhebox\TranslationsUI\Models\Language;
use Outhebox\TranslationsUI\Models\Translation;
use Outhebox\TranslationsUI\Models\TranslationFile;

class SyncPhrasesAction
class SyncPhrasesActionForked
{
public static function execute(Translation $source, $key, $value, $locale, $file): void
{
Expand Down Expand Up @@ -44,7 +44,9 @@ public static function execute(Translation $source, $key, $value, $locale, $file
], [
'value' => (empty($value) ? null : $value),
'parameters' => getPhraseParameters($value),
'phrase_id' => $translation->source ? null : $source->phrases()->where('key', $key)->first()?->id,
'phrase_id' => $translation->source ? null : $source->phrases()->where('translation_file_id', $translationFile->id)
->where('group', $translationFile->name)
->where('key', $key)->first()?->id,
]);
}
}
2 changes: 1 addition & 1 deletion src/Console/Commands/ImportTranslationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function syncMissingTranslations(Translation $source, string $locale): vo
$source->load('phrases.translation', 'phrases.file');

$source->phrases->each(function ($phrase) use ($translation, $locale) {
if (! $translation->phrases()->where('key', $phrase->key)->first()) {
if (! $translation->phrases()->where('group', $phrase->group)->where('key', $phrase->key)->first()) {
$fileName = $phrase->file->name.'.'.$phrase->file->extension;

if ($phrase->file->name === config('translations.source_language')) {
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ protected function setUp(): void
protected function refreshTestDatabase(): void
{
if (! RefreshDatabaseState::$migrated) {
//$this->artisan('vendor:publish', ['--tag' => 'mixpost-migrations', '--force' => true])->run();
//$this->artisan('migrate:fresh', $this->migrateFreshUsing());
// $this->artisan('vendor:publish', ['--tag' => 'mixpost-migrations', '--force' => true])->run();
// $this->artisan('migrate:fresh', $this->migrateFreshUsing());

$this->app[Kernel::class]->setArtisan(null);

Expand Down
Loading

0 comments on commit 72ce93e

Please sign in to comment.