Browse Source

Rename `EnableGoogleTranslation` to `EnableGoogleTranslate`.

pull/20213/head
maliming 2 years ago
parent
commit
9023e30b83
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs
  2. 4
      modules/docs/src/Volo.Docs.Web/DocsWebGoogleOptions.cs
  3. 16
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

2
modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs

@ -166,7 +166,7 @@ namespace VoloDocs.Web
Configure<DocsWebGoogleOptions>(options => Configure<DocsWebGoogleOptions>(options =>
{ {
options.EnableGoogleTranslation = true; options.EnableGoogleTranslate = true;
options.EnableGoogleProgrammableSearchEngine = true; options.EnableGoogleProgrammableSearchEngine = true;
options.GoogleSearchEngineId = "77c7266532da1427f"; options.GoogleSearchEngineId = "77c7266532da1427f";
}); });

4
modules/docs/src/Volo.Docs.Web/DocsWebGoogleOptions.cs

@ -6,7 +6,7 @@ namespace Volo.Docs;
public class DocsWebGoogleOptions public class DocsWebGoogleOptions
{ {
public bool EnableGoogleTranslation { get; set; } public bool EnableGoogleTranslate { get; set; }
/// <summary> /// <summary>
/// https://cloud.google.com/translate/docs/languages /// https://cloud.google.com/translate/docs/languages
@ -21,7 +21,7 @@ public class DocsWebGoogleOptions
public DocsWebGoogleOptions() public DocsWebGoogleOptions()
{ {
EnableGoogleTranslation = false; EnableGoogleTranslate = false;
IncludedLanguages = IncludedLanguages =
[ [
"en", "en",

16
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

@ -22,7 +22,7 @@
@inject IThemeManager ThemeManager @inject IThemeManager ThemeManager
@inject IPageLayout PageLayout @inject IPageLayout PageLayout
@inject IHtmlLocalizer<DocsResource> L @inject IHtmlLocalizer<DocsResource> L
@inject IOptions<DocsWebGoogleOptions> DocsWebOptions @inject IOptions<DocsWebGoogleOptions> DocsWebGoogleOptions
@model IndexModel @model IndexModel
@{ @{
@ -58,15 +58,15 @@
<abp-script src="/Pages/Documents/Shared/Scripts/vs.js"/> <abp-script src="/Pages/Documents/Shared/Scripts/vs.js"/>
<abp-script src="/Pages/Documents/Project/index.js"/> <abp-script src="/Pages/Documents/Project/index.js"/>
</abp-script-bundle> </abp-script-bundle>
if (DocsWebOptions.Value.EnableGoogleTranslation) if (DocsWebGoogleOptions.Value.EnableGoogleTranslate)
{ {
<script type="text/javascript"> <script type="text/javascript">
function googleTranslateElementInit() { function googleTranslateElementInit() {
new google.translate.TranslateElement({ new google.translate.TranslateElement({
pageLanguage: '@DocsWebOptions.Value.GetCultureLanguageCode(CultureInfo.CurrentUICulture)', pageLanguage: '@DocsWebGoogleOptions.Value.GetCultureLanguageCode(CultureInfo.CurrentUICulture)',
autoDisplay: false, autoDisplay: false,
disableAutoTranslation: true, disableAutoTranslation: true,
includedLanguages: '@string.Join(",", DocsWebOptions.Value.IncludedLanguages)', includedLanguages: '@string.Join(",", DocsWebGoogleOptions.Value.IncludedLanguages)',
layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
}, 'google_translate_element'); }, 'google_translate_element');
} }
@ -86,9 +86,9 @@
</script> </script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
} }
if (DocsWebOptions.Value.EnableGoogleProgrammableSearchEngine) if (DocsWebGoogleOptions.Value.EnableGoogleProgrammableSearchEngine)
{ {
<script async src="https://cse.google.com/cse.js?cx=@DocsWebOptions.Value.GoogleSearchEngineId"></script> <script async src="https://cse.google.com/cse.js?cx=@DocsWebGoogleOptions.Value.GoogleSearchEngineId"></script>
} }
} }
else else
@ -218,7 +218,7 @@
} }
</div> </div>
@if (DocsWebOptions.Value.EnableGoogleTranslation) @if (DocsWebGoogleOptions.Value.EnableGoogleTranslate)
{ {
<div class="docs-version mt-2 skiptranslate"> <div class="docs-version mt-2 skiptranslate">
<span>@L["GoogleTranslate"]</span> <span>@L["GoogleTranslate"]</span>
@ -323,7 +323,7 @@
</div> </div>
} }
@if (DocsWebOptions.Value.EnableGoogleProgrammableSearchEngine) @if (DocsWebGoogleOptions.Value.EnableGoogleProgrammableSearchEngine)
{ {
<div class="gcse-search"></div> <div class="gcse-search"></div>
} }

Loading…
Cancel
Save