Rearranging the languages/ folder

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Rearranging the languages/ folder
« on October 11th, 2011, 06:15 PM »
Been thinking about this, don't expect most people will notice the difference, but I think it'll be quite important in the long run. It certainly simplifies a few things, and causes others.

Right now, there's Themes/default/languages/index.*.php where you have one file for each language, e.g. index.english.php. That's cool and all, but I want to move them.

Specifically I want to convert it to Themes/default/languages/*/index.php so that instead of the language being part of the filename, it's part of the folder.

On the one hand, it will provide a performance boost to installations with lots of languages by segmenting the files into folders rather than one big folder.[1] It does also simplify adding new languages from a folder permissions/upload/unpacking scenario.[2]

On the other, it means that whereas before with the list of languages being shown to users based on their filename, it makes it based on language and that's slightly more prone to being wrong.

<discuss />
 1. Mind you, there's 34 PHP files and 1 image per language. Less if it's based on English and makes use of English as a fallback.
 2. That said, I've thought about not having an interface in the ACP for uploading a new language and expecting users to upload it manually. That, or ship Wedge with all known/available languages and just be done with it. Certainly, if it's in a folder it should be easier to upload manually.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Dr. Deejay

  • Happy new year all!
  • Posts: 118

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Rearranging the languages/ folder
« Reply #2, on October 11th, 2011, 07:23 PM »
TBH it should be something like index.lang or index.inc, index.php, login.php can be confusing. But otherwise the idea's good.
The way it's meant to be

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Rearranging the languages/ folder
« Reply #3, on November 5th, 2012, 06:09 PM »
Bumping. Anyone have any reason why I shouldn't?

I'll rename things to languages/english/index.lang.php rather than the current languages/index.english.php for example.


(This is in no way because I want to start on my own little language packs and want to make life easy on myself while I'm doing it.)

Nao

  • Dadman with a boy
  • Posts: 16,078
Re: Rearranging the languages/ folder
« Reply #4, on November 5th, 2012, 06:59 PM »
Hmm... I suspect it wouldn't take long to convert..?

I'd suggest having the languages folder at the root, (possibly with a test on Themes/custom/languages in case the default theme isn't enabled), but that's just me and my silly ideas... :whistle:

PS: the only issue is that if you're manually updating all new files by FTP, well, it does mean entering three times as many folders as originally just to upload the various files...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Rearranging the languages/ folder
« Reply #5, on November 5th, 2012, 07:07 PM »
It wouldn't. I just don't want to do it unless you're happy wiht it.

The one problem with having it at the root is, as you sort of get at, is custom themes who almost certainly have their own language file(s) to contend with. But that's no huge deal, it should just be a case of updating the options that loadLanguage follows through on. Plugins will not be affected by this.

As far as updating goes, I'd just drag and drop the entire languages folder and be done with it, WinSCP is smart enough to cope with that ;)
Re: Rearranging the languages/ folder
« Reply #6, on November 6th, 2012, 01:28 AM »
If you're happy with it, I'll do the file moving tomorrow and fixing the relevant logic, it'll just take a few commits to get everything moved (while keeping history)

Nao

  • Dadman with a boy
  • Posts: 16,078
Re: Rearranging the languages/ folder
« Reply #7, on November 6th, 2012, 10:05 AM »
Quote from Arantor on November 5th, 2012, 07:07 PM
It wouldn't. I just don't want to do it unless you're happy wiht it.
I'm happy with it (I've always been wondering whether it's okay to supply the French package in the default install or if I should remove it from SVN... That way we can do it however we want, as it's so easy to just remove the French folder entirely), it's just that I think it could be an opportunity to restructure the Themes folder...
Quote
The one problem with having it at the root is, as you sort of get at, is custom themes who almost certainly have their own language file(s) to contend with. But that's no huge deal, it should just be a case of updating the options that loadLanguage follows through on. Plugins will not be affected by this.
Okay, perhaps not at the root then... (Or, only if we don't end up doing what I'm suggesting below.)
But it would be a good opportunity to move the default theme out of the Themes folder. Let me explain. Here's how we could pull off something interesting...

/Theme/languages/english/
/Theme/languages/french/
/Theme/index.template.php
/Theme/css/index.css
/Theme/js/script.js <-- I was thinking it would be more logical to rename this to js, considering the root folder names..?
/MoreThemes/ <-- empty folder (proper name to determine), only has subfolders
/MoreThemes/my-theme/languages/english/* <-- loaded first, then fallback to the /Theme/languages/english/* folder
etc.
Quote
As far as updating goes, I'd just drag and drop the entire languages folder and be done with it, WinSCP is smart enough to cope with that ;)
Yeah, well, with sometimes unexpected results, e.g. the Home template screw-up from yesterday.... :^^;:

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Rearranging the languages/ folder
« Reply #8, on November 6th, 2012, 01:24 PM »
Quote
Yeah, well, with sometimes unexpected results, e.g. the Home template screw-up from yesterday....
Had it actually been the one in SVN, complete with all the bug fixes and so on that it's had which aren't in SVN, there wouldn't have been a problem :P

As far as the other changes go, I like it :)