Skip to content

Fix glossary term matching for Japanese docs #882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

josh-wong
Copy link
Member

@josh-wong josh-wong commented Jun 25, 2025

Description

This PR fixes the component GlossaryInjector, which is used for showing terms in the glossary across pages. The problem was that many glossary terms were not showing on Japanese pages because those terms weren't detected with/without plurals, which was specific to only English terms. The problem occurred after introducing support for glossary terms in plural form in #834.

To fix this issue, I've refactored glossary term detection to better handle Japanese language pages by avoiding word boundaries and pluralization logic that are not applicable. This ensures accurate glossary injection for both English and Japanese documentation.

Related issues and/or PRs

Changes made

  • Introduced isJapaneseSite flag: Added a flag to detect if the current site is Japanese (/ja-jp/) and reused this flag across multiple sections for cleaner and consistent logic. ([1], [2])
  • Regex pattern adjustments: Modified the regex pattern generation to avoid word boundaries for Japanese terms, ensuring compatibility with Japanese characters. (src/components/GlossaryInjector.tsxL96-R112)
  • Base term matching logic: Adjusted the logic for finding base terms in the glossary. Japanese terms now require an exact match, while English terms still support singular and plural forms. (src/components/GlossaryInjector.tsxL110-R136)
  • Pluralization logic: Restricted pluralization handling to English terms, ensuring that Japanese terms are processed correctly without unnecessary modifications. (src/components/GlossaryInjector.tsxL141-R163)

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have updated the side navigation as necessary.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Refactored glossary term detection to fix handling of Japanese language pages by avoiding word boundaries and pluralization logic that are not applicable. This ensures accurate glossary injection for both English and Japanese documentation.
@josh-wong josh-wong self-assigned this Jun 25, 2025
@josh-wong josh-wong added the bugfix Fix that resolves bugs label Jun 25, 2025
@josh-wong josh-wong merged commit 2307ea1 into main Jun 25, 2025
1 check passed
@josh-wong josh-wong deleted the fix-missing-glossary-tooltip-in-ja-jp-docs branch June 25, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fix that resolves bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant