lautaroangelico / WebEngine

WebEngine is an open-source, fast and secure CMS for private Mu Online game servers.
MIT License
114 stars 61 forks source link

Regarding how the official plugins load language files #65

Open amarillonmc opened 4 months ago

amarillonmc commented 4 months ago

In all of the officially provided plugins loader.php, there are this snippet that decides which language to load: (Example Taken from Change Class Plugin)

// language phrases
if(file_exists(__PATH_CHANGECLASS_ROOT__ . 'languages/'.config('language_default', true).'/language.php')) {
    // attempt to load same language as website
    if(!@include_once(__PATH_CHANGECLASS_ROOT__ . 'languages/'.config('language_default', true).'/language.php')) throw new Exception('Error loading language file (changeclass).');
} else {
    // load default language file (en)
    if(!@include_once(__PATH_CHANGECLASS_ROOT__ . 'languages/en/language.php')) throw new Exception('Error loading language file (changeclass).');

 }

However, it only checks for the language_default value in the configs, and not $_SESSION['language_display'], which means even if a translation is provided by populating the language.php file, and the user switched to said language, the plugin language will still be in the language_default value, defeating the purpose of multi-language.

Please advise, thanks.