Zen Cart Logo
Forums / Bug Reports / Language files -checking existence and loading

Language files -checking existence and loading

Views: 1,272

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

oldngrey

Zen Follower

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

Language files -checking existence and loading

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.

11 Mar 2023, 10:39
#2
swguy avatar

swguy

Administrator

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

Re: Language files -checking existence and loading

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.

12 Mar 2023, 16:11
#3
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Language files -checking existence and loading

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?

15 Mar 2023, 05:14
#4
oldngrey avatar

oldngrey

Zen Follower

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

Re: Language files -checking existence and loading

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.

15 Mar 2023, 10:49
#5
torvista avatar

torvista

Totally Zenned

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

Re: Language files -checking existence and loading

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