nmLocalizeConfigStatus function

String nmLocalizeConfigStatus(
  1. NmParsingL10n l,
  2. String status
)

Localizes the stable English status / sample messages a config editor emits.

Implementation

String nmLocalizeConfigStatus(NmParsingL10n l, String status) {
  RegExpMatch? m;
  if ((m = RegExp(r'^(\d+) platforms loaded from (.+)$').firstMatch(status)) != null) {
    return l.statusLoaded(int.parse(m!.group(1)!), m.group(2)!);
  }
  if ((m = RegExp(r'^platforms/ not found under (.+)$').firstMatch(status)) != null) return l.statusNotFound(m!.group(1)!);
  if ((m = RegExp(r'^wrote (\d+) files? at (.+)$').firstMatch(status)) != null) {
    return l.statusWrote(int.parse(m!.group(1)!), m.group(2)!);
  }
  if ((m = RegExp(r'^sample unreadable: (.+)$').firstMatch(status)) != null) return l.sampleUnreadable(m!.group(1)!);
  return switch (status) {
    'discarded pending changes' => l.statusDiscarded,
    'no sample' => l.noSample,
    'no sample loaded' => l.noSampleLoaded,
    'jQuery-only pseudo-class' => l.jqueryOnly,
    'not a valid CSS selector' => l.invalidCss,
    _ => status,
  };
}