Problem/Motivation

Drupal uses language negotiation, selection, detection and providers to name things that are often overlapping.

This is mere a META issue to unify classes of functions in the language negotiation APIs ie. figure out the classes of functions, pull out their names, confirm their terminology is sound, unify their names.

Proposed resolution

We need to figure out the bigger level things and then doing the changes themselves in "sub-issues".

so the larger picture right now is that

(a) we are moving language support code from locale module to the respective modules (comment, path, node) and

(b) setting up a pattern with a language API that can support them, so => we can move on to add language support to other entity types like taxonomy and files and in parallel, we are

(c) cleaning up the language negotiation API in preparation of => moving it in with the language module, leaving locale module to UI translation (and still a tiny bit of config translation with date formats for now) only and finally also in parallel

(d) we are updating schemas and APIs to use langcode for DX so when we do the moves after (a) and (b) to add language to new entities, we use the standard understandable schema in other words, we mostly do prepwork ATM, but the good cool stuff is not far

Remaining tasks

#1416392: Clean up language (types) bootstrap function naming and documentation

User interface changes

tbd

API changes

tbd

Original report by Gábor Hojtsy

Drupal uses language negotiation, selection, detection and providers to name things that are often overlapping.

Now in locale.admin.inc:
- locale_languages_overview/add/predefined, etc. for language configuration
- locale_languages_configure_* for negotiation configuration
- locale_language_providers_* for provider configuration
- locale_translate_import/export for import and export
- locale_date_* for date related stuff

Now in locale.module:
- hook_language_negotiation_info() defines the providers(!)
- hook_language_types_info() defines the language types

locale.inc uses LOCALE_LANGUAGE_NEGOTIATION_* constants for providers, while language.inc uses LANGUAGE_NEGOTIATION_*.

language_negotiation_get/set() gets/sets a provider(!)

language_provider_invoke() invokes a provider (ha)

The UI calls the process selection and detection, while the internals use negotiation and providers interchangeably. I wanted to first start this cleanup by moving negotiation related admin functions to their own page, but that did not receive good feedback. Looks like people want to keep language selection settings as part of the "core" of locale module.

Anyway, let's skip that then and get to the meat, because unlike the string editing (#1222072: Split translation editing functionality out of locale.admin.inc and locale.inc) and gettext import/export (#1219236: Locale module includes 1350+ lines of unneeded code on all page loads), at least langauge negotiation is relatively well placed within the different code files, if we want to keep them with the basics of locale.module we don't seem to need to move much around.

However, to clean up the API, we do not need to define what kind of naming we'd like to use. As the above quick analysis points out, there is a sizable disagreement in the API as to whether to call this "language configuration", "language negotiation" or "language providers". The language configuration admin screen configures language negotiation for language types, which are defined by language providers. Except that whenever the API said language negotiation (type, get/set, etc), it meant providers. There does not seem to be an actual function or hook that is named "negotiation" and performs negotiation (selection and detection). The providers do that. You define providers and then they do the work.

Following Drupal's standard, we should

1. Use "provider_get/set/info" in place of negotiation get/set/info.
2. Use "negotiation configure" in place of language configure for setting the negotiation (ordering, enabled providers)
3. Use "provider configure" where you actually configure one specific provider.

That is if we are about to keep calling this negotiation, which is never mentioned on the user interface. The W3C clearly calls the process language negotiation (http://www.w3.org/International/techniques/server-setup), but we think this is too scary for users(?). We can obviously keep doing this double naming like we do for nodes and content, but then at least come to fix our naming for the APIs in light of that. Feedback welcome before I start to work crazy on yet another big patch :D

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

I don't really care how we call it in the UI (let's just use whatever makes sense there), but in code, it should be called "negotiation".

That's a typical case of where we have a clearly defined technical terminology, but which doesn't necessarily make sense for the average Joe, so the product/application can expose the feature in whatever means makes sense - as long as we also retain sense and sanity on the internal, technical level.

I agree that the hook and function names are a mess. Singular and plural names seem to be inconsistent, too.

On API level, we should have:

- hook_language_type_info() defines language types
- hook_language_provider_info() defines language providers
- language_load/_save/_delete for language CRUD
- language_provider_load/_save/_delete for language provider configuration CRUD
- locale_date_* for date locale CRUD stuff

...and also do something about language_provider_invoke(), since that _invoke() pattern isn't really state of the art.

On UI level:

- locale_language_overview/_form/_delete_form for language configuration
- locale_language_provider_form() for provider configuration
- locale_language_negotiation_form() for negotiation configuration
- locale_translate_import/export_form() for import and export
- locale_date_*_* for date locale UI stuff

Gábor Hojtsy’s picture

All right, we seem to agree here then :) I think we can / should keep this issue for negotiation related cleanups. Functions, APIs, constants, etc. will need to be renamed at different places for this, and this is a big logical piece we can work with.

BTW For the language CRUD, I've opened #1215716: Introduce locale_language_save() (although it kind of tanked due to having no clear way to address languages (no good name for language identifiers, so that we could do a clean load API for updates), which prompted #1216094: We call too many things 'language', clean that up which is currently in indecision. For fixing the import/export API and naming of the related functions, we have #1189184: OOP & PSR-0-ify gettext .po file parsing and generation which is already a followup to #1219236: Locale module includes 1350+ lines of unneeded code on all page loads. For the translation page/admin UI naming, we'll have followup once #1222072: Split translation editing functionality out of locale.admin.inc and locale.inc lands.

sun’s picture

Issue tags: +API clean-up
plach’s picture

About the language type terminology issue brought up by @chx: what about language scope?

Gábor Hojtsy’s picture

Newb question: where does core use language scope? :)

plach’s picture

Dumb reply: AFAIK nowhere yet. I'm just suggesting that we replace things like LANGUAGE_TYPE_URL and $language_type with LANGUAGE_SCOPE_URL and $language_scope.

Probably I'm missing your point as usual :)

Gábor Hojtsy’s picture

No, I was missing your point :) Sounds like a good idea.

plach’s picture

Wow, let's see if @sun and @chx agree.

plach’s picture

Title: Unify language nagotiation/selection/detection/provider hooks, APIs and functions » Unify language negotiation/selection/detection/provider hooks, APIs and functions
sun’s picture

I'm a bit lost with this issue - some parts of the summary and the proposal seem to be outdated in the meantime, and I'm not even sure how much of #1 still applies.

Is anyone able to overlook the current state of the art and revise the issue summary accordingly? (would also be very helpful to shorten it where possible, as well as presenting the precise problem and proposed change first, details only later)

Gábor Hojtsy’s picture

@sun: most of the issue starter problems still apply. The negotiation functions and hooks are not yet renamed in any way. I wonder if we want to do this reorganization before or as part of moving negotiation to language.module.

plach’s picture

I think a two steps approach might be safer: mixing the two tasks in a unique patch would increase the risk of producing code none has familiarity with. Which would mean more bugs, I guess. In this light perhaps I'd first move language negotiation and only after I'd clean it up...

Gábor Hojtsy’s picture

Here is a quick rundown of UI related code/paths:

- UI is under paths admin/config/regional/language/configure and under there. I think 'language/configure' is way too general for this functionality.

- The forms involved in the UI are locale_languages_configure_form, locale_language_providers_url_form, locale_language_providers_session_form; I think the last two make sense if we can fit them in a general pattern but the first again is too general IMHO

Then starting from the bootstrap:

- The initial bootstrap function is called drupal_language_initialize() and is one of two exceptions. All other bootstrap functions are called _drupal_bootstrap_something().

- drupal_language_types() is the only other function within the drupal_* namespace vs. language and it is a (just) default list of types, looks pretty odd; the actual list of types is language_types(); so why not rename drupal_language_types() to language_types_default() or something along those lines instead?

- There is a language_types_info() which says it returns a list of language type names, and is hardly distinguishable on the API level from language_types() itself, which just returns the keys (they also work from very different data sources so it is hard to tell what is going on there)

- Most language_types_*(), language_provider_*() and language_negotiation_*() functions seems to be well in their 'namespaces' however if you look closer, language_negotiation_info() says it returns language *provider* info

- Then there are some utility functions right in the top language namespace like language_from_default(), and then from locale.inc many like locale_language_from_*(); maybe language_from_*() is a pattern, not sure its in line with other patterns we use throughout core; its not a noun :) I mean we could say language_source_*() for example; also I assume the locale_language_from_*() ones would need to merge in the language_* namespace in some form.

All in all I think there is a fair bit of cleanup to do and we can probably do it gradually, eg. identify and clean up the bootstrap related function names, etc. I don't think we need to do any significant development on the negotiation functionality itself, it is good, but IMHO we should apply some cleanup so that it is crystal clear and can be moved to language module.

I know / see that one of the naming inconsistencies comes from the language negotiation system being in part in bootstrap.inc, in part in language.inc and in part in locale.inc. That is because bootstrap.inc is always there, language.inc is only included if there are multiple languages enabled (which just in theory could happen without langauge module (or in D7 locale module) being there), but for the reason it being theoretically separate the final portion of the code is in locale.inc which is only loaded with locale. I think the whole set of functions fits well within language.inc, if there are multiple languages and language module is not enabled, that is a very-very special case and those who hack core to that extent will bear the consequences :) Yes, langauge module is theoretically replaceable but not really in practice.

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
24.12 KB

Thinking more on the last point (language_from_* and locale_language_from_*), sounds like instead of introducing yet another term for it, we should call it what it is a "language provider callback", right? This is just some mass search and replace to ignite some discussion, no code moved yet but establishing this "sub-namespace". Note that the related constants are still called LANGUAGE_NEGOTIATION_* (vs. provider). Not sure why is this difference? Looks like there is no clear terminology applied there. Should those be LANGUAGE_PROVIDER_* instead?

(I deliberately avoided changing the name of the locale providers to avoid need an update function for now).

Gábor Hojtsy’s picture

Wups, the first hunk should not have been there, because I did not actually move stuff.

Status: Needs review » Needs work

The last submitted patch, language-provider-callback.patch, failed testing.

Gábor Hojtsy’s picture

Test fail independent of this patch due to #61456: Aggregator titles display quotes and other characters with HTML entity equivalents badly (write tests).

BTW opened a sub-issue for bootstrap and language type functions at #1416392: Clean up language (types) bootstrap function naming and documentation which is "just" 5 function name changes there to establish a consistent langauge_types_* namespace proper. I think that is probably the most limited area of this question to solve fast and then move on to bigger questions like the above suggestion for providers.

Gábor Hojtsy’s picture

Status: Needs work » Needs review

#15: language-provider-callback.patch queued for re-testing.

plach’s picture

- Most language_types_*(), language_provider_*() and language_negotiation_*() functions seems to be well in their 'namespaces' however if you look closer, language_negotiation_info() says it returns language *provider* info

In my original patches "provider" was roughly an "educated" version of the "callback" term. The "negotiation" terminology was (re)introduced later, since actually providers are only gears of the general language negotiation mechanism. If we want to achieve a better consistency and unify the two terminologies I'd definitely suppress the "provider" term in favor of something like language_negotiation_browser() / language_negotiation_url(). This is consistent with the (locale_)language_switcher_* and (locale_)language_url_rewrite_* callback namespaces.

- UI is under paths admin/config/regional/language/configure and under there. I think 'language/configure' is way too general for this functionality.

Agreed. This should be "admin/config/regional/language/negotiation" or "admin/config/regional/language/detection" depending on whether we want to expose the API terminology at "UI level" (which I think we don't after all).

- The forms involved in the UI are locale_languages_configure_form, locale_language_providers_url_form, locale_language_providers_session_form; I think the last two make sense if we can fit them in a general pattern but the first again is too general IMHO

I think these should become language_negotiation_form(),language_negotiation_url_form(), etc.

- The initial bootstrap function is called drupal_language_initialize() and is one of two exceptions. All other bootstrap functions are called _drupal_bootstrap_something().

Well, one reason to keep the status quo here is that the other bootstrap functions are private, while language initialization can be called outside the bootstrap scope. I ain't sure it's worth to bikeshed this, since drupal_language_initialize() will probabaly go away when WSCCI lands.

- drupal_language_types() is the only other function within the drupal_* namespace vs. language and it is a (just) default list of types, looks pretty odd; the actual list of types is language_types(); so why not rename drupal_language_types() to language_types_default() or something along those lines instead?

It was an attempt to convey the idea that those are actually the core built-in language types vs module-defined one. No strong preference about this.

- There is a language_types_info() which says it returns a list of language type names, and is hardly distinguishable on the API level from language_types() itself, which just returns the keys (they also work from very different data sources so it is hard to tell what is going on there)

The docs are wrong here, language_types_info() returns full language type definitions, the function name is pretty clear and consistent with other analogous core functions. I'd keep it as is and just fix the docs.

I know / see that one of the naming inconsistencies comes from the language negotiation system being in part in bootstrap.inc, in part in language.inc and in part in locale.inc. That is because bootstrap.inc is always there, language.inc is only included if there are multiple languages enabled (which just in theory could happen without langauge module (or in D7 locale module) being there), but for the reason it being theoretically separate the final portion of the code is in locale.inc which is only loaded with locale. I think the whole set of functions fits well within language.inc, if there are multiple languages and language module is not enabled, that is a very-very special case and those who hack core to that extent will bear the consequences :) Yes, langauge module is theoretically replaceable but not really in practice.

.

Well, I tried to design everything so that in theory one could disable/swap locale.module and use only the functions living in language.inc which are the pure API. Locale is the core implementation of the language negotiation system and provides the language type definitions on behalf of core. On one hand moving language negotiation/switcher/url rewrite callback into language.inc would "pollute" it, since in theory an alternative Language module could ship with its own language negotiation implementation, and so a large part of language.inc would be unused. OTOH this is just theory and I don't see many real life use-cases for it, this distinction was just a guidance to achieve a good architecture.
In this light I'd be ok with hook_language_types_info() and hook_language_negotiation_info() core implementations living in language.module and the actual callbacks living in language.inc, until the pure API is moved to OOP as part of the WSCCI "migration".

Aside from the things above, I think @chx raised a good point about the expressiveness of the language type terminology, I think we could definitely exploit this issue to change it to language scope, which IMO is far closer to its real meaning.

Gábor Hojtsy’s picture

Issue tags: +sprint

Tagging as current focus.

Gábor Hojtsy’s picture

Issue tags: +language-base

Tagging for base language system.

Gábor Hojtsy’s picture

@plach: well, this issue is more like exploding to a meta issue in and of itself as far as I see. I branched off the type renaming to #1416392: Clean up language (types) bootstrap function naming and documentation. The existing function names don't show a lot of similarity to be able to tell what is going on and I think I have a solid proposal there. I also agree that the replaceability of language.module is pretty theoretic. Code works with language_list() (which language_load() falls back on) which works with the language table directly and does not really let people do their own thing. We could build in a bunch of levels of abstraction there but I don't think there seems to be a viable a use case for it, or that we should be obsessed with abstracting this to perfection in Drupal 8. I am merely trying to standardize what we have so we can say we did our best for DX when using this API.

Anyway, #1416392: Clean up language (types) bootstrap function naming and documentation looks like a small well defined set of actionable pieces we can work on now. I've retracted from the suggestion to rename the bootstrap function for now, but I think the type functions need a clear pattern, because the lack of that contributes a lot to the misunderstanding. We can also rename types to scopes I guess there and then move on to the upper layer of providers and negotiation :)

Gábor Hojtsy’s picture

Issue tags: +negotiation

Tagging for language negotiation too.

clemens.tolboom’s picture

Issue summary: View changes

Applied feedback from Gábor @ irc #drupal-i18n

Gábor Hojtsy’s picture

Title: Unify language negotiation/selection/detection/provider hooks, APIs and functions » META: Unify language negotiation/selection/detection/provider hooks, APIs and functions

@plach: took the first third of your feedback from #19 above and created #1430986: Clean up naming for language negotiation configuration functions/paths. Please review there. I used language_negotiation_configure_* as a namespace for the config UI/form functions to ensure we keep the language_negotiation_* namespace cleaner for the other things (vs. your suggestion above to directly put config forms there like language_negotiation_form()). Otherwise its all coded based on your suggestions! Anyway, please review there!

Also naming this issue a META so instead of getting in patches from here, we can keep spawning issues to get concrete changes in as we already did with #1416392: Clean up language (types) bootstrap function naming and documentation.

Gábor Hojtsy’s picture

Status: Needs review » Active

Moved the trivial part of the above patch to #1431040: Rename LOCALE_LANGUAGE_NEGOTIATION_* constants to LANGUAGE_NEGOTIATION_*, which was big enough in itself :). Marking active (issue not focused on producing patches but to oversee this issue family). Please review these two new spinoffs.

plach’s picture

Another clean-up to be done before moving negotiation code to teh Language module: #1222194: Rename global $language to $language_interface.

Gábor Hojtsy’s picture

- Most language_types_*(), language_provider_*() and language_negotiation_*() functions seems to be well in their 'namespaces' however if you look closer, language_negotiation_info() says it returns language *provider* info

In my original patches "provider" was roughly an "educated" version of the "callback" term. The "negotiation" terminology was (re)introduced later, since actually providers are only gears of the general language negotiation mechanism. If we want to achieve a better consistency and unify the two terminologies I'd definitely suppress the "provider" term in favor of something like language_negotiation_browser() / language_negotiation_url(). This is consistent with the (locale_)language_switcher_* and (locale_)language_url_rewrite_* callback namespaces.

I was trying to work on a patch for this, but figuring out a consistent terminology here seems not so easy. http://api.drupal.org/api/drupal/modules%21locale%21locale.api.php/funct... is the poster child of that. How do we call the "callback descriptor structures"? They cannot be called "negotiations" right? At least that sounds pretty silly :) Also, "negotiation callback" sounds problematic as we (a) specify other type of callbacks too (b) we also provide metadata.

@plach: I think if we can figure out how would we want to clean up wording/terminology of variables / concepts in http://api.drupal.org/api/drupal/modules%21locale%21locale.api.php/funct... we cracked this and can apply that to all other places in the negotiation system getting a nice patch. What do you think?

Gábor Hojtsy’s picture

#1416392: Clean up language (types) bootstrap function naming and documentation landed and #1222194: Rename global $language to $language_interface is about to land, so I'd be happy to help produce the next patch(es) for the provider/negotiation cleanup BUT we'd need to figure out what naming we want to use as per my questions in #27. @plach?

plach’s picture

Below I tried to replace the "provider" terminology with the "negotiation method" one in the PHP doc of hook_language_negotiation_info(). I also renamed the callback keys to have a noun indicating an action everywhere. Overall it looks good to me.

/**
 * Allow modules to define their own language negotiation methods.
 *
 * @return
 *   An array of language negotiation method definitions. Each method has an
 *   identifier key. The language negotiation method definition is an indexed
 *   array that may contain the following key-value pairs:
 *   - "types": An array of allowed language types. If a language negotiation
 *     method does not specify which language types it should be used with, it
 *     will be available for all the configurable language types.
 *   - "callbacks": An array of functions that will be called to perform various
 *     tasks. Possible key-value pairs are:
 *     - "negotiation": Required. The callback that will determine the language
 *       value.
 *     - "language_switch": The callback that will determine the language
 *       switch links associated to the current language provider.
 *     - "url_rewrite": The callback that will provide URL rewriting.
 *   - "file": A file that will be included before the callback is invoked; this
 *     allows callback functions to be in separate files.
 *   - "weight": The default weight the language negotiation method has.
 *   - "name": A human-readable identifier.
 *   - "description": A description of the language negotiation method.
 *   - "config": An internal path pointing to the language negotiation method
 *     configuration page.
 *   - "cache": The value Drupal's page cache should be set to for the current
 *     language negotiation method to be run.
 */
 

As a side note, I think we should have a separate file key for each callback, as we cannot assume they will always live in the same file (and a path key for consistency with other subsystems). OTOH if this is going to be converted to PSR-0, code will be autoloaded and we will be able to get rid of the file key altogether. Perhaps a @todo just in case this don't happen could be enough for now.

However, here is how function names would change accordingly:

Previous name New name Rationale
language_negotiation_get() language_negotiation_method_enabled() The function names are totally misleading wrt the intended usage. Moreover language_negotiation_get() could be split into separate, single-behavior, functions (see below). These two could be merged instead, by making the language type parameter optional.
language_negotiation_get_any() language_negotiation_method_enabled_any()
language_negotiation_get() language_negotiation_method_get_first() Refactored to return the first enabled language negotiation method for the given language type (as the PHP doc currently suggests).
language_negotiation_get_switch_links() No change Well namespaced and self-documenting.
language_negotiation_info() No change See above
language_negotiation_purge() No change See above
language_negotiation_set() No change See above
language_provider_invoke() language_negotiation_method_run() OOP methods are invoked. Retaining this terminology might lead to confusion, since we would have also the method term. Alternative verbs could be used, for instance execute or call, run is the shortest one.
language_provider_weight() language_negotiation_method_weight() Straightforward terminology switch.
Gábor Hojtsy’s picture

@plach: I think is is looking good. Can you fix the previous names though so its clearer? You have duplicates :) Also I think its fine if we keep invoke vs. Run, invoke is a common pattern in Drupal core.

I am excited as we are getting closer to having this entirely cleaned up.

plach’s picture

Can you fix the previous names though so its clearer? You have duplicates :)

I did not explain myself well: language_negotiation_get() now serves two purposes, depending on the parameters it is passed: returns the first enabled provider for the given language type or whether a specified provider is enabled. I'm suggesting to split it into two separate functions, and merge the one that checks if a provider is enabled for a given language type with the one checking if it is enabled for any language type.

Also I think its fine if we keep invoke vs. Run, invoke is a common pattern in Drupal core.

Ok

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
57.7 KB

Ok, this sounds like might be the last piece in renaming for terminology, and we'd only need to rename for moving to language.module, which will happen elsewhere, so I decided to put the patch here. Let me know if you think that is not good.

It was a *lot* more work then I've anticipated honestly, lots of intricate details. Followed your suggested naming scheme except _invoke instead of _run as discussed above.

Status: Needs review » Needs work

The last submitted patch, negotiation_method.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
57.96 KB

Fixed two typos in the patch which fixed some of the tests at least for me (did not run all locally).

plach’s picture

Title: META: Unify language negotiation/selection/detection/provider hooks, APIs and functions » Unify language negotiation/selection/detection/provider hooks, APIs and functions
FileSize
59.79 KB
25.02 KB

I toroughly reviewed/tested #34 and made some adjustment:

  • As I suggested previously, I merged language_negotiation_method_enabled() and language_negotiation_method_enabled_any() into a single function having the language type parameter optional. This makes a lot of sense to me, since the former was never used and given that they shared most of the logic.
  • To improve consistency I replaced every occurrence of the $negotiation_method variable with the $method one, which was appearing more frequently. I also ensured that the full "language negotiation method" terminology is always used, instead of the abbreviated "negotiation method" or "language method" ones.
  • I actually renamed the negotiation and language_switch callback keys, adjusting the update function as needed.

Attached you can find an interdiff. Let's see if the bot is happy.

Gábor Hojtsy’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Changes look good. Reviewed via both the interdiff and the patch. We still need upgrade testing, right?

plach’s picture

Status: Needs work » Needs review
FileSize
59.46 KB

We still need upgrade testing, right?

The callback keys update is covered, I tested it while coding. We probably need some extra assertion for the weight variable. To be sure let's revert that portion of the update and see what happens.

plach’s picture

Status: Needs review » Needs work

We probably need some extra assertion for the weight variable.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
60.94 KB

Is this looking good for that? (Started off from your patch in #35).

Gábor Hojtsy’s picture

Title: Unify language negotiation/selection/detection/provider hooks, APIs and functions » Unify language negotiation APIs, declutter terminology
Issue tags: -Needs tests

Retitled for current focus.

plach’s picture

I fixed the couple of stupid issues below + renamed locale_language_methods_weight_* to locale_language_negotiation_methods_weight_*. Attaching a test-only version to check test coverage for method weights.

+++ b/core/modules/simpletest/tests/upgrade/upgrade.language.test
@@ -77,5 +77,13 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {
+    // Check if langugae negotiation weights were renamed properly. This is
+    // a reproduction of the previous weights from the dump.

Typo + wrong wrapping.

+++ b/core/modules/simpletest/tests/upgrade/upgrade.language.test
@@ -77,5 +77,13 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {
+    // Used to be locale_language_providers_weight_language, check for
+    // both rename to 'language_interface' and 'methods'.

Wrong wrapping.

2 days to next Drupal core point release.

Status: Needs review » Needs work

The last submitted patch, negotiation_method-1222106-41-test.patch, failed testing.

plach’s picture

Status: Needs work » Needs review

This should be ok.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
160.94 KB

Ok I think this looks good and is big enough for it to hopefully land sooner than later. Just for illustration purposes, here is an annotated version of the D7 language negotiation graph I made for the docs issue (#1156576: Language negotiation is undocumented), which we'll tackle once this lands and we have a fully cleaned up terminology. This patch is about getting rid of the "provider" terminology that was an unnecessary jargon and became very confusing (eg. hook_negotiation_info() returned providers(!)). With the terminology cleanup, we have a clear set of APIs clustered by language_type_*, language_negotiation_* and language_negotiation_method_*. This issue is the remaining piece in that.

Drupal8LanguageTerminology.png

sun’s picture

This looks good to me.

The only part that slightly confused me was language_negotiation_info(). Somehow expected that to be language_negotiation_method_info(). But perhaps it's only me. Either way, can be a follow-up issue.

That said, we should also try to get rid of wonky patterns like *_invoke() functions... the $method_id was additionally not immediately clear to me. Unless I'm missing something, then those language negotiation methods seem to be perfect candidates for OO conversion. Either way, also follow-up issues.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Yes, any OO conversion would need to be a follow-up. We are trying to clean up terminology here to be able to move in negotiation with language module and to help improve DX. It likely sounds better though to include a hook_negotiation_method_info() rename if @plach agrees.

sun’s picture

Status: Needs work » Reviewed & tested by the community

I'm not 100% sure on the info hook rename. I'd suggest to go ahead with the patch as-is for now.

plach’s picture

Rerolled after the latest D8MI commits. Just renamed the 8002 update function to 8003: quickly checked the new 8002 function and everything should be ok, so leaving RTBC.

xjm’s picture

I inspected the update hook to make sure it didn't contain any API functions. :) There's a few minor things to adjust in the docs, which I'll roll in right now since I'm about to start on #1317626: Clean up API docs for includes directory, files starting with H-M.

xjm’s picture

FileSize
5.14 KB
61.25 KB

Phew, big patch. :) Awesome work everyone!

Edit: Note that #1272840: Add upgrade path for language domains and validation was reverted, in case that ends up affecting the hook numbering.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1222106-50.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
61.24 KB

Thanks for your great changes! Rerolled against HEAD. No changes included.

Gábor Hojtsy’s picture

FileSize
61.24 KB

Reuploading since testbot seems to be stuck on something (it says this passed but it is still marked postponed). Also no UI for retesting it in this case... :/

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Was RTBC before it did not apply cleanly for some other changes. I've renamed the update function to 8002 as per @xjm's note that the existing 8002 was backed out.

plach’s picture

+++ b/core/includes/language.inc
@@ -154,7 +154,7 @@ function language_types_set() {
 /**
- * Returns the ID of the first language negotiation method for the language type.
+ * Returns the ID of the first negotiation method for the language type.
  *

Reverted this change as we are trying to standardize on the full "language negotiation method" terminology. Leaving RTBC as this was already had been set to RTBC before.

0 days to next Drupal core point release.

xjm’s picture

@plach -- The (fairly minor) concern is that line is over 80 chars. Any suggestions for a rewording that is 1-2 characters shorter but includes the needed info?

Edit: Would this be OK?
Returns the ID of the language type's first language negotiation method.

plach’s picture

Isn't the first phpdoc line allowed to go over 80 chars? However the above suggestion looks good to me...

xjm’s picture

Well, according to this standard it should be under:
http://drupal.org/node/1354#functions

I'll reroll quickly with that small fix. Thanks plach!

xjm’s picture

Gábor Hojtsy’s picture

Update 8002 is now taken. Rerolled with 8003.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, negotiation_method-1222106-60.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
61.24 KB

Uhm, wrong patch, this one represents the changes shown in the interdiff.

Lars Toomre’s picture

Gabor,

I would recommend that type hinting be added to all of the functions being touched by this patch (@param and @return directives), especially near the top in language.inc. In a couple of places, I was unsure of whether the variable in question referred to a string, integer or what.

Cheers!

Gábor Hojtsy’s picture

@Lars: I agree adding type hinting all around the language system would be great, please open a new issue about that and link it in here.

Lars Toomre’s picture

As per Gabor's request in #64, issue #1463858: Add variable type hinting to functions in language sub-system has been opened to follow up on the type hinting issue once this patch lands.

Dries’s picture

Dries’s picture

Asking for a re-test as I don't think this patch applies anymore.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, negotiation_method-1222106-61.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
61.35 KB

Just a straight reroll. Should be back to RTBC unless the testbot does not like it :) Nothing changed.

Dries’s picture

I just committed #1272840: Add upgrade path for language domains and validation so I think this needs another re-roll because of the test file changes. I'll ask for a re-test.

Dries’s picture

plach’s picture

Assigned: Unassigned » plach

On it

Status: Reviewed & tested by the community » Needs work

The last submitted patch, negotiation_method-1222106-69.patch, failed testing.

plach’s picture

Assigned: plach » Unassigned
Status: Needs work » Reviewed & tested by the community
FileSize
61.37 KB

Here it is

Status: Reviewed & tested by the community » Needs work

The last submitted patch, negotiation_method-1222106-73.patch, failed testing.

plach’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
61.36 KB

It was a problem with windows line endings. Straight reroll of #69 so leaving RTBC.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the quick re-roll. Committed to 8.x. Thanks everyone.

Gábor Hojtsy’s picture

Issue tags: -sprint

Woot, woot, woot! Yay, thanks everyone!

Gábor Hojtsy’s picture

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added some more summary texts from Gábor.