1111
1212namespace Ahc \Cli \Test \Helper ;
1313
14+ use Ahc \Cli \Application ;
1415use Ahc \Cli \Helper \InflectsString ;
1516use PHPUnit \Framework \TestCase ;
1617
@@ -31,4 +32,28 @@ public function test_to_words()
3132 $ this ->assertSame ('The Long Name ' , $ this ->toWords ('--the_long-name ' ));
3233 $ this ->assertSame ('A BC ' , $ this ->toWords ('a_bC ' ));
3334 }
35+
36+ public function test_default_translate (): void
37+ {
38+ $ this ->assertSame ('Show version ' , $ this ->translate ('Show version ' ));
39+ $ this ->assertSame ('Verbosity level [default: 0] ' , $ this ->translate ('%s [default: %s] ' , ['Verbosity level ' , 0 ]));
40+ $ this ->assertSame ('Command "rmdir" already added ' , $ this ->translate ('Command "%s" already added ' , ['rmdir ' ]));
41+ }
42+
43+ public function test_custom_translations (): void
44+ {
45+ Application::addLocale ('fr ' , [
46+ 'Show version ' => 'Afficher la version ' ,
47+ '%s [default: %s] ' => '%s [par défaut: %s] ' ,
48+ 'Command "%s" already added ' => 'La commande "%s" a déjà été ajoutée '
49+ ], true );
50+
51+
52+ $ this ->assertSame ('Afficher la version ' , $ this ->translate ('Show version ' ));
53+ $ this ->assertSame ('Verbosity level [par défaut: 0] ' , $ this ->translate ('%s [default: %s] ' , ['Verbosity level ' , 0 ]));
54+ $ this ->assertSame ('La commande "rmdir" a déjà été ajoutée ' , $ this ->translate ('Command "%s" already added ' , ['rmdir ' ]));
55+
56+ // untranslated key
57+ $ this ->assertSame ('Show help ' , $ this ->translate ('Show help ' ));
58+ }
3459}
0 commit comments