aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ivanov <ai@contributor.pw>2019-11-10 01:27:11 +0300
committerAlex Shpak <alex-shpak@users.noreply.github.com>2019-11-16 20:34:46 +0100
commit9cd378a2d27ad4c9cb2e46d12022e68e23f96ea7 (patch)
tree7ed204e6b8781a9d92175de669b812efc5fe8733
parent890cc000bbe3d5c6058de507e57dc8a4ab095f23 (diff)
Multilang (#93)
* Add i18n langs trans example * partials * Update sample site * cc of variables of config * Clean PR * revert master data
-rw-r--r--exampleSite/config.toml11
-rw-r--r--exampleSite/config.yaml11
-rw-r--r--exampleSite/content/_index.ru.md80
-rw-r--r--exampleSite/i18n/en.yaml6
-rw-r--r--exampleSite/i18n/ru.yaml6
-rw-r--r--layouts/partials/docs/language-switch.html14
-rw-r--r--layouts/partials/docs/menu.html5
-rw-r--r--layouts/partials/docs/translation-switch.html14
8 files changed, 147 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 779c74f..a255c7d 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -13,6 +13,17 @@ enableGitInfo = true
# pygmentsStyle = 'monokailight'
pygmentsCodeFences = true
+# Multilang config
+defaultContentLanguage = 'en'
+
+[languages]
+ [languages.en]
+ languageName = 'English'
+ weight = 1
+ [languages.ru]
+ languageName = 'Russian'
+ weight = 2
+
[params]
# (Optional, default 6) Set how many table of contents levels to be showed on page.
# Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 36b3b5d..5ed865e 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -13,6 +13,17 @@ enableGitInfo: true
# pygmentsStyle: monokailight
pygmentsCodeFences: true
+# Multilang config
+defaultContentLanguage: en
+
+languages:
+ en:
+ languageName: English
+ weight: 1
+ ru:
+ languageName: Russian
+ weight: 2
+
params:
# (Optional, default 6) Set how many table of contents levels to be showed on page.
# Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
diff --git a/exampleSite/content/_index.ru.md b/exampleSite/content/_index.ru.md
new file mode 100644
index 0000000..6bda002
--- /dev/null
+++ b/exampleSite/content/_index.ru.md
@@ -0,0 +1,80 @@
+---
+title: Введение
+type: docs
+---
+
+# Был самым горьким
+
+{{< columns >}}
+
+## Звезд украденное
+
+Существует смутное и Питфие являются гнев большой HAWK царя севера. все, что
+он низводит **руки ее** сестры, стал известно о **маслинах** и я от других,
+просто загорелся? О опрокинуты берега _adicit cursu_ уверенность, чтобы сделать
+
+<--->
+
+## Эм куот вита
+
+Она улыбнулась _furtique_ братья земли больше. Моя шея и держали
+Размешайте несчастные жертвы уже утверждены. Можно сказать, что Совет _quam_,
+сейчас ориентировочным дела идут с правой стороны своего офиса в общем.
+{{< /columns >}}
+
+
+## Tempora nisi nunc
+
+Lorem **markdownum** emicat gestu. Cannis sol pressit ducta. **Est** Idaei,
+tremens ausim se tutaeque, illi ulnis hausit, sed, lumina cutem. Quae avis
+sequens!
+
+ var panel = ram_design;
+ if (backup + system) {
+ file.readPoint = network_native;
+ sidebar_engine_device(cell_tftp_raster,
+ dual_login_paper.adf_vci.application_reader_design(
+ graphicsNvramCdma, lpi_footer_snmp, integer_model));
+ }
+ public_keyboard_docking += error.controller_gibibyte_plug.ip(4,
+ asciiPetaflops, software(supercomputer_compatible_status + 4));
+ dynamic_disk.indexModeLaptop = bufferTftpReality;
+ var export_vlog_sequence = trinitron_flowchart + supercomputer_cluster_rj(
+ -1, toolbar_powerpoint_query, -2 / multiprocessing_impression);
+
+## Locis suis novi cum suoque decidit eadem
+
+Idmoniae ripis, at aves, ali missa adest, ut _et autem_, et ab? Venit spes
+versus finis sermonibus patefecit murum nec est sine oculis. _Ille_ inmota
+macies domoque caelestia cadit tantummodo scelus procul, corde!
+
+1. Dolentem capi parte rostro alvum habentem pudor
+2. Fulgentia sanguine paret
+3. E punior consurgit lentus
+4. Vox hasta eras micantes
+
+## Facibus pharetrae indetonsusque indulsit sic incurrite foliis
+
+Nefandam et prisci palmas! Blandita cutis flectitur montis macies, te _nati_
+Latiis; turbaque inferias. Virginis tibi peracta avidusque facies caper nec, e
+at ademptae, mira.
+
+ direct *= font(inputScareware(sliHome), crossplatform.byte(
+ ppl_encryption.excel_e_rte(integratedModelModifier), timeVirtual,
+ floating_speakers.media_printer(us, yahoo, primaryPhp)));
+ friendly_metal_flatbed(cd, isoPrimaryStorage(reader), dmaMirrored);
+ if (parse_flash_cron.metalGif(1, adServiceDevice, utility)) {
+ adf -= operation_cdma_samba;
+ imapGif.switch += torrent;
+ } else {
+ pmu.disk_captcha = digital_ppp_pci + recursionTransistor(5, dram);
+ ajax_service += grayscalePythonLock;
+ google_scroll_capacity = ftp + engine_dslam_sidebar / tape - 1;
+ }
+ drive_rw = zipTftp;
+ var suffix = software_router_extension.dimm_ddr(-5,
+ kernel_digital_minisite);
+
+Vocavit toto; alas **mitis** maestus in liquidarum ab legi finitimosque dominam
+tibi subitus; Orionis vertitur nota. Currere alti etiam seroque cernitis
+innumeris miraturus amplectique collo sustinet quemque! Litora ante turba?
diff --git a/exampleSite/i18n/en.yaml b/exampleSite/i18n/en.yaml
new file mode 100644
index 0000000..93b0488
--- /dev/null
+++ b/exampleSite/i18n/en.yaml
@@ -0,0 +1,6 @@
+# General
+- id: translations
+ translation: Translations
+
+- id: languages
+ translation: Languages \ No newline at end of file
diff --git a/exampleSite/i18n/ru.yaml b/exampleSite/i18n/ru.yaml
new file mode 100644
index 0000000..6584a39
--- /dev/null
+++ b/exampleSite/i18n/ru.yaml
@@ -0,0 +1,6 @@
+# General
+- id: translations
+ translation: Переводы
+
+- id: languages
+ translation: Языки \ No newline at end of file
diff --git a/layouts/partials/docs/language-switch.html b/layouts/partials/docs/language-switch.html
new file mode 100644
index 0000000..4a84ade
--- /dev/null
+++ b/layouts/partials/docs/language-switch.html
@@ -0,0 +1,14 @@
+{{ if .Site.IsMultiLingual }}
+<ul>
+ <li class="book-section-flat">
+ <span>{{ i18n "languages" }}</span>
+ <ul>
+ {{ range .Site.Home.AllTranslations -}}
+ <li>
+ <a href="{{ .Permalink }}" class="{{ if (eq $.Site.Language .Language ) }}active{{ end }}">{{ .Language.LanguageName }}</a>
+ </li>
+ {{- end }}
+ </ul>
+ </li>
+</ul>
+{{ end }}
diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html
index 6a72ac9..3d04b04 100644
--- a/layouts/partials/docs/menu.html
+++ b/layouts/partials/docs/menu.html
@@ -10,6 +10,11 @@
{{ end }}
{{ partial "docs/inject/menu-after" . }}
+
+{{ if .Site.IsMultiLingual }}
+ {{ partial "docs/translation-switch" . }}
+ {{ partial "docs/language-switch" . }}
+{{ end }}
</nav>
<!-- Restore menu position as soon as possible to avoid flickering -->
diff --git a/layouts/partials/docs/translation-switch.html b/layouts/partials/docs/translation-switch.html
new file mode 100644
index 0000000..4ad0f1a
--- /dev/null
+++ b/layouts/partials/docs/translation-switch.html
@@ -0,0 +1,14 @@
+{{ if .IsTranslated }}
+<ul>
+ <li class="book-section-flat">
+ <span>{{ i18n "translations" }}</span>
+ <ul>
+ {{ range .Translations }}
+ <li>
+ <a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
+ </li>
+ {{ end }}
+ </ul>
+ </li>
+</ul>
+{{ end }} \ No newline at end of file