diff --git a/.github/workflows/purge-fastly.yml b/.github/workflows/purge-fastly.yml index 17d99e20207d..15a421305d0d 100644 --- a/.github/workflows/purge-fastly.yml +++ b/.github/workflows/purge-fastly.yml @@ -46,4 +46,4 @@ jobs: if: ${{ !inputs.nuke_all }} env: LANGUAGES: ${{ inputs.languages }} - run: .github/actions-scripts/purge-fastly-edge-cache-per-language.js + run: src/languages/scripts/purge-fastly-edge-cache-per-language.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b1618c69f6d5..a37ff1a63785 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,9 +34,9 @@ jobs: id: set-matrix with: script: | - // We only want to run the 'translations' suite when we know + // We only want to run the 'languages' suite when we know // we're on the private docs-internal repo because only that - // one has ability to clone the remote (private) translations + // one has ability to clone the remote (private) languages // repos. // You can run multiple paths per suite as space-separated in `path`. // Note that *if you add* to this, remember to also add that @@ -64,7 +64,7 @@ jobs: { name: 'search', path: 'src/search/tests', }, { name: 'shielding', path: 'src/shielding/tests', }, context.payload.repository.full_name === 'github/docs-internal' && - { name: 'translations', path: 'tests/translations', }, + { name: 'languages', path: 'src/languages/tests', }, { name: 'unit', path: 'tests/unit', }, // { name: 'tools', path: 'src/tools/tests', } { name: 'webhooks', path: 'src/webhooks/tests', }, @@ -88,7 +88,7 @@ jobs: uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: ./.github/actions/setup-elasticsearch - if: ${{ matrix.name == 'search' || matrix.name == 'translations' }} + if: ${{ matrix.name == 'search' || matrix.name == 'languages' }} - uses: ./.github/actions/node-npm-setup @@ -117,7 +117,7 @@ jobs: tests/fixtures/data - name: Clone all translations - if: ${{ matrix.name == 'translations' }} + if: ${{ matrix.name == 'languages' }} uses: ./.github/actions/clone-translations with: token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} @@ -169,7 +169,7 @@ jobs: - name: Index fixtures into the local Elasticsearch # For the sake of saving time, only run this step if the group # is one that will run tests against an Elasticsearch on localhost. - if: ${{ matrix.name == 'search' || matrix.name == 'translations' }} + if: ${{ matrix.name == 'search' || matrix.name == 'languages' }} run: npm run index-test-fixtures - name: Run tests @@ -178,8 +178,8 @@ jobs: CHANGELOG_CACHE_FILE_PATH: tests/fixtures/changelog-feed.json # By default, when `process.env.NODE_ENV === 'test'` it forces the # tests run only in English. The exception is the - # `tests/translations/` suite which needs all languages to be set up. - ENABLED_LANGUAGES: ${{ matrix.name == 'translations' && 'all' || '' }} + # `languages` suite which needs all languages to be set up. + ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }} ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'tests/fixtures' || '' }} TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo') && 'tests/fixtures/translations' || '' }} run: npm test -- ${{ matrix.path }}/ diff --git a/components/DefaultLayout.tsx b/components/DefaultLayout.tsx index ac3d34f9c4d0..10f911eefdb3 100644 --- a/components/DefaultLayout.tsx +++ b/components/DefaultLayout.tsx @@ -9,7 +9,7 @@ import { SupportSection } from 'components/page-footer/SupportSection' import { DeprecationBanner } from 'components/page-header/DeprecationBanner' import { RestBanner } from 'src/rest/components/RestBanner' import { useMainContext } from 'components/context/MainContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Breadcrumbs } from 'components/page-header/Breadcrumbs' const MINIMAL_RENDER = Boolean(JSON.parse(process.env.MINIMAL_RENDER || 'false')) diff --git a/components/article/ArticlePage.tsx b/components/article/ArticlePage.tsx index 7a35210879af..9b6ef62e40bc 100644 --- a/components/article/ArticlePage.tsx +++ b/components/article/ArticlePage.tsx @@ -20,7 +20,7 @@ import { LearningTrackCard } from 'src/learning-track/components/article/Learnin import { RestRedirect } from 'src/rest/components/RestRedirect' import { Breadcrumbs } from 'components/page-header/Breadcrumbs' import { Link } from 'components/Link' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { LinkPreviewPopover } from 'components/LinkPreviewPopover' const ClientSideRefresh = dynamic(() => import('components/ClientSideRefresh'), { diff --git a/components/page-footer/Contribution.tsx b/components/page-footer/Contribution.tsx index 9b515c3df4c4..0624ddb4e184 100644 --- a/components/page-footer/Contribution.tsx +++ b/components/page-footer/Contribution.tsx @@ -1,7 +1,7 @@ import { GitPullRequestIcon } from '@primer/octicons-react' import { useMainContext } from 'components/context/MainContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export const Contribution = () => { const { relativePath } = useMainContext() diff --git a/components/page-footer/LegalFooter.tsx b/components/page-footer/LegalFooter.tsx index c251970f3bf8..6ba4c5119af5 100644 --- a/components/page-footer/LegalFooter.tsx +++ b/components/page-footer/LegalFooter.tsx @@ -2,7 +2,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { LinkExternalIcon } from '@primer/octicons-react' import cx from 'classnames' -import { useTranslation } from '../hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export const LegalFooter = () => { const router = useRouter() diff --git a/components/page-footer/Support.tsx b/components/page-footer/Support.tsx index 16e388da7a46..9a69c2c56726 100644 --- a/components/page-footer/Support.tsx +++ b/components/page-footer/Support.tsx @@ -1,6 +1,6 @@ import { PeopleIcon, CommentDiscussionIcon } from '@primer/octicons-react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { useMainContext } from 'components/context/MainContext' export const Support = () => { diff --git a/components/page-footer/SupportSection.tsx b/components/page-footer/SupportSection.tsx index 6d873b30b949..3a1a060404cd 100644 --- a/components/page-footer/SupportSection.tsx +++ b/components/page-footer/SupportSection.tsx @@ -6,7 +6,7 @@ import { Support } from 'components/page-footer/Support' import { useMainContext } from 'components/context/MainContext' import { useVersion } from 'components/hooks/useVersion' import { useRouter } from 'next/router' -import { useTranslation } from '../hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export const SupportSection = () => { const { currentVersion } = useVersion() diff --git a/components/page-header/Header.tsx b/components/page-header/Header.tsx index d28dbb63c82c..099a0edc8306 100644 --- a/components/page-header/Header.tsx +++ b/components/page-header/Header.tsx @@ -15,10 +15,10 @@ import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' import { Link } from 'components/Link' import { useMainContext } from 'components/context/MainContext' import { useHasAccount } from 'components/hooks/useHasAccount' -import { LanguagePicker } from './LanguagePicker' +import { LanguagePicker } from 'src/languages/components/LanguagePicker' import { HeaderNotifications } from 'components/page-header/HeaderNotifications' import { ApiVersionPicker } from 'src/rest/components/ApiVersionPicker' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Search } from 'src/search/components/Search' import { Breadcrumbs } from 'components/page-header/Breadcrumbs' import { VersionPicker } from 'components/page-header/VersionPicker' diff --git a/components/page-header/HeaderNotifications.tsx b/components/page-header/HeaderNotifications.tsx index 562c4f8cd909..75e73951dc7e 100644 --- a/components/page-header/HeaderNotifications.tsx +++ b/components/page-header/HeaderNotifications.tsx @@ -2,12 +2,12 @@ import { useRouter } from 'next/router' import cx from 'classnames' import { XIcon } from '@primer/octicons-react' -import { useLanguages } from 'components/context/LanguagesContext' +import { useLanguages } from 'src/languages/components/LanguagesContext' import { useMainContext } from 'components/context/MainContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ExcludesNull } from 'components/lib/ExcludesNull' import { useVersion } from 'components/hooks/useVersion' -import { useUserLanguage } from 'components/hooks/useUserLanguage' +import { useUserLanguage } from 'src/languages/components/useUserLanguage' import styles from './HeaderNotifications.module.scss' enum NotificationType { diff --git a/components/page-header/VersionPicker.tsx b/components/page-header/VersionPicker.tsx index 41dbfd64b8a1..b4336726e679 100644 --- a/components/page-header/VersionPicker.tsx +++ b/components/page-header/VersionPicker.tsx @@ -3,7 +3,7 @@ import { ArrowRightIcon, InfoIcon } from '@primer/octicons-react' import { useMainContext } from 'components/context/MainContext' import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Picker } from 'src/tools/components/Picker' import styles from './VersionPicker.module.scss' diff --git a/components/ui/MiniTocs/MiniTocs.tsx b/components/ui/MiniTocs/MiniTocs.tsx index 2aca6e78dcf5..2e234a106e60 100644 --- a/components/ui/MiniTocs/MiniTocs.tsx +++ b/components/ui/MiniTocs/MiniTocs.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react' import cx from 'classnames' import type { MiniTocItem } from 'components/context/ArticleContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import styles from './Minitocs.module.scss' diff --git a/components/ui/PermissionsStatement/PermissionsStatement.tsx b/components/ui/PermissionsStatement/PermissionsStatement.tsx index b45f3a709539..cd646119f2fd 100644 --- a/components/ui/PermissionsStatement/PermissionsStatement.tsx +++ b/components/ui/PermissionsStatement/PermissionsStatement.tsx @@ -1,7 +1,7 @@ import cx from 'classnames' import styles from './PermissionsStatement.module.scss' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' type Props = { permissions: string diff --git a/contributing/development.md b/contributing/development.md index 7634a20cc8a8..8b09c30c3dd2 100644 --- a/contributing/development.md +++ b/contributing/development.md @@ -44,7 +44,7 @@ The [`script/bookmarklets`](../script/bookmarklets) directory contains some brow By default the local server won't run with all supported languages enabled. If you need to run the server with a particular language, you can temporarily edit the `start` script in `package.json` and update the `ENABLED_LANGUAGES` variable. For example, to enable Japanese and Portuguese, you can set it to `ENABLED_LANGUAGES='en,ja,pt'` and then you need to restart the server for the change to take effect. -The supported language codes are defined in [lib/languages.js](../lib/languages.js). +The supported language codes are defined in [lib/languages.js](#src/languages/lib/languages.js). ## Site structure diff --git a/lib/get-data.js b/lib/get-data.js index f2ee1964323d..49f564960c74 100644 --- a/lib/get-data.js +++ b/lib/get-data.js @@ -5,7 +5,7 @@ import yaml from 'js-yaml' import matter from 'gray-matter' import { merge, get } from 'lodash-es' -import languages from './languages.js' +import languages from '#src/languages/lib/languages.js' import { correctTranslatedContentStrings } from './correct-translation-content.js' // If you run `export DEBUG_JIT_DATA_READS=true` in your terminal, diff --git a/lib/page-data.js b/lib/page-data.js index 7dddf09690b7..1f209bf9f02a 100644 --- a/lib/page-data.js +++ b/lib/page-data.js @@ -1,6 +1,6 @@ import path from 'path' -import languages from './languages.js' +import languages from '#src/languages/lib/languages.js' import { allVersions } from './all-versions.js' import createTree from './create-tree.js' import nonEnterpriseDefaultVersion from './non-enterprise-default-version.js' diff --git a/lib/page.js b/lib/page.js index 726cbddcf8cc..cc290dd604fb 100644 --- a/lib/page.js +++ b/lib/page.js @@ -8,7 +8,7 @@ import getEnglishHeadings from './get-english-headings.js' import getTocItems from './get-toc-items.js' import pathUtils from './path-utils.js' import Permalink from './permalink.js' -import languages from './languages.js' +import languages from '#src/languages/lib/languages.js' import { renderContent } from '#src/content-render/index.js' import processLearningTracks from '#src/learning-track/lib/process-learning-tracks.js' import { productMap } from './all-products.js' diff --git a/middleware/archived-enterprise-versions.js b/middleware/archived-enterprise-versions.js index 5830ad968425..f8b3370f8200 100644 --- a/middleware/archived-enterprise-versions.js +++ b/middleware/archived-enterprise-versions.js @@ -14,7 +14,7 @@ import { setFastlySurrogateKey, SURROGATE_ENUMS } from './set-fastly-surrogate-k import got from 'got' import { readCompressedJsonFileFallbackLazily } from '../lib/read-json-file.js' import { archivedCacheControl, languageCacheControl } from './cache-control.js' -import { pathLanguagePrefixed, languagePrefixPathRegex } from '../lib/languages.js' +import { pathLanguagePrefixed, languagePrefixPathRegex } from '#src/languages/lib/languages.js' import getRedirect, { splitPathByLanguage } from '../src/redirects/lib/get-redirect.js' import getRemoteJSON from './get-remote-json.js' diff --git a/middleware/context.js b/middleware/context.js index 716c1c36a986..215502dba0fc 100644 --- a/middleware/context.js +++ b/middleware/context.js @@ -1,4 +1,4 @@ -import languages from '../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import enterpriseServerReleases from '../lib/enterprise-server-releases.js' import { allVersions } from '../lib/all-versions.js' import { productMap } from '../lib/all-products.js' diff --git a/middleware/contextualizers/product-groups.js b/middleware/contextualizers/product-groups.js index fb6d4d1f1a2a..41ced45c9502 100644 --- a/middleware/contextualizers/product-groups.js +++ b/middleware/contextualizers/product-groups.js @@ -1,6 +1,6 @@ import { getProductGroups } from '../../lib/get-product-groups.js' import warmServer from '../../lib/warm-server.js' -import { languageKeys } from '../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { allVersionKeys } from '../../lib/all-versions.js' const isHomepage = (path) => { diff --git a/middleware/find-page.js b/middleware/find-page.js index 68a91daa65e0..40756102ef1b 100644 --- a/middleware/find-page.js +++ b/middleware/find-page.js @@ -3,7 +3,7 @@ import { existsSync } from 'fs' import { ROOT } from '../lib/constants.js' import Page from '../lib/page.js' -import { languagePrefixPathRegex } from '../lib/languages.js' +import { languagePrefixPathRegex } from '#src/languages/lib/languages.js' const englishPrefixRegex = /^\/en(\/|$)/ const CONTENT_ROOT = path.join(ROOT, 'content') diff --git a/middleware/index.js b/middleware/index.js index 129c2131c8ff..a81b515a0bbb 100644 --- a/middleware/index.js +++ b/middleware/index.js @@ -17,7 +17,7 @@ import { } from './set-fastly-surrogate-key.js' import handleErrors from '#src/observability/middleware/handle-errors.js' import handleNextDataPath from './handle-next-data-path.js' -import detectLanguage from './detect-language.js' +import detectLanguage from '#src/languages/middleware/detect-language.js' import reloadTree from './reload-tree.js' import context from './context.js' import shortVersions from './contextualizers/short-versions.js' diff --git a/middleware/reload-tree.js b/middleware/reload-tree.js index 32f4144d39c7..eaa6d64da22d 100644 --- a/middleware/reload-tree.js +++ b/middleware/reload-tree.js @@ -16,7 +16,7 @@ import path from 'path' -import languages, { languageKeys } from '../lib/languages.js' +import languages, { languageKeys } from '#src/languages/lib/languages.js' import createTree from '../lib/create-tree.js' import warmServer from '../lib/warm-server.js' import { loadSiteTree, loadPages, loadPageMap } from '../lib/page-data.js' diff --git a/middleware/render-page.js b/middleware/render-page.js index 28e46ff9899d..68a4bc870790 100644 --- a/middleware/render-page.js +++ b/middleware/render-page.js @@ -4,7 +4,7 @@ import FailBot from '#src/observability/lib/failbot.js' import patterns from '../lib/patterns.js' import getMiniTocItems from '../lib/get-mini-toc-items.js' import Page from '../lib/page.js' -import { pathLanguagePrefixed } from '../lib/languages.js' +import { pathLanguagePrefixed } from '#src/languages/lib/languages.js' import statsd from '#src/observability/lib/statsd.js' import { allVersions } from '../lib/all-versions.js' import { isConnectionDropped } from './halt-on-dropped-connection.js' diff --git a/next.config.js b/next.config.js index f6b535ef9e6d..33f58dc66b86 100644 --- a/next.config.js +++ b/next.config.js @@ -2,7 +2,7 @@ import fs from 'fs' import path from 'path' import frontmatter from 'gray-matter' -import { languageKeys } from './lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { ROOT } from './lib/constants.js' const homepage = path.posix.join(ROOT, 'content/index.md') diff --git a/script/purge-fastly-by-url.js b/script/purge-fastly-by-url.js index 4a885fb197cd..5d1f8b96f464 100755 --- a/script/purge-fastly-by-url.js +++ b/script/purge-fastly-by-url.js @@ -12,7 +12,7 @@ import fs from 'fs/promises' import path from 'path' import { program } from 'commander' import { execSync } from 'child_process' -import libLanguages from '../lib/languages.js' +import libLanguages from '#src/languages/lib/languages.js' import { getPathWithoutLanguage } from '../lib/path-utils.js' const languageCodes = Object.keys(libLanguages) diff --git a/src/assets/scripts/find-orphaned-assets.js b/src/assets/scripts/find-orphaned-assets.js index 3ccb9725ccc7..54f19a8e8acb 100755 --- a/src/assets/scripts/find-orphaned-assets.js +++ b/src/assets/scripts/find-orphaned-assets.js @@ -13,7 +13,7 @@ import { program } from 'commander' import walk from 'walk-sync' import walkFiles from '../../../script/helpers/walk-files.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' const EXCEPTIONS = new Set([ 'assets/images/site/favicon.ico', diff --git a/src/automated-pipelines/components/parameter-table/ChildBodyParametersRows.tsx b/src/automated-pipelines/components/parameter-table/ChildBodyParametersRows.tsx index 69241776dfe0..fe2807740da9 100644 --- a/src/automated-pipelines/components/parameter-table/ChildBodyParametersRows.tsx +++ b/src/automated-pipelines/components/parameter-table/ChildBodyParametersRows.tsx @@ -1,6 +1,6 @@ import cx from 'classnames' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ParameterRow } from './ParameterRow' import type { ChildParameter } from './types' diff --git a/src/automated-pipelines/components/parameter-table/ParameterRow.tsx b/src/automated-pipelines/components/parameter-table/ParameterRow.tsx index 1be3a51067d7..1fce2eccda98 100644 --- a/src/automated-pipelines/components/parameter-table/ParameterRow.tsx +++ b/src/automated-pipelines/components/parameter-table/ParameterRow.tsx @@ -1,6 +1,6 @@ import cx from 'classnames' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ChildBodyParametersRows } from './ChildBodyParametersRows' import type { ChildParameter } from './types' diff --git a/src/automated-pipelines/components/parameter-table/ParameterTable.tsx b/src/automated-pipelines/components/parameter-table/ParameterTable.tsx index 8a8ae6f5ed8d..6d667d71b39a 100644 --- a/src/automated-pipelines/components/parameter-table/ParameterTable.tsx +++ b/src/automated-pipelines/components/parameter-table/ParameterTable.tsx @@ -1,5 +1,5 @@ import cx from 'classnames' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ParameterRow } from './ParameterRow' import { BodyParameter, ChildParameter, Parameter } from './types' diff --git a/src/codeql-cli/scripts/convert-markdown-for-docs.js b/src/codeql-cli/scripts/convert-markdown-for-docs.js index 51783a253f4c..8c8770ea5263 100644 --- a/src/codeql-cli/scripts/convert-markdown-for-docs.js +++ b/src/codeql-cli/scripts/convert-markdown-for-docs.js @@ -7,7 +7,7 @@ import { visitParents } from 'unist-util-visit-parents' import { visit, SKIP } from 'unist-util-visit' import { remove } from 'unist-util-remove' -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { MARKDOWN_OPTIONS } from '../../content-linter/lib/helpers/unified-formatter-options.js' const { targetDirectory, removeKeywords } = JSON.parse( diff --git a/src/content-linter/lib/linting-rules/internal-links-lang.js b/src/content-linter/lib/linting-rules/internal-links-lang.js index 2c728b4400ab..4bebe573d133 100644 --- a/src/content-linter/lib/linting-rules/internal-links-lang.js +++ b/src/content-linter/lib/linting-rules/internal-links-lang.js @@ -1,7 +1,7 @@ import { filterTokens } from 'markdownlint-rule-helpers' import { addFixErrorDetail, getRange } from '../helpers/utils.js' -import { languageKeys } from '../../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' export const internalLinksLang = { names: ['GHD005', 'internal-links-lang'], diff --git a/src/content-linter/tests/lint-files.js b/src/content-linter/tests/lint-files.js index ff055c974e53..871e451dfbc0 100755 --- a/src/content-linter/tests/lint-files.js +++ b/src/content-linter/tests/lint-files.js @@ -15,7 +15,7 @@ import semver from 'semver' import { jest } from '@jest/globals' import { frontmatter, deprecatedProperties } from '../../../lib/frontmatter.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import releaseNotesSchema from '../lib/release-notes-schema.js' import learningTracksSchema from '../lib/learning-tracks-schema.js' import { liquid } from '#src/content-render/index.js' diff --git a/src/content-render/tests/data.js b/src/content-render/tests/data.js index 90f5f39cf696..51608df4a6ca 100644 --- a/src/content-render/tests/data.js +++ b/src/content-render/tests/data.js @@ -1,7 +1,7 @@ import { afterAll, beforeAll, expect, describe, it } from '@jest/globals' import Page from '../../../lib/page.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import nonEnterpriseDefaultVersion from '../../../lib/non-enterprise-default-version.js' import { DataDirectory } from '../../../tests/helpers/data-directory.js' diff --git a/src/content-render/tests/liquid-helpers.js b/src/content-render/tests/liquid-helpers.js index e28b78ba96de..4496c2cd7f31 100644 --- a/src/content-render/tests/liquid-helpers.js +++ b/src/content-render/tests/liquid-helpers.js @@ -1,6 +1,6 @@ import { afterAll, jest, beforeAll, expect } from '@jest/globals' import { liquid } from '#src/content-render/index.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { DataDirectory } from '../../../tests/helpers/data-directory.js' describe('liquid helper tags', () => { diff --git a/src/early-access/tests/early-access-unit.js b/src/early-access/tests/early-access-unit.js index b07d40f85298..395762f3cd25 100644 --- a/src/early-access/tests/early-access-unit.js +++ b/src/early-access/tests/early-access-unit.js @@ -2,7 +2,7 @@ import { expect, jest, test } from '@jest/globals' import { get, getDOM } from '../../../tests/helpers/e2etest.js' import { describeIfDocsEarlyAccess } from '../../../tests/helpers/conditional-runs.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' const VALID_EARLY_ACCESS_URI = '/early-access/github/save-time-with-slash-commands' diff --git a/src/events/components/Survey.tsx b/src/events/components/Survey.tsx index 20dfa28b4393..c89b26b405a6 100644 --- a/src/events/components/Survey.tsx +++ b/src/events/components/Survey.tsx @@ -2,7 +2,7 @@ import { useState, useRef, useEffect } from 'react' import cx from 'classnames' import { useRouter } from 'next/router' import { ThumbsdownIcon, ThumbsupIcon } from '@primer/octicons-react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Link } from 'components/Link' import { sendEvent, EventType } from 'src/events/components/events' diff --git a/src/events/lib/schema.js b/src/events/lib/schema.js index bf4834fc9cd1..ab26f5aa287c 100644 --- a/src/events/lib/schema.js +++ b/src/events/lib/schema.js @@ -1,4 +1,4 @@ -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { allVersionKeys } from '../../../lib/all-versions.js' import { productIds } from '../../../lib/all-products.js' import { allTools } from '#src/tools/lib/all-tools.js' diff --git a/src/frame/pages/app.tsx b/src/frame/pages/app.tsx index ddbe3bd9cbda..e4866413f712 100644 --- a/src/frame/pages/app.tsx +++ b/src/frame/pages/app.tsx @@ -10,7 +10,7 @@ import { LanguagesContext, LanguagesContextT, LanguageItem, -} from 'components/context/LanguagesContext' +} from 'src/languages/components/LanguagesContext' import { useTheme } from 'components/hooks/useTheme' type MyAppProps = AppProps & { diff --git a/src/ghes-releases/scripts/archive-version.js b/src/ghes-releases/scripts/archive-version.js index 1e9fe308e463..65698aefae90 100755 --- a/src/ghes-releases/scripts/archive-version.js +++ b/src/ghes-releases/scripts/archive-version.js @@ -19,7 +19,7 @@ import createApp from '../../../lib/app.js' import EnterpriseServerReleases from '../../../lib/enterprise-server-releases.js' import loadRedirects from '#src/redirects/lib/precompile.js' import { loadPageMap } from '../../../lib/page-data.js' -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' const port = '4001' const host = `http://localhost:${port}` diff --git a/src/github-apps/components/PermissionsList.tsx b/src/github-apps/components/PermissionsList.tsx index 7cf40cea711d..60864cf59f33 100644 --- a/src/github-apps/components/PermissionsList.tsx +++ b/src/github-apps/components/PermissionsList.tsx @@ -3,7 +3,7 @@ import cx from 'classnames' import { slug as githubSlug } from 'github-slugger' import { HeadingLink } from 'components/article/HeadingLink' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Link } from 'components/Link' import { MainContextT } from 'components/context/MainContext' import { diff --git a/src/graphql/components/Enum.tsx b/src/graphql/components/Enum.tsx index 3140750b2ede..734c376d5ac3 100644 --- a/src/graphql/components/Enum.tsx +++ b/src/graphql/components/Enum.tsx @@ -1,6 +1,6 @@ import React from 'react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { GraphqlItem } from './GraphqlItem' import type { EnumT } from './types' diff --git a/src/graphql/components/InputObject.tsx b/src/graphql/components/InputObject.tsx index 4631685d7123..95cd8471da8b 100644 --- a/src/graphql/components/InputObject.tsx +++ b/src/graphql/components/InputObject.tsx @@ -1,6 +1,6 @@ import { GraphqlItem } from './GraphqlItem' import { Table } from './Table' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { InputObjectT } from './types' type Props = { diff --git a/src/graphql/components/Interface.tsx b/src/graphql/components/Interface.tsx index 83f87b71671d..3c75c14d3894 100644 --- a/src/graphql/components/Interface.tsx +++ b/src/graphql/components/Interface.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { GraphqlItem } from './GraphqlItem' import { Table } from './Table' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { ObjectT, InterfaceT } from './types' type Props = { diff --git a/src/graphql/components/Mutation.tsx b/src/graphql/components/Mutation.tsx index 689287aafd67..4ed2d9e5b019 100644 --- a/src/graphql/components/Mutation.tsx +++ b/src/graphql/components/Mutation.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { GraphqlItem } from './GraphqlItem' import { Notice } from './Notice' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Table } from './Table' import type { MutationT } from './types' import React from 'react' diff --git a/src/graphql/components/Notice.tsx b/src/graphql/components/Notice.tsx index 0fcaa713b398..c8212d7d7bc6 100644 --- a/src/graphql/components/Notice.tsx +++ b/src/graphql/components/Notice.tsx @@ -1,7 +1,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { GraphqlT } from './types' type Props = { diff --git a/src/graphql/components/Object.tsx b/src/graphql/components/Object.tsx index f57de6474c5e..332490dc5d0d 100644 --- a/src/graphql/components/Object.tsx +++ b/src/graphql/components/Object.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { GraphqlItem } from './GraphqlItem' import { Table } from './Table' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { ObjectT, ImplementsT } from './types' type Props = { diff --git a/src/graphql/components/Previews.tsx b/src/graphql/components/Previews.tsx index 2e59393eccad..875c0fc06fb9 100644 --- a/src/graphql/components/Previews.tsx +++ b/src/graphql/components/Previews.tsx @@ -3,7 +3,7 @@ import GithubSlugger from 'github-slugger' import cx from 'classnames' import { HeadingLink } from 'components/article/HeadingLink' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { PreviewT } from './types' import styles from 'components/ui/MarkdownContent/MarkdownContent.module.scss' diff --git a/src/graphql/components/Query.tsx b/src/graphql/components/Query.tsx index 5c37f0d0e5fd..068e486efb16 100644 --- a/src/graphql/components/Query.tsx +++ b/src/graphql/components/Query.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { GraphqlItem } from './GraphqlItem' import { Table } from './Table' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { QueryT } from './types' type Props = { diff --git a/src/graphql/components/Table.tsx b/src/graphql/components/Table.tsx index 231ea65653db..4e846d079c49 100644 --- a/src/graphql/components/Table.tsx +++ b/src/graphql/components/Table.tsx @@ -2,7 +2,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { Notice } from './Notice' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { FieldT } from './types' type Props = { diff --git a/src/graphql/components/Union.tsx b/src/graphql/components/Union.tsx index a1b56f74587d..76c7621f6ec6 100644 --- a/src/graphql/components/Union.tsx +++ b/src/graphql/components/Union.tsx @@ -2,7 +2,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import { GraphqlItem } from './GraphqlItem' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { UnionT } from './types' type Props = { diff --git a/src/graphql/lib/index.js b/src/graphql/lib/index.js index 6614783bb820..4d75fe5d20d0 100644 --- a/src/graphql/lib/index.js +++ b/src/graphql/lib/index.js @@ -3,7 +3,7 @@ import { readCompressedJsonFileFallback, } from '../../../lib/read-json-file.js' import { getAutomatedPageMiniTocItems } from '../../../lib/get-mini-toc-items.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { allVersions } from '../../../lib/all-versions.js' export const GRAPHQL_DATA_DIR = 'src/graphql/data' diff --git a/src/landings/components/ArticleCards.tsx b/src/landings/components/ArticleCards.tsx index 02b1390751c3..3fac65536122 100644 --- a/src/landings/components/ArticleCards.tsx +++ b/src/landings/components/ArticleCards.tsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react' import { useProductGuidesContext } from 'src/landings/components/ProductGuidesContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ArticleCard } from './ArticleCard' import { ItemInput } from '@primer/react/lib/deprecated/ActionList/List' diff --git a/src/landings/components/ArticleList.tsx b/src/landings/components/ArticleList.tsx index 99d24dc93a1c..4eb9ed9501e5 100644 --- a/src/landings/components/ArticleList.tsx +++ b/src/landings/components/ArticleList.tsx @@ -1,7 +1,7 @@ import cx from 'classnames' import dayjs from 'dayjs' import { ActionList } from '@primer/react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Link } from 'components/Link' import { ArrowRightIcon } from '@primer/octicons-react' import { FeaturedLink } from 'src/landings/components/ProductLandingContext' diff --git a/src/landings/components/FeaturedArticles.tsx b/src/landings/components/FeaturedArticles.tsx index dc492f7d93bd..fc84110bddec 100644 --- a/src/landings/components/FeaturedArticles.tsx +++ b/src/landings/components/FeaturedArticles.tsx @@ -1,7 +1,7 @@ import cx from 'classnames' import { useProductLandingContext } from 'src/landings/components/ProductLandingContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ArticleList } from 'src/landings/components/ArticleList' export const FeaturedArticles = () => { diff --git a/src/landings/components/GuideCards.tsx b/src/landings/components/GuideCards.tsx index f7f56d7d2a92..04a9a0270d79 100644 --- a/src/landings/components/GuideCards.tsx +++ b/src/landings/components/GuideCards.tsx @@ -6,7 +6,7 @@ import { useMainContext } from 'components/context/MainContext' import { useProductLandingContext } from 'src/landings/components/ProductLandingContext' import { GuideCard } from 'src/landings/components/GuideCard' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export const GuideCards = () => { const router = useRouter() diff --git a/src/landings/components/HomePageHero.tsx b/src/landings/components/HomePageHero.tsx index e92dbb659a12..bd22ef8f5656 100644 --- a/src/landings/components/HomePageHero.tsx +++ b/src/landings/components/HomePageHero.tsx @@ -1,5 +1,5 @@ import { OctocatHeader } from 'src/landings/components/OctocatHeader' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export const HomePageHero = () => { const { t } = useTranslation(['header', 'homepage']) diff --git a/src/landings/components/LandingHero.tsx b/src/landings/components/LandingHero.tsx index 92fd6cfa61aa..e242d5791bbf 100644 --- a/src/landings/components/LandingHero.tsx +++ b/src/landings/components/LandingHero.tsx @@ -5,7 +5,7 @@ import { LinkExternalIcon, NoteIcon } from '@primer/octicons-react' import { Link } from 'components/Link' import { useProductLandingContext } from 'src/landings/components/ProductLandingContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { useVersion } from 'components/hooks/useVersion' import { Lead } from 'components/ui/Lead' diff --git a/src/landings/components/ProductGuides.tsx b/src/landings/components/ProductGuides.tsx index ba24651d6ef5..c52e78a469f2 100644 --- a/src/landings/components/ProductGuides.tsx +++ b/src/landings/components/ProductGuides.tsx @@ -4,7 +4,7 @@ import { LandingSection } from 'src/landings/components/LandingSection' import { GuidesHero } from 'src/landings/components/GuidesHero' import { LearningTracks } from 'src/learning-track/components/guides/LearningTracks' import { ArticleCards } from 'src/landings/components/ArticleCards' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { useMainContext } from 'components/context/MainContext' export const ProductGuides = () => { diff --git a/src/landings/components/ProductLanding.tsx b/src/landings/components/ProductLanding.tsx index abf3ae315819..48fd7821d928 100644 --- a/src/landings/components/ProductLanding.tsx +++ b/src/landings/components/ProductLanding.tsx @@ -8,7 +8,7 @@ import { GuideCards } from 'src/landings/components/GuideCards' import { SponsorsExamples } from 'src/landings/components/SponsorsExamples' import { CommunityExamples } from 'src/landings/components/CommunityExamples' import { LandingSection } from 'src/landings/components/LandingSection' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ProductArticlesList } from 'src/landings/components/ProductArticlesList' import { ProductReleases } from 'src/landings/components/ProductReleases' import { useVersion } from 'components/hooks/useVersion' diff --git a/src/landings/components/ProductReleases.tsx b/src/landings/components/ProductReleases.tsx index c91f0f206048..df7d2293a199 100644 --- a/src/landings/components/ProductReleases.tsx +++ b/src/landings/components/ProductReleases.tsx @@ -1,7 +1,7 @@ import { ArrowRightIcon, ArrowUpIcon, FileIcon, ListUnorderedIcon } from '@primer/octicons-react' import { useMainContext } from 'components/context/MainContext' import { useProductLandingContext } from 'src/landings/components/ProductLandingContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Link } from 'components/Link' import { useRouter } from 'next/router' diff --git a/src/landings/components/TocLanding.tsx b/src/landings/components/TocLanding.tsx index 22312023d09f..ab1b7fe13aef 100644 --- a/src/landings/components/TocLanding.tsx +++ b/src/landings/components/TocLanding.tsx @@ -2,7 +2,7 @@ import { useRouter } from 'next/router' import cx from 'classnames' import { useTocLandingContext } from 'components/context/TocLandingContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { DefaultLayout } from 'components/DefaultLayout' import { TableOfContents } from 'src/landings/components/TableOfContents' import { ArticleTitle } from 'components/article/ArticleTitle' diff --git a/src/landings/pages/home.tsx b/src/landings/pages/home.tsx index 3706d8ce5988..a0c4a12da9bc 100644 --- a/src/landings/pages/home.tsx +++ b/src/landings/pages/home.tsx @@ -4,7 +4,7 @@ import type { GetServerSideProps } from 'next' import { MainContextT, MainContext, getMainContext } from 'components/context/MainContext' import { DefaultLayout } from 'components/DefaultLayout' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ArticleList } from 'src/landings/components/ArticleList' import { HomePageHero } from 'src/landings/components/HomePageHero' import type { ProductGroupT } from 'src/landings/components/ProductSelections' diff --git a/src/languages/README.md b/src/languages/README.md new file mode 100644 index 000000000000..bfbf1610b962 --- /dev/null +++ b/src/languages/README.md @@ -0,0 +1,19 @@ +# LANGUAGES + +TBD what is LANGUAGES + +## What LANGUAGES does + +TBD why is LANGUAGES on the docs + +## How LANGUAGES works + +TBD step-by-step instructions to work on LANGUAGES + +## How to work on LANGUAGES + +TBD step-by-step instructions on how to work on LANGUAGES + +## How to get help for LANGUAGES + +TBD reference material diff --git a/components/page-header/LanguagePicker.tsx b/src/languages/components/LanguagePicker.tsx similarity index 94% rename from components/page-header/LanguagePicker.tsx rename to src/languages/components/LanguagePicker.tsx index f8e31daec31a..bd751a12b53c 100644 --- a/components/page-header/LanguagePicker.tsx +++ b/src/languages/components/LanguagePicker.tsx @@ -1,9 +1,9 @@ import { useRouter } from 'next/router' import { GlobeIcon } from '@primer/octicons-react' -import { useLanguages } from 'components/context/LanguagesContext' -import { useTranslation } from 'components/hooks/useTranslation' -import { useUserLanguage } from 'components/hooks/useUserLanguage' +import { useLanguages } from 'src/languages/components/LanguagesContext' +import { useTranslation } from 'src/languages/components/useTranslation' +import { useUserLanguage } from 'src/languages/components/useUserLanguage' import { ActionList, ActionMenu, IconButton, Link } from '@primer/react' type Props = { diff --git a/components/context/LanguagesContext.tsx b/src/languages/components/LanguagesContext.tsx similarity index 100% rename from components/context/LanguagesContext.tsx rename to src/languages/components/LanguagesContext.tsx diff --git a/components/hooks/useTranslation.ts b/src/languages/components/useTranslation.ts similarity index 100% rename from components/hooks/useTranslation.ts rename to src/languages/components/useTranslation.ts diff --git a/components/hooks/useUserLanguage.ts b/src/languages/components/useUserLanguage.ts similarity index 87% rename from components/hooks/useUserLanguage.ts rename to src/languages/components/useUserLanguage.ts index 4e2f570508ab..522fd9b81dd7 100644 --- a/components/hooks/useUserLanguage.ts +++ b/src/languages/components/useUserLanguage.ts @@ -2,8 +2,8 @@ import { useState, useEffect } from 'react' import Cookies from 'components/lib/cookies' import { useRouter } from 'next/router' -import { useLanguages } from 'components/context/LanguagesContext' -import { USER_LANGUAGE_COOKIE_NAME } from '../../lib/constants.js' +import { useLanguages } from 'src/languages/components/LanguagesContext' +import { USER_LANGUAGE_COOKIE_NAME } from '../../../lib/constants.js' export function useUserLanguage() { const { locale } = useRouter() diff --git a/lib/languages.js b/src/languages/lib/languages.js similarity index 99% rename from lib/languages.js rename to src/languages/lib/languages.js index 1e6234489a35..de04af779534 100644 --- a/lib/languages.js +++ b/src/languages/lib/languages.js @@ -6,7 +6,7 @@ import fs from 'fs' import dotenv from 'dotenv' -import { ROOT, TRANSLATIONS_ROOT, TRANSLATIONS_FIXTURE_ROOT } from './constants.js' +import { ROOT, TRANSLATIONS_ROOT, TRANSLATIONS_FIXTURE_ROOT } from '../../../lib/constants.js' dotenv.config() diff --git a/middleware/detect-language.js b/src/languages/middleware/detect-language.js similarity index 93% rename from middleware/detect-language.js rename to src/languages/middleware/detect-language.js index 9a5b8041b5e9..789de87775fb 100644 --- a/middleware/detect-language.js +++ b/src/languages/middleware/detect-language.js @@ -1,7 +1,7 @@ -import languages, { languageKeys } from '../lib/languages.js' +import languages, { languageKeys } from '#src/languages/lib/languages.js' import parser from 'accept-language-parser' -import { USER_LANGUAGE_COOKIE_NAME } from '../lib/constants.js' +import { USER_LANGUAGE_COOKIE_NAME } from '../../../lib/constants.js' const chineseRegions = [ 'CN', // Mainland diff --git a/script/i18n/clone-translations.sh b/src/languages/scripts/clone-translations.sh similarity index 100% rename from script/i18n/clone-translations.sh rename to src/languages/scripts/clone-translations.sh diff --git a/script/i18n/create-translation-health-report.js b/src/languages/scripts/create-translation-health-report.js similarity index 92% rename from script/i18n/create-translation-health-report.js rename to src/languages/scripts/create-translation-health-report.js index 71a1f7379e3d..4365178d5b23 100755 --- a/script/i18n/create-translation-health-report.js +++ b/src/languages/scripts/create-translation-health-report.js @@ -59,11 +59,11 @@ console.warn = console.error = (...args) => { } // Weird import syntax, but forces it to load after process.env... changes -const { languageKeys } = await import('../../lib/languages.js') -const { loadPages, loadPageMap } = await import('../../lib/page-data.js') -const { precompileRedirects } = await import('../../src/redirects/lib/precompile.js') -const { allVersions, allVersionKeys } = await import('../../lib/all-versions.js') -const { getProductStringFromPath } = await import('../../lib/path-utils.js') +const { languageKeys } = await import('#src/languages/lib/languages.js') +const { loadPages, loadPageMap } = await import('../../../lib/page-data.js') +const { precompileRedirects } = await import('../../../src/redirects/lib/precompile.js') +const { allVersions, allVersionKeys } = await import('../../../lib/all-versions.js') +const { getProductStringFromPath } = await import('../../../lib/path-utils.js') // Check that the language is valid const { language, gitref } = program.opts() diff --git a/.github/actions-scripts/purge-fastly-edge-cache-per-language.js b/src/languages/scripts/purge-fastly-edge-cache-per-language.js similarity index 87% rename from .github/actions-scripts/purge-fastly-edge-cache-per-language.js rename to src/languages/scripts/purge-fastly-edge-cache-per-language.js index 655180b0b6fe..ab9a84894c94 100755 --- a/.github/actions-scripts/purge-fastly-edge-cache-per-language.js +++ b/src/languages/scripts/purge-fastly-edge-cache-per-language.js @@ -1,9 +1,9 @@ #!/usr/bin/env node -import { languageKeys } from '../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' -import { makeLanguageSurrogateKey } from '../../middleware/set-fastly-surrogate-key.js' -import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js' +import { makeLanguageSurrogateKey } from '../../../middleware/set-fastly-surrogate-key.js' +import purgeEdgeCache from '../../../script/deployment/purge-edge-cache.js' /** * In simple terms, this script sends purge commands for... diff --git a/script/i18n/test-html-pages.js b/src/languages/scripts/test-html-pages.js similarity index 93% rename from script/i18n/test-html-pages.js rename to src/languages/scripts/test-html-pages.js index 57b55d162e16..43736fcea051 100755 --- a/script/i18n/test-html-pages.js +++ b/src/languages/scripts/test-html-pages.js @@ -13,9 +13,9 @@ import Bottleneck from 'bottleneck' // npm install --include=optional // -import { loadPages } from '../../lib/page-data.js' -import { allVersions } from '../../lib/all-versions.js' -import languages from '../../lib/languages.js' +import { loadPages } from '../../../lib/page-data.js' +import { allVersions } from '../../../lib/all-versions.js' +import languages from '#src/languages/lib/languages.js' const port = 4002 dotenv.config() diff --git a/tests/translations/api-search.js b/src/languages/tests/api-search.js similarity index 91% rename from tests/translations/api-search.js rename to src/languages/tests/api-search.js index 3ca0246d67cc..7e0aee787e08 100644 --- a/tests/translations/api-search.js +++ b/src/languages/tests/api-search.js @@ -1,7 +1,7 @@ import { jest, test, expect } from '@jest/globals' -import { describeIfElasticsearchURL } from '../helpers/conditional-runs.js' -import { get } from '../helpers/e2etest.js' +import { describeIfElasticsearchURL } from '../../../tests/helpers/conditional-runs.js' +import { get } from '../../../tests/helpers/e2etest.js' // This suite only runs if $ELASTICSEARCH_URL is set. describeIfElasticsearchURL('search v1 middleware in non-English', () => { diff --git a/tests/translations/files.js b/src/languages/tests/files.js similarity index 90% rename from tests/translations/files.js rename to src/languages/tests/files.js index f5bccebe1b87..99511471392b 100644 --- a/tests/translations/files.js +++ b/src/languages/tests/files.js @@ -1,4 +1,4 @@ -import languages from '../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { jest } from '@jest/globals' describe('files', () => { diff --git a/tests/translations/frame.js b/src/languages/tests/frame.js similarity index 94% rename from tests/translations/frame.js rename to src/languages/tests/frame.js index 2e7ea87b4271..af422ae48d5f 100644 --- a/tests/translations/frame.js +++ b/src/languages/tests/frame.js @@ -1,7 +1,7 @@ -import { languageKeys } from '../../lib/languages.js' -import { blockIndex } from '../../middleware/block-robots.js' -import { get, getDOMCached as getDOM } from '../helpers/e2etest.js' -import Page from '../../lib/page.js' +import { languageKeys } from '#src/languages/lib/languages.js' +import { blockIndex } from '../../../middleware/block-robots.js' +import { get, getDOMCached as getDOM } from '../../../tests/helpers/e2etest.js' +import Page from '../../../lib/page.js' import { jest } from '@jest/globals' const langs = languageKeys.filter((lang) => lang !== 'en') diff --git a/tests/translations/glossary.js b/src/languages/tests/glossary.js similarity index 76% rename from tests/translations/glossary.js rename to src/languages/tests/glossary.js index ee4d5ac34bbe..9cac6be55f5b 100644 --- a/tests/translations/glossary.js +++ b/src/languages/tests/glossary.js @@ -1,5 +1,5 @@ -import { languageKeys } from '../../lib/languages.js' -import { getDOM } from '../helpers/e2etest.js' +import { languageKeys } from '#src/languages/lib/languages.js' +import { getDOM } from '../../../tests/helpers/e2etest.js' const langs = languageKeys.filter((lang) => lang !== 'en') diff --git a/tests/translations/redirects.js b/src/languages/tests/redirects.js similarity index 89% rename from tests/translations/redirects.js rename to src/languages/tests/redirects.js index 63371d1b0d4f..02ec9186cee4 100644 --- a/tests/translations/redirects.js +++ b/src/languages/tests/redirects.js @@ -1,6 +1,6 @@ -import { languageKeys } from '../../lib/languages.js' -import { get } from '../helpers/e2etest.js' -import { USER_LANGUAGE_COOKIE_NAME } from '../../lib/constants.js' +import { languageKeys } from '#src/languages/lib/languages.js' +import { get } from '../../../tests/helpers/e2etest.js' +import { USER_LANGUAGE_COOKIE_NAME } from '../../../lib/constants.js' const langs = languageKeys.filter((lang) => lang !== 'en') diff --git a/tests/translations/search.js b/src/languages/tests/search.js similarity index 77% rename from tests/translations/search.js rename to src/languages/tests/search.js index 987b42e63c07..e9dbb31ff888 100644 --- a/tests/translations/search.js +++ b/src/languages/tests/search.js @@ -1,5 +1,5 @@ -import { languageKeys } from '../../lib/languages' -import { get } from '../helpers/e2etest.js' +import { languageKeys } from '#src/languages/lib/languages' +import { get } from '../../../tests/helpers/e2etest.js' const langs = languageKeys.filter((lang) => lang !== 'en') diff --git a/src/learning-track/components/article/LearningTrackCard.tsx b/src/learning-track/components/article/LearningTrackCard.tsx index 353c0ca5c089..681e6002a2b3 100644 --- a/src/learning-track/components/article/LearningTrackCard.tsx +++ b/src/learning-track/components/article/LearningTrackCard.tsx @@ -2,7 +2,7 @@ import { useRouter } from 'next/router' import { Link } from 'components/Link' import type { LearningTrack } from 'components/context/ArticleContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' type Props = { track: LearningTrack diff --git a/src/learning-track/components/article/LearningTrackNav.tsx b/src/learning-track/components/article/LearningTrackNav.tsx index 1dad81e57878..ccb4f053a673 100644 --- a/src/learning-track/components/article/LearningTrackNav.tsx +++ b/src/learning-track/components/article/LearningTrackNav.tsx @@ -1,6 +1,6 @@ import { Link } from 'components/Link' import type { LearningTrack } from 'components/context/ArticleContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' type Props = { track: LearningTrack diff --git a/src/learning-track/components/guides/LearningTrack.tsx b/src/learning-track/components/guides/LearningTrack.tsx index d5dc2d2bc0e8..5bbfdb3366e6 100644 --- a/src/learning-track/components/guides/LearningTrack.tsx +++ b/src/learning-track/components/guides/LearningTrack.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { ArrowRightIcon } from '@primer/octicons-react' import { LearningTrack as LearningTrackT } from 'src/landings/components/ProductGuidesContext' import { Link } from 'components/Link' diff --git a/src/redirects/lib/get-redirect.js b/src/redirects/lib/get-redirect.js index 684f9198c140..a4bd0af37c01 100644 --- a/src/redirects/lib/get-redirect.js +++ b/src/redirects/lib/get-redirect.js @@ -1,4 +1,4 @@ -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import nonEnterpriseDefaultVersion from '../../../lib/non-enterprise-default-version.js' import { allVersions } from '../../../lib/all-versions.js' import { diff --git a/src/redirects/middleware/handle-redirects.js b/src/redirects/middleware/handle-redirects.js index b9987ddc06e0..a496572e3de2 100644 --- a/src/redirects/middleware/handle-redirects.js +++ b/src/redirects/middleware/handle-redirects.js @@ -1,6 +1,6 @@ import patterns from '../../../lib/patterns.js' import { URL } from 'url' -import { pathLanguagePrefixed } from '../../../lib/languages.js' +import { pathLanguagePrefixed } from '#src/languages/lib/languages.js' import { deprecatedWithFunctionalRedirects } from '../../../lib/enterprise-server-releases.js' import getRedirect from '../lib/get-redirect.js' import { defaultCacheControl, languageCacheControl } from '../../../middleware/cache-control.js' diff --git a/src/redirects/middleware/language-code-redirects.js b/src/redirects/middleware/language-code-redirects.js index c68cc09ac1ce..6b9fa753b9ee 100644 --- a/src/redirects/middleware/language-code-redirects.js +++ b/src/redirects/middleware/language-code-redirects.js @@ -1,4 +1,4 @@ -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { defaultCacheControl } from '../../../middleware/cache-control.js' const redirectPatterns = Object.values(languages) diff --git a/src/release-notes/components/GHAEReleaseNotePatch.tsx b/src/release-notes/components/GHAEReleaseNotePatch.tsx index d6dc0bb73aaf..61d895824907 100644 --- a/src/release-notes/components/GHAEReleaseNotePatch.tsx +++ b/src/release-notes/components/GHAEReleaseNotePatch.tsx @@ -1,7 +1,7 @@ import { useRef } from 'react' import dayjs from 'dayjs' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { PatchNotes } from './PatchNotes' import { CurrentVersion, ReleaseNotePatch } from './types' diff --git a/src/release-notes/components/GHESReleaseNotePatch.tsx b/src/release-notes/components/GHESReleaseNotePatch.tsx index 434df0cae049..78c3f081e232 100644 --- a/src/release-notes/components/GHESReleaseNotePatch.tsx +++ b/src/release-notes/components/GHESReleaseNotePatch.tsx @@ -1,7 +1,7 @@ import { useRef } from 'react' import dayjs from 'dayjs' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { PatchNotes } from './PatchNotes' import { Link } from 'components/Link' import { CurrentVersion, ReleaseNotePatch, GHESMessage } from './types' diff --git a/src/rest/components/ApiVersionPicker.tsx b/src/rest/components/ApiVersionPicker.tsx index 029cb0713221..d447eb5d7d74 100644 --- a/src/rest/components/ApiVersionPicker.tsx +++ b/src/rest/components/ApiVersionPicker.tsx @@ -5,7 +5,7 @@ import { InfoIcon } from '@primer/octicons-react' import { useMainContext } from 'components/context/MainContext' import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' import { Picker } from 'src/tools/components/Picker' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { API_VERSION_COOKIE_NAME } from 'src/rest/components/RestRedirect' const API_VERSION_SUFFIX = ' (latest)' diff --git a/src/rest/components/RestBanner.tsx b/src/rest/components/RestBanner.tsx index ac5b66baa3db..36b897429363 100644 --- a/src/rest/components/RestBanner.tsx +++ b/src/rest/components/RestBanner.tsx @@ -5,7 +5,7 @@ import { useRouter } from 'next/router' import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' import { Link } from 'components/Link' import { useMainContext } from 'components/context/MainContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' const restRepoDisplayPages = [ 'branches', diff --git a/src/rest/components/RestCodeSamples.tsx b/src/rest/components/RestCodeSamples.tsx index 2cf3d440cf1d..bf1e41f95c66 100644 --- a/src/rest/components/RestCodeSamples.tsx +++ b/src/rest/components/RestCodeSamples.tsx @@ -9,7 +9,7 @@ import json from 'highlight.js/lib/languages/json' import javascript from 'highlight.js/lib/languages/javascript' import hljsCurl from 'highlightjs-curl' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import useClipboard from 'src/rest/components/useClipboard' import { getShellExample, diff --git a/src/rest/components/RestOperation.tsx b/src/rest/components/RestOperation.tsx index 9b56ef1c2954..8020e195cb8c 100644 --- a/src/rest/components/RestOperation.tsx +++ b/src/rest/components/RestOperation.tsx @@ -5,7 +5,7 @@ import cx from 'classnames' import { HeadingLink } from 'components/article/HeadingLink' import { Link } from 'components/Link' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { RestPreviewNotice } from './RestPreviewNotice' import { ParameterTable } from 'src/automated-pipelines/components/parameter-table/ParameterTable' import { RestCodeSamples } from './RestCodeSamples' diff --git a/src/rest/components/RestStatusCodes.tsx b/src/rest/components/RestStatusCodes.tsx index 7a22f9fb54f0..0e747fbacc1c 100644 --- a/src/rest/components/RestStatusCodes.tsx +++ b/src/rest/components/RestStatusCodes.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { StatusCode } from './types' type Props = { diff --git a/src/rest/lib/index.js b/src/rest/lib/index.js index 0251370aa531..d05677fbb76e 100644 --- a/src/rest/lib/index.js +++ b/src/rest/lib/index.js @@ -4,7 +4,7 @@ import path from 'path' import { readCompressedJsonFileFallback } from '../../../lib/read-json-file.js' import { getAutomatedPageMiniTocItems } from '../../../lib/get-mini-toc-items.js' import { allVersions, getOpenApiVersion } from '../../../lib/all-versions.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' export const REST_DATA_DIR = 'src/rest/data' export const REST_SCHEMA_FILENAME = 'schema.json' diff --git a/src/search/components/NoQuery.tsx b/src/search/components/NoQuery.tsx index c281b012abdc..424c6cb666fa 100644 --- a/src/search/components/NoQuery.tsx +++ b/src/search/components/NoQuery.tsx @@ -1,7 +1,7 @@ import { Heading, Flash } from '@primer/react' import { useMainContext } from 'components/context/MainContext' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' export function NoQuery() { const { t } = useTranslation(['search']) diff --git a/src/search/components/Search.tsx b/src/search/components/Search.tsx index def2eb8da586..fa7239413e96 100644 --- a/src/search/components/Search.tsx +++ b/src/search/components/Search.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { IconButton, TextInput } from '@primer/react' import { SearchIcon } from '@primer/octicons-react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' import { useQuery } from 'src/search/components/useQuery' import { useBreakpoint } from 'src/search/components/useBreakpoint' diff --git a/src/search/components/SearchResults.tsx b/src/search/components/SearchResults.tsx index a6e5aa46c482..85c00884bb8a 100644 --- a/src/search/components/SearchResults.tsx +++ b/src/search/components/SearchResults.tsx @@ -4,7 +4,7 @@ import { useRouter } from 'next/router' import cx from 'classnames' import type { SearchResultsT, SearchResultHitT, SearchQueryT } from './types' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { Link } from 'components/Link' import { sendEvent, EventType } from 'src/events/components/events' diff --git a/src/search/components/ValidationErrors.tsx b/src/search/components/ValidationErrors.tsx index 4012a108dd4d..e0d502cc62fa 100644 --- a/src/search/components/ValidationErrors.tsx +++ b/src/search/components/ValidationErrors.tsx @@ -1,6 +1,6 @@ import { Flash } from '@primer/react' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { SearchValidationErrorT } from './types' interface Props { diff --git a/src/search/components/index.tsx b/src/search/components/index.tsx index ed7997de141a..43b9ddb75332 100644 --- a/src/search/components/index.tsx +++ b/src/search/components/index.tsx @@ -2,7 +2,7 @@ import Head from 'next/head' import { Heading } from '@primer/react' import type { SearchT } from 'src/search/components/types' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion' import { useNumberFormatter } from 'src/search/components/useNumberFormatter' import { SearchResults } from 'src/search/components/SearchResults' diff --git a/src/search/middleware/get-search-request.js b/src/search/middleware/get-search-request.js index bfc39ba3f152..4a9173851e6d 100644 --- a/src/search/middleware/get-search-request.js +++ b/src/search/middleware/get-search-request.js @@ -1,6 +1,6 @@ import { format } from 'node:util' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { allVersions } from '../../../lib/all-versions.js' import { POSSIBLE_HIGHLIGHT_FIELDS, DEFAULT_HIGHLIGHT_FIELDS } from './es-search.js' diff --git a/src/search/scripts/analyze-text.js b/src/search/scripts/analyze-text.js index 50daf0d7da2c..19d7d1d74c4d 100755 --- a/src/search/scripts/analyze-text.js +++ b/src/search/scripts/analyze-text.js @@ -17,7 +17,7 @@ import { program, Option } from 'commander' import chalk from 'chalk' import dotenv from 'dotenv' -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { allVersions } from '../../../lib/all-versions.js' // Now you can optionally have set the ELASTICSEARCH_URL in your .env file. diff --git a/src/search/scripts/build-records.js b/src/search/scripts/build-records.js index dec42edfb561..227d2ade32f2 100644 --- a/src/search/scripts/build-records.js +++ b/src/search/scripts/build-records.js @@ -7,7 +7,7 @@ import { HTTPError } from 'got' import parsePageSectionsIntoRecords from './parse-page-sections-into-records.js' import getPopularPages from './popular-pages.js' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import domwaiter from '../../../script/domwaiter.js' const pageMarker = chalk.green('|') diff --git a/src/search/scripts/index-elasticsearch.js b/src/search/scripts/index-elasticsearch.js index e2384c0382c5..1831e203f040 100755 --- a/src/search/scripts/index-elasticsearch.js +++ b/src/search/scripts/index-elasticsearch.js @@ -16,7 +16,7 @@ import chalk from 'chalk' import dotenv from 'dotenv' import { retryOnErrorTest } from '../../../script/helpers/retry-on-error-test.js' -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { allVersions } from '../../../lib/all-versions.js' import statsd from '#src/observability/lib/statsd.js' diff --git a/src/search/scripts/sync-search-indices.js b/src/search/scripts/sync-search-indices.js index c1fcaed570b0..575a7114e954 100755 --- a/src/search/scripts/sync-search-indices.js +++ b/src/search/scripts/sync-search-indices.js @@ -12,7 +12,7 @@ import { existsSync } from 'fs' import assert from 'assert' import { program, Option } from 'commander' -import { languageKeys } from '../../../lib/languages.js' +import { languageKeys } from '#src/languages/lib/languages.js' import { allVersions } from '../../../lib/all-versions.js' import searchSync from './sync.js' diff --git a/src/search/scripts/sync.js b/src/search/scripts/sync.js index 1186b73f94dc..959afa40a876 100644 --- a/src/search/scripts/sync.js +++ b/src/search/scripts/sync.js @@ -1,7 +1,7 @@ #!/usr/bin/env node import chalk from 'chalk' -import languages from '../../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import buildRecords from './build-records.js' import findIndexablePages from './find-indexable-pages.js' import { allVersions } from '../../../lib/all-versions.js' diff --git a/src/webhooks/components/Webhook.tsx b/src/webhooks/components/Webhook.tsx index e5035828c546..2caeee8f8df4 100644 --- a/src/webhooks/components/Webhook.tsx +++ b/src/webhooks/components/Webhook.tsx @@ -8,7 +8,7 @@ import cx from 'classnames' import { useMainContext } from 'components/context/MainContext' import { useVersion } from 'components/hooks/useVersion' import { HeadingLink } from 'components/article/HeadingLink' -import { useTranslation } from 'components/hooks/useTranslation' +import { useTranslation } from 'src/languages/components/useTranslation' import type { WebhookAction, WebhookData } from './types' import { ParameterTable } from 'src/automated-pipelines/components/parameter-table/ParameterTable' diff --git a/tests/unit/get-data.js b/tests/unit/get-data.js index 5ecf06250ace..1de7f6413f40 100644 --- a/tests/unit/get-data.js +++ b/tests/unit/get-data.js @@ -3,7 +3,7 @@ import path from 'path' import { expect, test, describe, beforeAll, afterAll } from '@jest/globals' -import languages from '../../lib/languages.js' +import languages from '#src/languages/lib/languages.js' import { getDataByLanguage, getDeepDataByLanguage, getUIDataMerged } from '../../lib/get-data.js' import { DataDirectory } from '../helpers/data-directory.js' diff --git a/tests/unit/pages.js b/tests/unit/pages.js index b802fd19ff7a..0b58b69bacac 100644 --- a/tests/unit/pages.js +++ b/tests/unit/pages.js @@ -1,7 +1,7 @@ import { jest } from '@jest/globals' import path from 'path' import { loadPages } from '../../lib/page-data.js' -import libLanguages from '../../lib/languages.js' +import libLanguages from '#src/languages/lib/languages.js' import { liquid } from '#src/content-render/index.js' import patterns from '../../lib/patterns.js' import GithubSlugger from 'github-slugger'