Skip to content

Commit 9bb528d

Browse files
committed
Add translation keys for loading messages and implement Dutch translations
1 parent 4f8e794 commit 9bb528d

File tree

7 files changed

+86
-4
lines changed

7 files changed

+86
-4
lines changed

.phpunit.cache/test-results

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/lang/en/flowforge.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

33
return [
4-
// Flowforge translation keys will be added here as needed
4+
'loading_more_cards' => 'Loading more cards...',
5+
'no_cards_in_column' => 'No :cardLabel in this column',
6+
'cards_count' => '{0} :cards|{1} :card|[2,*] :cards',
57
];

resources/lang/nl/flowforge.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
'loading_more_cards' => 'Meer kaarten laden...',
5+
'no_cards_in_column' => 'Geen :cardLabel in deze kolom',
6+
'cards_count' => '{0} :cards|{1} :card|[2,*] :cards',
7+
];

resources/views/livewire/column.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class="ff-column__loader"
6060
>
6161
<div wire:loading wire:target="loadMoreItems('{{ $columnId }}')"
6262
class="ff-column__loading-text">
63-
{{ __('Loading more cards...') }}
63+
{{ __('flowforge::flowforge.loading_more_cards') }}
6464
<div class="mt-1 flex justify-center">
6565
<svg class="animate-spin h-4 w-4 text-primary-600 dark:text-primary-400"
6666
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">

resources/views/livewire/empty-column.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
class="ff-empty-column__icon"
77
/>
88
<p class="ff-empty-column__text">
9-
{{ __('No :cardLabel in this column', ['cardLabel' => strtolower($pluralCardLabel)]) }}
9+
{{ __('flowforge::flowforge.no_cards_in_column', ['cardLabel' => strtolower($pluralCardLabel)]) }}
1010
</p>
1111
</div>

src/FlowforgeServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function configurePackage(Package $package): void
3333
->hasInstallCommand(function (InstallCommand $command) {
3434
$command
3535
->publishConfigFile()
36+
->publishMigrations()
37+
->askToRunMigrations()
3638
->askToStarRepoOnGitHub('relaticle/flowforge');
3739
});
3840

tests/Feature/TranslationTest.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\App;
4+
use Relaticle\Flowforge\FlowforgeServiceProvider;
5+
6+
test('translation files exist for supported languages', function () {
7+
$englishPath = __DIR__ . '/../../resources/lang/en/flowforge.php';
8+
$dutchPath = __DIR__ . '/../../resources/lang/nl/flowforge.php';
9+
10+
expect(file_exists($englishPath))->toBeTrue();
11+
expect(file_exists($dutchPath))->toBeTrue();
12+
});
13+
14+
test('english translation file contains required keys', function () {
15+
$translations = require __DIR__ . '/../../resources/lang/en/flowforge.php';
16+
17+
$requiredKeys = [
18+
'loading_more_cards',
19+
'no_cards_in_column',
20+
'cards_count',
21+
];
22+
23+
foreach ($requiredKeys as $key) {
24+
expect($translations)->toHaveKey($key)
25+
->and($translations[$key])->not->toBeEmpty();
26+
}
27+
});
28+
29+
test('dutch translation file contains same keys as english', function () {
30+
$englishTranslations = require __DIR__ . '/../../resources/lang/en/flowforge.php';
31+
$dutchTranslations = require __DIR__ . '/../../resources/lang/nl/flowforge.php';
32+
33+
expect(array_keys($dutchTranslations))->toEqual(array_keys($englishTranslations));
34+
});
35+
36+
test('translation keys resolve correctly', function () {
37+
App::setLocale('en');
38+
39+
expect(__('flowforge::flowforge.loading_more_cards'))->toBe('Loading more cards...')
40+
->and(__('flowforge::flowforge.no_cards_in_column', ['cardLabel' => 'tasks']))->toBe('No tasks in this column');
41+
});
42+
43+
test('dutch translations resolve correctly', function () {
44+
App::setLocale('nl');
45+
46+
expect(__('flowforge::flowforge.loading_more_cards'))->toBe('Meer kaarten laden...')
47+
->and(__('flowforge::flowforge.no_cards_in_column', ['cardLabel' => 'taken']))->toBe('Geen taken in deze kolom');
48+
});
49+
50+
test('card count pluralization works correctly', function () {
51+
App::setLocale('en');
52+
53+
// Test singular
54+
$singular = trans_choice('flowforge::flowforge.cards_count', 1, ['card' => 'card', 'cards' => 'cards']);
55+
expect($singular)->toBe('card');
56+
57+
// Test plural
58+
$plural = trans_choice('flowforge::flowforge.cards_count', 5, ['card' => 'card', 'cards' => 'cards']);
59+
expect($plural)->toBe('cards');
60+
61+
// Test zero
62+
$zero = trans_choice('flowforge::flowforge.cards_count', 0, ['card' => 'card', 'cards' => 'cards']);
63+
expect($zero)->toBe('cards');
64+
});
65+
66+
test('service provider has translation support enabled', function () {
67+
// Check if the service provider enables translations via hasTranslations()
68+
$serviceProviderPath = __DIR__ . '/../../src/FlowforgeServiceProvider.php';
69+
$content = file_get_contents($serviceProviderPath);
70+
71+
expect($content)->toContain('$package->hasTranslations()');
72+
});

0 commit comments

Comments
 (0)