Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions i18n/de_DE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1554,10 +1554,10 @@ ui:
title: Erweiterte Suchtipps
tag: "<1>[tag]</1> Suche mit einem Tag"
user: "<1>user:username</1> Suche nach Autor"
answer: "<1>Antworten:0</1> unbeantwortete Fragen"
answer: "<1>answers:0</1> unbeantwortete Fragen"
score: "<1>score:3</1> Beiträge mit einer 3+ Punktzahl"
question: "<1>is:question</1> Suchfragen"
is_answer: "<1>ist:answer</1> Suchantworten"
is_answer: "<1>is:answer</1> Suchantworten"
empty: Wir konnten nichts finden. <br /> Versuche es mit anderen oder weniger spezifischen Keywords.
share:
name: Teilen
Expand Down
8 changes: 4 additions & 4 deletions i18n/fr_FR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1544,11 +1544,11 @@ ui:
tips:
title: Astuces de recherche avancée
tag: "<1>[tag]</1> recherche à l'aide d'un tag"
user: "<1>utilisateur:username</1> recherche par auteur"
answer: "<1>réponses:0</1> questions sans réponses"
user: "<1>user:username</1> recherche par auteur"
answer: "<1>answers:0</1> questions sans réponses"
score: "<1>score:3</1> messages avec plus de 3 points"
question: "<1>est:question</1> rechercher des questions"
is_answer: "<1>est :réponse</1> réponses de recherche"
question: "<1>is:question</1> rechercher des questions"
is_answer: "<1>is:answer</1> réponses de recherche"
empty: Nous n'avons rien trouvé. <br /> Essayez des mots-clés différents ou moins spécifiques.
share:
name: Partager
Expand Down
94 changes: 94 additions & 0 deletions i18n/i18n_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package i18n

import (
"io/fs"
"regexp"
"strings"
"testing"

"gopkg.in/yaml.v3"
)

type searchTips struct {
UI struct {
Search struct {
Tips struct {
Tag string `yaml:"tag"`
User string `yaml:"user"`
Answer string `yaml:"answer"`
Score string `yaml:"score"`
Question string `yaml:"question"`
IsAnswer string `yaml:"is_answer"`
} `yaml:"tips"`
} `yaml:"search"`
} `yaml:"ui"`
}

// TestSearchTipsUseParserOperators guards the examples shown on the search
// page. They are meant to be typed into the search box, but the parser
// (internal/service/search_parser) matches only the English operators, so a
// translated operator inside the <1></1> code span produces a useless example.
func TestSearchTipsUseParserOperators(t *testing.T) {
files, err := fs.Glob(I18n, "*.yaml")
if err != nil {
t.Fatal(err)
}
codeSpan := regexp.MustCompile(`<1>(.*?)</1>`)
tag := regexp.MustCompile(`^\[.+\]$`)

for _, file := range files {
if file == "i18n.yaml" {
continue
}
data, err := I18n.ReadFile(file)
if err != nil {
t.Fatalf("%s: %v", file, err)
}
var tr searchTips
if err = yaml.Unmarshal(data, &tr); err != nil {
t.Fatalf("%s: %v", file, err)
}
tips := tr.UI.Search.Tips
cases := []struct {
key string
value string
valid func(string) bool
}{
{"tag", tips.Tag, tag.MatchString},
{"user", tips.User, func(v string) bool { return strings.HasPrefix(v, "user:") }},
{"answer", tips.Answer, func(v string) bool { return strings.HasPrefix(v, "answers:") }},
{"score", tips.Score, func(v string) bool { return strings.HasPrefix(v, "score:") }},
{"question", tips.Question, func(v string) bool { return v == "is:question" }},
{"is_answer", tips.IsAnswer, func(v string) bool { return v == "is:answer" }},
}
for _, c := range cases {
m := codeSpan.FindStringSubmatch(c.value)
if m == nil {
t.Errorf("%s: tips.%s has no <1> code span: %q", file, c.key, c.value)
continue
}
if !c.valid(m[1]) {
t.Errorf("%s: tips.%s code span %q is not an operator the search parser understands", file, c.key, m[1])
}
}
}
}
4 changes: 2 additions & 2 deletions i18n/it_IT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,8 @@ ui:
title: Suggerimenti per ricerca avanzata
tag: "<1>[tag]</1> cerca dentro un tag"
user: "<1>user:username</1> ricerca per autore"
answer: "<1>risposte:0</1> domande senza risposta"
score: "<1>punteggio:3</1> messaggi con un punteggio di 3+"
answer: "<1>answers:0</1> domande senza risposta"
score: "<1>score:3</1> messaggi con un punteggio di 3+"
question: "<1>is:question</1> cerca domande"
is_answer: "<1>is:answer</1> cerca risposte"
empty: Non siamo riusciti a trovare nulla. <br /> Prova parole chiave diverse o meno specifiche.
Expand Down
10 changes: 5 additions & 5 deletions i18n/ja_JP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,11 +1545,11 @@ ui:
tips:
title: 詳細検索のヒント
tag: "<1>[tag]</1> タグで検索"
user: "<1>ユーザー:ユーザー名</1>作成者による検索"
answer: "<1>回答:0</1>未回答の質問"
score: "<1>スコア:3</1>3以上のスコアを持つ投稿"
question: "<1>質問</1>質問を検索"
is_answer: "<1>は答え</1>答えを検索"
user: "<1>user:username</1>作成者による検索"
answer: "<1>answers:0</1>未回答の質問"
score: "<1>score:3</1>3以上のスコアを持つ投稿"
question: "<1>is:question</1>質問を検索"
is_answer: "<1>is:answer</1>答えを検索"
empty: 何も見つかりませんでした。 <br /> 別のキーワードまたはそれ以下の特定のキーワードをお試しください。
share:
name: シェア
Expand Down
2 changes: 1 addition & 1 deletion i18n/pl_PL.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ ui:
title: Porady dotyczące wyszukiwania zaawansowanego
tag: "<1>[tag]</1> search with a tag"
user: "<1>user:username</1> wyszukiwanie według autora"
answer: "<1> answers:0 </1> pytania bez odpowiedzi"
answer: "<1>answers:0</1> pytania bez odpowiedzi"
score: "<1>score:3</1> posty z oceną 3+"
question: "<1>is:question</1> wyszukiwanie pytań"
is_answer: "<1>is:answer</1> wyszukiwanie odpowiedzi"
Expand Down
10 changes: 5 additions & 5 deletions i18n/ro_RO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1544,11 +1544,11 @@ ui:
tips:
title: Sfaturi de căutare avansate
tag: "<1>[tag]</1> search with a tag"
user: "<1>utilizator:username</1> căutare de către autor"
answer: "<1>răspunsuri:0</1> întrebări fără răspuns"
score: "<1>scor:3</1> postări cu un scor de 3+"
question: "<1>este:question</1> întrebări de căutare"
is_answer: "<1>este:răspuner</1> răspunsuri la căutare"
user: "<1>user:username</1> căutare de către autor"
answer: "<1>answers:0</1> întrebări fără răspuns"
score: "<1>score:3</1> postări cu un scor de 3+"
question: "<1>is:question</1> întrebări de căutare"
is_answer: "<1>is:answer</1> răspunsuri la căutare"
empty: Nu am putut găsi nimic. <br /> Încearcă cuvinte cheie diferite sau mai puţin specifice.
share:
name: Distribuiți
Expand Down
4 changes: 2 additions & 2 deletions i18n/ru_RU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,10 +1545,10 @@ ui:
title: Советы по расширенному поиску
tag: "<1>[tag]</1> поиск по тегу"
user: "<1>user:username</1> поиск по автору"
answer: "<1>ответов:0</1> вопросы без ответов"
answer: "<1>answers:0</1> вопросы без ответов"
score: "<1>score:3</1> записи с рейтингом 3+"
question: "<1>is:question</1> поиск по вопросам"
is_answer: "<1>ответ</1> поиск ответов"
is_answer: "<1>is:answer</1> поиск ответов"
empty: Мы ничего не смогли найти. <br /> Попробуйте другие или менее специфичные ключевые слова.
share:
name: Поделиться
Expand Down
10 changes: 5 additions & 5 deletions i18n/uk_UA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1544,11 +1544,11 @@ ui:
tips:
title: Підказки щодо розширеного пошуку
tag: "<1>[tag]</1> шукати за тегом"
user: "<1>користувач:ім'я користувача</1> пошук за автором"
answer: "<1>відповіді:0</1> питання без відповіді"
score: "<1>рахунок: 3</1> записи із 3+ рахунком"
question: "<1>є:питання</1> пошукові питання"
is_answer: "<1>є:відповідь</1> пошукові відповіді"
user: "<1>user:username</1> пошук за автором"
answer: "<1>answers:0</1> питання без відповіді"
score: "<1>score:3</1> записи із 3+ рахунком"
question: "<1>is:question</1> пошукові питання"
is_answer: "<1>is:answer</1> пошукові відповіді"
empty: Ми не змогли нічого знайти. <br /> Спробуйте різні або менш конкретні ключові слова.
share:
name: Поділитись
Expand Down