Skip to content

fix(i18n): keep search operators untranslated in search tips - #1671

Merged
LinkinStars merged 1 commit into
apache:devfrom
haosb:fix/search-tips-translated-operators
Nov 18, 2026
Merged

LinkinStars merged 1 commit into
apache:devfrom
haosb:fix/search-tips-translated-operators

Conversation

@haosb

@haosb haosb commented Nov 17, 2026 •

Copy link
Copy Markdown

The advanced search tips show examples meant to be typed into the search box. In some locales the operator inside the code span is translated together with the description, so the examples do not work. For example, the Russian site shows ответов:0 and ответ instead of answers:0 and is:answer.

The search parser (internal/service/search_parser) matches only the English tokens user:, answers:, score:, is:question and is:answer. A translated token is treated as plain text, so searching with the displayed example does not apply the filter.

Restore the literal tokens in de_DE, fr_FR, it_IT, ja_JP, pl_PL, ro_RO, ru_RU and uk_UA. The translated descriptions are unchanged.

Before:
image
After:
image

A test in i18n/i18n_test.go checks the code span of every locale against the operators the parser understands. It fails on the previous locale files and passes with this change.

Checked all locales: ko_KR and tr_TR use translated placeholders but keep the correct English prefixes, so they were left alone.

Verification: go test ./i18n/ passes.

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.
@haosb

haosb commented Nov 17, 2026

Copy link
Copy Markdown
Author

@neermilov cc

@LinkinStars

Copy link
Copy Markdown
Member

Thanks for the fix! The i18n and search parser tests passed, including validation that every locale’s complete search-tip examples use supported syntax.

@LinkinStars
LinkinStars merged commit 8a84643 into apache:dev Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants