mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved search experience in many languages
This commit is contained in:
parent
c75fca5105
commit
e6e7536356
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
material/assets/javascripts/bundle.dd72b84b.min.js
vendored
Normal file
2
material/assets/javascripts/bundle.dd72b84b.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.dd72b84b.min.js.map
Normal file
1
material/assets/javascripts/bundle.dd72b84b.min.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,10 +1,10 @@
|
||||
{
|
||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.565e6875.min.js",
|
||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.565e6875.min.js.map",
|
||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.dd72b84b.min.js",
|
||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.dd72b84b.min.js.map",
|
||||
"assets/javascripts/vendor.js": "assets/javascripts/vendor.de50e36d.min.js",
|
||||
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.de50e36d.min.js.map",
|
||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.7a2ea5ba.min.js",
|
||||
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.7a2ea5ba.min.js.map",
|
||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.9b3611bd.min.js",
|
||||
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.9b3611bd.min.js.map",
|
||||
"assets/stylesheets/main.css": "assets/stylesheets/main.545621a7.min.css",
|
||||
"assets/stylesheets/main.css.map": "assets/stylesheets/main.545621a7.min.css.map",
|
||||
"assets/stylesheets/palette.css": "assets/stylesheets/palette.36d1b78f.min.css",
|
||||
|
@ -183,7 +183,7 @@
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/vendor.de50e36d.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.565e6875.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.dd72b84b.min.js' | url }}"></script>
|
||||
{%- set translations = {} -%}
|
||||
{%- for key in [
|
||||
"clipboard.copy",
|
||||
@ -207,7 +207,7 @@
|
||||
base: "{{ base_url }}",
|
||||
features: {{ config.theme.features | tojson }},
|
||||
search: Object.assign({
|
||||
worker: "{{ 'assets/javascripts/worker/search.7a2ea5ba.min.js' | url }}"
|
||||
worker: "{{ 'assets/javascripts/worker/search.9b3611bd.min.js' | url }}"
|
||||
}, typeof search !== "undefined" && search)
|
||||
})
|
||||
</script>
|
||||
|
@ -11,8 +11,7 @@
|
||||
"footer.next": "التالية",
|
||||
"meta.comments": "التعليقات",
|
||||
"meta.source": "المصدر",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "بحث",
|
||||
"search.result.placeholder": "اكتب لبدء البحث",
|
||||
"search.result.none": "لا توجد نتائج",
|
||||
|
@ -10,7 +10,6 @@
|
||||
"footer.next": "Další",
|
||||
"meta.comments": "Komentáře",
|
||||
"meta.source": "Zdroj",
|
||||
"search.config.lang": "ro",
|
||||
"search.placeholder": "Hledat",
|
||||
"search.result.placeholder": "Pište co se má vyhledat",
|
||||
"search.result.none": "Nenalezeny žádné dokumenty",
|
||||
|
@ -10,7 +10,6 @@
|
||||
"footer.next": "Järgmine",
|
||||
"meta.comments": "Kommentaarid",
|
||||
"meta.source": "Lähtekood",
|
||||
"search.config.pipeline": "",
|
||||
"search.placeholder": "Otsi",
|
||||
"search.result.placeholder": "Otsimiseks kirjuta siia",
|
||||
"search.result.none": "Otsingule ei leitud ühtegi vastet",
|
||||
|
@ -10,6 +10,7 @@
|
||||
"footer.next": "Προηγούμενη",
|
||||
"meta.comments": "Σχόλια",
|
||||
"meta.source": "Πηγή",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "Αναζήτηση",
|
||||
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
|
||||
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",
|
||||
|
@ -11,8 +11,7 @@
|
||||
"footer.next": "הַבָּא",
|
||||
"meta.comments": "הערות",
|
||||
"meta.source": "מָקוֹר",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "לחפש",
|
||||
"search.result.placeholder": "הקלד כדי להתחיל לחפש",
|
||||
"search.result.none": "אין מסמכים תואמים",
|
||||
|
@ -10,8 +10,7 @@
|
||||
"footer.next": "आगामी",
|
||||
"meta.comments": "टिप्पणियाँ",
|
||||
"meta.source": "स्रोत",
|
||||
"search.config.lang": "ar"
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "खोज",
|
||||
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
|
||||
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",
|
||||
|
@ -10,7 +10,6 @@
|
||||
"footer.next": "Sljedeće",
|
||||
"meta.comments": "Komentari",
|
||||
"meta.source": "Izvor",
|
||||
"search.config.pipeline": "",
|
||||
"search.placeholder": "Pretraživanje",
|
||||
"search.result.placeholder": "Unesite pojam pretraživanja",
|
||||
"search.result.none": "Ništa nije pronađeno",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"meta.comments": "コメント",
|
||||
"meta.source": "ソース",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\s\- 、。,.]+",
|
||||
"search.placeholder": "検索",
|
||||
"search.result.placeholder": "検索キーワードを入力してください",
|
||||
|
@ -10,7 +10,6 @@
|
||||
"footer.next": "다음",
|
||||
"meta.comments": "댓글",
|
||||
"meta.source": "출처",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "검색",
|
||||
"search.result.placeholder": "검색어를 입력하세요",
|
||||
|
@ -13,8 +13,7 @@
|
||||
"meta.comments": "မှတ်ချက်များ",
|
||||
"meta.source": "ရင်းမြစ်",
|
||||
"nav.title": "လမ်းညွှန်",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "ရှာရန်",
|
||||
"search.reset": "ရှင်းလင်း",
|
||||
"search.result.placeholder": "ရှာဖွေခြင်းစရန် စာရိုက်ပါ",
|
||||
|
@ -11,7 +11,6 @@
|
||||
"meta.comments": "Комментарии",
|
||||
"meta.source": "Исходный код",
|
||||
"search.config.lang": "ru",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.placeholder": "Поиск",
|
||||
"search.result.placeholder": "Начните печатать для поиска",
|
||||
"search.result.none": "Совпадений не найдено",
|
||||
|
@ -10,7 +10,6 @@
|
||||
"footer.next": "Sledeće",
|
||||
"meta.comments": "Komentari",
|
||||
"meta.source": "Izvor",
|
||||
"search.config.lang": "ro",
|
||||
"search.placeholder": "Pretraga",
|
||||
"search.result.placeholder": "Unesite pojam pretrage",
|
||||
"search.result.none": "Ništa nije pronađeno",
|
||||
|
@ -11,7 +11,6 @@
|
||||
"meta.comments": "Коментари",
|
||||
"meta.source": "Извор",
|
||||
"search.config.lang": "ru",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.placeholder": "Претрага",
|
||||
"search.result.placeholder": "Унесите појам претраге",
|
||||
"search.result.none": "Нису пронађени документи",
|
||||
|
@ -10,6 +10,7 @@
|
||||
"footer.next": "ต่อไป",
|
||||
"meta.comments": "ความคิดเห็น",
|
||||
"meta.source": "แหล่งที่มา",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "ค้นหา",
|
||||
"search.result.placeholder": "พิมพ์เพื่อเริ่มค้นหา",
|
||||
"search.result.none": "ไม่พบเอกสารที่ตรงกัน",
|
||||
|
@ -10,6 +10,7 @@
|
||||
"footer.next": "Sau",
|
||||
"meta.comments": "Bình luận",
|
||||
"meta.source": "Mã nguồn",
|
||||
"search.config.lang": "vi",
|
||||
"search.placeholder": "Tìm kiếm",
|
||||
"search.result.placeholder": "Nhập để bắt đầu tìm kiếm",
|
||||
"search.result.none": "Không tìm thấy tài liệu liên quan",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"meta.comments": "評論",
|
||||
"meta.source": "來源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\,\。]+",
|
||||
"search.placeholder": "搜尋",
|
||||
"search.result.placeholder": "鍵入以開始檢索",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"meta.comments": "留言",
|
||||
"meta.source": "來源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\s\- 、。,.?;]+",
|
||||
"search.placeholder": "搜尋",
|
||||
"search.result.placeholder": "打字進行搜尋",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"meta.comments": "评论",
|
||||
"meta.source": "来源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\,\。]+",
|
||||
"search.placeholder": "搜索",
|
||||
"search.result.placeholder": "键入以开始搜索",
|
||||
|
@ -58,9 +58,9 @@ export interface SearchIndexDocument {
|
||||
* Search index pipeline function
|
||||
*/
|
||||
export type SearchIndexPipelineFn =
|
||||
| "stemmer" /* Stemmer */
|
||||
| "stopWordFilter" /* Stop word filter */
|
||||
| "trimmer" /* Trimmer */
|
||||
| "stopWordFilter" /* Stop word filter */
|
||||
| "stemmer" /* Stemmer */
|
||||
|
||||
/**
|
||||
* Search index pipeline
|
||||
@ -92,6 +92,25 @@ export interface SearchResult {
|
||||
sections: SectionDocument[] /* Section documents */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Compute the difference of two lists of strings
|
||||
*
|
||||
* @param a - 1st list of strings
|
||||
* @param b - 2nd list of strings
|
||||
*
|
||||
* @return Difference
|
||||
*/
|
||||
function difference(a: string[], b: string[]): string[] {
|
||||
const [x, y] = [new Set(a), new Set(b)]
|
||||
return [
|
||||
...new Set([...x].filter(value => !y.has(value)))
|
||||
]
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Class
|
||||
* ------------------------------------------------------------------------- */
|
||||
@ -147,15 +166,20 @@ export class Search {
|
||||
this.use((lunr as any).multiLanguage(...config.lang))
|
||||
}
|
||||
|
||||
/* Set up pipeline according to configuration */
|
||||
this.pipeline.reset()
|
||||
for (const fn of pipeline!)
|
||||
this.pipeline.add(lunr[fn])
|
||||
/* Compute functions to be removed from the pipeline */
|
||||
const fns = difference([
|
||||
"trimmer", "stopWordFilter", "stemmer"
|
||||
], pipeline!)
|
||||
|
||||
/* Set up search pipeline according to configuration */
|
||||
this.searchPipeline.reset()
|
||||
for (const fn of pipeline!)
|
||||
this.searchPipeline.add(lunr[fn])
|
||||
/* Remove functions from the pipeline for every language */
|
||||
for (const lang of config.lang.map(language => (
|
||||
language === "en" ? lunr : (lunr as any)[language]
|
||||
))) {
|
||||
for (const fn of fns) {
|
||||
this.pipeline.remove(lang[fn])
|
||||
this.searchPipeline.remove(lang[fn])
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up fields and reference */
|
||||
this.field("title", { boost: 1000 })
|
||||
|
@ -51,5 +51,5 @@ export function defaultTransform(value: string): string {
|
||||
return value
|
||||
.replace(/(?:^|\s+)[*+-:^~]+(?=\s+|$)/g, "")
|
||||
.trim()
|
||||
.replace(/\s+|\b$/g, "* ")
|
||||
.replace(/\s+|(?![^\x00-\x7F]|^)$|\b$/g, "* ")
|
||||
}
|
||||
|
@ -31,8 +31,7 @@
|
||||
"footer.next": "التالية",
|
||||
"meta.comments": "التعليقات",
|
||||
"meta.source": "المصدر",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "بحث",
|
||||
"search.result.placeholder": "اكتب لبدء البحث",
|
||||
"search.result.none": "لا توجد نتائج",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"footer.next": "Další",
|
||||
"meta.comments": "Komentáře",
|
||||
"meta.source": "Zdroj",
|
||||
"search.config.lang": "ro",
|
||||
"search.placeholder": "Hledat",
|
||||
"search.result.placeholder": "Pište co se má vyhledat",
|
||||
"search.result.none": "Nenalezeny žádné dokumenty",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"footer.next": "Järgmine",
|
||||
"meta.comments": "Kommentaarid",
|
||||
"meta.source": "Lähtekood",
|
||||
"search.config.pipeline": "",
|
||||
"search.placeholder": "Otsi",
|
||||
"search.result.placeholder": "Otsimiseks kirjuta siia",
|
||||
"search.result.none": "Otsingule ei leitud ühtegi vastet",
|
||||
|
@ -30,6 +30,7 @@
|
||||
"footer.next": "Προηγούμενη",
|
||||
"meta.comments": "Σχόλια",
|
||||
"meta.source": "Πηγή",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "Αναζήτηση",
|
||||
"search.result.placeholder": "Πληκτρολογήστε για να αρχίσει η αναζήτηση",
|
||||
"search.result.none": "Δε βρέθηκαν αντίστοιχα αρχεία",
|
||||
|
@ -31,8 +31,7 @@
|
||||
"footer.next": "הַבָּא",
|
||||
"meta.comments": "הערות",
|
||||
"meta.source": "מָקוֹר",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "לחפש",
|
||||
"search.result.placeholder": "הקלד כדי להתחיל לחפש",
|
||||
"search.result.none": "אין מסמכים תואמים",
|
||||
|
@ -30,8 +30,7 @@
|
||||
"footer.next": "आगामी",
|
||||
"meta.comments": "टिप्पणियाँ",
|
||||
"meta.source": "स्रोत",
|
||||
"search.config.lang": "ar"
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "खोज",
|
||||
"search.result.placeholder": "खोज शुरू करने के लिए टाइप करें",
|
||||
"search.result.none": "कोई मिलान डॉक्यूमेंट नहीं",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"footer.next": "Sljedeće",
|
||||
"meta.comments": "Komentari",
|
||||
"meta.source": "Izvor",
|
||||
"search.config.pipeline": "",
|
||||
"search.placeholder": "Pretraživanje",
|
||||
"search.result.placeholder": "Unesite pojam pretraživanja",
|
||||
"search.result.none": "Ništa nije pronađeno",
|
||||
|
@ -31,6 +31,7 @@
|
||||
"meta.comments": "コメント",
|
||||
"meta.source": "ソース",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\s\- 、。,.]+",
|
||||
"search.placeholder": "検索",
|
||||
"search.result.placeholder": "検索キーワードを入力してください",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"footer.next": "다음",
|
||||
"meta.comments": "댓글",
|
||||
"meta.source": "출처",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "검색",
|
||||
"search.result.placeholder": "검색어를 입력하세요",
|
||||
|
@ -33,8 +33,7 @@
|
||||
"meta.comments": "မှတ်ချက်များ",
|
||||
"meta.source": "ရင်းမြစ်",
|
||||
"nav.title": "လမ်းညွှန်",
|
||||
"search.config.lang": "ar",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "ရှာရန်",
|
||||
"search.reset": "ရှင်းလင်း",
|
||||
"search.result.placeholder": "ရှာဖွေခြင်းစရန် စာရိုက်ပါ",
|
||||
|
@ -31,7 +31,6 @@
|
||||
"meta.comments": "Комментарии",
|
||||
"meta.source": "Исходный код",
|
||||
"search.config.lang": "ru",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.placeholder": "Поиск",
|
||||
"search.result.placeholder": "Начните печатать для поиска",
|
||||
"search.result.none": "Совпадений не найдено",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"footer.next": "Sledeće",
|
||||
"meta.comments": "Komentari",
|
||||
"meta.source": "Izvor",
|
||||
"search.config.lang": "ro",
|
||||
"search.placeholder": "Pretraga",
|
||||
"search.result.placeholder": "Unesite pojam pretrage",
|
||||
"search.result.none": "Ništa nije pronađeno",
|
||||
|
@ -31,7 +31,6 @@
|
||||
"meta.comments": "Коментари",
|
||||
"meta.source": "Извор",
|
||||
"search.config.lang": "ru",
|
||||
"search.config.pipeline": "stemmer",
|
||||
"search.placeholder": "Претрага",
|
||||
"search.result.placeholder": "Унесите појам претраге",
|
||||
"search.result.none": "Нису пронађени документи",
|
||||
|
@ -30,6 +30,7 @@
|
||||
"footer.next": "ต่อไป",
|
||||
"meta.comments": "ความคิดเห็น",
|
||||
"meta.source": "แหล่งที่มา",
|
||||
"search.config.pipeline": " ",
|
||||
"search.placeholder": "ค้นหา",
|
||||
"search.result.placeholder": "พิมพ์เพื่อเริ่มค้นหา",
|
||||
"search.result.none": "ไม่พบเอกสารที่ตรงกัน",
|
||||
|
@ -30,6 +30,7 @@
|
||||
"footer.next": "Sau",
|
||||
"meta.comments": "Bình luận",
|
||||
"meta.source": "Mã nguồn",
|
||||
"search.config.lang": "vi",
|
||||
"search.placeholder": "Tìm kiếm",
|
||||
"search.result.placeholder": "Nhập để bắt đầu tìm kiếm",
|
||||
"search.result.none": "Không tìm thấy tài liệu liên quan",
|
||||
|
@ -31,6 +31,7 @@
|
||||
"meta.comments": "評論",
|
||||
"meta.source": "來源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\,\。]+",
|
||||
"search.placeholder": "搜尋",
|
||||
"search.result.placeholder": "鍵入以開始檢索",
|
||||
|
@ -31,6 +31,7 @@
|
||||
"meta.comments": "留言",
|
||||
"meta.source": "來源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\s\- 、。,.?;]+",
|
||||
"search.placeholder": "搜尋",
|
||||
"search.result.placeholder": "打字進行搜尋",
|
||||
|
@ -31,6 +31,7 @@
|
||||
"meta.comments": "评论",
|
||||
"meta.source": "来源",
|
||||
"search.config.lang": "ja",
|
||||
"search.config.pipeline": "trimmer, stemmer",
|
||||
"search.config.separator": "[\,\。]+",
|
||||
"search.placeholder": "搜索",
|
||||
"search.result.placeholder": "键入以开始搜索",
|
||||
|
Loading…
Reference in New Issue
Block a user