Skip to content

Commit 0b3a150

Browse files
fix(Crowdin): anable whitespace cleanup
Set `cleanWhitespace: true` when initializing `proxyTranslator` so translated content preserves spaces around inline elements like links and emphasis. Added a focused unit test to ensure the option is passed during initialization.
1 parent a618a71 commit 0b3a150

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/js/crowdin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ function initCrowdIn(project = 'LizardByte', platform = null) {
173173
// Initialize Crowdin translator
174174
globalThis.proxyTranslator.init({
175175
baseUrl: currentBaseUrl,
176+
// Preserve spaces around inline elements such as links and emphasized text.
177+
cleanWhitespace: true,
176178
distribution: projectSettings[project].distribution,
177179
defaultLanguage: "en",
178180
languageTitles: languageTitles,

tests/crowdin.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ describe('initCrowdIn', () => {
114114
);
115115
});
116116

117+
it('should preserve whitespace around translated inline elements', () => {
118+
initCrowdIn();
119+
120+
// Simulate script loading
121+
jest.runAllTimers();
122+
123+
expect(globalThis.proxyTranslator.init).toHaveBeenCalledWith(
124+
expect.objectContaining({
125+
cleanWhitespace: true
126+
})
127+
);
128+
});
129+
117130
it('should initialize proxyTranslator with LizardByte-docs settings', () => {
118131
initCrowdIn('LizardByte-docs');
119132

0 commit comments

Comments
 (0)