Skip to content
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
2 changes: 1 addition & 1 deletion tools/Plotree.Site/Plotree.Site.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LithoSharp" Version="0.3.0" />
<PackageReference Include="LithoSharp" Version="0.3.1" />
</ItemGroup>
</Project>
16 changes: 15 additions & 1 deletion tools/Plotree.Site/PlotreeDocsTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,25 @@ private static string Customize(string relativePath, string html, SiteTemplateCo
var languageSwitch = BuildLanguageSwitch(relativePath, context);
if (languageSwitch.Length > 0)
{
html = html.Replace("</header>", $"{languageSwitch}</header>", StringComparison.Ordinal);
html = InsertLanguageSwitch(html, languageSwitch);
}

return ReplacePagination(relativePath, html, language, context);
}

private static string InsertLanguageSwitch(string html, string languageSwitch)
{
const string headerActions = "<div class=\"docs-header-actions\">";
var actionsStart = html.IndexOf(headerActions, StringComparison.Ordinal);
var actionsEnd = actionsStart < 0
? -1
: html.IndexOf("</div>", actionsStart, StringComparison.Ordinal);

return actionsEnd >= 0
? html.Insert(actionsEnd, languageSwitch)
: html.Replace("</header>", $"{languageSwitch}</header>", StringComparison.Ordinal);
}

private static string BuildNavigation(
string relativePath,
string language,
Expand Down Expand Up @@ -115,6 +128,7 @@ private static string LocalizeChrome(string html, string language)
.Replace("aria-label=\"Documentation navigation\"", "aria-label=\"ドキュメントナビゲーション\"", StringComparison.Ordinal)
.Replace(">On this page<", ">この記事の内容<", StringComparison.Ordinal)
.Replace("aria-label=\"On this page\"", "aria-label=\"この記事の内容\"", StringComparison.Ordinal)
.Replace("aria-label=\"Dark mode\"", "aria-label=\"ダークモード\"", StringComparison.Ordinal)
.Replace("aria-label=\"Document navigation\"", "aria-label=\"文書ナビゲーション\"", StringComparison.Ordinal);
}

Expand Down
Loading