Problem/Motivation

Locale module still has a bunch of legacy include files. As part of the core-wide initiative #3097045: [META] Provide modern replacements for and deprecate the legacy include files this issue focuses on Locale module.

Include files

  • locale.batch.inc #3581303: [pp-2] Convert locale batch callbacks
    • locale_translation_batch_version_check
    • locale_translation_batch_status_check
    • locale_translation_batch_status_finished
    • locale_translation_batch_fetch_download
    • locale_translation_batch_fetch_import
    • locale_translation_batch_fetch_finished
  • File management #3577671: Modernize locale file handling
    • locale_translation_http_check
    • locale_translation_download_source
  • locale.bulk.inc
    • batch related #3581303: [pp-2] Convert locale batch callbacks
      • locale_translate_batch_import_files
      • locale_translate_batch_build
      • locale_translate_batch_import
      • locale_translate_batch_import_save
      • locale_translate_batch_refresh
      • locale_translate_batch_finished
      • locale_config_batch_update_components
      • locale_config_batch_build
      • locale_config_batch_update_default_config_langcodes
      • locale_config_batch_set_config_langcodes deprecated
      • locale_config_batch_update_config_translations
      • locale_config_batch_refresh_name deprecated
      • locale_config_batch_finished
    • File management #3577671: Modernize locale file handling
      • locale_translate_get_interface_translation_files
      • locale_translate_file_create
      • locale_translate_file_attach_properties
      • locale_translate_delete_translation_files
  • locale.compare.inc
    • #3037031: Convert locale.compare.inc to a service (note 1)
      • locale_translation_flush_projects
      • locale_translation_build_projects
      • locale_translation_project_list
      • _locale_translation_prepare_project_list
      • locale_translation_default_translation_server
      • locale_translation_check_projects
      • locale_translation_check_projects_batch
      • locale_translation_batch_status_build
      • _locale_translation_batch_status_operations
      • locale_translation_check_projects_local
  • locale.fetch.inc #3572339: Modernize locale.fetch.inc
    • Already deprecated
  • locale.pages.inc
    • Already deprecated
  • locale.translation.inc

Module file

  • 15 Constants see: #2831617: [pp-2] Deprecate global constants in locale module
  • locale_get_plural #2660338: [pp-3] locale_get_plural call in PluralTranslatableString is wrong
  • Locale system - to be created
    • locale_system_set_config_langcodes
    • locale_system_update
    • locale_system_remove
  • locale submit callbacks - to be created
    • locale_form_language_admin_add_form_alter_submit
    • locale_form_language_admin_edit_form_alter_submit
    • locale_system_file_system_settings_submit
  • #3037156: Create locale import history service
    • locale_translation_get_file_history
    • locale_translation_update_file_history
    • locale_translation_file_history_delete
  • locale status - to be created
    • locale_translation_get_status
    • locale_translation_status_save
    • locale_translation_status_delete_languages
    • locale_translation_status_delete_projects
    • locale_translation_clear_status
  • locale various - to be created
    • locale_translation_use_remote_source
    • locale_string_is_safe
    • locale_translatable_language_list
    • locale_js_translate
    • locale_translation_language_table
    • locale_is_translatable
  • locale underscore - to be created
    • _locale_refresh_translations
    • _locale_refresh_configuration
    • _locale_strip_quotes
    • _locale_parse_js_file
    • _locale_invalidate_js
    • _locale_rebuild_js

Constants

There are several manual require_once and loadInclude.
locale.translation.inc is manually required by:

  • locale.batch.inc
  • locale.compare.inc
  • locale.fetch.inc

Using moduleHandler there are many cross includes.

  • batch
    • includes bulk
  • bulk
    • compare
  • fetch
    • compare
  • module
    • bulk
    • compare
    • fetch
    • translation
  • translation
    • compare
    • fetch

Locale related, but not in scope

Note 1: Part of #1577902: [META] Remove all usages of drupal_static() & drupal_static_reset()
Note 2: Part of #2999721: [META] Deprecate the legacy include files before Drupal 9
Note 3: Part of #1861442: [meta] Review of Drupal\Component\GetText files

Steps to reproduce

Take one file at a time deprecate and move all functions to .module
Deprecate file

Work on constants separately
Start with translations.inc since it is manually required three times.
This will break the chain fastest.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

Sutharsan created an issue. See original summary.

sutharsan’s picture

Issue summary: View changes
sutharsan’s picture

Issue summary: View changes
andypost’s picture

gábor hojtsy’s picture

Fantastic collection. Locale has a lot of history ;) I think chipping away at this in manageable pieces is the best strategy. Hopefully we have enough existing test coverage to ensure refactored things still work. Also we need to identify in each case which parts are "API" and therefore need a full-on @deprecated/@trigger_error treatment. Hopefully most are not.

gábor hojtsy’s picture

Issue summary: View changes

Reparenting constants to this one, since its parent has been fixed for a while.

sutharsan’s picture

I'm working on a spreadsheet to identify procedural functions of Locale module that could be considered candidates for conversion. But Google has changed its interface and I can't find a way to share the content publicly. Slack or mail me your email and I will grand you access.

gábor hojtsy’s picture

#2927222: Move cache invalidation to event out of TranslateEditForm::submitForm() has been clarified. I removed this issue as it's parent, but maybe it is still related. No clear cut lines here :D

sutharsan’s picture

This spreadsheet list all procedural functions of Locale module (not hooks, not preprocess) which may be involved in modernizing. I'm looking at functions that naturally belong together or share enough ground to be grouped together.

https://docs.google.com/spreadsheets/d/1rK4HuF_8fLuHdkspOKXBoJNt7eo-V6NN...

DM me for access.

sutharsan’s picture

Issue summary: View changes
andypost’s picture

Version: 9.3.x-dev » 9.4.x-dev

Moving to 9.4/10

Used to check old issues and found great schema #1189184-200: OOP & PSR-0-ify gettext .po file parsing and generation

GettextOOP.png

Author is Gábor Hojtsy)

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
claudiu.cristea’s picture

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
andypost’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

dcam’s picture

While reviewing #3586472: locale_string_is_safe fails on valid safe html I noted that Drupal\Tests\locale\Kernel\LocaleStringIsSafeTest::testLocaleStringIsSafe() can be converted to a Unit test when locale_string_is_safe() is moved from the .module file into a class. I assume it isn't already a Unit test because of the global procedural function calls.