Skip to content

Commit 5aaaa2e

Browse files
committed
extract: enhance shell string extraction to include "class" variable patterns
1 parent 6ad6c19 commit 5aaaa2e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scripts/extract_i18n_strings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def extract_strings_from_shell_file(file_path: str) -> List[Dict[str, any]]:
7979
# Pattern to match the three add_*_entry functions and extract the 3rd parameter
8080
# These functions have format: add_*_entry "param1" "param2" "param3" ...
8181
# We want to extract param3 (the translatable string)
82+
# Pattern to match variables named "class" is also included
8283
patterns = [
8384
# Match add_plain_info_entry with 3rd parameter in double quotes
8485
r'add_plain_info_entry\s+(?:"[^"]*"|\'[^\']*\'|\$\w+)\s+(?:"[^"]*"|\'[^\']*\'|\$\w+)\s+"([^"]+)"',
@@ -92,6 +93,9 @@ def extract_strings_from_shell_file(file_path: str) -> List[Dict[str, any]]:
9293
r'add_bar_info_entry\s+(?:"[^"]*"|\'[^\']*\'|\$\w+)\s+(?:"[^"]*"|\'[^\']*\'|\$\w+)\s+"([^"]+)"',
9394
# Match add_bar_info_entry with 3rd parameter in single quotes
9495
r"add_bar_info_entry\s+(?:\"[^\"]*\"|'[^']*'|\$\w+)\s+(?:\"[^\"]*\"|'[^']*'|\$\w+)\s+'([^']+)'",
96+
# Match with all variable named "class" parameters e.g. class="Base Info"
97+
r"class\s*=\s*\"([^\"]+)\"",
98+
r"class\s*=\s*'([^']+)'",
9599
]
96100

97101
for line_num, line in enumerate(lines, start=1):

0 commit comments

Comments
 (0)