string_literal_finder 0.1.0 copy "string_literal_finder: ^0.1.0" to clipboard
string_literal_finder: ^0.1.0 copied to clipboard

outdated

A sample command-line application.

string_literal_finder #

Simple command line application to find non translated string literals in dart code.

Tries to be smart about ignoring specific strings.

Example #

The following dart file:

import 'package:string_literal_finder_annotations/string_literal_finder_annotations.dart';
import 'package:logging/logging.dart';

final _logger = Logger('example');

void exampleFunc(@NonNls String ignored, String warning) {}

void main() {
  exampleFunc('Hello world', 'not translated');
  _logger.finer('Lorem ipsum');

  final testMap = nonNls({
    'key': 'value',
  });
}

will result in those warnings:

$ dart bin/string_literal_finder.dart example
2020-08-08 14:38:47.800339 INFO string_literal_finder - Found 1 literals:
2020-08-08 14:38:47.801934 INFO string_literal_finder - lib/example.dart:17:30 'not translated'
Found 1 literals in 1 files.
$ 

Ignored literal strings #

  • Any argument annotated with @NonNls or @NonNlsArg()
  • Anything which is parsed into the nonNls function.
  • Anything passed to logging library Logger class.
  • Any line with a line end comment // NON-NLS