|
7 | 7 | * It looks for easy "low hanging fruit" that we can correct for.
|
8 | 8 | *
|
9 | 9 | */
|
10 |
| -export function correctTranslatedContentStrings(content, englishContent, debug = false) { |
| 10 | +export function correctTranslatedContentStrings(content, englishContent, context = {}) { |
11 | 11 | // A lot of translations have corruptions around the AUTOTITLE links.
|
12 | 12 | // We've requested that these are corrected back but as a temporary
|
13 | 13 | // solution we'll manually recover now.
|
@@ -86,5 +86,31 @@ export function correctTranslatedContentStrings(content, englishContent, debug =
|
86 | 86 | // are suddenly gone.
|
87 | 87 | content = content.replaceAll(' | | ', ' |\n| ')
|
88 | 88 |
|
| 89 | + // This is a bit of a hack, but it works. |
| 90 | + // It looks for patterns like this: |
| 91 | + // |
| 92 | + // Some words --------|-------|{ |
| 93 | + // |
| 94 | + // And from that it tries to convert it to: |
| 95 | + // |
| 96 | + // Some words |
| 97 | + // --------|-------|{ |
| 98 | + // |
| 99 | + // But because it's quite a broad solution specifically around any |
| 100 | + // Markdown table syntax, let's be extra careful and only apply it |
| 101 | + // to the select few pages with known problems. |
| 102 | + if (context.relativePath?.endsWith('scopes-for-oauth-apps.md')) { |
| 103 | + if (context.code === 'pt') { |
| 104 | + // As of Aug 2023, the Portuguese translation seems to have lost the |
| 105 | + // `|` characters in their Markdown table syntax. |
| 106 | + content = content.replace(/(\w)(\s-+\s-+\s){%/g, (whole, start, rest) => { |
| 107 | + return `${start}\n${rest.replace(/\s/g, '|')}` |
| 108 | + }) |
| 109 | + } |
| 110 | + content = content.replace(/(\S\s*)(--+\|--+\|{)/, (whole, start, rest) => { |
| 111 | + return `${start}\n${rest}` |
| 112 | + }) |
| 113 | + } |
| 114 | + |
89 | 115 | return content
|
90 | 116 | }
|
0 commit comments