Update Search Index Script for new languages (#854)

This commit is contained in:
Tim Condon 2023-07-09 11:22:40 +01:00 committed by GitHub
parent eae2c9b388
commit ceca45e819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -69,7 +69,7 @@ You can check it out by running `mkdocs serve` in the terminal. Once you are sat
> NOTE: If a file isn't translated, it will just default to the default language file. So you don't have to translate everything all at once.
Finally, you should add the new language to the [issue template](https://github.com/vapor/docs/blob/main/.github/workflows/translation-issue-template.md) to ensure that any future changes are applied to the new translation.
Finally, you should add the new language to the [issue template](https://github.com/vapor/docs/blob/main/.github/workflows/translation-issue-template.md) to ensure that any future changes are applied to the new translation and to the [search index script](https://github.com/vapor/docs/blob/main/fixSearchIndex.swift) to ensure search works correctly.

View File

@ -37,13 +37,22 @@ let searchIndex = try JSONDecoder().decode(SearchIndex.self, from: indexData)
var newSearchIndex = searchIndex
var searchIndexDocs = [SearchIndexDocs]()
let knownLanguages = [
"en",
"de",
"es",
"fr",
"it",
"ko",
"nl",
"pl",
"zh",
].map { "\($0)/" }
for doc in newSearchIndex.docs {
if !doc.location.starts(with: "en/")
&& !doc.location.starts(with: "zh/")
&& !doc.location.starts(with: "de/")
&& !doc.location.starts(with: "fr/")
&& !doc.location.starts(with: "nl/") {
searchIndexDocs.append(doc)
if !knownLanguages.contains(where: { doc.location.starts(with: $0) }) {
searchIndexDocs.append(doc)
}
}