Code Tidy: Clean up further obsoleted code scheduled for removal in Umbraco 18 (ILocalizationService)#22677
Conversation
…e all callers to non-obsolete alternatives.
|
Claude finished @AndyButland's task in 6m 6s —— View job PR ReviewTarget: Removes
Important
Suggestions
Request ChangesOne important bug (dictionary items added to the result list even when the save fails, including with |
There was a problem hiding this comment.
Pull request overview
Removes the obsolete ILocalizationService API surface (and implementation) as part of the Umbraco 18 cleanup, migrating all remaining callers to ILanguageService and IDictionaryItemService (plus repositories where int-ID lookups are needed).
Changes:
- Deleted
ILocalizationService/LocalizationServiceand removed DI registration. - Migrated core/runtime callers (telemetry, search, packaging, published-value fallback, editing services) to
ILanguageService+IDictionaryItemServiceand adjustedServiceContext. - Refactored a couple of sync-over-async paths (notably
IDictionaryService.CalculatePathAsync) and updated/added tests accordingly.
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Examine/ContentValueSetBuilderTests.cs | Updates builder tests for removed localization dependency. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Telemetry/SystemTroubleshootingInformationTelemetryProviderTests.cs | Switches test wiring from ILocalizationService to ILanguageService. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/SystemInformationServiceTests.cs | Updates mocks to ILanguageService.GetDefaultIsoCodeAsync(). |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DictionaryServiceTests.cs | Adds unit tests for new CalculatePathAsync behavior. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Models/UserExtensionsTests.cs | Adds tests for CalculateAllowedLanguageIdsAsync. |
| tests/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/UrlAndDomains/DomainAndUrlsTests.cs | Updates default language retrieval to ILanguageService. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/LocalizationServiceTests.cs | Removes integration tests for deleted localization service. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/EntityXmlSerializerTests.cs | Uses IDictionaryItemService for dictionary item lookup. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockListElementLevelVariationTests.Publishing.cs | Updates default culture lookup to ILanguageService. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs | Removes unused ILocalizationService fixture property. |
| tests/Umbraco.Tests.Integration/Umbraco.Examine.Lucene/UmbracoExamine/IndexInitializer.cs | Removes localization dependency and updates mocked language service usage. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Packaging/CreatedPackagesRepositoryTests.cs | Adjusts PackagesRepository construction; adds export coverage for language int-ID path. |
| tests/Umbraco.Tests.Integration/CompatibilitySuppressions.xml | Drops suppression tied to removed ctor signature. |
| src/Umbraco.Web.Common/Templates/TemplateRenderer.cs | Drops unused ILocalizationService constructor parameter and doc entry. |
| src/Umbraco.Infrastructure/Telemetry/Providers/SystemTroubleshootingInformationTelemetryProvider.cs | Swaps to ILanguageService for default language reporting. |
| src/Umbraco.Infrastructure/Telemetry/Providers/LanguagesTelemetryProvider.cs | Swaps language counting to ILanguageService. |
| src/Umbraco.Infrastructure/Search/UmbracoTreeSearcherFields.cs | Swaps configured-language enumeration to ILanguageService. |
| src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs | Splits localization concerns into ILanguageService/IDictionaryItemService, adds warning logging and userId→key resolution. |
| src/Umbraco.Infrastructure/Examine/ContentValueSetBuilder.cs | Removes redundant ILocalizationService dependency and reuses earlier default culture value. |
| src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs | Updates factory methods to new PackagesRepository/PackageDataInstallation constructors. |
| src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Examine.cs | Removes localization service injection from ContentValueSetBuilder construction. |
| src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs | Changes optional ctor dependency from ILocalizationService? to ILanguageService?. |
| src/Umbraco.Core/Services/ServiceContext.cs | Removes LocalizationService; adds LanguageService and DictionaryItemService. |
| src/Umbraco.Core/Services/NotificationService.cs | Updates language lookups to ILanguageService. |
| src/Umbraco.Core/Services/MemberContentEditingService.cs | Removes obsolete localization dependency from base ctor chain. |
| src/Umbraco.Core/Services/MediaEditingService.cs | Removes obsolete localization dependency from base ctor chain. |
| src/Umbraco.Core/Services/LocalizationService.cs | Deletes obsolete implementation. |
| src/Umbraco.Core/Services/ILocalizationService.cs | Deletes obsolete public interface. |
| src/Umbraco.Core/Services/IDictionaryService.cs | Replaces CalculatePath with async CalculatePathAsync. |
| src/Umbraco.Core/Services/EntityXmlSerializer.cs | Uses IDictionaryItemService for child enumeration. |
| src/Umbraco.Core/Services/ElementEditingService.cs | Removes obsolete localization dependency from base ctor chain. |
| src/Umbraco.Core/Services/DictionaryService.cs | Refactors to async recursion using IDictionaryItemService. |
| src/Umbraco.Core/Services/ContentEditingServiceWithSortingBase.cs | Removes obsolete localization dependency from base ctor chain. |
| src/Umbraco.Core/Services/ContentEditingServiceBase.cs | Switches allowed-language calculation to new async extension. |
| src/Umbraco.Core/Services/ContentEditingService.cs | Removes obsolete localization dependency from ctor. |
| src/Umbraco.Core/Services/ContentBlueprintEditingService.cs | Removes obsolete localization dependency from base ctor chain. |
| src/Umbraco.Core/PublishedCache/DefaultCultureAccessor.cs | Uses ILanguageService.GetDefaultIsoCodeAsync() instead of localization service. |
| src/Umbraco.Core/Packaging/PackagesRepository.cs | Replaces localization service with repositories + scope provider for int-ID lookups; consolidates scope usage. |
| src/Umbraco.Core/Notifications/LanguageSavingNotification.cs | Updates docs to reference ILanguageService (needs wording tweak—see comments). |
| src/Umbraco.Core/Notifications/LanguageSavedNotification.cs | Updates docs to reference ILanguageService (needs wording tweak—see comments). |
| src/Umbraco.Core/Notifications/LanguageDeletingNotification.cs | Updates docs to reference ILanguageService. |
| src/Umbraco.Core/Notifications/LanguageDeletedNotification.cs | Updates docs to reference ILanguageService. |
| src/Umbraco.Core/Notifications/DictionaryItemSavingNotification.cs | Updates docs to reference IDictionaryItemService (needs wording tweak—see comments). |
| src/Umbraco.Core/Notifications/DictionaryItemSavedNotification.cs | Updates docs to reference IDictionaryItemService (needs wording tweak—see comments). |
| src/Umbraco.Core/Notifications/DictionaryItemDeletingNotification.cs | Updates docs to reference IDictionaryItemService. |
| src/Umbraco.Core/Notifications/DictionaryItemDeletedNotification.cs | Updates docs to reference IDictionaryItemService. |
| src/Umbraco.Core/Models/UserExtensions.cs | Replaces sync CalculateAllowedLanguageIds with CalculateAllowedLanguageIdsAsync. |
| src/Umbraco.Core/Models/PublishedContent/PublishedValueFallback.cs | Uses ServiceContext.LanguageService and async language lookups. |
| src/Umbraco.Core/Dictionary/DefaultCultureDictionaryFactory.cs | Splits dependency into ILanguageService + IDictionaryItemService. |
| src/Umbraco.Core/Dictionary/DefaultCultureDictionary.cs | Replaces localization service usage with language/dictionary item services. |
| src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs | Removes ILocalizationService registration from core services. |
| src/Umbraco.Core/CLAUDE.md | Updates service list documentation to replace localization service with language/dictionary services. |
# Conflicts: # src/Umbraco.Core/Services/EntityXmlSerializer.cs # src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs # src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs # tests/Umbraco.Tests.Integration/CompatibilitySuppressions.xml
nikolajlauridsen
left a comment
There was a problem hiding this comment.
Looks good, I've merged v18/dev into this branch 👍
# Conflicts: # src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs # src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/LocalizationServiceTests.cs
Description
This continues the v18 cleanup series, removing the
ILocalizationServiceinterface and itsLocalizationServiceimplementation. Both were[Obsolete]and scheduled for removal in Umbraco 18; every public method onILocalizationServicehad a named replacement (ILanguageService,IDictionaryItemService) and all internal callers have been migrated.Removed
Umbraco.Cms.Core.Services.ILocalizationServiceUmbraco.Cms.Core.Services.LocalizationServiceServices.AddUnique<ILocalizationService, LocalizationService>()registrationLocalizationServiceTests(existingLanguageServiceTestsandDictionaryItemServiceTestscover all the behaviour the deleted suite covered, plus more)Migrated callers
LogPageUrlJob,LanguagesTelemetryProvider,SystemTroubleshootingInformationTelemetryProvider,UmbracoTreeSearcherFields,DefaultCultureAccessor,ContentValueSetBuilder,UmbracoContentIndex(Lucene) →ILanguageServiceTemplateRenderer→ unusedILocalizationServiceparameter droppedDictionaryService,EntityXmlSerializer→IDictionaryItemServiceDefaultCultureDictionary+DefaultCultureDictionaryFactory,PublishedValueFallback,NotificationService→ILanguageService+IDictionaryItemServiceContentEditingServiceBase(and the six derived services:ContentEditingService,ContentEditingServiceWithSortingBase,ContentBlueprintEditingService,MediaEditingService,MemberContentEditingService,ElementEditingService) →ILanguageService(consumed via the migratedIUser.CalculateAllowedLanguageIdsAsyncextension)PackageDataInstallation→ILanguageService+IDictionaryItemService+IUserIdKeyResolverPackagesRepository→ILanguageRepository+IDictionaryRepository+ICoreScopeProvider(mirrors what the deletedLocalizationService.GetLanguageById(int)/GetDictionaryItemById(int)did internally — these int-ID lookups have no equivalent on the new public services)ServiceContextThe
ILocalizationService LocalizationServiceproperty and its corresponding constructor /CreatePartialparameter have been removed. Equivalents for the replacement services have been added so they remain accessible fromServiceContext:LanguageService,DictionaryItemService.Async refactors
IUser.CalculateAllowedLanguageIds(ILocalizationService)extension has been removed and replaced withCalculateAllowedLanguageIdsAsync(ILanguageService). The single internal caller (ContentEditingServiceBase.GetAllowedCulturesForEditingUser) was already async, so this removes a sync-over-async hop on the editing/validation path.IDictionaryService.CalculatePathhas been replaced withCalculatePathAsync. The implementation now uses true async recursion viaIDictionaryItemService.GetAsyncinstead of.GetAwaiter().GetResult().Tests
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DictionaryServiceTests.cswith four unit tests covering the null-parent, root-parent, nested-hierarchy, and missing-parent paths throughCalculatePathAsync.UserExtensionsTests.cscoveringCalculateAllowedLanguageIdsAsyncfor the access-to-all and group-restricted paths.GivenLanguages_WhenPackageExported_ThenTheXmlContainsThemtoCreatedPackagesRepositoryTests— exercises the int-ID →_languageRepository.Get(int)path inPackagesRepository.PackageLanguages, which previously had no test coverage.Mock.Of<ILocalizationService>()to use the appropriate replacement service mock.Other notable changes
PackageDataInstallation.Import*methods now log a warning when aCreate/Updateattempt fails. PreviouslyLocalizationService.Save(ILanguage)threwInvalidOperationExceptiononLanguageOperationStatus.InvalidFallback; now a single bad language no longer aborts the whole package install — it logs and continues, matching howImportScripts,ImportPartialViews, etc. behave.PackageDataInstallationresolves user ids to user keys viaIUserIdKeyResolver.TryGetAsync, falling back toSuperUserKeyfor unknown ids — same pattern introduced in Code Tidy: Clean up further obsoleted code scheduled for removal in Umbraco 18 (IFileService) #22675.PackagesRepository.PackageLanguagesandPackageDictionaryItemsnow open a single scope around the loop rather than one per iteration. The class is[Obsolete]at class level butExportPackagedoesn't establish an ambient scope, so the scopes are still required.ContentValueSetBuilderhadILocalizationServiceinjected alongside the already-presentILanguageService— the redundant dependency has been dropped and the second_localizationService.GetDefaultLanguageIsoCode()call site reuses the existingdefaultCulturelocal from earlier in the same method.ILocalizationService.Breaking changes
All driven by the
ILocalizationServiceremoval; unavoidable while keeping the public API coherent in v18:ServiceContext: constructor signature changed;LocalizationServiceproperty removed;CreatePartialparameter removed. NewLanguageService/DictionaryItemServiceproperties added in their place.NotificationService,DictionaryService,DefaultCultureAccessor,DefaultCultureDictionaryFactory,ContentValueSetBuilder,UmbracoTreeSearcherFields,LanguagesTelemetryProviderconstructors:ILocalizationServiceparameter replaced by the relevant per-domain service(s).UmbracoContentIndex(Lucene): optionalILocalizationService?constructor parameter is nowILanguageService?; the protectedLanguageServiceproperty type has changed to match.IUser.CalculateAllowedLanguageIds(ILocalizationService)extension has been removed; newCalculateAllowedLanguageIdsAsync(ILanguageService)added.IDictionaryService.CalculatePath(Guid?, int)has been removed; newCalculatePathAsync(Guid?, int)added.PackageDataInstallationprimary constructor addsILanguageService,IDictionaryItemService,IUserIdKeyResolverand dropsILocalizationService. The two[Obsolete]v19-scheduled overloads have been deleted (each took anILocalizationServiceparameter that no longer exists, so they could not be retained for the originally scheduled deprecation window).PackagesRepositoryconstructor (already[Obsolete]at the class level):ILocalizationServiceparameter replaced byILanguageRepository+IDictionaryRepository+ICoreScopeProvider.Testing
Solution builds and tests pass.
I've done manual checks of:
AutomaticPackageMigrationPlancontaining a language and a dictionary item with translations, to verify thePackageDataInstallation.ImportLanguagesandImportDictionaryItemspaths still work end-to-end.