Translate: a translation into a language the page already has replaces and renames that translation; unknown codes are stored

Đang mở
#612 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@guidol-ive đang làm issue này rồi.

Từ ngày 28/10/2026.

  • #613 của @guidol-ive — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php

Hướng nghiên cứu

Start with textpage::translateAction() in system/datatypes/text.php:220 and Language::getIsoList(); the issue identifies the existing invalid-language message and asks for a new translation-exists message. Check how translations are stored and how the form is shown again after validation fails. Done means unknown language codes and languages already present on the page are rejected, with the form shown again; linked pull request #613 already contains a proposed implementation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Impact: Medium Level: Easy Pagetype: Text Type: Bug Value: Users Value: Visitors

The translate view of a text page offers every language except the current one, also languages in which the page already has a translation, and textpage::translateAction() saves into whatever language is posted (system/datatypes/text.php:220 has // TODO: validate that the language is a valid one).

  1. Translating into an existing language replaces that translation. hypha_setPage() finds the language, renames it to the new name, and storeWikiContent() stores the new text as its latest version. The old address of that translation gives 404, so inbound links and search results break, and the translator gets "page successfully updated" without a warning. (The old text is still in the version list.)
  2. An unknown language code is stored. A posted textLanguage=qq creates <language id="qq"> in hypha.xml. HyphaRequest only accepts codes of languages.json, so the translation can never be opened, and qq then appears in the language list of every page and in the language selector (Language::getLanguageOptionList() reads $isoLangList['qq'], which does not exist).

Steps to reproduce (fictional site, PHP 8.2 container of docs/container; nl/Over_ons has the English translation en/About_us):

  1. Log in, open nl/Over_ons/translate, choose en, name About_the_editors, any text, save.
  2. en/About_us now gives 404; en/About_the_editors has the new text.
$ curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8172/en/About_us
404

#129 mentions the dropdown ("maybe the server-side handling code will even allow them ... I haven't checked"); this issue is about the server side.

Suggested fix. In translateAction(), refuse a language that is not in Language::getIsoList() (message invalid-language, which exists) and a language the page already has (new message translation-exists), and show the form again. Leaving the existing translations out of the dropdown, or showing them separately, is part of #129. The linked pull request does the server side.

Found while checking multilingual sites. Tested in the PHP 8.2 and 8.5 containers of docs/container with a fictional test site: reproduces on main (d97ab7b), gone with the linked pull request, which is offered as a suggestion and a starting point.

🤖 Generated with Claude Code

Ngôn ngữ chính
JavaScript
Star
5
Fork
9
Merge trung bình
18 giờ 49 phút
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PlanBCode/hypha

Tất cả issue của PlanBCode/hypha

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.