Page 1 of 2

Changing Language Files

Posted: Wed Mar 19, 2025 11:40 am
by burt
The way that everyone knows

In the "good old days" of early Phoenix, if you wanted to make text changes in (eg) /includes/languages/english/account.php or any other language file you would do this in one of two ways;

1. FTP in, download the file, make your changes, upload the file
or
2. Use the admin/define_languages.php to make the changes

#1 is fine.
#2 was removed due to security concerns, so is now defunct

In both cases, it would be possible to lose your changes on an update to a newer Phoenix version, as Core might have changed the file you have already changed.

The template way

The architecture in Phoenix allows language files to be overridden in the template you are using. So, you can copy (eg) /includes/languages/english/account.php to templates/{tpl}/includes/languages/english/account.php and then make changes in that new file.

Upside of this new approach is that the new file inside your template will never get overwritten by Core.
Downside of this new approach is knowing what to do to actually copy the file from one location to another location (where that location might not yet exist);

1. FTP into /includes/languages/english/account.php
2. Download the file and make changes
3. FTP traverse from /english/ down to /languages/ down to /includes/
4. FTP traverse into /templates/ then into the /{tpl}/ you are using.

At this point depending on whether this has been done before...

If it has;
5. FTP traverse into /includes/ then into /languages/ then into /english/
6. Upload the new file.

If it has not;

5. Create /includes/ folder and traverse into it
6. Create /languages/ folder and traverse into it
7. Create /english/ folder and traverse into it
8. Upload file

Not difficult, but not straightforward for someone without much technical experience.

A potential solution
Language Explorer v4.zip
This little package adds in a new link in the admin > tools dropdown called "language explorer"
From there, this should link to a new language_explorer page.

That page should be self-explanatory. If anyone could find a minute to test it, I would be very thankful.

With this new tool, the `hard work` of creating/traversing folders using FTP is gone. FTP still needs to be used to download the file, notepad or whatever to change the file, and FTP to upload the file. So there is still some technical stuff, but it is greatly reduced.

Please let me know your thoughts/idea/comments/suggestions.
I'm all ears and would appreciate anyone taking the time.

Re: Changing Language Files

Posted: Thu Mar 20, 2025 11:54 am
by Kofod95
From a quick run through:
Handy tool, works well with multiple languages. Easy to use as is. Well done!

To make it more user friendly, maybe it could list the language-files in groups, based on where they are loaded?
Maybe also some sort of search function to find the file(s) containing specific strings.

//Daniel

Re: Changing Language Files

Posted: Thu Mar 20, 2025 12:43 pm
by burt
TY for feedback, appreciate you taking the time :+1:

If all the language stuff was in the Database, this would make grouping and searching etc super easy. Unfortunately moving to a DB language system would mean a major architecture change...which probably isn't something we'd want to look at right now, but might be a good idea at some point in the future.

There's not much more we can do with file based languages.

Re: Changing Language Files

Posted: Thu Mar 20, 2025 1:42 pm
by ecartz
burt wrote: Thu Mar 20, 2025 12:43 pm moving to a DB language system would mean a major architecture change...
We could do that as an add-on. Which I think would really demonstrate the flexibility of CE Phoenix Cart. It seems huge, but I think it could be done smaller than it first seems, entirely as a no-modified-code add-on.

It would require

1. A template so that it doesn't load most of the language files.
2. Implementing something that loads the base language defines from the database.
3. Implementing something that loads page-specific language defines from the database.
4. Implementing a no-op file that defines nothing so that we don't have to remove the existing require statements.

Optionally, it could load module and class language defines from the database, although that would be harder to integrate with other add-ons. Without this, we'd use a mix of methods. The base and page-specific translations would be in the database while the module and class defines would be in files.

Another alternative would be to mix them. If the database entries exist, do not use the files. If the files exist but the database entries do not, load them into the database. Then people could try it out and see how they like it. If it's popular, we could switch core. However, there would be no hurry in doing so, and we could leave the mixing code in for an extended period of time.

The code needed for that last is roughly the same size as the override template, as it could mostly be done in the template's class file. For everything but translations, it could just refer to the parent template.

Re: Changing Language Files

Posted: Thu Mar 20, 2025 3:24 pm
by burt
It's definitely something to consider, for sure. It would make the system even more flexible than it already is.

In the meantime this little tool might make the process of overriding a lang file a bit more straightforward.

Re: Changing Language Files

Posted: Fri Mar 21, 2025 7:33 am
by heatherbell
Kofod95 wrote: Thu Mar 20, 2025 11:54 am To make it more user friendly, maybe it could list the language-files in groups, based on where they are loaded?
Please test this?
Language Explorer v4 - Grouped.zip

Re: Changing Language Files

Posted: Fri Mar 21, 2025 6:20 pm
by Omar_one
Working as it should. well done
on our shop we are using two addon to editing the language file
one created by @zipurman app.php/addons/free_addon/language_search_edit/
This tool allows you to search all language files within any of your selected languages

and another one allows the shop owner to edit the text on any page in his shop which is located beneath the root directory
I like it because you can Select a language directory - Select a file

Re: Changing Language Files

Posted: Sat Mar 22, 2025 5:12 am
by heatherbell
Omar_one wrote: Fri Mar 21, 2025 6:20 pm Working as it should. well done
Thank you for testing.
Omar_one wrote: Fri Mar 21, 2025 6:20 pm on our shop we are using two addon to editing the language file
Both of those have the same issues associated with the 'old system' - see original post in this topic.

Language Explorer - latest version uses Accordion Drop Down for a better display:
Language Explorer v4 - Grouped Accordion.zip

Re: Changing Language Files

Posted: Sat Mar 22, 2025 5:52 am
by Omar_one
heatherbell wrote: Sat Mar 22, 2025 5:12 am Both of those have the same issues associated with the 'old system' - see original post in this topic.

I am working on another one ;) to pick the language folders from template folder update it
heatherbell wrote: Sat Mar 22, 2025 5:12 am Language Explorer - latest version uses Accordion Drop Down for a better display:
Language Explorer v4 - Grouped Accordion.zip
I will check it out

Re: Changing Language Files

Posted: Sat Mar 22, 2025 6:22 am
by heatherbell
Omar_one wrote: Sat Mar 22, 2025 5:52 am I am working on another one ;) to pick the language folders from template folder update it
Language Explorer is all about trying to make it easier for average new user.
This stems from recently having to help a new shop-owner change a Language constant for the first time.
The process of creating the correct folder tree (up to 5 levels!) in /templates/yourTemplate/ before then copying over the language file on the server was difficult enough for me to explain in an e-mail, even more difficult for the new user to do. I know we have lost new users for this reason alone.
Language Explorer does all this with a few clicks.
User can then just securely edit the new file on the server.

To make it easier for new users, so they do not have to find and install an Addon that they will probably not even know exists, this will be an addition to core which is the purpose of the request for testing in this topic.