Skip to content

Conversation

@josh-wong
Copy link
Member

@josh-wong josh-wong commented Nov 14, 2024

Description

This PR adds a language dropdown, but only for versions 3.13 and later.

Docusaurus has a built-in language-switching feature, but it assumes that the docs are in multiple languages across versions. Since our docs in Japanese start from ScalarDB 3.13, we need to show the language dropdown menu for version 3.13 and later.

Note

For now, the Google Translate widget will still exist on versions of docs (3.4 to 3.12) that don't have translations.

Related issues and/or PRs

Changes made

  • Swizzled the NavbarItem/HtmlNavbarItem.tsx component and modified it to only allow the dropdown menu to appear on certain versions.
  • In the docusaurus.config.js file:
    • Enabled the internationalization (i18n) feature.
    • Added a custom field to specify which versions have Japanese docs.
      • Note: When a new version is released, we'll need to add that version in this custom field.
  • In the NavbarItem/LocaleDropdownNavbarItem/index.js file, made the Google Translate widget appear for versions that don't have docs in Japanese.

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

Add a conditional statement where only certain versions specified in `docusaurus.config.js` should show language dropdown menu.
The custom field `allowedLanguageDropdownVersions` specifies which versions of docs should show the language dropdown menu. This custom field is based on the conditional statements in `src/theme/NavbarItem/LocaleDropdownNavbarItem/index.js`.
If a version doesn't have Japanese docs, redirect visitors to the English page and URL. Without this fix, visitors would see English content with Japanese UI elements on a link with `ja-jp` in the URL.
Since ScalarDB 3.13 and later will have Japanese versions of docs, the Google Translate widget should still appear at the top of the page for earlier versions.
This commit fixes an issue with the Google Translate widget not reappearing when navigating from a version that has Japanese docs (like 3.13), to a version that doesn't have Japanese docs (like 3.12), then moving back to a version that has Japanese docs, (like 3.13), and then back to a version that doesn't have Japanese docs (like 3.11).
@josh-wong josh-wong added the enhancement New feature or request label Nov 14, 2024
@josh-wong josh-wong self-assigned this Nov 14, 2024
@josh-wong josh-wong marked this pull request as ready for review November 21, 2024 15:09
@josh-wong josh-wong merged commit b272746 into main Nov 21, 2024
1 check passed
@josh-wong josh-wong deleted the add-language-dropdown-for-3.13-and-later branch November 21, 2024 17:11
josh-wong added a commit that referenced this pull request May 14, 2025
* Enable language dropdown menu

* Make specific versions show language dropdown menu

Add a conditional statement where only certain versions specified in `docusaurus.config.js` should show language dropdown menu.

* Add custom field (`allowedLanguageDropdownVersions`)

The custom field `allowedLanguageDropdownVersions` specifies which versions of docs should show the language dropdown menu. This custom field is based on the conditional statements in `src/theme/NavbarItem/LocaleDropdownNavbarItem/index.js`.

* Redirect visitors on versions without Japanese docs

If a version doesn't have Japanese docs, redirect visitors to the English page and URL. Without this fix, visitors would see English content with Japanese UI elements on a link with `ja-jp` in the URL.

* Show Google Translate widget only on 3.4 to 3.12

Since ScalarDB 3.13 and later will have Japanese versions of docs, the Google Translate widget should still appear at the top of the page for earlier versions.

* Fix Google Translate widget not reappearing on versions

This commit fixes an issue with the Google Translate widget not reappearing when navigating from a version that has Japanese docs (like 3.13), to a version that doesn't have Japanese docs (like 3.12), then moving back to a version that has Japanese docs, (like 3.13), and then back to a version that doesn't have Japanese docs (like 3.11).

* Update README.mdx

* Create README.mdx

* Remove redirect

Redirects don't seem to work for docs in the non-primary language.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant