Skip to content

Commit 389952d

Browse files
authored
stringtables: support single quotes (#1233)
1 parent dd3e10c commit 389952d

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

libs/stringtable/src/project.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ fn process_keys(
172172
}
173173
}
174174
let mut offset = 0;
175-
let regex = Regex::new(r#"(?m)ID\s?=\s?\"([^\"]+?)\""#).expect("Failed to compile regex");
175+
let regex =
176+
Regex::new(r#"(?m)ID\s?=\s?['\"]([^'\"]+?)['\"]"#).expect("Failed to compile regex");
176177
for (linenum, line) in source.lines().enumerate() {
177178
let result = regex.captures_iter(line);
178179
for cap in result {

libs/stringtable/tests/lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ macro_rules! lint {
2323
}
2424

2525
lint!(l01_sorted);
26+
lint!(l02_usage_single_quotes);
2627
lint!(l03_no_newlines_in_tags);
2728

2829
fn lint(file: &str) -> String {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Project name="test">
3+
<Package name="test">
4+
<Key ID='MyID'>
5+
<English>My ID</English>
6+
</Key>
7+
</Package>
8+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
source: libs/stringtable/tests/lints.rs
3+
expression: lint(stringify! (l02_usage_single_quotes))
4+
---
5+
warning[L-L02U]: There are 1 unused keys in stringtables.
6+
= note: A list has been generated in .hemttout/unused_stringtables.txt

0 commit comments

Comments
 (0)