@@ -77,6 +77,38 @@ export function correctTranslatedContentStrings(content, englishContent, context
77
77
'- % data variables.product.prodname_copilot_enterprise %}' ,
78
78
'- {% data variables.product.prodname_copilot_enterprise %}' ,
79
79
)
80
+
81
+ // This might not be exclusive to Japanese but put here because, at
82
+ // the time of writing, it only happens on the Japanse translations.
83
+ // According to the Microsoft translation guidelines, they're not
84
+ // supposed to translate words that will be seen in the UI, but
85
+ // instead mention then like this:
86
+ //
87
+ // [Save changes](THE TRANSLATION OF "Save changes" IN JAPANESE)
88
+ //
89
+ // The problem is when these are wrapped in a deliberate Markdown link.
90
+ // For example:
91
+ //
92
+ // [[Save changes](THE TRANSLATION OF "Save changes" IN JAPANESE)](#some-section)
93
+ //
94
+ // A real observed example is:
95
+ //
96
+ // [[Allow deletions](削除を許可)](#allow-deletions)
97
+ //
98
+ // Here, because "削除を許可" contains no spaces, the Markdown parser
99
+ // thinks "削除を許可" is the URL! But in actuality,
100
+ // `[Allow deletions](削除を許可)` is the text and `#allow-deletions`
101
+ // is the URL.
102
+ // This problem does not exhibit if the text "削除を許可" were to contain
103
+ // a space character. But we can't assume that we can just add a space.
104
+ // For example "削除 を許可" would be incorrect. And where do you put the
105
+ // space? Between which characters.
106
+ // Instead, we can inject a "hair space" whitespace character between
107
+ // the `]` and the `(`. Then, the Markdown processor does not get confused
108
+ // and the link is rendered correctly.
109
+ // The `\u200A` is the "hair space" character. Technically whitespace
110
+ // but not wide enough to visually appear as a space.
111
+ content = content . replace ( / \[ ( \[ .* ?\] ) ( \( \S + \) \] \( ) / g, '[$1\u200A$2' )
80
112
}
81
113
82
114
if ( context . code === 'zh' ) {
0 commit comments