Browse Source

Generate lang app.php for "id" locale

tags/0.1.6^0 0.1.6
Nafies Luthfi 8 years ago
parent
commit
d86aabad83
  1. 11
      src/Generators/LangFileGenerator.php
  2. 18
      src/stubs/lang-app-id.stub
  3. 2
      src/stubs/lang-app.stub
  4. 34
      tests/Generators/LangGeneratorTest.php

11
src/Generators/LangFileGenerator.php

@ -68,6 +68,15 @@ class LangFileGenerator extends BaseGenerator
*/
private function getAppLangFileContent()
{
return $this->files->get(__DIR__.'/../stubs/lang-app.stub');
$locale = config('app.locale');
$langStubPath = __DIR__.'/../stubs/lang-app-'.$locale.'.stub';
if ($this->files->exists($langStubPath)) {
$stub = $this->files->get($langStubPath);
} else {
$stub = $this->files->get(__DIR__.'/../stubs/lang-app.stub');
}
return $stub;
}
}

18
src/stubs/lang-app-id.stub

@ -0,0 +1,18 @@
<?php
return [
// Labels
'table_no' => '#',
'total' => 'Total',
'action' => 'Pilihan',
'show_detail_title' => 'Lihat detail :type :name',
// Actions
'show' => 'Lihat Detail',
'edit' => 'Edit',
'delete' => 'Hapus',
'cancel' => 'Batal',
'reset' => 'Reset',
'delete_confirm' => 'Anda yakin akan menghapus?',
'delete_confirm_button' => 'YA, hapus saja!',
];

2
src/stubs/lang-app.stub

@ -5,8 +5,6 @@ return [
'table_no' => '#',
'total' => 'Total',
'action' => 'Actions',
'views' => 'Views',
'downloads' => 'Downloads',
'show_detail_title' => 'View :name :type detail',
// Actions

34
tests/Generators/LangGeneratorTest.php

@ -109,8 +109,6 @@ return [
'table_no' => '#',
'total' => 'Total',
'action' => 'Actions',
'views' => 'Views',
'downloads' => 'Downloads',
'show_detail_title' => 'View :name :type detail',
// Actions
@ -125,4 +123,36 @@ return [
";
$this->assertEquals($appLangContent, file_get_contents($langPath));
}
/** @test */
public function it_creates_app_lang_based_on_locale_if_stub_exists()
{
config(['app.locale' => 'id']);
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$locale = config('app.locale');
$langPath = resource_path('lang/'.$locale.'/app.php');
$this->assertFileExists($langPath);
$appLangContent = "<?php
return [
// Labels
'table_no' => '#',
'total' => 'Total',
'action' => 'Pilihan',
'show_detail_title' => 'Lihat detail :type :name',
// Actions
'show' => 'Lihat Detail',
'edit' => 'Edit',
'delete' => 'Hapus',
'cancel' => 'Batal',
'reset' => 'Reset',
'delete_confirm' => 'Anda yakin akan menghapus?',
'delete_confirm_button' => 'YA, hapus saja!',
];
";
$this->assertEquals($appLangContent, file_get_contents($langPath));
}
}
Loading…
Cancel
Save