Skip to content

Commit f080ef4

Browse files
committed
i18n
1 parent b92054c commit f080ef4

File tree

27 files changed

+390
-89
lines changed

27 files changed

+390
-89
lines changed

assets/js/flexsearch.zh-cn.js

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*!
2+
* FlexSearch for Bootstrap based Thulite sites
3+
* Copyright 2021-2024 Thulite
4+
* Licensed under the MIT License
5+
* Based on https://github.com/frjo/hugo-theme-zen/blob/main/assets/js/search.js
6+
*/
7+
8+
/* eslint-disable no-undef, guard-for-in */
9+
10+
/**
11+
* @file
12+
* A JavaScript file for flexsearch.
13+
*/
14+
15+
// import * as FlexSearch from 'flexsearch';
16+
import Index from 'flexsearch';
17+
18+
(function () {
19+
20+
'use strict';
21+
22+
// const index = new FlexSearch.Document({
23+
const index = new Index.Document({
24+
tokenize: 'forward',
25+
document: {
26+
id: 'id',
27+
index: [
28+
{
29+
field: 'title'
30+
},
31+
{
32+
field: 'tags'
33+
},
34+
{
35+
field: {{ if site.Params.doks.indexSummary }}'summary'{{ else }}'content'{{ end }}
36+
},
37+
{
38+
field: 'date',
39+
tokenize: 'strict',
40+
encode: false
41+
}
42+
],
43+
store: ['title','summary','date','permalink']
44+
}
45+
});
46+
47+
function showResults(items) {
48+
const template = document.querySelector('template').content;
49+
const fragment = document.createDocumentFragment();
50+
51+
const results = document.querySelector('.search-results');
52+
results.textContent = '';
53+
54+
const itemsLength = Object.keys(items).length;
55+
56+
// Show/hide "No recent searches" and "No search results" messages
57+
if ((itemsLength === 0) && (query.value === '')) {
58+
// Hide "No search results" message
59+
document.querySelector('.search-no-results').classList.add('d-none');
60+
// Show "No recent searches" message
61+
document.querySelector('.search-no-recent').classList.remove('d-none');
62+
} else if ((itemsLength === 0) && (query.value !== '')) {
63+
// Hide "No recent searches" message
64+
document.querySelector('.search-no-recent').classList.add('d-none');
65+
// Show "No search results" message
66+
const queryNoResults = document.querySelector('.query-no-results');
67+
queryNoResults.innerText = query.value;
68+
document.querySelector('.search-no-results').classList.remove('d-none');
69+
} else {
70+
// Hide both "No recent searches" and "No search results" messages
71+
document.querySelector('.search-no-recent').classList.add('d-none');
72+
document.querySelector('.search-no-results').classList.add('d-none');
73+
}
74+
75+
for (const id in items) {
76+
const item = items[id];
77+
const result = template.cloneNode(true);
78+
const a = result.querySelector('a');
79+
const time = result.querySelector('time');
80+
const content = result.querySelector('.content');
81+
a.innerHTML = item.title;
82+
a.href = item.permalink;
83+
time.innerText = item.date;
84+
content.innerHTML = item.summary;
85+
fragment.appendChild(result);
86+
}
87+
88+
results.appendChild(fragment);
89+
}
90+
91+
function doSearch() {
92+
const query = document.querySelector('.search-text').value.trim();
93+
const limit = {{ .searchLimit }};
94+
const results = index.search({
95+
query: query,
96+
enrich: true,
97+
limit: limit,
98+
});
99+
const items = {};
100+
101+
results.forEach(function (result) {
102+
result.result.forEach(function (r) {
103+
items[r.id] = r.doc;
104+
});
105+
});
106+
107+
showResults(items);
108+
}
109+
110+
function enableUI() {
111+
const searchform = document.querySelector('.search-form');
112+
searchform.addEventListener('submit', function (e) {
113+
e.preventDefault();
114+
doSearch();
115+
});
116+
searchform.addEventListener('input', function () {
117+
doSearch();
118+
});
119+
document.querySelector('.search-loading').classList.add('d-none');
120+
document.querySelector('.search-input').classList.remove('d-none');
121+
document.querySelector('.search-text').focus();
122+
}
123+
124+
function buildIndex() {
125+
document.querySelector('.search-loading').classList.remove('d-none');
126+
fetch("{{ site.LanguagePrefix }}/search-index.json")
127+
.then(function (response) {
128+
return response.json();
129+
})
130+
.then(function (data) {
131+
data.forEach(function (item) {
132+
index.add(item);
133+
});
134+
});
135+
}
136+
137+
buildIndex();
138+
enableUI();
139+
})();

config/_default/hugo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ summarylength = 20 # 70 (default)
1212

1313
# Multilingual
1414
defaultContentLanguage = "en"
15-
disableLanguages = ["de", "nl"]
15+
disableLanguages = []
1616
defaultContentLanguageInSubdir = false
1717

1818
copyRight = "Copyright (c) 2020-2024 Thulite"

config/_default/languages.toml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
[en]
2-
languageName = "English"
32
contentDir = "content/en"
3+
disabled = false
4+
languageCode = 'en-US'
5+
languageDirection = 'ltr'
6+
languageName = 'English'
7+
title = 'MikaShell'
48
weight = 10
59
[en.params]
6-
languageISO = "EN"
7-
languageTag = "en-US"
810
footer = 'Brought to you by <a class="text-muted" href="https://thulite.io/">Thulite</a>'
9-
alertText = '<a class="alert-link stretched-link fw-normal" href="/blog/example-post/">Doks version 1.0 just shipped!</a>'
1011

11-
[de]
12-
languageName = "German"
13-
contentDir = "content/de"
14-
weight = 15
15-
[de.params]
16-
languageISO = "DE"
17-
languageTag = "de-DE"
18-
footer = 'Gebaut mit <a class="text-muted" href="https://thulite.io/">Thulite</a>'
19-
alertText = 'Neue Version ist da! <a class="alert-link stretched-link" href="https://getdoks.org/blog/doks-v0.5/">Doks v0.5</a>'
20-
21-
[nl]
22-
languageName = "Nederlands"
23-
contentDir = "content/nl"
24-
weight = 20
25-
[nl.params]
26-
languageISO = "NL"
27-
languageTag = "nl-NL"
28-
titleAddition = "Modern documentatie-thema"
29-
description = "Doks is een Hugo-thema waarmee je moderne documentatie-websites kunt bouwen die veilig, snel en klaar voor SEO zijn — standaard."
30-
titleHome = "Doks thema"
31-
footer = 'Mogelijk gemaakt door <a href="https://www.netlify.com/">Netlify</a>, <a href="https://gohugo.io/">Hugo</a>, en <a href="https://getdoks.org/">Doks</a>'
32-
alertText = 'Introductie van het Doks-kinderthema, verschillende DX + UX-updates en meer! <a class="alert-link stretched-link" href="https://getdoks.org/blog/doks-v0.2/">Bekijk Doks v0.2</a>'
12+
[zh-cn]
13+
contentDir = "content/zh-cn"
14+
disabled = false
15+
languageCode = 'zh-CN'
16+
languageDirection = 'ltr'
17+
languageName = '简体中文'
18+
title = 'MikaShell'
19+
[zh-cn.params]
20+
footer = 'Brought to you by <a class="text-muted" href="https://thulite.io/">Thulite</a>'

config/_default/menus/menus.nl.toml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# [[docs]]
2+
# name = "Prologue"
3+
# weight = 10
4+
# identifier = "prologue"
5+
# url = "/docs/prologue/"
6+
7+
# [[docs]]
8+
# name = "Help"
9+
# weight = 60
10+
# identifier = "help"
11+
# url = "/docs/help/"
12+
13+
# [[docs]]
14+
# name = "Lorem"
15+
# weight = 70
16+
# identifier = "lorem"
17+
# url = "/docs/lorem/"
18+
19+
[[guide]]
20+
name = "Lorem"
21+
weight = 10
22+
identifier = "lorem"
23+
url = "/guide/lorem/"
24+
25+
[[tutorial]]
26+
name = "Lorem"
27+
weight = 10
28+
identifier = "lorem"
29+
url = "/tutorial/lorem/"
30+
31+
[[main]]
32+
name = "Docs"
33+
url = "/docs/guides/example-guide/"
34+
# url = "/docs/1.0/prologue/introduction/"
35+
weight = 10
36+
37+
[[main]]
38+
name = "Blog"
39+
url = "/blog/"
40+
weight = 30
41+
42+
# [[social]]
43+
# name = "Twitter"
44+
# pre = '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M4 4l11.733 16h4.267l-11.733 -16z"></path><path d="M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"></path></svg>'
45+
# url = "https://twitter.com/getdoks"
46+
# weight = 10
47+
#
48+
# [[social]]
49+
# name = "Discord"
50+
# pre = '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-discord" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 12a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M14 12a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8.5 17c0 1 -1.356 3 -1.832 3c-1.429 0 -2.698 -1.667 -3.333 -3c-.635 -1.667 -.476 -5.833 1.428 -11.5c1.388 -1.015 2.782 -1.34 4.237 -1.5l.975 1.923a11.913 11.913 0 0 1 4.053 0l.972 -1.923c1.5 .16 3.043 .485 4.5 1.5c2 5.667 2.167 9.833 1.5 11.5c-.667 1.333 -2 3 -3.5 3c-.5 0 -2 -2 -2 -3"></path><path d="M7 16.5c3.5 1 6.5 1 10 0"></path></svg>'
51+
# url = "https://getdoks.org/chat"
52+
# weight = 20
53+
54+
[[social]]
55+
name = "GitHub"
56+
pre = '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-github" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5"></path></svg>'
57+
url = "https://github.com/thuliteio/doks"
58+
post = "v0.1.0"
59+
weight = 30
60+
61+
# [[social]]
62+
# name = "LinkedIn"
63+
# pre = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M21,21H17V14.25C17,13.19 15.81,12.31 14.75,12.31C13.69,12.31 13,13.19 13,14.25V21H9V9H13V11C13.66,9.93 15.36,9.24 16.5,9.24C19,9.24 21,11.28 21,13.75V21M7,21H3V9H7V21M5,3A2,2 0 0,1 7,5A2,2 0 0,1 5,7A2,2 0 0,1 3,5A2,2 0 0,1 5,3Z"/></svg>'
64+
# url = "https://www.linkedin.com/"
65+
# weight = 40
66+
67+
# [[sidebar_docs]]
68+
# name = "Guides"
69+
# pageRef = "/docs/guides"
70+
# weight = 10
71+
#
72+
# [[sidebar_docs]]
73+
# name = "Reference"
74+
# pageRef = "/docs/reference"
75+
# weight = 20
76+
#
77+
# [[sidebar_docs]]
78+
# name = "Resources"
79+
# pageRef = "/docs/resources"
80+
# weight = 30
81+
82+
[[footer]]
83+
name = "Privacy Policy"
84+
url = "/privacy/"
85+
weight = 10
86+
87+
# [[footer]]
88+
# name = "Terms of Service"
89+
# url = "/terms/"
90+
# weight = 20

config/_default/module.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99

1010
## content
1111
[[mounts]]
12-
source = "content"
12+
source = "content/en"
1313
target = "content"
14+
[[mounts]]
15+
source = "content/zh-cn"
16+
target = "content"
17+
lang = "zh-cn"
1418

1519
## data
1620
[[mounts]]

config/_default/params.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ mainSections = ["docs"]
5151
scrollSpy = true # true (default) or false
5252

5353
# Multilingual
54-
multilingualMode = false # false (default) or true
54+
multilingualMode = true # false (default) or true
5555
showMissingLanguages = true # whether or not to show untranslated languages in the language menu; true (default) or false
5656

5757
# Versioning

content/en/_index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "MikaShell"
3+
description: ""
4+
lead: "Build your own Linux desktop shell using modern web front-end technologies."
5+
date: 2023-09-07T16:33:54+02:00
6+
lastmod: 2023-09-07T16:33:54+02:00
7+
draft: false
8+
seo:
9+
title: "MikaShell" # custom title (optional)
10+
description: "" # custom description (recommended)
11+
canonical: "" # custom canonical URL (optional)
12+
noindex: false # false (default) or true
13+
---
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)