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: 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: 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- #3569328: Modernize locale.translations.inc
- Already deprecated
Module file
- 15 Constants see: #2831617: [pp-1] Deprecate global constants in locale module
- Locale plural index #2660338: Deprecate locale_get_plural
- locale_get_plural
- locale submit callbacks #3595084: Deprecate locale submit callbacks
- locale_system_set_config_langcodes
- locale_system_update
- locale_system_remove
- locale_form_language_admin_add_form_alter_submit
- locale_form_language_admin_edit_form_alter_submit
- #3037156: Modernize locale history functions
- locale_translation_get_file_history
- locale_translation_update_file_history
- locale_translation_file_history_delete
- locale status - #3590050: Deprecate and replace locale_status related functions
- 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
- #1834298: Unify name space in Locale module (note 2)
- #2935189: Complete docblock comments in Gettext component. (note 3)
- #1861360: Refactor localization update test so people can just enable the test module to test
- #2965866: Refactor LocaleUpdateBase to allow locale kernel tests
- #2927222: Move cache invalidation to event out of TranslateEditForm::submitForm()
- #2875279: Update core modules to use the new batch builder
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.
Comments
Comment #2
sutharsan commentedComment #3
sutharsan commentedComment #4
andypostBatches could use #2875279: Update core modules to use the new batch builder
Comment #5
gábor hojtsyFantastic 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.
Comment #6
gábor hojtsyReparenting constants to this one, since its parent has been fixed for a while.
Comment #7
sutharsan commentedI'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.Comment #8
gábor hojtsy#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
Comment #9
sutharsan commentedThis 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.
Comment #10
sutharsan commentedComment #11
sutharsan commentedAdding references to related issues to make discovering this issue easier.
Comment #12
andypostMoving 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
Author is Gábor Hojtsy)
Comment #17
nicxvan commentedComment #18
nicxvan commentedComment #19
nicxvan commentedComment #20
nicxvan commentedComment #21
nicxvan commentedComment #22
nicxvan commentedComment #23
claudiu.cristeaComment #24
nicxvan commentedComment #25
nicxvan commentedComment #26
nicxvan commentedComment #27
andypostComment #28
nicxvan commentedComment #29
nicxvan commentedComment #30
nicxvan commentedComment #31
nicxvan commentedComment #32
nicxvan commentedComment #33
nicxvan commentedComment #34
nicxvan commentedComment #35
nicxvan commentedComment #36
nicxvan commentedComment #37
nicxvan commentedComment #38
nicxvan commentedComment #39
dcam commentedWhile 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 whenlocale_string_is_safe()is moved from the.modulefile into a class. I assume it isn't already a Unit test because of the global procedural function calls.Comment #40
nicxvan commentedComment #41
nicxvan commentedComment #42
nicxvan commentedI just checked how many search results there are for each function. I think some of the hook related ones should be grouped:
locale_translatable_language_list 14 results
locale_get_plural 8 results
locale_system_set_config_langcodes 2 results, only tests already replaced
locale_system_update 3 results can move to LocaleHooks protected maybe
locale_system_remove 2 results can move to LocaleHooks protected maybe
locale_js_translate 1 results can move to LocaleHooks protected maybe
locale_form_language_admin_add_form_alter_submit 2 results can move to LocaleHooks
locale_form_language_admin_edit_form_alter_submit 1 result can move to LocaleHooks
locale_system_file_system_settings_submit 0 results already deprecated
locale_translation_status_delete_languages 1 result can move to LocaleHooks
locale_is_translatable 8 results
locale_translation_get_file_history 12 results
locale_translation_update_file_history 3 results
locale_translation_file_history_delete 2 results
locale_translation_get_status 26 results
locale_translation_status_save 5 results
locale_translation_status_delete_projects 2 results only deletes keyvalue
locale_translation_clear_status 3 results only deletes keyvalue and state
locale_translation_use_remote_source 6 results only checks config
locale_string_is_safe 11 results
_locale_refresh_translations 3 results
_locale_refresh_configuration 1 result inline in TranslateEditForm
_locale_strip_quotes 5 results
_locale_parse_js_file 6 results
_locale_invalidate_js 5 results
_locale_rebuild_js 4 results
locale_translation_language_table 1 result inline in TranslationStatusForm
Comment #43
berdirReplying here, re #2660338: Deprecate locale_get_plural and #42:
I think it might be better to focus on locale_get_plural() there. That's a non-trivial case that goes outside of locale module. not sure if that needs to remain postponed, I don't think it directly conflicts with the others too much, but it's been helpful to focus on those issues one-by-one.
Agreed on grouping a bunch of functions that we move to protected methods on the hook service, the system ones and possibly also JS. Plus, several underscored helpers are called through locale_js_translate() that could go in there as well.
Maybe one other issue for everything form related. note: locale_translation_language_table is a callback, agree it can be a static method on the form, not "inline" though. _locale_refresh_configuration() unsure, while that one is only called from the form, it's right next do _locale_refresh_translations(), which has 2 additional calls, might make sense to keep them together.
The leftovers are then I think one or multiple utility service(s), we can split depending on their dependencies for example. locale_translatable_language_list() and locale_is_translatable() are clearly related, locale_translation_use_remote_source() kind of. locale_string_is_safe() and then there's not too much left.
Comment #44
nicxvan commentedYes after doing the review of usages I think you're right I'll update the plural issue in a bit.
Comment #45
nicxvan commentedComment #46
nicxvan commentedComment #47
nicxvan commented