Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows localization of search categories #5053

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace DotNetNuke.Services.Search.Internals
/// -----------------------------------------------------------------------------
internal class InternalSearchControllerImpl : IInternalSearchController
{
private const string SearchableModuleDefsKey = "{0}-{1}";
private const string SearchableModuleDefsKey = "{0}-{1}-{2}";
private const string SearchableModuleDefsCacheKey = "SearchableModuleDefs";
private const string LocalizedResxFile = "~/DesktopModules/Admin/SearchResults/App_LocalResources/SearchableModules.resx";

Expand Down Expand Up @@ -79,7 +79,7 @@ public InternalSearchControllerImpl()
public IEnumerable<SearchContentSource> GetSearchContentSourceList(int portalId)
{
var searchableModuleDefsCacheArgs = new CacheItemArgs(
string.Format(SearchableModuleDefsKey, SearchableModuleDefsCacheKey, portalId),
string.Format(SearchableModuleDefsKey, SearchableModuleDefsCacheKey, portalId, Thread.CurrentThread.CurrentCulture),
120, CacheItemPriority.Default);

var list = CBO.GetCachedObject<IList<SearchContentSource>>(
Expand All @@ -92,7 +92,7 @@ public IEnumerable<SearchContentSource> GetSearchContentSourceList(int portalId)
public string GetSearchDocumentTypeDisplayName(SearchResult searchResult)
{
// ModuleDefId will be zero for non-module
var key = string.Format("{0}-{1}", searchResult.SearchTypeId, searchResult.ModuleDefId);
var key = string.Format("{0}-{1}-{2}", searchResult.SearchTypeId, searchResult.ModuleDefId, Thread.CurrentThread.CurrentCulture);
var keys = CBO.Instance.GetCachedObject<IDictionary<string, string>>(
new CacheItemArgs(key, 120, CacheItemPriority.Default), this.SearchDocumentTypeDisplayNameCallBack, false);

Expand Down Expand Up @@ -340,7 +340,7 @@ private object SearchDocumentTypeDisplayNameCallBack(CacheItemArgs cacheItem)
var searchContentSources = this.GetSearchContentSourceList(portal.PortalID);
foreach (var searchContentSource in searchContentSources)
{
var key = string.Format("{0}-{1}", searchContentSource.SearchTypeId, searchContentSource.ModuleDefinitionId);
var key = string.Format("{0}-{1}-{2}", searchContentSource.SearchTypeId, searchContentSource.ModuleDefinitionId, Thread.CurrentThread.CurrentCulture);
if (!data.ContainsKey(key))
{
data.Add(key, searchContentSource.LocalizedName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void SetUp()
this.internalSearchController = InternalSearchController.Instance;

this.mockCBO = new Mock<ICBO>();
var tabKey = string.Format("{0}-{1}", TabSearchTypeId, 0);
var userKey = string.Format("{0}-{1}", UserSearchTypeId, 0);
var tabKey = string.Format("{0}-{1}-{2}", TabSearchTypeId, 0, CultureEnUs);
var userKey = string.Format("{0}-{1}-{2}", UserSearchTypeId, 0, CultureEnUs);
this.mockCBO.Setup(c => c.GetCachedObject<IDictionary<string, string>>(It.IsAny<CacheItemArgs>(), It.IsAny<CacheItemExpiredCallback>(), It.IsAny<bool>()))
.Returns(new Dictionary<string, string>() { { tabKey, TabSearchTypeName }, { userKey, UserSearchTypeName } });
CBO.SetTestableInstance(this.mockCBO.Object);
Expand Down