Files
Umbraco-CMS/src/Umbraco.Core/Extensions/LanguageServiceExtensions.cs
Andy Butland 78f4caa2be Refactoring: Add extension method for retrieval of language ISO codes if that's all we need (#20324)
* Retrieve only ISO codes from the database rather than full language objects if that's all we need.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Removed repository updates and migrated the new service method to an extension method.

* Fixed issue after merge.

* Removed left-over using

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
2025-10-01 18:21:41 +00:00

17 lines
602 B
C#

using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Core.Extensions;
/// <summary>
/// Provides extension methods for <see cref="ILanguageService"/>.
/// </summary>
public static class LanguageServiceExtensions
{
/// <summary>
/// Retrieves all ISO codes of all languages.
/// </summary>
/// <param name="service">The <see cref="ILanguageService"/>.</param>
/// <returns>A collection of language ISO codes.</returns>
public static async Task<IEnumerable<string>> GetAllIsoCodesAsync(this ILanguageService service) => (await service.GetAllAsync()).Select(x => x.IsoCode);
}