コード例 #1
0
 public function test_to_array_and_fallback_with_country_based_locales_enabled()
 {
     $this->app->config->set('translatable.use_fallback', true);
     $this->app->config->set('translatable.fallback_locale', 'fr');
     $this->app->config->set('translatable.locales', ['en' => ['GB'], 'fr']);
     $this->app->config->set('translatable.locale_separator', '-');
     $data = ['id' => 1, 'fr' => ['name' => 'frites']];
     Food::create($data);
     $fritesArray = Food::find(1)->toArray();
     $this->assertSame('frites', $fritesArray['name']);
 }
コード例 #2
0
 public function test_fallback_for_country_based_locales()
 {
     $this->app->config->set('translatable.use_fallback', true);
     $this->app->config->set('translatable.fallback_locale', 'fr');
     $this->app->config->set('translatable.locales', ['en' => ['US', 'GB'], 'fr']);
     $this->app->config->set('translatable.locale_separator', '-');
     $data = ['id' => 1, 'fr' => ['name' => 'frites'], 'en-GB' => ['name' => 'chips'], 'en' => ['name' => 'french fries']];
     Food::create($data);
     $fries = Food::find(1);
     $this->assertSame('french fries', $fries->getTranslation('en-US')->name);
 }