@@ -19,6 +19,7 @@ function getProgress(array $translations): array
19
19
"Present " ,
20
20
];
21
21
22
+ $ translations_file = file (__DIR__ . "/../src/translations.php " );
22
23
$ progress = [];
23
24
foreach ($ translations as $ locale => $ phrases ) {
24
25
$ translated = 0 ;
@@ -29,10 +30,12 @@ function getProgress(array $translations): array
29
30
}
30
31
$ percentage = round (($ translated / count ($ phrases_to_translate )) * 100 );
31
32
$ locale_name = Locale::getDisplayName ($ locale , $ locale );
33
+ $ line_number = getLineNumber ($ translations_file , $ locale );
32
34
$ progress [$ locale ] = [
33
35
"locale " => $ locale ,
34
36
"locale_name " => $ locale_name ,
35
37
"percentage " => $ percentage ,
38
+ "line_number " => $ line_number ,
36
39
];
37
40
}
38
41
// sort by percentage
@@ -42,6 +45,18 @@ function getProgress(array $translations): array
42
45
return $ progress ;
43
46
}
44
47
48
+ /**
49
+ * Get the line number of the locale in the translations file
50
+ *
51
+ * @param array $translations_file The translations file
52
+ * @param string $locale The locale
53
+ * @return int The line number of the locale in the translations file
54
+ */
55
+ function getLineNumber (array $ translations_file , string $ locale ): int
56
+ {
57
+ return key (preg_grep ("/^ \\s* \"$ locale \"\\s*=> \\s* \\[/ " , $ translations_file )) + 1 ;
58
+ }
59
+
45
60
/**
46
61
* Convert progress to labeled badges
47
62
*
@@ -55,7 +70,8 @@ function progressToBadges(array $progress): string
55
70
$ badges .= str_repeat ("| --- " , $ per_row ) . "| " . "\n" ;
56
71
$ i = 0 ;
57
72
foreach (array_values ($ progress ) as $ data ) {
58
- $ badges .= "| ` {$ data ["locale " ]}` - {$ data ["locale_name " ]} <br /> ![ {$ data ["locale_name " ]} {$ data ["percentage " ]}%](https://progress-bar.dev/ {$ data ["percentage " ]}) " ;
73
+ $ line_url = "https://github.com/DenverCoder1/github-readme-streak-stats/blob/main/src/translations.php#L {$ data ["line_number " ]}" ;
74
+ $ badges .= "| [` {$ data ["locale " ]}`]( {$ line_url }) - {$ data ["locale_name " ]} <br /> [![ {$ data ["locale_name " ]} {$ data ["percentage " ]}%](https://progress-bar.dev/ {$ data ["percentage " ]})]( {$ line_url }) " ;
59
75
$ i ++;
60
76
if ($ i % $ per_row === 0 ) {
61
77
$ badges .= "| \n" ;
0 commit comments