diff --git a/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts b/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts index b00fe9e72..ee74ff3b3 100644 --- a/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts +++ b/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts @@ -7,7 +7,6 @@ import { translate } from "@docusaurus/Translate"; -import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds"; import { SchemaObject } from "../types"; /** @@ -130,7 +129,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined { } let message = `**${translate({ - id: OPENAPI_SCHEMA_ITEM.POSSIBLE_VALUES, + id: "theme.openapi.schemaItem.possibleValues", message: "Possible values:", })}** `; @@ -149,11 +148,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined { let minLength; let maxLength; const charactersMessage = translate({ - id: OPENAPI_SCHEMA_ITEM.CHARACTERS, + id: "theme.openapi.schemaItem.characters", message: "characters", }); const nonEmptyMessage = translate({ - id: OPENAPI_SCHEMA_ITEM.NON_EMPTY, + id: "theme.openapi.schemaItem.nonEmpty", message: "non-empty", }); if (schema.minLength && schema.minLength > 1) { @@ -218,7 +217,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined { if (schema.pattern) { const expressionMessage = translate({ - id: OPENAPI_SCHEMA_ITEM.EXPRESSION, + id: "theme.openapi.schemaItem.expression", message: "Value must match regular expression", }); qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``); diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx index 2c09937c4..c73446b4e 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx @@ -12,7 +12,6 @@ import FormItem from "@theme/ApiExplorer/FormItem"; import FormSelect from "@theme/ApiExplorer/FormSelect"; import FormTextInput from "@theme/ApiExplorer/FormTextInput"; import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_AUTH } from "@theme/translationIds"; import { setAuthData, setSelectedAuth } from "./slice"; @@ -37,7 +36,7 @@ function Authorization() { { if (file === undefined) { @@ -322,7 +324,7 @@ function Body({ {/* @ts-ignore */} { @@ -24,7 +25,7 @@ function Export({ url, proxy }: any) { className="dropdown dropdown--hoverable dropdown--right" >
  • @@ -36,7 +37,10 @@ function Export({ url, proxy }: any) { className="dropdown__link" href={`${url}`} > - OpenAPI Spec + {translate({ + id: "theme.openapi.export.openapiSpec", + message: "OpenAPI Spec", + })}
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormFileUpload/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormFileUpload/index.tsx index 386f2d7cf..4f07acb7f 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormFileUpload/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormFileUpload/index.tsx @@ -9,7 +9,6 @@ import React, { useState } from "react"; import { translate } from "@docusaurus/Translate"; import FloatingButton from "@theme/ApiExplorer/FloatingButton"; -import { OPENAPI_FORM_FILE_UPLOAD } from "@theme/translationIds"; import MagicDropzone from "react-magic-dropzone"; type PreviewFile = { preview: string } & File; @@ -105,7 +104,7 @@ function FormFileUpload({ placeholder, onChange }: Props) { }} > {translate({ - id: OPENAPI_FORM_FILE_UPLOAD.CLEAR_BUTTON, + id: "theme.openapi.formFileUpload.clearButton", message: "Clear", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormLabel/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormLabel/index.tsx index 499a75a89..60eae4099 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormLabel/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormLabel/index.tsx @@ -8,7 +8,6 @@ import React from "react"; import { translate } from "@docusaurus/Translate"; -import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds"; export interface Props { htmlFor?: string; @@ -31,7 +30,7 @@ function FormLabel({ htmlFor, label, type, required }: Props) { {required && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx index 61f7651f0..570c4e1d6 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx @@ -11,7 +11,6 @@ import React, { useId } from "react"; import { translate } from "@docusaurus/Translate"; import { ErrorMessage } from "@hookform/error-message"; import FormLabel from "@theme/ApiExplorer/FormLabel"; -import { OPENAPI_FORM } from "@theme/translationIds"; import clsx from "clsx"; import { useFormContext } from "react-hook-form"; @@ -59,7 +58,7 @@ function FormTextInput({ {...register(paramName, { required: isRequired ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/LiveEditor/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/LiveEditor/index.tsx index b9d05ca08..1f93c9fba 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/LiveEditor/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/LiveEditor/index.tsx @@ -11,7 +11,6 @@ import { usePrismTheme } from "@docusaurus/theme-common"; import { translate } from "@docusaurus/Translate"; import useIsBrowser from "@docusaurus/useIsBrowser"; import { ErrorMessage } from "@hookform/error-message"; -import { OPENAPI_FORM } from "@theme/translationIds"; import clsx from "clsx"; import { Controller, useFormContext } from "react-hook-form"; import { LiveProvider, LiveEditor, withLive } from "react-live"; @@ -89,7 +88,7 @@ function App({ required: isRequired && !code ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx index ce872d9aa..4346eff9d 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx @@ -15,7 +15,6 @@ import FormSelect from "@theme/ApiExplorer/FormSelect"; import FormTextInput from "@theme/ApiExplorer/FormTextInput"; import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice"; import { useTypedDispatch } from "@theme/ApiItem/hooks"; -import { OPENAPI_FORM } from "@theme/translationIds"; import { Controller, useFormContext } from "react-hook-form"; export interface ParamProps { @@ -138,7 +137,7 @@ export default function ParamArrayFormItem({ rules={{ required: param.required ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, @@ -177,7 +176,10 @@ export default function ParamArrayFormItem({ className="openapi-explorer__thin-btn" onClick={handleAddItem} > - Add item + {translate({ + id: "theme.openapi.paramArray.addItem", + message: "Add item", + })} )} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx index 77e49c63e..898109cd5 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx @@ -12,7 +12,6 @@ import { ErrorMessage } from "@hookform/error-message"; import FormSelect from "@theme/ApiExplorer/FormSelect"; import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice"; import { useTypedDispatch } from "@theme/ApiItem/hooks"; -import { OPENAPI_FORM } from "@theme/translationIds"; import { Controller, useFormContext } from "react-hook-form"; export interface ParamProps { @@ -60,7 +59,7 @@ export default function ParamBooleanFormItem({ rules={{ required: param.required ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx index 9c57b02b3..c26e2f88e 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx @@ -13,7 +13,6 @@ import FormMultiSelect from "@theme/ApiExplorer/FormMultiSelect"; import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions"; import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice"; import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_FORM } from "@theme/translationIds"; import { Controller, useFormContext } from "react-hook-form"; export interface ParamProps { @@ -75,7 +74,7 @@ export default function ParamMultiSelectFormItem({ rules={{ required: param.required ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx index 7bf8c0a5f..5164b0acf 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx @@ -13,7 +13,6 @@ import FormSelect from "@theme/ApiExplorer/FormSelect"; import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions"; import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice"; import { useTypedDispatch } from "@theme/ApiItem/hooks"; -import { OPENAPI_FORM } from "@theme/translationIds"; import { Controller, useFormContext } from "react-hook-form"; export interface ParamProps { @@ -58,7 +57,7 @@ export default function ParamSelectFormItem({ rules={{ required: param.required ? translate({ - id: OPENAPI_FORM.FIELD_REQUIRED, + id: "theme.openapi.form.fieldRequired", message: "This field is required", }) : false, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/index.tsx index 7b0993554..2851ab4a6 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/index.tsx @@ -15,7 +15,6 @@ import ParamMultiSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormI import ParamSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem"; import ParamTextFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem"; import { useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_PARAM_OPTIONS } from "@theme/translationIds"; import { Param } from "./slice"; @@ -207,11 +206,11 @@ function ParamOptions() { {showOptional ? translate({ - id: OPENAPI_PARAM_OPTIONS.HIDE_OPTIONAL, + id: "theme.openapi.paramOptions.hideOptional", message: "Hide optional parameters", }) : translate({ - id: OPENAPI_PARAM_OPTIONS.SHOW_OPTIONAL, + id: "theme.openapi.paramOptions.showOptional", message: "Show optional parameters", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx index c7abe5d0a..892009f86 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx @@ -16,6 +16,7 @@ import Authorization from "@theme/ApiExplorer/Authorization"; import Body from "@theme/ApiExplorer/Body"; import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest"; import ContentType from "@theme/ApiExplorer/ContentType"; +import { useResolvedEncoding } from "@theme/ApiExplorer/EncodingSelection/useResolvedEncoding"; import ParamOptions from "@theme/ApiExplorer/ParamOptions"; import { setResponse, @@ -25,9 +26,7 @@ import { clearHeaders, } from "@theme/ApiExplorer/Response/slice"; import Server from "@theme/ApiExplorer/Server"; -import { useResolvedEncoding } from "@theme/ApiExplorer/EncodingSelection/useResolvedEncoding"; import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_REQUEST } from "@theme/translationIds"; import type { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types"; import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types"; @@ -137,26 +136,26 @@ function Request({ item }: { item: ApiItem }) { switch (errorType) { case "timeout": return translate({ - id: OPENAPI_REQUEST.ERROR_TIMEOUT, + id: "theme.openapi.request.error.timeout", message: "The request timed out waiting for the server to respond. Please try again. If the issue persists, try using a different client (e.g., curl) with a longer timeout.", }); case "network": return translate({ - id: OPENAPI_REQUEST.ERROR_NETWORK, + id: "theme.openapi.request.error.network", message: "Unable to reach the server. Please check your network connection and verify the server URL is correct. If the server is running, this may be a CORS issue.", }); case "cors": return translate({ - id: OPENAPI_REQUEST.ERROR_CORS, + id: "theme.openapi.request.error.cors", message: "The request was blocked, possibly due to CORS restrictions. Ensure the server allows requests from this origin, or try using a proxy.", }); case "unknown": default: return translate({ - id: OPENAPI_REQUEST.ERROR_UNKNOWN, + id: "theme.openapi.request.error.unknown", message: "An unexpected error occurred while making the request. Please try again.", }); @@ -167,7 +166,7 @@ function Request({ item }: { item: ApiItem }) { dispatch( setResponse( translate({ - id: OPENAPI_REQUEST.FETCHING_MESSAGE, + id: "theme.openapi.request.fetchingMessage", message: "Fetching...", }) ) @@ -195,7 +194,7 @@ function Request({ item }: { item: ApiItem }) { errorMessage = getErrorMessage(e.type); } else { errorMessage = translate({ - id: OPENAPI_REQUEST.CONNECTION_FAILED, + id: "theme.openapi.request.connectionFailed", message: "Connection failed", }); } @@ -253,7 +252,7 @@ function Request({ item }: { item: ApiItem }) {
{translate({ - id: OPENAPI_REQUEST.REQUEST_TITLE, + id: "theme.openapi.request.title", message: "Request", })} @@ -264,7 +263,7 @@ function Request({ item }: { item: ApiItem }) { onClick={collapseAllDetails} > {translate({ - id: OPENAPI_REQUEST.COLLAPSE_ALL, + id: "theme.openapi.request.collapseAll", message: "Collapse all", })} @@ -275,7 +274,7 @@ function Request({ item }: { item: ApiItem }) { onClick={expandAllDetails} > {translate({ - id: OPENAPI_REQUEST.EXPAND_ALL, + id: "theme.openapi.request.expandAll", message: "Expand all", })} @@ -296,7 +295,7 @@ function Request({ item }: { item: ApiItem }) { }} > {translate({ - id: OPENAPI_REQUEST.BASE_URL_TITLE, + id: "theme.openapi.request.baseUrl.title", message: "Base URL", })} @@ -315,7 +314,10 @@ function Request({ item }: { item: ApiItem }) { setExpandAuth(!expandAuth); }} > - {translate({ id: OPENAPI_REQUEST.AUTH_TITLE, message: "Auth" })} + {translate({ + id: "theme.openapi.request.auth.title", + message: "Auth", + })} @@ -335,7 +337,7 @@ function Request({ item }: { item: ApiItem }) { }} > {translate({ - id: OPENAPI_REQUEST.PARAMETERS_TITLE, + id: "theme.openapi.request.parameters.title", message: "Parameters", })} @@ -354,12 +356,15 @@ function Request({ item }: { item: ApiItem }) { setExpandBody(!expandBody); }} > - {translate({ id: OPENAPI_REQUEST.BODY_TITLE, message: "Body" })} + {translate({ + id: "theme.openapi.request.body.title", + message: "Body", + })} {requestBodyRequired && (   {translate({ - id: OPENAPI_REQUEST.REQUIRED_LABEL, + id: "theme.openapi.request.requiredLabel", message: "required", })} @@ -388,7 +393,7 @@ function Request({ item }: { item: ApiItem }) { }} > {translate({ - id: OPENAPI_REQUEST.ACCEPT_TITLE, + id: "theme.openapi.request.accept.title", message: "Accept", })} @@ -398,7 +403,7 @@ function Request({ item }: { item: ApiItem }) { {showRequestButton && item.method !== "event" && ( diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx index abda447a5..1f654b338 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx @@ -15,7 +15,6 @@ import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock"; import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; import SchemaTabs from "@theme/SchemaTabs"; import TabItem from "@theme/TabItem"; -import { OPENAPI_REQUEST, OPENAPI_RESPONSE } from "@theme/translationIds"; import clsx from "clsx"; import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types"; @@ -134,7 +133,10 @@ function Response({ item }: { item: ApiItem }) {
- {translate({ id: OPENAPI_RESPONSE.TITLE, message: "Response" })} + {translate({ + id: "theme.openapi.response.title", + message: "Response", + })}
- + Send API Request @@ -202,7 +204,7 @@ function Response({ item }: { item: ApiItem }) { {/* @ts-ignore */} - + Send API Request diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/SecuritySchemes/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/SecuritySchemes/index.tsx index 442ca4ab9..fb026047c 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/SecuritySchemes/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/SecuritySchemes/index.tsx @@ -10,7 +10,6 @@ import React from "react"; import Link from "@docusaurus/Link"; import { translate } from "@docusaurus/Translate"; import { useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_SECURITY_SCHEMES } from "@theme/translationIds"; function SecuritySchemes(props: any) { const options = useTypedSelector((state: any) => state.auth.options); @@ -25,45 +24,54 @@ function SecuritySchemes(props: any) { const selectedAuth = options[selected]; - const keyTranslations: Record = { - description: { - id: OPENAPI_SECURITY_SCHEMES.DESCRIPTION, - message: "description:", - }, - scheme: { - id: OPENAPI_SECURITY_SCHEMES.SCHEME, - message: "scheme:", - }, - bearerFormat: { - id: OPENAPI_SECURITY_SCHEMES.BEARER_FORMAT, - message: "bearerFormat:", - }, - openIdConnectUrl: { - id: OPENAPI_SECURITY_SCHEMES.OPEN_ID_CONNECT_URL, - message: "openIdConnectUrl:", - }, + // Each label uses a static `translate()` call (literal id + message) so that + // `docusaurus write-translations` can statically extract it. A dynamic + // `translate({ id: someVar })` would be skipped by the extractor. + const renderRestLabel = (k: string): string => { + switch (k) { + case "description": + return translate({ + id: "theme.openapi.securitySchemes.description", + message: "description:", + }); + case "scheme": + return translate({ + id: "theme.openapi.securitySchemes.scheme", + message: "scheme:", + }); + case "bearerFormat": + return translate({ + id: "theme.openapi.securitySchemes.bearerFormat", + message: "bearerFormat:", + }); + case "openIdConnectUrl": + return translate({ + id: "theme.openapi.securitySchemes.openIdConnectUrl", + message: "openIdConnectUrl:", + }); + default: + return `${k}:`; + } }; const renderRest = (rest: Record) => - Object.keys(rest).map((k) => { - const translation = keyTranslations[k]; - const label = translation - ? translate({ id: translation.id, message: translation.message }) - : `${k}:`; - return ( - - {label} - {typeof rest[k] === "object" - ? JSON.stringify(rest[k], null, 2) - : String(rest[k])} - - ); - }); + Object.keys(rest).map((k) => ( + + {renderRestLabel(k)} + {typeof rest[k] === "object" + ? JSON.stringify(rest[k], null, 2) + : String(rest[k])} + + )); return (

- Authorization: {selectedAuth[0].name ?? selectedAuth[0].type} + {translate({ + id: "theme.openapi.securitySchemes.authorization", + message: "Authorization:", + })}{" "} + {selectedAuth[0].name ?? selectedAuth[0].type}

{selectedAuth.map((auth: any) => { @@ -87,7 +95,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -96,7 +104,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -106,7 +114,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.SCOPES, + id: "theme.openapi.securitySchemes.scopes", message: "scopes:", })} {" "} @@ -134,7 +142,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -143,7 +151,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -153,7 +161,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.SCOPES, + id: "theme.openapi.securitySchemes.scopes", message: "scopes:", })} {" "} @@ -179,7 +187,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -188,7 +196,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -197,7 +205,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.IN, + id: "theme.openapi.securitySchemes.in", message: "in:", })} {" "} @@ -222,7 +230,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -231,7 +239,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -241,7 +249,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.SCOPES, + id: "theme.openapi.securitySchemes.scopes", message: "scopes:", })} {" "} @@ -270,7 +278,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -279,7 +287,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -289,7 +297,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.SCOPES, + id: "theme.openapi.securitySchemes.scopes", message: "scopes:", })} {" "} @@ -304,7 +312,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.FLOWS, + id: "theme.openapi.securitySchemes.flows", message: "flows:", })} {" "} @@ -331,7 +339,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.NAME, + id: "theme.openapi.securitySchemes.name", message: "name:", })} {" "} @@ -340,7 +348,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.TYPE, + id: "theme.openapi.securitySchemes.type", message: "type:", })} {" "} @@ -350,7 +358,7 @@ function SecuritySchemes(props: any) { {translate({ - id: OPENAPI_SECURITY_SCHEMES.SCOPES, + id: "theme.openapi.securitySchemes.scopes", message: "scopes:", })} {" "} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx index ac1bbfab6..26067e864 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx @@ -13,7 +13,6 @@ import FormItem from "@theme/ApiExplorer/FormItem"; import FormSelect from "@theme/ApiExplorer/FormSelect"; import FormTextInput from "@theme/ApiExplorer/FormTextInput"; import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; -import { OPENAPI_SERVER } from "@theme/translationIds"; import { setServer, setServerVariable } from "./slice"; @@ -65,7 +64,10 @@ function Server({ labelId }: ServerProps) { return ( setIsEditing(true)} - label={translate({ id: OPENAPI_SERVER.EDIT_BUTTON, message: "Edit" })} + label={translate({ + id: "theme.openapi.server.editButton", + message: "Edit", + })} > @@ -79,7 +81,10 @@ function Server({ labelId }: ServerProps) {
setIsEditing(false)} - label={translate({ id: OPENAPI_SERVER.HIDE_BUTTON, message: "Hide" })} + label={translate({ + id: "theme.openapi.server.hideButton", + message: "Hide", + })} > {
{translate({ - id: OPENAPI_SCHEMA_ITEM.EXAMPLE, + id: "theme.openapi.schemaItem.example", message: "Example:", })}{" "} @@ -121,7 +120,7 @@ export const renderExamplesRecord = (
{translate({ - id: OPENAPI_SCHEMA_ITEM.EXAMPLES, + id: "theme.openapi.schemaItem.examples", message: "Examples:", })} @@ -153,7 +152,7 @@ const renderExampleObject = (

{translate({ - id: OPENAPI_SCHEMA_ITEM.DESCRIPTION, + id: "theme.openapi.schemaItem.description", message: "Description:", })}{" "} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsDetails/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsDetails/index.tsx index a4f5c7be0..ddfe20762 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsDetails/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsDetails/index.tsx @@ -12,7 +12,6 @@ import { translate } from "@docusaurus/Translate"; import Details from "@theme/Details"; import ParamsItem from "@theme/ParamsItem"; import SkeletonLoader from "@theme/SkeletonLoader"; -import { OPENAPI_PARAMS_DETAILS } from "@theme/translationIds"; interface Props { parameters: any[]; @@ -35,7 +34,7 @@ const ParamsDetailsComponent: React.FC = ({ parameters }) => {

{translate( { - id: OPENAPI_PARAMS_DETAILS.PARAMETERS_TITLE, + id: "theme.openapi.paramsDetails.parametersTitle", message: "{type} Parameters", }, { type: type.charAt(0).toUpperCase() + type.slice(1) } diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx index afd829049..e24753738 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ParamsItem/index.tsx @@ -11,7 +11,6 @@ import { translate } from "@docusaurus/Translate"; import { Example } from "@theme/Example"; import Markdown from "@theme/Markdown"; /* eslint-disable import/no-extraneous-dependencies*/ -import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds"; import clsx from "clsx"; import { getQualifierMessage, getSchemaName } from "../../markdown/schema"; @@ -41,11 +40,11 @@ export interface Props { const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => { if (enumDescriptions?.length) { const enumValue = translate({ - id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE, + id: "theme.openapi.schemaItem.enumValue", message: "Enum Value", }); const description = translate({ - id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION, + id: "theme.openapi.schemaItem.enumDescription", message: "Description", }); return `| ${enumValue} | ${description} | @@ -92,13 +91,19 @@ function ParamsItem({ param, ...rest }: Props) { const renderSchemaRequired = guard(required, () => ( - {translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })} + {translate({ + id: "theme.openapi.schemaItem.required", + message: "required", + })} )); const renderDeprecated = guard(deprecated, () => ( - {translate({ id: OPENAPI_SCHEMA_ITEM.DEPRECATED, message: "deprecated" })} + {translate({ + id: "theme.openapi.schemaItem.deprecated", + message: "deprecated", + })} )); @@ -113,7 +118,7 @@ function ParamsItem({ param, ...rest }: Props) { return undefined; } const label = translate({ - id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE, + id: "theme.openapi.schemaItem.constantValue", message: "Constant value:", }); return ( @@ -152,7 +157,7 @@ function ParamsItem({ param, ...rest }: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE, + id: "theme.openapi.schemaItem.defaultValue", message: "Default value:", })}{" "} @@ -166,7 +171,7 @@ function ParamsItem({ param, ...rest }: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE, + id: "theme.openapi.schemaItem.defaultValue", message: "Default value:", })}{" "} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx index 2b340a212..f045101a6 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx @@ -22,7 +22,6 @@ import SchemaExpansionControl from "@theme/SchemaExpansion"; import SchemaTabs from "@theme/SchemaTabs"; import SkeletonLoader from "@theme/SkeletonLoader"; import TabItem from "@theme/TabItem"; -import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds"; import type { MediaTypeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types"; interface Props { @@ -81,13 +80,13 @@ const RequestSchemaComponent: React.FC = ({ title, body, style }) => {

{translate({ - id: OPENAPI_REQUEST.BODY_TITLE, + id: "theme.openapi.request.body.title", message: title, })} {body.required === true && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} @@ -167,7 +166,7 @@ const RequestSchemaComponent: React.FC = ({ title, body, style }) => {

{translate({ - id: OPENAPI_REQUEST.BODY_TITLE, + id: "theme.openapi.request.body.title", message: title, })} {firstBody.type === "array" && ( @@ -176,7 +175,7 @@ const RequestSchemaComponent: React.FC = ({ title, body, style }) => { {body.required && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ResponseExamples/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ResponseExamples/index.tsx index 6013f2136..482738899 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ResponseExamples/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ResponseExamples/index.tsx @@ -11,7 +11,6 @@ import { translate } from "@docusaurus/Translate"; import CodeSamples from "@theme/CodeSamples"; import Markdown from "@theme/Markdown"; import TabItem from "@theme/TabItem"; -import { OPENAPI_RESPONSE_EXAMPLES } from "@theme/translationIds"; import { sampleResponseFromSchema } from "docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample"; import format from "xml-formatter"; @@ -115,7 +114,7 @@ export const ResponseExample: React.FC = ({ // @ts-ignore = ({ // @ts-ignore = ({ // @ts-ignore = ({
{translate({ - id: OPENAPI_SCHEMA.NO_SCHEMA, + id: "theme.openapi.schema.noSchema", message: "No schema", })}
@@ -98,7 +97,7 @@ const ResponseSchemaComponent: React.FC = ({ {body.required === true && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx index 90049bda1..6926d362c 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx @@ -22,7 +22,6 @@ import { import SchemaItem from "@theme/SchemaItem"; import SchemaTabs from "@theme/SchemaTabs"; import TabItem from "@theme/TabItem"; -import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds"; // eslint-disable-next-line import/no-extraneous-dependencies import { merge } from "allof-merge"; import clsx from "clsx"; @@ -261,7 +260,7 @@ const Summary: React.FC = ({ {nullable && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.NULLABLE, + id: "theme.openapi.schemaItem.nullable", message: "nullable", })} @@ -269,7 +268,7 @@ const Summary: React.FC = ({ {isRequired && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} @@ -277,7 +276,7 @@ const Summary: React.FC = ({ {deprecated && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.DEPRECATED, + id: "theme.openapi.schemaItem.deprecated", message: "deprecated", })} @@ -314,8 +313,8 @@ const AnyOneOf: React.FC = ({ } const type = schema.oneOf - ? translate({ id: OPENAPI_SCHEMA_ITEM.ONE_OF, message: "oneOf" }) - : translate({ id: OPENAPI_SCHEMA_ITEM.ANY_OF, message: "anyOf" }); + ? translate({ id: "theme.openapi.schemaItem.oneOf", message: "oneOf" }) + : translate({ id: "theme.openapi.schemaItem.anyOf", message: "anyOf" }); // Generate a unique ID for this anyOf/oneOf to prevent tab value collisions const uniqueId = React.useMemo( @@ -364,12 +363,12 @@ const AnyOneOf: React.FC = ({ if (!label) { if (anyOneSchema.oneOf) { label = translate({ - id: OPENAPI_SCHEMA_ITEM.ONE_OF, + id: "theme.openapi.schemaItem.oneOf", message: "oneOf", }); } else if (anyOneSchema.anyOf) { label = translate({ - id: OPENAPI_SCHEMA_ITEM.ANY_OF, + id: "theme.openapi.schemaItem.anyOf", message: "anyOf", }); } else { @@ -550,7 +549,7 @@ const PropertyDiscriminator: React.FC = ({ {required && ( {translate({ - id: OPENAPI_SCHEMA_ITEM.REQUIRED, + id: "theme.openapi.schemaItem.required", message: "required", })} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaExpansion/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaExpansion/index.tsx index abd518623..d008bb07a 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaExpansion/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaExpansion/index.tsx @@ -16,7 +16,6 @@ import React, { } from "react"; import { translate } from "@docusaurus/Translate"; -import { OPENAPI_SCHEMA_EXPANSION } from "@theme/translationIds"; import clsx from "clsx"; import { useSchemaExpansion } from "./context"; @@ -146,17 +145,17 @@ const SchemaExpansionControl: React.FC = () => { if (!config.enabled) return null; const buttonLabel = translate({ - id: OPENAPI_SCHEMA_EXPANSION.BUTTON_LABEL, + id: "theme.openapi.schema.expansion.button", message: "Schema expansion depth", description: "Aria/title tooltip for the schema expansion icon button", }); const menuLabel = translate({ - id: OPENAPI_SCHEMA_EXPANSION.MENU_LABEL, + id: "theme.openapi.schema.expansion.menu", message: "Schema expansion depth options", description: "Accessible label for the expansion options menu", }); const allLabel = translate({ - id: OPENAPI_SCHEMA_EXPANSION.ALL, + id: "theme.openapi.schema.expansion.all", message: "All", description: "Label for the expand-all option", }); @@ -201,7 +200,7 @@ const SchemaExpansionControl: React.FC = () => { ? allLabel : translate( { - id: OPENAPI_SCHEMA_EXPANSION.DEPTH_OPTION, + id: "theme.openapi.schema.expansion.depthOption", message: "Expand to depth {depth}", description: "Accessible label for a depth option", }, diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx index 83593cc78..490f22cd9 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx @@ -10,7 +10,6 @@ import React, { ReactNode } from "react"; import { translate } from "@docusaurus/Translate"; import { Example } from "@theme/Example"; import Markdown from "@theme/Markdown"; -import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds"; import clsx from "clsx"; import { getQualifierMessage } from "../../markdown/schema"; @@ -41,11 +40,11 @@ const transformEnumDescriptions = ( const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => { if (enumDescriptions?.length) { const enumValue = translate({ - id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE, + id: "theme.openapi.schemaItem.enumValue", message: "Enum Value", }); const description = translate({ - id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION, + id: "theme.openapi.schemaItem.enumDescription", message: "Description", }); return `| ${enumValue} | ${description} | @@ -97,20 +96,29 @@ export default function SchemaItem(props: Props) { Array.isArray(required) ? required.includes(name) : required, () => ( - {translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })} + {translate({ + id: "theme.openapi.schemaItem.required", + message: "required", + })} ) ); const renderDeprecated = guard(deprecated, () => ( - {translate({ id: OPENAPI_SCHEMA_ITEM.DEPRECATED, message: "deprecated" })} + {translate({ + id: "theme.openapi.schemaItem.deprecated", + message: "deprecated", + })} )); const renderNullable = guard(nullable, () => ( - {translate({ id: OPENAPI_SCHEMA_ITEM.NULLABLE, message: "nullable" })} + {translate({ + id: "theme.openapi.schemaItem.nullable", + message: "nullable", + })} )); @@ -148,7 +156,7 @@ export default function SchemaItem(props: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE, + id: "theme.openapi.schemaItem.defaultValue", message: "Default value:", })}{" "} @@ -162,7 +170,7 @@ export default function SchemaItem(props: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE, + id: "theme.openapi.schemaItem.defaultValue", message: "Default value:", })}{" "} @@ -182,7 +190,7 @@ export default function SchemaItem(props: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE, + id: "theme.openapi.schemaItem.constantValue", message: "Constant value:", })}{" "} @@ -196,7 +204,7 @@ export default function SchemaItem(props: Props) {
{translate({ - id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE, + id: "theme.openapi.schemaItem.constantValue", message: "Constant value:", })}{" "} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx index a47afbc8f..952d6faa6 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx @@ -14,7 +14,6 @@ import Markdown from "@theme/Markdown"; import ResponseHeaders from "@theme/ResponseHeaders"; import ResponseSchema from "@theme/ResponseSchema"; import TabItem from "@theme/TabItem"; -import { OPENAPI_STATUS_CODES } from "@theme/translationIds"; import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; interface Props { @@ -55,7 +54,7 @@ const StatusCodes: React.FC = ({ label, id, responses }: any) => { {translate({ - id: OPENAPI_STATUS_CODES.RESPONSE_HEADERS, + id: "theme.openapi.statusCodes.responseHeaders", message: "Response Headers", })} @@ -67,7 +66,7 @@ const StatusCodes: React.FC = ({ label, id, responses }: any) => { )} ` call site now passes + * its id as an inline string literal instead. + * + * WHY THE DICTIONARY WAS REMOVED + * ------------------------------ + * `docusaurus write-translations` only performs STATIC analysis of the source + * code (via @docusaurus/babel) — it never runs the site. To collect a string + * it evaluates the argument of every `translate()` / `` call with + * Babel's `path.evaluate()` and keeps it only when the result is `confident`. + * + * An id referenced through an imported constant, e.g. + * + * import { OPENAPI_REQUEST } from "@theme/translationIds"; + * translate({ id: OPENAPI_REQUEST.COLLAPSE_ALL, message: "Collapse all" }); + * + * is a member expression on a binding imported from another module. Babel + * cannot statically resolve a cross-module binding, so `evaluate()` returns + * `confident === false`, the extractor skips the call (emitting a warning), and + * NOTHING is written to the locale `code.json`. As a result `write-translations` + * produced an empty template and downstream projects had no ids to translate, + * even though the strings rendered fine at runtime (the inlined constant value + * matched the runtime lookup key). + * + * The id and message must therefore be static string literals AT THE CALL SITE. + * This is the approach Docusaurus' own theme-classic uses and what its i18n + * guide mandates ("Text labels must be static"): + * + * - https://docusaurus.io/docs/i18n/tutorial#translate-your-react-code + * - https://docusaurus.io/docs/docusaurus-core#translate + * + * Keep this note here so the removal of the constants is discoverable; do not + * reintroduce a shared id dictionary for `translate()` arguments. + */ -export const OPENAPI_SECURITY_SCHEMES = { - NAME: "theme.openapi.securitySchemes.name", - TYPE: "theme.openapi.securitySchemes.type", - SCOPES: "theme.openapi.securitySchemes.scopes", - IN: "theme.openapi.securitySchemes.in", - FLOWS: "theme.openapi.securitySchemes.flows", - DESCRIPTION: "theme.openapi.securitySchemes.description", - SCHEME: "theme.openapi.securitySchemes.scheme", - BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat", - OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl", -}; +export {};