Use zh as language code instead of cn (#33560)

This commit is contained in:
Kevin Heis 2022-12-14 11:10:05 -08:00 коммит произвёл GitHub
Родитель aa3b224db2
Коммит e7983eb8d2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 21 добавлений и 17 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -19,7 +19,7 @@ You can also query our search endpoint directly at:
`https://docs.github.com/search?version=<VERSION>&language=<LANGUAGE CODE>&filters=topics:<TOPIC>&query=<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

Просмотреть файл

@ -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,
},

Просмотреть файл

@ -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).+?\/.+/

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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.

Просмотреть файл

@ -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