зеркало из https://github.com/github/docs.git
Unbreak the scopes-for-oauth-apps markdown table in translations (#40366)
This commit is contained in:
Родитель
173e0b14d7
Коммит
8adab0e825
|
@ -7,7 +7,7 @@
|
|||
* It looks for easy "low hanging fruit" that we can correct for.
|
||||
*
|
||||
*/
|
||||
export function correctTranslatedContentStrings(content, englishContent, debug = false) {
|
||||
export function correctTranslatedContentStrings(content, englishContent, context = {}) {
|
||||
// A lot of translations have corruptions around the AUTOTITLE links.
|
||||
// We've requested that these are corrected back but as a temporary
|
||||
// solution we'll manually recover now.
|
||||
|
@ -86,5 +86,31 @@ export function correctTranslatedContentStrings(content, englishContent, debug =
|
|||
// are suddenly gone.
|
||||
content = content.replaceAll(' | | ', ' |\n| ')
|
||||
|
||||
// This is a bit of a hack, but it works.
|
||||
// It looks for patterns like this:
|
||||
//
|
||||
// Some words --------|-------|{
|
||||
//
|
||||
// And from that it tries to convert it to:
|
||||
//
|
||||
// Some words
|
||||
// --------|-------|{
|
||||
//
|
||||
// But because it's quite a broad solution specifically around any
|
||||
// Markdown table syntax, let's be extra careful and only apply it
|
||||
// to the select few pages with known problems.
|
||||
if (context.relativePath?.endsWith('scopes-for-oauth-apps.md')) {
|
||||
if (context.code === 'pt') {
|
||||
// As of Aug 2023, the Portuguese translation seems to have lost the
|
||||
// `|` characters in their Markdown table syntax.
|
||||
content = content.replace(/(\w)(\s-+\s-+\s){%/g, (whole, start, rest) => {
|
||||
return `${start}\n${rest.replace(/\s/g, '|')}`
|
||||
})
|
||||
}
|
||||
content = content.replace(/(\S\s*)(--+\|--+\|{)/, (whole, start, rest) => {
|
||||
return `${start}\n${rest}`
|
||||
})
|
||||
}
|
||||
|
||||
return content
|
||||
}
|
||||
|
|
|
@ -150,7 +150,10 @@ async function translateTree(dir, langObj, enTree) {
|
|||
)
|
||||
|
||||
// The "content" isn't a frontmatter key
|
||||
translatedData.markdown = correctTranslatedContentStrings(content, enPage.markdown)
|
||||
translatedData.markdown = correctTranslatedContentStrings(content, enPage.markdown, {
|
||||
relativePath,
|
||||
code: langObj.code,
|
||||
})
|
||||
|
||||
item.page = new Page(
|
||||
Object.assign(
|
||||
|
|
Загрузка…
Ссылка в новой задаче