This issue is spawned from #1222106: Unify language negotiation APIs, declutter terminology to do standardization in the language bootstrap and language types initialization that is closely related. The proposed changes are as follows:

Previous name New name Rationale
drupal_language_initialize() no change As per suggestions in #1222106: Unify language negotiation APIs, declutter terminology by @plach.
drupal_language_types() language_types_get_default() Establish a language_types_get_* namespace for list getter functions (there are three of them to unify). Avoid overcrowding the drupal_* namespace.
language_types() language_types_get_all() See above.
language_types_configurable() language_types_get_configurable() See above.
language_initialize() language_types_initialize() Initializes language types in fact. Should keep under this 'namespace'.
language_types_info() no change Returns hook_language_types_info() values altered with hook_language_types_info_alter().
language_types_disable() no change Disables language types.
language_types_set() no change Resets the language types cache list (used by all the language_types_get_*() functions).

That is all the language_types_*() functions after the patch neatly lined up according to a consistent pattern. Before the patch (if you look at the first column), the function names are spread wide and wild. (The attached patch is untested just to start up this cleanup).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, langauge-types-unify-names.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
19.92 KB

drupal_language_intiialize() was not renamed at all places. Ha.

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.

aspilicious’s picture

Status: Needs review » Needs work
+++ b/core/includes/language.incundefined
@@ -11,11 +11,41 @@
+ * Choose a language for the given type based on language negotiation settings.

ChooseS I know that the old docs made the same mistake but as you're writing new ones.

+++ b/core/includes/language.incundefined
@@ -11,11 +11,41 @@
+/**
+ * Return information about all defined language types.
+ *
+ * @see hook_language_types_info().
+ * @return

ReturnS

The @see should be in the end with a newline above it.

+++ b/core/includes/language.incundefined
@@ -11,11 +11,41 @@
+ *   An associated array of language type information arrays keyed by type ¶

trailing whitespace

+++ b/core/modules/locale/locale.api.phpundefined
@@ -65,13 +65,19 @@ function hook_language_switch_links_alter(array &$links, $type, $path) {
- *   the following key-value pairs:
+ *   An associative array of language type definitions. ¶
+ * ¶
+ *   Each language type has an identifier key which is used as the name for the
+ *   global variable corresponding to the language type in the bootstrap phase. ¶
+ *
+ *   The language type definition is an associative array that may contain the
+ *   following key-value pairs:
  *   - "name": The human-readable language type identifier.
  *   - "description": A description of the language type.
- *   - "fixed": An array of language provider identifiers. Defining this key
- *     makes the language type non-configurable.
+ *   - "fixed": A fixed array of language provider identifiers to use to ¶
+ *     initialize this language. Defining this key makes the language type
+ *     non-configurable and will always use the specified providers in the

Trailing whitespace party

-25 days to next Drupal core point release.

aspilicious’s picture

Issue summary: View changes

Updated issue summary.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
16.61 KB

@plach: Reverted change suggestions for the bootstrap function based on @plach's comment in #1222106: Unify language negotiation APIs, declutter terminology and in the interest of less dispute :) Updated issue summary.
@aspilicious: made changes you've suggested, thanks!

Also noticed the file name had a typo. Fixed that too.

Status: Needs review » Needs work

The last submitted patch, language-types-unify-names-6.patch, failed testing.

aspilicious’s picture

+++ b/core/includes/bootstrap.incundefined
@@ -2620,13 +2620,19 @@ function drupal_language_initialize() {
+ *   An array of key-values pairs where the key is the language type name and ¶

another one

You should search for an "remove trailing whitespaces on save" option in your text editor. Makes your life easier ;)

-26 days to next Drupal core point release.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
16.62 KB

I admit I'm evaluating sublime text 2 now, and did not yet figure out the trailing whitespace issue :) Here is a quick patch update which hopefully fixes all line end whitespace and the test failure as well. I certainly don't want to bother you with whitespace issues :)

Gábor Hojtsy’s picture

Issue tags: +negotiation

Tagging for language negotiation too.

aspilicious’s picture

http://drupal.org/node/1346890 i made this page, you will like it

plach’s picture

Issue summary: View changes

Updated issue summary.

plach’s picture

Status: Needs review » Needs work

Do we want to switch to the scope terminology in this patch? If so I'd go for the singular form:

language_scope_get_defaults()
language_scope_get_all()
language_scope_get_configurable()
language_scope_initialize()
language_scope_info() 
hook_language_scope_info()
hook_language_scope_info_alter()
language_scope_disable()
language_scope_set()

Anyway:

+++ b/core/includes/language.inc
@@ -11,11 +11,42 @@
+ *   An associated array of language type information arrays keyed by type
+ *   names. Base on information from hook_language_types_info().

Associated? I think we normally use the "indexed" or "associative" terms. Also "Base" should be "Based", I guess.

+++ b/core/includes/language.inc
@@ -113,12 +145,12 @@ function language_types_set() {
+  // Ensure that subsequent calls of language_types_get_configurable() return the

Wrong comment wrapping.

+++ b/core/modules/locale/locale.api.php
@@ -88,6 +94,7 @@ function hook_language_types_info() {
+ * @see hook_language_types_info().

IIRC there should be a blank line before the @param(s).

+++ b/core/modules/locale/locale.api.php
@@ -65,13 +65,19 @@ function hook_language_switch_links_alter(array &$links, $type, $path) {
+ *     non-configurable and will always use the specified providers in the
+ *     given priority order.

"given" should be moved one line up.

-28 days to next Drupal core point release.

Gábor Hojtsy’s picture

Ok, let's do those then!

rvilar’s picture

Assigned: Unassigned » rvilar

After a little mail conversation with Gábor, I'm going to work on the switch scope terminology

plach’s picture

@rvilar:

Great! Also LANGUAGE_TYPE_* constants will need to be updated.

sun’s picture

Hm. Where did we discuss "scope"? When I read #12 I had no idea what a scope is and that the proposal was to rename language types to scopes. I'm not sure whether that term is really an improvement over the current, and thus, whether it's worth to break and change the API and what people have learned (aside from the locale/language function name changes). It might be, but hm.

Gábor Hojtsy’s picture

@sun: I could not find any discussion either (and cannot recall one where scope was decided on either). The closest to that happened in #1156576: Language negotiation is undocumented, but we did not discuss what to rename types to. Just that "types" is not the best name maybe. I don't know if scope or type is better, either case it needs documentation to enlighten the use of the terms in Drupal as neither is a well known term (but rather Drupalisms). Whether it is good to move to a new Drupalism from an old Drupalism, I don't know. The above patch did not get much traction otherwise, so it was logical to try and move to a direction accepted by more reviewers I guess. If you happen to stand on the language_types side, then well, we have a passing patch and we can talk about making that land - and then we can document it in a way that is easily backportable :) I believe it needs some good documentation either way and wanted to get people going on that once we have the types / negotiation APIs cleaned up.

plach’s picture

@sun:

I proposed this change in #1222106-4: Unify language negotiation APIs, declutter terminology and Gabor seemed to approve it. I spoke with @chx in IRC proposing him the scope terminology and he said something like "everything is better than type". If we want to go the scope way @rvilar is available to write the patch, if not no worries, but the patch in #9 needs work.

sun’s picture

I guess we can simply move on and discuss the terminology in parallel. May or may not be a simple rename in the final patch in the end, depending on the discussion. We need to change the function names either way.

rvilar’s picture

Assigned: rvilar » Unassigned
Status: Needs work » Needs review
FileSize
62.12 KB

I attach a patch with the rename done. Please, review and comment on that.

Gábor Hojtsy’s picture

@rvilar: have you applied the other changes suggested by @plach?

rvilar’s picture

Yes. I've applied all the suggestions and corrections.

plach’s picture

Status: Needs review » Needs work

Now we have two mostly RTBC patches, let's discuss which one we prefer :)

As I said, if we want to change the type terminology (which might make sense) I'd go for scope, since IMHO it make more clear what the actual meaning is: for instance, I'm thinking of a page where the admin menu and the local tasks have the admin language, the rest of the UI has the site default language and a translated content is being showed. Type fits here as well, but if we want to change it, scope is my favorite alternative.

Maybe what we want is a committer feedback here? I doubt we will get any from @chx.

@rvilar:

Thanks, I had a quick look to the patch and found some comments not wrapping correctly:

+++ b/core/includes/language.inc
@@ -11,54 +11,85 @@
+ * A language scope maybe configurable or fixed. A fixed language scope is a scope
...
+++ b/core/includes/language.inc
@@ -11,54 +11,85 @@
+ *   If set to FALSE retrieves values from the actual language scope definitions.
...
+++ b/core/includes/language.inc
@@ -68,57 +99,58 @@ function language_types_configurable($stored = TRUE) {
+  // whether the 'fixed' key is defined. Non-configurable (fixed) language scopes
...
+++ b/core/includes/language.inc
@@ -68,57 +99,58 @@ function language_types_configurable($stored = TRUE) {
+  // Ensure that subsequent calls of language_scope_get_configurable() return the
...
+++ b/core/modules/locale/locale.admin.inc
@@ -72,11 +72,11 @@ function _locale_languages_configure_form_language_table(&$form, $type) {
+    // List the provider only if the current scope is defined in its 'scopes' key.
...
+++ b/core/modules/locale/locale.admin.inc
@@ -187,29 +187,29 @@ function theme_locale_languages_configure_form($variables) {
+  // Update non-configurable language scopes and the related language negotiation
...
+++ b/core/modules/locale/locale.api.php
@@ -104,9 +111,9 @@ function hook_language_types_info_alter(array &$language_types) {
+ *   - "scopes": An array of allowed language scopes. If a language provider does

Wrong comment wrapping.

Gábor Hojtsy’s picture

My view on type vs. scope is that either will need to be well documented and will not be immediately understood by people, so I'm neutral on that really. Chatted with @sun a bit in IRC about it and after he pulled out a dictionary to look up the concrete definition of scope, he said he might like scope more, but it might not have been his final word.

sun’s picture

"scope" might be the best option. But I think we should ideally ask some developers who are unfamiliar with this issue to answer this open question:

What is or what kind of functionality would you associate with a Language Scope API?

(you can replace "Scope" with "Type", "Context", etc)

Tor Arne Thune’s picture

Speaking as myself when I first encountered the term 'language type' it made absolutely no sense to me. I can only imagine how my understanding would be with the term 'language scope' back when I started out, but now it makes more sense to me than language type. Language scope to me means on what 'areas' the language settings will apply. Language type does not let me imagine what this could mean in the context of Drupal at all. Language context is not bad either, but I feel scope is better, because it probably will not be used elsewhere in Drupal, and therefore be less confounding when encountering other parts of Drupal with similar names.

Gábor Hojtsy’s picture

Let's see if we get any input (not that it would be representative): https://twitter.com/gaborhojtsy/status/164326586336821249

Gábor Hojtsy’s picture

All feedback I got was:

- Dave Reid: "Literally have no idea what functionality a language scope API would be responsible for or do."
- Neclimdul: "Oh no. Language Scope API doesn't mean anything to me but I don't do a lot of internationalization development. "
- Crell: "It would allow you to translate mouthwash into different languages."

Which looks like it confirms that (a) people don't engage with D8MI much (b) it will need a lot more docs either way.

plach’s picture

It would allow you to translate mouthwash into different languages

LOL

I think we need Dries' feedback. As Tor Arne Thune was pointing out in #26 probably for someone needing to deal with ML aspects scope would be a bit more accessible than type, but docs will be a key factor anyway. We need to understand if the time spent on polishing the terminology is worth this gain or whether we should leave it as is.

Gábor Hojtsy’s picture

I'm still not sure it is worth the gain (especially given the very limited scope of this API if you forgive the pun :) as we need to document it anyways.

plach’s picture

No problem at all with that. I just want to have a link to show to anyone will say the language type does not mean anything ;)

Kristen Pol’s picture

I'll throw in my 2 cents... I prefer "type" rather than "scope" only because it is a more familiar term (in general) and I don't normally see "scope" used in programming. I definitely do have a strong aversion to using "context" only because of the Context module and CTools context and other uses of the word within Drupal.

[update] After seeing the drupal_language_types() function, I understand why "scope" was proposed. It does seem more "appropriate" though I still like the sound of "type" better for some intangible reason.

function drupal_language_types() {
  return array(
    LANGUAGE_TYPE_INTERFACE => TRUE,
    LANGUAGE_TYPE_CONTENT => FALSE,
    LANGUAGE_TYPE_URL => FALSE,
  );
}

What about language group? Or, category?

Kristen

plach’s picture

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

Rerolled #9 with the cosmetic fixes proposed in #12 applied. The patch "logic" is unchanged.

I'd be glad If @Dries could let us know his opinion about whether we need to change the "language type" terminology (see #16 and following). IMO his feedback has a double value here: as the project lead's and as the one of a core developer non deeply involved in multilingual stuff.

If we decide to keep "type" I'd say this is ready to go in.

Status: Reviewed & tested by the community » Needs work
Issue tags: -API clean-up, -D8MI, -sprint, -language-base, -negotiation

The last submitted patch, language_types-1416392-33.patch, failed testing.

plach’s picture

Status: Needs work » Needs review

#33: language_types-1416392-33.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +API clean-up, +D8MI, +sprint, +language-base, +negotiation

The last submitted patch, language_types-1416392-33.patch, failed testing.

plach’s picture

It seems some new tests got in meanwhile...

Gábor Hojtsy’s picture

@plach: Keeping type seems like the safest choice since we did not get much support to change it to something else either. I think strong docs will help there a lot. Also, we should not be obsessed with this qustion a lot, we have a lot more important stuff to do. Can you work on fixing the tests?

plach’s picture

I'l have a look to tests tonight if someone does not beat me to it before
(feel free ;)

plach’s picture

Status: Needs work » Needs review
FileSize
17.3 KB

Tests were failing due to #1331370: [Upgrade path broken] Stored include paths need to be updated to /core before running the upgrade path that introduced a new call to language_types() in the upgrade preparation phase.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

I think based on the feedback we got, it looks like we are better off committing this simple cleanup now and see how the context system progresses later, when this code will be revisited again. We can move on in the meantime to work with the rest of the negotiation code and move it around to language module, so if this is committed, our work can roll on.

The patch only contains phpdoc fixes and standarized function names as documented above in the issue summary, and I think its a straightforward and logical DX improvement to get in. We'll proceed documenting the whole negotiation system when we are over cleaning up the rest of the negotiation components.

Kristen Pol’s picture

Looks good... thanks @plach!

Kristen

Dries’s picture

Assigned: Unassigned » Dries

Assigning this to myself so I can comment on the terminology (as requested above). I think I should be able to do this tomorrow.

Gábor Hojtsy’s picture

@Dries, this has been a week ago. Can you help move this forward?

plach’s picture

#40: language_types-1416392-40.patch queued for re-testing.

Gábor Hojtsy’s picture

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

Patch did not apply anymore due to changes in #1430986: Clean up naming for language negotiation configuration functions/paths. Only a single hunk in locale.admin.inc was not applying due to changes very close to where it should change to language_types_get_configurable(). Rerolled. Should be back to RTBC IMHO once it proves it passes tests again.

Gábor Hojtsy’s picture

Testbot got stuck. Re-upload patch to get it rested since it cannot be re-tested via the UI in this state. Same patch as the previous comment, no change, just re-trigging testbot.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC as per the above.

Gábor Hojtsy’s picture

Patch applied with offsets. Rerolling just to make sure it applies 100% clean. No changes (same byte size in fact :).

Dries’s picture

Assigned: Dries » Unassigned
Status: Reviewed & tested by the community » Fixed

I'm not sure $scope is better than $type. We can discuss that in another issue. In the mean time, this patch looks like great progress. Committed to 8.x. Sorry for holding this one up.

Gábor Hojtsy’s picture

Issue tags: -sprint

Added change notice at http://drupal.org/node/1450154. Removing outdated tag.

Gábor Hojtsy’s picture

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.