Skip to content

Commit

Permalink
LanguageFile Registration improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Nov 26, 2024
1 parent 3a0aa4a commit 7069916
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/Domain/Menu/Repositories/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ class Menu
'submenu' => [
5 => ['type' => 'item', 'module' => 'timesheets', 'role' => 'manager', 'title' => 'menu.all_timesheets', 'icon' => 'fa fa-fw fa-business-time', 'tooltip' => 'menu.all_timesheets_tooltip', 'href' => '/timesheets/showAll', 'active' => ['showAll']],
10 => ['type' => 'item', 'module' => 'projects', 'role' => 'manager', 'title' => 'menu.all_projects', 'icon' => 'fa fa-fw fa-briefcase', 'tooltip' => 'menu.all_projects_tooltip', 'href' => '/projects/showAll', 'active' => ['showAll']],
15 => ['type' => 'item', 'module' => 'clients', 'role' => 'administrator', 'title' => 'menu.all_clients', 'icon' => 'fa fa-fw fa-address-book', 'tooltip' => 'menu.all_clients_tooltip', 'href' => '/clients/showAll', 'active' => ['showAll']],
20 => ['type' => 'item', 'module' => 'users', 'role' => 'administrator', 'title' => 'menu.all_users', 'icon' => 'fa fa-fw fa-users', 'tooltip' => 'menu.all_users_tooltip', 'href' => '/users/showAll', 'active' => ['showAll']],
15 => ['type' => 'item', 'module' => 'clients', 'role' => 'admin', 'title' => 'menu.all_clients', 'icon' => 'fa fa-fw fa-address-book', 'tooltip' => 'menu.all_clients_tooltip', 'href' => '/clients/showAll', 'active' => ['showAll']],
20 => ['type' => 'item', 'module' => 'users', 'role' => 'admin', 'title' => 'menu.all_users', 'icon' => 'fa fa-fw fa-users', 'tooltip' => 'menu.all_users_tooltip', 'href' => '/users/showAll', 'active' => ['showAll']],
],
],
15 => [
'type' => 'submenu', 'id' => 'administration', 'title' => 'menu.sidemenu_administration', 'visual' => 'open', 'role' => 'administrator',
'type' => 'submenu', 'id' => 'administration', 'title' => 'menu.sidemenu_administration', 'visual' => 'open', 'role' => 'admin',
'submenu' => [
5 => ['type' => 'item', 'module' => 'plugins', 'title' => 'menu.leantime_apps', 'icon' => 'fa fa-fw fa-puzzle-piece', 'tooltip' => 'menu.leantime_apps_tooltip', 'href' => '/plugins/marketplace', 'active' => ['marketplace', 'myapps']],
10 => ['type' => 'item', 'module' => 'connector', 'title' => 'menu.integrations', 'icon' => 'fa fa-fw fa-circle-nodes', 'tooltip' => 'menu.connector_tooltip', 'href' => '/connector/show', 'active' => ['show']],
Expand Down
21 changes: 15 additions & 6 deletions app/Domain/Plugins/Services/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,26 @@ public function registerLanguageFiles(array $languages)

//Always load en-Us as this is the default fallback language
if (! Cache::store('installation')->has($pluginId.'.language.en-US')) {
$languageArray += parse_ini_file(app_path().'/Plugins/'.$pluginId.'/Language/en-US.ini', true);

if(file_exists(app_path().'/Plugins/'.$pluginId.'/Language/en-US.ini')) {
$languageArray += parse_ini_file(
app_path() . '/Plugins/' . $pluginId . '/Language/en-US.ini',
true
);
}
}

if ((($userLanguage = session('usersettings.language') ?? $config->language) !== 'en-US') && in_array($userLanguage, $languages)) {

if (! Cache::store('installation')->has($pluginId.'.language.'.$userLanguage)) {
Cache::store('installation')->put(
$pluginId.'.language.'.$userLanguage,
parse_ini_file(app_path().'/Plugins/'.$pluginId.'/Language/'.$userLanguage.'.ini', true),
Carbon::now()->addDays(30)
);

if(file_exists(app_path().'/Plugins/'.$pluginId.'/Language/'.$userLanguage.'.ini')) {
Cache::store('installation')->put(
$pluginId.'.language.'.$userLanguage,
parse_ini_file(app_path().'/Plugins/'.$pluginId.'/Language/'.$userLanguage.'.ini', true),
Carbon::now()->addDays(30)
);
}
}

$languageArray = array_merge($languageArray, Cache::store('installation')->get($pluginId.'.language.'.$language));
Expand Down

0 comments on commit 7069916

Please sign in to comment.