diff --git a/.github/workflows/msft-create-translation-batch-pr.yml b/.github/workflows/msft-create-translation-batch-pr.yml index 50f4cb823f..bab7a09566 100644 --- a/.github/workflows/msft-create-translation-batch-pr.yml +++ b/.github/workflows/msft-create-translation-batch-pr.yml @@ -41,7 +41,7 @@ jobs: language_dir: translations/pt-BR language_repo: github/docs-internal.pt-br - - language: cn + - language: zh language_dir: translations/zh-CN language_repo: github/docs-internal.zh-cn diff --git a/.github/workflows/sync-search-elasticsearch.yml b/.github/workflows/sync-search-elasticsearch.yml index e5c955ae60..7c704f3fbd 100644 --- a/.github/workflows/sync-search-elasticsearch.yml +++ b/.github/workflows/sync-search-elasticsearch.yml @@ -59,7 +59,7 @@ jobs: script: | // Edit this list for the definitive list of languages // (other than English) we want to index in Elasticsearch. - const allNonEnglish = ["ja", "es", "pt", "cn", "ru", "fr", "ko", "de"] + const allNonEnglish = ["ja", "es", "pt", "zh", "ru", "fr", "ko", "de"] const allPossible = ["en", ...allNonEnglish] if (context.eventName === "workflow_run") { @@ -114,7 +114,7 @@ jobs: if: ${{ matrix.language != 'en' }} uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: - repository: github/docs-internal.${{ fromJSON('{"cn":"zh-cn","es":"es-es","ru":"ru-ru","ja":"ja-jp","pt":"pt-br","de":"de-de","fr":"fr-fr","ko":"ko-kr"}')[matrix.language] }} + repository: github/docs-internal.${{ fromJSON('{"zh":"zh-cn","es":"es-es","ru":"ru-ru","ja":"ja-jp","pt":"pt-br","de":"de-de","fr":"fr-fr","ko":"ko-kr"}')[matrix.language] }} token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }} path: translation diff --git a/.github/workflows/translation-health-report.yml b/.github/workflows/translation-health-report.yml index ad7ee733dc..5620c311fb 100644 --- a/.github/workflows/translation-health-report.yml +++ b/.github/workflows/translation-health-report.yml @@ -37,7 +37,7 @@ jobs: language_dir: translations/pt-BR language_repo: github/docs-internal.pt-br - - language: cn + - language: zh language_dir: translations/zh-CN language_repo: github/docs-internal.zh-cn diff --git a/contributing/search.md b/contributing/search.md index e8b9904d65..ec893526e0 100644 --- a/contributing/search.md +++ b/contributing/search.md @@ -19,7 +19,7 @@ You can also query our search endpoint directly at: `https://docs.github.com/search?version=&language=&filters=topics:&query=` - The VERSION can be any numbered GitHub Enterprise Server version (e.g., `2.22`, `3.0`), GitHub AE (`ghae`), or the Free pro team plan (`dotcom`). -- The LANGUAGE CODE can be: `cn`, `de`, `en`, `es`, `ja`, or `pt`. +- The LANGUAGE CODE can be: `zh`, `de`, `en`, `es`, `ja`, or `pt`. - TOPIC can be any topics in [the allowed list of topics](/data/allowed-topics.js). The values in the `topics` attribute are **not** case sensitive, so filtering on `GitHub actions` or `github actions` will return the same result. **Note:** Currently, the topics filter only works for the dotcom version in the English language. We plan to expand this search query to other languages and versions in the future. - Any search QUERY you'd like. @@ -94,15 +94,15 @@ There's a separate search index for each combination of product and language. So Index Name | Description ---------- | ----------- -`github-docs-dotcom-cn` | GitHub.com Chinese +`github-docs-dotcom-zh` | GitHub.com Chinese `github-docs-dotcom-en` | GitHub.com English `github-docs-dotcom-es` | GitHub.com Spanish `github-docs-dotcom-ja` | GitHub.com Japanese -`github-docs-2.18-cn` | GitHub Enterprise 2.18 Chinese +`github-docs-2.18-zh` | GitHub Enterprise 2.18 Chinese `github-docs-2.18-en` | GitHub Enterprise 2.18 English `github-docs-2.18-es` | GitHub Enterprise 2.18 Spanish `github-docs-2.18-ja` | GitHub Enterprise 2.18 Japanese -`github-docs-2.17-cn` | GitHub Enterprise 2.17 Chinese +`github-docs-2.17-zh` | GitHub Enterprise 2.17 Chinese `github-docs-2.17-en` | GitHub Enterprise 2.17 English `github-docs-2.17-es` | GitHub Enterprise 2.17 Spanish `github-docs-2.17-ja` | GitHub Enterprise 2.17 Japanese @@ -129,4 +129,4 @@ Each record represents a section of a page. Sections are derived by splitting up - Our search querying has typo tolerance. Try spelling something wrong and see what you get! - Our search querying has lots of controls for customizing each index, so we can add weights to certain attributes and create rules like "title is more important than body", etc. But it works pretty well as-is without any configuration. - Our search querying has support for "advanced query syntax" for exact matching of quoted expressions and exclusion of words preceded by a `-` sign. This is off by default but we have it enabled in our browser client. The settings in the web interface can be overridden by the search endpoint. See [middleware/search.js]([middleware/search.js). -- When needed, the Docs Engineering team can commit updates to the search index, as long as the label `skip-index-check` is applied to the PR. \ No newline at end of file +- When needed, the Docs Engineering team can commit updates to the search index, as long as the label `skip-index-check` is applied to the PR. diff --git a/lib/languages.js b/lib/languages.js index 57398c739d..06849e270e 100644 --- a/lib/languages.js +++ b/lib/languages.js @@ -42,12 +42,12 @@ const languages = { dir: getRoot('en'), wip: false, }, - cn: { + zh: { name: 'Simplified Chinese', nativeName: '简体中文', - code: 'cn', + code: 'zh', hreflang: 'zh-Hans', - redirectPatterns: [/^\/zh-\w{2}/, /^\/zh/], + redirectPatterns: [/^\/cn/], dir: getRoot('zh-cn'), wip: false, }, diff --git a/lib/patterns.js b/lib/patterns.js index e9365fd1cf..a574e4cb91 100644 --- a/lib/patterns.js +++ b/lib/patterns.js @@ -27,7 +27,7 @@ export const ymd = /^\d{4}-\d{2}-\d{2}$/ export const hasLiquid = /[{{][{%]/ export const dataReference = /{% ?data\s(?:early-access\.)?(?:reusables|variables|ui)\..*?%}/gm export const imagePath = /\/?assets\/images\/.*?\.(png|svg|gif|pdf|ico|jpg|jpeg)/gi -export const homepagePath = /^\/\w{2}$/ // /en, /ja /cn +export const homepagePath = /^\/\w{2}$/ // /en, /ja export const multipleSlashes = /^(\/|\\){2,}/ export const assetPaths = /\/(?:javascripts|stylesheets|assets|node_modules|dist|_next)\// export const oldApiPath = /\/v[34]\/(?!guides|overview).+?\/.+/ diff --git a/middleware/detect-language.js b/middleware/detect-language.js index 4ab0cf66aa..9a5b8041b5 100644 --- a/middleware/detect-language.js +++ b/middleware/detect-language.js @@ -3,7 +3,12 @@ import parser from 'accept-language-parser' import { USER_LANGUAGE_COOKIE_NAME } from '../lib/constants.js' -const chineseRegions = ['CN', 'HK'] +const chineseRegions = [ + 'CN', // Mainland + 'HK', // Hong Kong + 'SG', // Singapore + 'TW', // Taiwan +] function translationExists(language) { if (language.code === 'zh') { @@ -14,7 +19,7 @@ function translationExists(language) { } function getLanguageCode(language) { - return language.code === 'zh' && chineseRegions.includes(language.region) ? 'cn' : language.code + return language.code === 'cn' && chineseRegions.includes(language.region) ? 'zh' : language.code } function getUserLanguage(browserLanguages) { diff --git a/middleware/redirects/language-code-redirects.js b/middleware/redirects/language-code-redirects.js index 91e5cf7bd2..5f5e30e350 100644 --- a/middleware/redirects/language-code-redirects.js +++ b/middleware/redirects/language-code-redirects.js @@ -22,7 +22,7 @@ const allRedirectPatterns = Object.values(languages) // // Examples: // /jp* -> /ja* -// /zh-TW* -> /cn* +// /zh-TW* -> /zh* export default function languageCodeRedirects(req, res, next) { // Only in the unlikely event that the `req.path` starts with one of these // prefixes do we bother looking up what the redirect should be. diff --git a/script/i18n/create-translation-health-report.js b/script/i18n/create-translation-health-report.js index 6155615c21..d958a9de26 100755 --- a/script/i18n/create-translation-health-report.js +++ b/script/i18n/create-translation-health-report.js @@ -147,7 +147,6 @@ async function createReport() { gitref, datetime: new Date().toJSON(), totalPages: pages.length, - // totalErrorPages should be around en: 0, es: 1043, ja: 1004, pt: 995, cn: 1063 totalErrorPages: pageErrors.length, pageErrors, // To group errors by message instead