This is an automated email from the ASF dual-hosted git repository.
LinkinStars pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/dev by this push:
new 8a84643b fix(i18n): keep search operators untranslated in all locales
8a84643b is described below
commit 8a84643b653fbf817372469c0e35f9eb0291c3a5
Author: Ruslan Usmanov <[email protected]>
AuthorDate: Tue Nov 17 17:29:58 2026 +0300
fix(i18n): keep search operators untranslated in all locales
The search parser matches only the English tokens user:, answers:,
score:, is:question and is:answer. Several locales translated these
tokens inside the advanced search tips, so the examples shown in the UI
do not work when typed into the search field.
Restore the literal tokens in de_DE, fr_FR, it_IT, ja_JP, pl_PL, ro_RO,
ru_RU and uk_UA. The surrounding translated text is unchanged.
Add a test that checks the code span of every locale's tips against the
operators the parser understands, so the same mistake is caught by go
test next time.
---
i18n/de_DE.yaml | 4 +--
i18n/fr_FR.yaml | 8 ++---
i18n/i18n_test.go | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
i18n/it_IT.yaml | 4 +--
i18n/ja_JP.yaml | 10 +++---
i18n/pl_PL.yaml | 2 +-
i18n/ro_RO.yaml | 10 +++---
i18n/ru_RU.yaml | 4 +--
i18n/uk_UA.yaml | 10 +++---
9 files changed, 120 insertions(+), 26 deletions(-)
diff --git a/i18n/de_DE.yaml b/i18n/de_DE.yaml
index 90a88ff0..e16ca9c3 100644
--- a/i18n/de_DE.yaml
+++ b/i18n/de_DE.yaml
@@ -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
diff --git a/i18n/fr_FR.yaml b/i18n/fr_FR.yaml
index a80fe88b..7fd4e21a 100644
--- a/i18n/fr_FR.yaml
+++ b/i18n/fr_FR.yaml
@@ -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
diff --git a/i18n/i18n_test.go b/i18n/i18n_test.go
new file mode 100644
index 00000000..8e711120
--- /dev/null
+++ b/i18n/i18n_test.go
@@ -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])
+ }
+ }
+ }
+}
diff --git a/i18n/it_IT.yaml b/i18n/it_IT.yaml
index 59d66da3..871a2f24 100644
--- a/i18n/it_IT.yaml
+++ b/i18n/it_IT.yaml
@@ -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.
diff --git a/i18n/ja_JP.yaml b/i18n/ja_JP.yaml
index 6d784362..c7d30805 100644
--- a/i18n/ja_JP.yaml
+++ b/i18n/ja_JP.yaml
@@ -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: シェア
diff --git a/i18n/pl_PL.yaml b/i18n/pl_PL.yaml
index 8b7b8a12..fb613a37 100644
--- a/i18n/pl_PL.yaml
+++ b/i18n/pl_PL.yaml
@@ -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"
diff --git a/i18n/ro_RO.yaml b/i18n/ro_RO.yaml
index 5b5f3489..504474ec 100644
--- a/i18n/ro_RO.yaml
+++ b/i18n/ro_RO.yaml
@@ -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
diff --git a/i18n/ru_RU.yaml b/i18n/ru_RU.yaml
index e716faa9..45e07211 100644
--- a/i18n/ru_RU.yaml
+++ b/i18n/ru_RU.yaml
@@ -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: Поделиться
diff --git a/i18n/uk_UA.yaml b/i18n/uk_UA.yaml
index 1b7db033..ecf46ae5 100644
--- a/i18n/uk_UA.yaml
+++ b/i18n/uk_UA.yaml
@@ -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: Поділитись