Русский и английский языки интерфейса
Язык выбирается в шапке панели, а до первого выбора берётся из настроек браузера. Переведены интерфейс, подписи и описания всех параметров конфигов, ошибки API и служебные сообщения менеджера в консоли. Подписи параметров вынесены из app.js в hints-<язык>.json: их больше четырёхсот на язык, и грузить чужой язык незачем. Сообщения менеджера переводятся на выходе из API по словарю, где ключом служит русская фраза из кода, — вывод самого игрового сервера через него проходит без изменений. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,7 @@ func (s *Server) handleCreateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if err := validateProfileMemory(dto); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func (s *Server) handleCreateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
AdminPassword: dto.AdminPassword,
|
||||
}
|
||||
if err := s.cfg.AddProfile(profile); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -106,13 +106,13 @@ func (s *Server) handleCreateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
// Профиль уже добавлен в память — откатываем, чтобы не остался
|
||||
// наполовину настроенный.
|
||||
_ = s.cfg.DeleteProfile(profile.ID)
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.cfg.Save(); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
writeError(w, r, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
s.sup.AppendLog("manager", fmt.Sprintf("Создан профиль %q", profile.Name()))
|
||||
@@ -152,7 +152,7 @@ func (s *Server) handleUpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
current, ok := s.cfg.Profile(id)
|
||||
if !ok {
|
||||
writeError(w, http.StatusNotFound, "профиль не найден")
|
||||
writeError(w, r, http.StatusNotFound, "профиль не найден")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *Server) handleUpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if err := validateProfileMemory(dto); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -180,11 +180,11 @@ func (s *Server) handleUpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := s.cfg.UpdateProfile(id, updated); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if err := s.cfg.Save(); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
writeError(w, r, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -198,11 +198,11 @@ func (s *Server) handleUpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleDeleteProfile(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if err := s.cfg.DeleteProfile(id); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if err := s.cfg.Save(); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
writeError(w, r, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
s.sup.AppendLog("manager", fmt.Sprintf(
|
||||
@@ -215,16 +215,16 @@ func (s *Server) handleDeleteProfile(w http.ResponseWriter, r *http.Request) {
|
||||
// сервере нельзя: профили делят игровые порты и файлы запуска.
|
||||
func (s *Server) handleActivateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
if s.sup.State() != pzserver.StateStopped {
|
||||
writeError(w, http.StatusConflict, "сначала остановите игровой сервер")
|
||||
writeError(w, r, http.StatusConflict, "сначала остановите игровой сервер")
|
||||
return
|
||||
}
|
||||
id := r.PathValue("id")
|
||||
if err := s.cfg.SetActive(id); err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
writeError(w, r, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if err := s.cfg.Save(); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
writeError(w, r, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
s.sup.AppendLog("manager", fmt.Sprintf("Активный профиль: %s", s.cfg.ActiveProfile().Name()))
|
||||
|
||||
Reference in New Issue
Block a user