Skip to content

fix: localize page builder form labels and permission-denied message (KGM-3903, KGM-4190/4183)#1083

Open
zhangshanwen wants to merge 1 commit into
mainfrom
fix/kgm-3903-4190-i18n-labels-and-permission-denied
Open

fix: localize page builder form labels and permission-denied message (KGM-3903, KGM-4190/4183)#1083
zhangshanwen wants to merge 1 commit into
mainfrom
fix/kgm-3903-4190-i18n-labels-and-permission-denied

Conversation

@zhangshanwen

Copy link
Copy Markdown
Contributor

What

Fix two i18n bugs where the Japanese admin UI rendered untranslated English text.

KGM-3903 — Page Categories "New" form shows English field labels in JP

Form field labels are resolved via i18n.PT(ctx.R, presets.ModelsI18nModuleKey, modelLabel, fieldLabel). For the Page Categories model the lookup keys (PageCategoriesName/Path/Description) were never registered for any locale, so they fell back to the English humanized field names in the JP locale.

ModelsI18nModuleKey can't be registered from the framework — i18n.RegisterForModule is last-writer-wins per (module, lang), so the host app is its single owner. Instead, the page builder now translates its category editing-form labels from its own I18nPageBuilderKey messages via presets.WrapperFieldLabel, mirroring the listing column labels (CustomizeColumnLabel). Any app embedding pagebuilder gets localized labels automatically.

KGM-4190 / KGM-4183 — "permission denied" shown in English in JP

perm.PermissionDenied (github.com/qor5/x/v3/perm) is a static English errors.New("permission denied"), and presets rendered perm.PermissionDenied.Error() directly at ~18 display sites, bypassing i18n.

Added Messages.PermissionDenied (CoreI18nModuleKey; en permission denied / zh 没有权限 / ja 権限がありません) and now render MustGetMessages(ctx.R).PermissionDenied at every user-facing display site (ShowMessage, vErr.GlobalError, page body h.Text, and EditingBuilder.UpdateOverlayContent). The sentinel error itself is unchanged — still used for errors.Is control flow.

Tests

  • example/integration/pagebuilder_category_i18n_test.go — Page Categories New form renders Japanese labels (名前/パス/説明) under Accept-Language: ja, English under en.
  • TestPageBuilderPerm — new JP case asserts the permission-denied text is 権限がありません (and not permission denied).
  • Full example/integration suite, presets/... (105) and docs permission tests all pass; default English locale unchanged (no regression).

🤖 Generated with Claude Code

…(KGM-3903, KGM-4190/4183)

Two i18n bugs where the JP UI rendered English text:

KGM-3903 — Page Categories "New" form field labels (Name/Path/Description)
showed English in the JP locale. The default field-label lookup goes through
presets.ModelsI18nModuleKey, which only the host app can register (RegisterForModule
is last-writer-wins per module+lang), so the framework cannot register there.
Fix: translate the category editing-form labels from the page builder's own
I18nPageBuilderKey messages via presets.WrapperFieldLabel, mirroring the listing
column labels. Any app embedding pagebuilder now gets localized labels.

KGM-4190/4183 — the "permission denied" message was rendered as the raw English
perm.PermissionDenied.Error() string at every display site (ShowMessage /
vErr.GlobalError / page body / UpdateOverlayContent), never translated.
Fix: add Messages.PermissionDenied (CoreI18nModuleKey, en/zh/ja) and render
MustGetMessages(ctx.R).PermissionDenied at every user-facing display site. The
sentinel error itself is unchanged (still used for errors.Is control flow).

Tests: example/integration/pagebuilder_category_i18n_test.go (JP category form
labels) and a JP case added to TestPageBuilderPerm (JP permission-denied text).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.88235% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
presets/section.go 14.28% 6 Missing ⚠️
presets/editing.go 50.00% 4 Missing ⚠️
presets/detailing.go 0.00% 2 Missing ⚠️
presets/presets.go 0.00% 2 Missing ⚠️
presets/listeditor.go 66.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
pagebuilder/builder.go 84.93% <100.00%> (+0.15%) ⬆️
presets/messages.go 68.96% <ø> (ø)
presets/listeditor.go 77.91% <66.66%> (ø)
presets/detailing.go 71.56% <0.00%> (ø)
presets/presets.go 79.83% <0.00%> (ø)
presets/editing.go 84.38% <50.00%> (+0.09%) ⬆️
presets/section.go 79.42% <14.28%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@deepsource-io

deepsource-io Bot commented Jun 16, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 3aa4c04...0ea9d3d on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Jun 16, 2026 7:27a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

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