/** * Manages the output for a translation of a given model object, and the required field. It will * use the language that is being used by the user and then return the value for that given field and * language code. * * @param Entity $model * @param string $field */ function lang(\Tectonic\LaravelLocalisation\Translator\Translated\Entity $model, $field) { $languageCode = \Tectonic\Shift\Library\Facades\CurrentLocale::code(); if (isset($model->{$field}[$languageCode])) { return $model->{$field}[$languageCode]; } // No Translation Available return '<<NTA>>'; }
public function testInvalidLanguageCodeCheck() { CurrentLocale::shouldReceive('code')->once()->andReturn('lkasdljsdf'); $this->assertEquals('<<NTA>>', lang($this->model, 'title')); }
public function compose() { App::setLocale(CurrentLocale::code()); }
public function testLocaleSetup() { CurrentLocale::shouldReceive('code')->once()->andReturn('code'); App::shouldReceive('setLocale')->with('code')->once(); with(new LocaleComposer())->compose(); }