Problem/Motivation

#3581303: Convert locale batch callbacks
See:

locale.module

  • LOCALE_JS_STRING
  • LOCALE_JS_OBJECT
  • LOCALE_NOT_CUSTOMIZED
  • LOCALE_CUSTOMIZED
  • LOCALE_TRANSLATION_USE_SOURCE_LOCAL
  • LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL
  • LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN
  • LOCALE_TRANSLATION_STATUS_TTL
  • LOCALE_TRANSLATION_OVERWRITE_ALL
  • LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED
  • LOCALE_TRANSLATION_OVERWRITE_NONE
  • LOCALE_TRANSLATION_REMOTE
  • LOCALE_TRANSLATION_LOCAL
  • LOCALE_TRANSLATION_CURRENT

Proposed resolution

Deprecate the constants and replace them according to the following table:

Deprecated constant Replaced by

No public replacement

LOCALE_JS_STRING moved as local variable to _locale_parse_js_file()
LOCALE_JS_OBJECT moved as local variable to _locale_parse_js_file()
LOCALE_JS_OBJECT_CONTEXT moved as local variable to _locale_parse_js_file()
LOCALE_NOT_CUSTOMIZED FALSE
LOCALE_CUSTOMIZED TRUE
LOCALE_TRANSLATION_OVERWRITE_ALL moved as protected constant in LocaleSettingsForm
LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED moved as protected constant in LocaleSettingsForm
LOCALE_TRANSLATION_OVERWRITE_NONE moved as protected constant in LocaleSettingsForm
LOCALE_TRANSLATION_STATUS_TTL moved as protected constant in TranslationStatusForm

Converted to enums

LOCALE_TRANSLATION_USE_SOURCE_LOCAL \Drupal\locale\Model\UsedSourceType::Local
LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL \Drupal\locale\Model\UsedSourceType::RemoteAndLocal
LOCALE_TRANSLATION_REMOTE \Drupal\locale\Model\TranslationSource::Remote
LOCALE_TRANSLATION_LOCAL \Drupal\locale\Model\TranslationSource::Local
LOCALE_TRANSLATION_CURRENT \Drupal\locale\Model\TranslationSource::Current

Remaining tasks

None.

User interface changes

None.

API changes

New enums, see above.

Data model changes

None.

Issue fork drupal-2831617

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mpdonadio created an issue. See original summary.

mpdonadio’s picture

Title: Deprecate global constants in local module » Deprecate global constants in locale module
Issue summary: View changes

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gábor hojtsy’s picture

Reparenting to #3215707: [META] Modernize Locale module where it has more likeliness to be fixed now. I think this may be resolved piece by piece as various include files and global functions that use the constants become services. So it may be that no direct work will be needed in this issue.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.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.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.

nicxvan’s picture

Issue summary: View changes
claudiu.cristea’s picture

I think grouped constants should be moved to backed enums:

For instance LOCALE_TRANSLATION_USE_SOURCE_LOCAL and LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL:

enum LocaleSourceType: string {

  case Local = 'local';
  case RemoteAndLocal = 'remote_and_local';

  public static function asOptions(): array {
    return [
      self::Local->value = t('Drupal translation server and local files'),
      self::Local->value = t('Local files only'),
    ];
  }
}

Same for LOCALE_TRANSLATION_OVERWRITE_* and LOCALE_TRANSLATION_* and LOCALE_TRANSLATION_SOURCE_COMPARE_*

claudiu.cristea’s picture

Assigned: Unassigned » claudiu.cristea

Let's try...

claudiu.cristea’s picture

Version: 11.x-dev » main
claudiu.cristea’s picture

claudiu.cristea’s picture

Issue summary: View changes

Update IS

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Update IS

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Updated the CR

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
nicxvan’s picture

I'd propose that the constants in locale.translations.inc

  • LOCALE_TRANSLATION_SOURCE_COMPARE_LT
  • LOCALE_TRANSLATION_SOURCE_COMPARE_EQ
  • LOCALE_TRANSLATION_SOURCE_COMPARE_GT

Be addressed in: #3569328: Modernize locale.translations.inc
It keeps everything nicely self contained.

claudiu.cristea’s picture

Did some progress but I still need to reflect on BC. This issue is part of modernizing Locale meta, and I think we need some refactoring not only moving the code around.

claudiu.cristea’s picture

Issue summary: View changes

Updating IS

claudiu.cristea’s picture

Issue summary: View changes

claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Issue summary: View changes
Status: Active » Needs review

This is ready for review

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
nicxvan’s picture

Couple of questions, I didn't finish my review.

nicxvan’s picture

Title: Deprecate global constants in locale module » [pp-3] Deprecate global constants in locale module
Status: Needs review » Postponed (maintainer needs more info)

Postponing on #3577671: Modernize locale file handling #3037031: Convert locale.compare.inc to a service and the batch conversion in .inc I haven't created yet.

I spoke briefly with @claudiu.cristeau about the overall order and he agreed this is ok.

nicxvan’s picture

Title: [pp-3] Deprecate global constants in locale module » [pp-2] Deprecate global constants in locale module
nicxvan’s picture

Title: [pp-2] Deprecate global constants in locale module » [pp-1] Deprecate global constants in locale module
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Postponed
nicxvan’s picture

Looking at what remains, this is actually the easiest to do, we should probably do this last since it won't require any dependency injection changes.