Skip to content

Commit acf022f

Browse files
committed
fix(translationtool) Fix f5562bf "Only handle vue template with custom parser".
Vue files can contain multiple (2, to be exact) script sections, one for setup, composition API, and one "ordinary" script section for the options API. At least fro Vue 2 both are at least wanted and maybe even needed and even with Vue 3 this is legal, see https://vuejs.org/api/sfc-spec.html This commit changes f5562bf and uses preg_match_all() with a look-ahead pattern in order to capture all script blocks. Fixes #799. Signed-off-by: Claus-Justus Heine <[email protected]>
1 parent 9e9b61a commit acf022f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

translations/translationtool/src/translationtool.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-FileCopyrightText: 2017, 2025 Nextcloud GmbH and Nextcloud contributors
77
* SPDX-FileCopyrightText: 2017 Jakob Sack <[email protected]>
88
* SPDX-License-Identifier: AGPL-3.0-or-later
99
*/
@@ -366,8 +366,8 @@ private function createFakeFileForVueFiles(): void {
366366
}
367367

368368
$matches = [];
369-
if (preg_match('/<script[^>]*>(.+)<\/script>/s', $vueSource, $matches)) {
370-
$fakeFileContent .= $matches[1] . ";\n";
369+
if (preg_match_all('/<script[^>]*>(.+(?=<\/script>))<\/script>/sU', $vueSource, $matches, PREG_PATTERN_ORDER)) {
370+
$fakeFileContent .= implode('', $matches[1]) . ";\n";
371371
}
372372

373373
if (preg_match('/<template>(.+)<\/template>/s', $vueSource, $matches, PREG_OFFSET_CAPTURE)) {

0 commit comments

Comments
 (0)