Locale.admin.inc is over 2000 lines of code, with locale.inc topping up at yet another 2300. Locale.module is doing 4-5 different big things but these are too intermixed, and we should split their functionality and then clean them up individually. Naming conventions are way off, there are no clear standards, anything goes. Let's start this with setting up per-system include files. One of the subsystems that no other major patch is touching now is langage negotiation.
First question is if we want to keep calling it "negotiation" even though it does not actually go back and forth in any way, it just takes some data and select languages based on that. I think language *selection* would probably be simpler and more to the point, but using negotiation here to get the split through at least if there are big disagreements. If there is great peace and agreement on renaming it to something simpler, we can do that here now, since now it is also in the filename.
This really just moves functions around to a different include file and does NO other change. Should be simple to review, doesn't it? (I've looked at other negotiation related functions in locale.inc and locale.module but those were not administrative per say and needed on more page requests).
| Comment | File | Size | Author |
|---|---|---|---|
| split-negotiation-admin-file.patch | 19.86 KB | gábor hojtsy |
Comments
Comment #1
rvilarBig improvement!
I think like you. "Selection" is less ambiguous than "negotiation". The first time I read "negotiation" my mind was confusing about its purpose.
Comment #2
fietserwin- +1 for "selection"
- I would name the new file locale.selection.admin.inc (or whatever term is chosen) to stress the fact that this file handles the admin part of language selection (though, that would mean to do the same on many other files, including the import, export files in [31219236]
- You say that this patch only moves code, so I guess a follow-up issue will be registered as soon as this one is committed that targets updating the comments and renaming the functions where appropriate? If so, I would propose to create that issue right now and set it to postponed (as being waiting on completion of this one).
Comment #3
gábor hojtsyWell, once/if we have some support for language "selection" as terminology, then would it make sense to open a new issue I think. On adding admin.inc to the filename too, I think that makes sense. Not sure what if there is a good system for naming these files. The node module for one has content_types.inc for the content types admin pages. No node, no admin in the filename :)
Comment #4
gábor hojtsyHa! I wanted to tag this issue usability, but turns out the UI does not mention the word negotiation at all. It says "detection" and "selection". Sounds like we should be free to use either for file and API naming for consistency?
Comment #5
fietserwinThere's now lots of "configure" in both function names and url's. I would change that all to "selection" (or whatever will be chosen). That's what I meant to say. You could open an issue about the naming anyway, to restrict this issue purely to moving code around.
If restricting to moving code, I consider this issue reviewed by myself and tested by the bot. Not sure if that is enough for RTBC :)
Comment #6
plachA big +1 to rename everything "detection" or "selection" (personally I prefer the former). I agree at all with #5.
About file naming conventions I think we might want to ask a feedback from our friendly core-gardener (@sun): let's follow them if any, otherwise let's find an agreement on something that can be used consistently all around core.
Typo: "Langauge"
11 days to next Drupal core point release.
Comment #7
gábor hojtsyI'm fine with detection too. Great to hear you being the author of this part of locale have full support :) Yay for DX!
Comment #8
sunI'm sorry, but the proposed split doesn't make too much sense for me.
locale.admin.inc contains UI functionality for:
Now, categorizing this functionality, I see:
So, if splitting this file at all, then I'd split it that way.
However, the question of splitting in which direction is a tough one, as it largely depends on the outcome of a couple of other discussions we currently have.
I'd see the following two options:
locale.pages.incorlocale.translation.inc.That would be on the assumption that all of this string translation functionality is actually a whole different beast than the pure core functionality of setting up languages and locales. As long as you setup language and locale configuration, you can happily use a totally different module and way to actually translate, import, and export strings. And as the http://drupal.org/project/l10n_client module proves, it's also not really "administrative" functionality (in the sense of living on an
admin/*path). So that current code only lives in locale.admin.inc, because we have a poor UI.locale.language.inc.That would be on the assumption that all of this functionality should actually be part of a new and separate Language module. And if/when that module exists, we'd move and rename that entire
locale.language.incmore or less as-is intolanguage.admin.inc.In short,
- I'm against splitting for the pure sake of splitting. When splitting, there should be a larger sense for doing so.
- I'm also opposed to renaming "language negotiation" to something else. The term is kind of an industry standard, which naturally involves detection and selection.
Comment #9
fietserwinI guess that larger sense is the D8MI. Gábor clearly states that this would be the first of a series of refactorings to more clearly separate and clean up these features. And as long as a large refactoring can be split up into more smaller ones, that is the way to go. Even if such an individual small refactoring makes no real sense on its own. Overall it will be easier to test, and trace errors when they are introduced during the time it takes to complete a large refactoring.
Comment #10
sun@fietserwin:
Comment #11
gábor hojtsy@sun: Sorry, I did not copy in more supporting arguments here, let me repeat some reasons from other discussions around the topic:
1. Locale really supports two kinds of websites. Monolingual foreign language and multilingual. Monolingual foreign language sites will need an absolute minimum of "language negotiation", because how to choose a language from a list of one languages does not require much code or any UI thereof. UI and code distractions for that case are just those, distractions. This is being discussed at http://groups.drupal.org/node/161589
2. Now since monolingual sites will not need the negotiation UI (and much of the API), it sounds like it makes sense to have a separation for that for the developer experience as well. We can keep it lumped up with all the rest, it would result in unneeded code includes and reduced DX.
3. Even with all these there are precedents for "splitting includes for the sake of splitting" so to say. Node module has content_types.inc and content_types.js, although frankly, what would node module do without these? The files are merely used for logical separation of big enough chunks. For locale, there are huge chunks of code for import/export, language list management, etc. We can split those also on the ground of logical separation like node module does and leave the rest in the generic admin.inc, if that sounds like the golden standard. Another great example is field.module, which starts off with these fine lines:
require_once DRUPAL_ROOT . '/modules/field/field.crud.inc';
require_once DRUPAL_ROOT . '/modules/field/field.default.inc';
require_once DRUPAL_ROOT . '/modules/field/field.info.inc';
require_once DRUPAL_ROOT . '/modules/field/field.multilingual.inc';
require_once DRUPAL_ROOT . '/modules/field/field.attach.inc';
require_once DRUPAL_ROOT . '/modules/field/field.form.inc';
Of course these all could be in the module file itself, but it is kept separate for the sake of developer experience. Even though some files are pretty small (multilingual is just a couple hundred lines), it makes sense for logical separation.
I think it makes sense here too. Except I'm not advocating (yet?) splitting locale.module to includes, but rather the admin pages to split to logical pieces, and those will not be included altogether at all times That sounds like an even better use case compared to field module?
4. In terms of splitting the translation and the import/export API from each other, that is being started off in #1219236: Locale module includes 1350+ lines of unneeded code on all page loads. There the 80% use case is being considered. People don't use the import/export functionality anymore to load and share translations. People use tens or even a hundred modules nowadays, and manually downloading those translation files to your desktop (making sure you have the right version, etc), and then importing them from your desktop on the web UI is not what people want / should use. We are integrating the localization update functionality as per the plan in Drupal 8 to provide a modern, usable solution. That makes the existing file system based locale .po file imports obsolete and the web UI for .po import/export a very-very rare use case. Bojhan argued we should remove it altogether from core. I think we should at least try and not include its immense code base when we don't need it (including the admin pages for it). Drupal 7 even includes the parsing/generation API for .po files on *all* page loads if locale module is enabled. See again in #1219236: Locale module includes 1350+ lines of unneeded code on all page loads.
In short:
- I'm attacking the monolingual foreign language site vs. multilingual site question. I'd love to tweak the UI and naming, and hoped we can postpone arguing about some details by doing these in steps. That is the larger picture in which this should make sense.
- For when the mono/multi separation does to guide us, I'm looking at the 80% use case.
- In terms of developer experience I'm trying to apply the same naming on the UI vs. code as well as similar patterns like node module and field module do for logical separation of the code even though it is then included to be used - if we use the same patterns as other modules do and have consistent terminology, people will better understand how this works.
Makes sense now?
Comment #12
sun1. + 2. Given that we're still hashing out conclusions in the thread you linked to, it doesn't sound wise to me to perform an "arbitrary" code re-organization in the mere hopes that it's going to be in line with the final decisions and direction. We should properly figure out how to cleanly separate monolingual/multilingual code logic first, before attempting to move individual parts here or there.
3. Field API's separation was never agreed-on in a community-wide discussion. The separation was introduced as part of the initial Field API patch, and that one was so large that this detail didn't really gain attention. As a developer who tries to find certain stuff relatively often in those files, in particular Field module's organization is often confusing and sub-optimal. Lastly, there's also an I/O performance factor involved in every file include. So by all means, this shouldn't serve as a good example to follow (yet). As of now, the community-wide agreed-on standard is
$module.admin.incand$module.pages.inc(where applicable).4. Right now, I'm seeing much more architectural design agreement on the suggested splitting of gettext/import/export related stuff (as in the other issue), as well as on the topic of string translations/l10n_update/l10n_client. It might also very well be that these topics are just simply easier to figure out, since they don't have system-wide implications. But anyway, in light of that, it would make much more sense for me to do option #8 1) then, "Split string localization/translation functionality into locale.pages.inc or locale.translation.inc." The net result is going to be more or less the same: locale.admin.inc vastly decreases in size. The difference IMHO is though that there's a much less vague plan for what to do with that localization UI admin functionality in the long run -- whereas I currently fail to see a sign of a solid concept for the monolingual/multilingual topic yet; too much to hash out API level wise and UI level wise in order to even think about which code should live where, what interdependencies might exist, etc.pp.
Comment #13
gábor hojtsyAll right, let's not waste our time here then.
Comment #14
sunDoes this mean that you disagree with splitting away the string localization admin UI functionality instead?
Comment #15
gábor hojtsyWe can repurpose this for locale.pages.inc if you think that is best. I think not much of the discussion above pertains to that, and we'll still need to clean up the API (if it is going to be called negotiation, we need to make the functions adhere to that), so I think it would be great to have this as a referencable discussion without derailing it into something else, and opening a new issue for locale.pages.inc.
Comment #16
gábor hojtsy@sun: opened #1222072: Split translation editing functionality out of locale.admin.inc and locale.inc for the translation page split with a patch.
Comment #17
gábor hojtsy@sun: also opened #1222106: Unify language negotiation APIs, declutter terminology for the negotiation/selection/detection/provider API cleanup. It is pretty interesting :)
Comment #18
gábor hojtsyTagging for base language system.
Comment #19
gábor hojtsyTagging for language negotiation too.