If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / Language files -checking existence and loading

Language files -checking existence and loading

Started by oldngrey on 11 Mar 2023, 7:56 AM · Views: 1,302

Results 1 to 5 of 5
11 Mar 2023, 7:56 AM
#1
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
433
Plugin Contributions:
0

Post #1 by oldngrey

zc158 - this is not a bug so if inappropriate please move to a more convenient discussion location.

With zc158 I am trying to understand about loading language files to enable the:
. payment plugin SecurePayXML
. shipping plugin AuPost
. ot-total module paymentmoduelfee
. to work better with PHP8.2 and edit orders and still operate with zc157d.

In admin/modules.php

at approx line 182 the $languageLoader->hasLanguageFile is called and passes

(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $file, '/modules/' . $module_type)

$module_type does not require the folder slash "/" on the end as this is added in the public function hasLanguageFile in /includes/classes/ResourceLoaders/LanguageLoader.php
This function looks for the pre zc158 language file first and if it exists returns true else it looks for the zc158 lang.language file and if it exists returns true

When control is passed back to admin/modules.php

the $languageLoader->loadExtraLanguageFiles(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $file, '/modules/' . $module_type);

is called in /includes/classes/ResourceLoaders/LangaugeLoader.php

The public function loadExtraLanguageFiles calls the arrayLoader 
    
$this->arrayLoader->loadExtraLanguageFiles($rootPath, $language, $fileName, $extraPath);
with the original $extrapath but does not append the folder slash "/" nor does it look for the zc158 lang.language file.

I'm looking for assistance to understand how this is supposed to work.

OldNGrey
ZC222 PHP 8.4.27
MySQL 11.8.5-MariaDB

11 Mar 2023, 10:39 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #2 by swguy

If you think you have found a bug, would you please express it at a higher level and provide reproduction steps?

For example, is there an issue when running the plugin Payment Module Fee that you're unsure how to solve? If so, please post the log and the steps for producing it.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Mar 2023, 4:11 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #3 by mc12345678

OldNGrey:

zc158 - this is not a bug so if inappropriate please move to a more convenient discussion location.

With zc158 I am trying to understand about loading language files to enable the:
. payment plugin SecurePayXML
. shipping plugin AuPost
. ot-total module paymentmoduelfee
. to work better with PHP8.2 and edit orders and still operate with zc157d.

In admin/modules.php

at approx line 182 the $languageLoader->hasLanguageFile is called and passes

(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $file, '/modules/' . $module_type)

$module_type does not require the folder slash "/" on the end as this is added in the public function hasLanguageFile in /includes/classes/ResourceLoaders/LanguageLoader.php
This function looks for the pre zc158 language file first and if it exists returns true else it looks for the zc158 lang.language file and if it exists returns true

When control is passed back to admin/modules.php

the $languageLoader->loadExtraLanguageFiles(DIR_FS_CATALOG . DIR_WS_LANGUAGES, $_SESSION['language'], $file, '/modules/' . $module_type);

is called in /includes/classes/ResourceLoaders/LangaugeLoader.php

The public function loadExtraLanguageFiles calls the arrayLoader 
    
$this->arrayLoader->loadExtraLanguageFiles($rootPath, $language, $fileName, $extraPath);
with the original $extrapath but does not append the folder slash "/" nor does it look for the zc158 lang.language file.

I'm looking for assistance to understand how this is supposed to work.

May i suggest looking at this document link about loading language files when trying to support 1.5.8 along with previous versions: https://docs.zen-cart.com/dev/code/158_language_files/#loading-a-language-file

Does that guidance resolve your concerns and difficulties?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Mar 2023, 5:14 AM
#4
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
433
Plugin Contributions:
0

Post #4 by oldngrey

I have read the documentation.

My main problem has been trying to make plugins work with both zc157 and zc158 and having constants not being defined before initial loading of the data.
I'll probably just produce separate versions.

OldNGrey
ZC222 PHP 8.4.27
MySQL 11.8.5-MariaDB

15 Mar 2023, 10:49 AM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Post #5 by torvista

I decided that it was a neater solution (visually, when comparing filesets of zencarts and plugins), to leave plugins/add-on code using the old language file format.
It keeps core and add-on visually separate and still works. Much effort has gone into making the two methods work together and that's not going anywhere anytime soon.

Attachment 20228

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...