1
0
mirror of synced 2025-12-26 14:02:45 -05:00

Merge pull request #21954 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2022-11-10 16:43:50 -08:00
committed by GitHub
5 changed files with 18 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
import { createContext, useContext } from 'react'
type LanguageItem = {
// 92BD1212-61B8-4E7A: Remove `wip: boolean` for the public ship of ko, fr, de, ru
wip: boolean
name: string
nativeName?: string
code: string

View File

@@ -30,7 +30,8 @@ export const HeaderNotifications = () => {
const translationNotices: Array<Notif> = []
if (router.locale === 'en') {
if (userLanguage && userLanguage !== 'en') {
// 92BD1212-61B8-4E7A: Remove ` && languages[userLanguage]?.wip === false` for the public ship of ko, fr, de, ru
if (userLanguage && userLanguage !== 'en' && languages[userLanguage]?.wip === false) {
let href = `/${userLanguage}`
if (currentPathWithoutLanguage !== '/') {
href += currentPathWithoutLanguage
@@ -46,7 +47,8 @@ export const HeaderNotifications = () => {
type: NotificationType.TRANSLATION,
content: data.reusables.policies.translation,
})
} else if (router.locale) {
// 92BD1212-61B8-4E7A: Remove ` && languages[router.locale]?.wip !== true` for the public ship of ko, fr, de, ru
} else if (router.locale && languages[router.locale]?.wip !== true) {
translationNotices.push({
type: NotificationType.TRANSLATION,
content: t('notices.localization_complete'),

View File

@@ -17,8 +17,8 @@ export const LanguagePicker = ({ variant }: Props) => {
const locale = router.locale || 'en'
const { t } = useTranslation('picker')
const langs = Object.values(languages)
// 92BD1212-61B8-4E7A: Remove `.filter(lang => !lang.wip)` for the public ship of ko, fr, de, ru
const langs = Object.values(languages).filter((lang) => !lang.wip)
const selectedLang = languages[locale]
// The `router.asPath` will always be without a hash in SSR

View File

@@ -26,13 +26,14 @@ function getRoot(languageCode) {
// Default
return path.join(TRANSLATIONS_ROOT, languageCode)
}
// 92BD1212-61B8-4E7A: Remove `wip: Boolean` for the public ship of ko, fr, de, ru
const languages = {
en: {
name: 'English',
code: 'en',
hreflang: 'en',
dir: getRoot('en'),
wip: false,
},
cn: {
name: 'Simplified Chinese',
@@ -41,6 +42,7 @@ const languages = {
hreflang: 'zh-Hans',
redirectPatterns: [/^\/zh-\w{2}/, /^\/zh/],
dir: getRoot('zh-CN'),
wip: false,
},
ja: {
name: 'Japanese',
@@ -49,6 +51,7 @@ const languages = {
hreflang: 'ja',
redirectPatterns: [/^\/jp/],
dir: getRoot('ja-JP'),
wip: false,
},
es: {
name: 'Spanish',
@@ -56,6 +59,7 @@ const languages = {
code: 'es',
hreflang: 'es',
dir: getRoot('es-ES'),
wip: false,
},
pt: {
name: 'Portuguese',
@@ -63,6 +67,7 @@ const languages = {
code: 'pt',
hreflang: 'pt',
dir: getRoot('pt-BR'),
wip: false,
},
}

View File

@@ -9,7 +9,8 @@ function translationExists(language) {
if (language.code === 'zh') {
return chineseRegions.includes(language.region)
}
return languageKeys.includes(language.code)
// 92BD1212-61B8-4E7A: Remove ` && !languages[language.code].wip` for the public ship of ko, fr, de, ru
return languageKeys.includes(language.code) && !languages[language.code].wip
}
function getLanguageCode(language) {
@@ -34,7 +35,8 @@ function getUserLanguage(browserLanguages) {
function getUserLanguageFromCookie(req) {
const value = req.cookies[PREFERRED_LOCALE_COOKIE_NAME]
if (value && languages[value]) {
// 92BD1212-61B8-4E7A: Remove ` && !languages[value].wip` for the public ship of ko, fr, de, ru
if (value && languages[value] && !languages[value].wip) {
return value
}
}