Skip to content

fix(i18n/gi18n): Fix issue where gi18n does not allow keyword-level access#4781

Open
chaegumi wants to merge 9 commits into
gogf:masterfrom
chaegumi:fix-gi18n-pattern
Open

fix(i18n/gi18n): Fix issue where gi18n does not allow keyword-level access#4781
chaegumi wants to merge 9 commits into
gogf:masterfrom
chaegumi:fix-gi18n-pattern

Conversation

@chaegumi

@chaegumi chaegumi commented Jun 5, 2026

Copy link
Copy Markdown

修复这个bug #4780

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Issue #4780 by improving gi18n translation lookup so TOML/JSON hierarchical keys can be accessed using dot notation in templates (e.g. {#app.site_name}), aligning i18n behavior with structured config formats.

Changes:

  • Change i18n storage from map[string]string to map[string]any to preserve hierarchical data loaded from TOML/JSON.
  • Use gjson-style pattern access during Translate placeholder replacement to support a.b.c lookups and dotted key-name compatibility.
  • Ensure GetContent returns strings from any values via gconv.String.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread i18n/gi18n/gi18n_manager.go Outdated
Comment thread i18n/gi18n/gi18n_manager.go Outdated
…ests

- Lazily create gjson object only when dotted keys are encountered, avoiding expensive gconv.Map deep conversion
- Reset ViolenceCheck after each lookup to prevent affecting subsequent substitutions
- Add direct map lookup for non-dotted keys for better performance
- Add Test_ViolenceCheck and Test_DottedKeyResolution regression tests
- Add test data files in testdata/violence-check/ and testdata/dotted-key/
@chaegumi chaegumi changed the title fix(gi18n/giq8n): Fix issue where gi18n does not allow keyword-level access fix(i18n/gi18n): Fix issue where gi18n does not allow keyword-level access Jul 11, 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