Skip to content

Commit

Permalink
Write dictionary items out in folders when UseFlat is false. KevinJum…
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Jul 28, 2021
1 parent cda3cfa commit 7d590d0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion uSync8.ContentEdition/Handlers/DictionaryHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;

Expand Down Expand Up @@ -168,7 +169,22 @@ protected override string GetItemName(IDictionaryItem item)
=> item.ItemKey;

protected override string GetItemPath(IDictionaryItem item, bool useGuid, bool isFlat)
=> item.ItemKey.ToSafeFileName();
{
if (isFlat) return item.ItemKey.ToSafeFileName();
return GetDictionaryPath(item);
}

private string GetDictionaryPath(IDictionaryItem item)
{
if (item.ParentId.HasValue)
{
var parent = localizationService.GetDictionaryItemById(item.ParentId.Value);
if (parent != null)
return item.ItemKey.ToSafeFileName() + Path.DirectorySeparatorChar + GetDictionaryPath(parent);
}

return item.ItemKey.ToSafeFileName();
}

protected override void InitializeEvents(HandlerSettings settings)
{
Expand Down

0 comments on commit 7d590d0

Please sign in to comment.