This is the final part of locale module cleaning out of things that are not related to interface translation. The date format translation storage and retrieval is mostly in system module, there are only a couple functions in locale module which is pretty very strange. The date format functions should be moved entirely to system module like we separated concerns before with moving node language to node, path language to path, etc. which in all cases handled it themselves already with minimal code from locale module. Same should apply here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hairqles’s picture

Assigned: Unassigned » hairqles
hairqles’s picture

The following patch should solve this issue.

Gábor Hojtsy’s picture

I think this looks good. The schema is already in system module and although it is keyed by locale, etc. we will hopefully covert this to CMI later, so there is no point to touch any of the code outside of putting it at its true place :) Only one thing we should possibly discuss AFAIS. Otherwise looks good.

+++ b/core/modules/system/system.moduleundefined
@@ -1110,6 +1113,36 @@ function system_menu() {
+  // Localize date formats.
+  if (module_exists('language')) {
+    $items['admin/config/regional/date-time/locale'] = array(

We need to figure out if we need to do this with a module exists or put the same thing in an access callback for the page.

Status: Needs review » Needs work
Gábor Hojtsy’s picture

Does not apply, should be rolled against latest Drupal 8!

hairqles’s picture

Status: Needs work » Needs review
FileSize
29.32 KB
Gábor Hojtsy’s picture

Status: Needs review » Needs work

The code basically renames and moves things around, and this code is going to be further cleaned up when being converted to CMI, so I don't think we should do any further cleanup here. This is purely about moving the functions/tests to their right place, where its schema and API is.

Needs work for the rename, needs review for the module_exists().

+++ b/core/modules/system/lib/Drupal/system/Tests/DateFormats/LocaleDateFormatsTest.phpundefined
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\locale\Tests\LocaleDateFormatsTest.
+ */
+
+namespace Drupal\system\Tests\DateFormats;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Functional tests for localizing date formats.
+ */
+class LocaleDateFormatsTest extends WebTestBase {

Should not be named "Locale..." if its not in locale. I'd name it DateFormatsLanguageTest

+++ b/core/modules/system/system.moduleundefined
@@ -1110,6 +1113,36 @@ function system_menu() {
+
+  // Localize date formats.
+  if (module_exists('language')) {
+    $items['admin/config/regional/date-time/locale'] = array(
+      'title' => 'Localize',

I'd value more feedback on what people think this is better vs. making an access callback which wraps the module_exists() instead. The menu cache is rebuilt when modules get enabled either way, the behavior is the same.

floretan’s picture

Small update: Rename the test and move it to core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php, next to the other Date Format test.

Also updated the form function names. By renaming 'locale_date_format_form' to 'system_date_format_form' we lose the fact that we're dealing with the date localization form and not the main date format form. Updated the name to 'system_date_format_localize_form'.

floretan’s picture

Status: Needs work » Needs review

Regarding the module_exists('language') issue, I find the current version better than creating a new access callback. The latter would be more verbose and would also be slightly less performant. As Gábor mentioned though, the functionality is not affected.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Looks good, just one thing now :)

+++ b/core/modules/locale/locale.moduleundefined
index 0000000..635d70f
--- /dev/null

--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.phpundefined

+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.phpundefined
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.phpundefined
@@ -0,0 +1,82 @@

@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\system\Tests\System\DateFormatLocalizeTest.
+ */
+
+namespace Drupal\system\Tests\System;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Functional tests for localizing date formats.
+ */
+class DateFormatsLanguageTest extends WebTestBase {

Comment in @file has wrong namespace name mentioned.

hairqles’s picture

Gábor Hojtsy’s picture

Status: Needs work » Needs review

Get it tested.

Status: Needs review » Needs work
Gábor Hojtsy’s picture

Status: Needs work » Needs review

Patch is also 3k smaller than previous patches. Did you forget to add/remove a file?

webflo’s picture

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Now looks great, thanks. Does not miss the testfile anymore :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks! :) Woohoo for cleaner code organization!

Gábor Hojtsy’s picture

Issue tags: -sprint

Thanks, moving off sprint.

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