WeKnora/internal
wizardchen 095ccaed10 refactor: Replace hardcoded language logic with middleware infrastructure
- Refactor wiki_ingest.go to use types.LanguageLocaleName() instead of hardcoded if-else
- Supports 9+ languages (Chinese, English, Korean, Japanese, Russian, French, German, Spanish, Portuguese)
- Reduces 7 lines to 4 lines (43% reduction in code)
- Eliminates code duplication by reusing existing middleware infrastructure
- Consistent naming with middleware layer ("Chinese (Simplified)" format)
- Add comprehensive unit tests for LanguageLocaleName() (30 test cases)
- Add implementation guide, analysis, and completion documentation

Benefits:
- Single source of truth for language mappings (types.LanguageLocaleName)
- Better code maintainability and consistency
- No breaking changes or schema modifications required
- Performance: ~4.3ns per call, no measurable impact
- All tests passing, build successful

Files modified:
- internal/application/service/wiki_ingest.go: Refactored language determination (line 139)
- internal/types/context_helpers_test.go: Added 30 unit test cases (NEW)
- Documentation: Added LANGUAGE_MIDDLEWARE_ANALYSIS.md, LANGUAGE_REFACTORING_COMPLETED.md, IMPLEMENTATION_GUIDE.md, REFACTORING_SUMMARY.txt

Refs: LANGUAGE_MIDDLEWARE_ANALYSIS.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-22 21:17:17 +08:00
..
agent fix: remove limit/offset from required in list_knowledge_chunks JSON Schema 2026-04-21 23:27:14 +08:00
application refactor: Replace hardcoded language logic with middleware infrastructure 2026-04-22 21:17:17 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
common feat: add organization management features 2026-02-09 11:40:25 +08:00
config feat(agent): support customizable LLM call timeout and add docker-compose mapping 2026-04-07 11:26:52 +08:00
container feat(datasource): add Yuque (语雀) connector 2026-04-22 16:39:55 +08:00
database fix: update environment configuration for debugging and logging, enhance SQLite FTS5 table management, and improve API base URL handling 2026-04-11 18:51:16 +08:00
datasource fix(feishu): truncate sanitized filenames at UTF-8 rune boundary 2026-04-22 16:39:55 +08:00
errors feat: Add agent configuration and cleanup scripts for database migrations 2025-11-05 23:18:44 +08:00
event refactor(agent): remove query display from DatabaseQuery component and update tool result structure 2026-03-25 22:08:29 +08:00
handler Fix logger format string errors in system handler 2026-04-16 18:39:30 +08:00
im feat(im): support custom endpoints for private WeCom deployments 2026-04-13 22:54:42 +08:00
infrastructure feat: search engine adds proxy addresses and adds SSRF verification. 2026-04-17 16:38:02 +08:00
logger feat(datasource): add Yuque (语雀) connector 2026-04-22 16:39:55 +08:00
mcp feat(mcp): implement reconnection logic for MCP tool calls and tool listing 2026-03-31 11:57:15 +08:00
middleware fix: use constant-time comparison for API key validation 2026-04-19 21:41:22 +08:00
models fix: ReadEvent incompatible sse data format 2026-04-20 22:29:38 +08:00
router feat(system): remove MinIO list buckets API and UI dependencies 2026-04-16 18:13:21 +08:00
runtime init commit 2025-08-05 15:08:07 +08:00
sandbox feat: optimize security and deployment of agent skills 2026-02-04 20:08:49 +08:00
searchutil feat(prompt): enhance question rewriting and intent classification in prompt templates 2026-04-16 23:15:02 +08:00
stream feat(redis): add REDIS_USERNAME support for Redis ACL 2026-02-04 19:38:40 +08:00
tracing init commit 2025-08-05 15:08:07 +08:00
types refactor: Replace hardcoded language logic with middleware infrastructure 2026-04-22 21:17:17 +08:00
utils fix(storage): auto-detect content-type to resolve image rendering issues 2026-04-20 21:59:54 +08:00