Skip to content

Commit

Permalink
fix: analyze should respect linked translations (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto authored Jun 22, 2024
1 parent d4d12f9 commit c342755
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion slang/lib/src/runner/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,18 @@ void _getUnusedTranslationsInSourceCodeRecursive({
);
} else {
final translationCall = '$translateVar.${child.path}';
if (!sourceCode.contains(translationCall)) {
const linkedPrefix = r'${_root';

// We only need to check if the translateVar is not part of the linked string.
// Since most developers use the default "t" as translateVar,
// we can ignore the linked call because it is already covered by the translateVar.
final linkedCall = linkedPrefix.endsWith(translateVar)
? null
: '$linkedPrefix.${child.path}';

final isUsed = sourceCode.contains(translationCall) ||
(linkedCall != null && sourceCode.contains(linkedCall));
if (!isUsed) {
// add whole base node which is expected
_addNodeRecursive(
node: child,
Expand Down

0 comments on commit c342755

Please sign in to comment.