diff --git a/tools/Plotree.Site/Plotree.Site.csproj b/tools/Plotree.Site/Plotree.Site.csproj index b10626e..e3bb922 100644 --- a/tools/Plotree.Site/Plotree.Site.csproj +++ b/tools/Plotree.Site/Plotree.Site.csproj @@ -7,6 +7,6 @@ - + diff --git a/tools/Plotree.Site/PlotreeDocsTemplate.cs b/tools/Plotree.Site/PlotreeDocsTemplate.cs index 9498848..6faca96 100644 --- a/tools/Plotree.Site/PlotreeDocsTemplate.cs +++ b/tools/Plotree.Site/PlotreeDocsTemplate.cs @@ -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("", $"{languageSwitch}", StringComparison.Ordinal); + html = InsertLanguageSwitch(html, languageSwitch); } return ReplacePagination(relativePath, html, language, context); } + private static string InsertLanguageSwitch(string html, string languageSwitch) + { + const string headerActions = "
"; + var actionsStart = html.IndexOf(headerActions, StringComparison.Ordinal); + var actionsEnd = actionsStart < 0 + ? -1 + : html.IndexOf("
", actionsStart, StringComparison.Ordinal); + + return actionsEnd >= 0 + ? html.Insert(actionsEnd, languageSwitch) + : html.Replace("", $"{languageSwitch}", StringComparison.Ordinal); + } + private static string BuildNavigation( string relativePath, string language, @@ -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); }