I have been working in a localization project ,in my app the language translation files are not loading in some pages.I don't know what wrong with my loadPath
function.
In my app user can change there language on profile section and the changes works perfectly on the same session.But When the user logout and login to the app at first the user not seen the his/her preferred language.
Here my code
protected function loadPath($path, $locale, $group)
{
if ( App::runningInConsole() ) {
return parent::loadPath( $path, $locale, $group );
}
$domain = get_subdomain();
$dir = "lang/{$locale}/{$domain}";
$key = $dir.'/'.$group.'.php';
if(\Session::has($key)){
$results = \Session::get($key);
$d = json_encode($results);
view::share('lang',$d);
return $results;
}else{
$this->s3 = App::make('aws')->factory(tenent_aws_config())->get('s3');
$domain = get_subdomain();
$bucket = "localbulkload";
$dir = "lang/{$locale}/{$domain}";
$langList = $this->s3->getIterator('ListObjects',[
"Bucket" => $bucket,
'Prefix' => "lang/$locale/{$domain}"
]);
foreach ($langList as $langObject){
$object = $this->s3->getObject([
"Bucket" => $bucket,
"Key" => $langObject['Key']
]);
$key = $langObject['Key'];
$string = ($object['Body']);
$results = eval("?>$string");
\Session::put($key,$results,60);
}
$info = $this->s3->doesObjectExist(
$bucket,
$dir . "/" . $group . ".php");
if ($info === false) {
if($this->files->exists($full = "{$path}/template/{$group}.php")) {
$results = $this->files->getRequire($full);
$d = json_encode($results);
view::share('lang',$d);
return $results;
}
else{
$this->files->exists($full = "{$path}/en/{$group}.php");
$results = $this->files->getRequire($full);
$d = json_encode($results);
view::share('lang',$d);
return $results;
}
}
}
return array();
}
How can I solve this?