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
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:
- 2831617-locale-constants
changes, plain diff MR !14391
- test-2831617
changes, plain diff MR !15095
Comments
Comment #2
mpdonadioComment #12
gábor hojtsyReparenting 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.
Comment #17
nicxvan commentedComment #18
claudiu.cristeaI think grouped constants should be moved to backed enums:
For instance LOCALE_TRANSLATION_USE_SOURCE_LOCAL and LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL:
Same for LOCALE_TRANSLATION_OVERWRITE_* and LOCALE_TRANSLATION_* and LOCALE_TRANSLATION_SOURCE_COMPARE_*
Comment #19
claudiu.cristeaLet's try...
Comment #20
claudiu.cristeaComment #21
claudiu.cristeaComment #23
claudiu.cristeaUpdate IS
Comment #24
claudiu.cristeaComment #25
claudiu.cristeaUpdate IS
Comment #26
claudiu.cristeaComment #27
claudiu.cristeaUpdated the CR
Comment #28
claudiu.cristeaComment #29
claudiu.cristeaComment #30
nicxvan commentedI'd propose that the constants in locale.translations.inc
Be addressed in: #3569328: Modernize locale.translations.inc
It keeps everything nicely self contained.
Comment #31
claudiu.cristeaDid 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.
Comment #32
claudiu.cristeaUpdating IS
Comment #33
claudiu.cristeaComment #36
claudiu.cristeaThis is ready for review
Comment #37
claudiu.cristeaComment #38
claudiu.cristeaComment #39
nicxvan commentedCouple of questions, I didn't finish my review.
Comment #40
nicxvan commentedPostponing 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.
Comment #41
nicxvan commentedComment #42
nicxvan commented#3581303: Convert locale batch callbacks
Comment #43
nicxvan commentedLooking 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.