Skip to content

Commit

Permalink
Reclassifying some failures as unsupported instead of errors (#393)
Browse files Browse the repository at this point in the history
* Reclassifying some failures as unsupported instead of errors

* Looking at likely subtags unsupported

* Dart fixes

---------

Co-authored-by: Moritz <[email protected]>
  • Loading branch information
sven-oly and mosuem authored Feb 26, 2025
1 parent fee1dcb commit 6056142
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
52 changes: 27 additions & 25 deletions executors/dart_web/bin/lang_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:intl4x/intl4x.dart';
String testLangNames(String jsonEncoded) {
final json = jsonDecode(jsonEncoded) as Map<String, dynamic>;

final outputLine = <String, dynamic>{};
final outputLine = <String, dynamic>{'label': json['label']};

final Locale locale;
try {
Expand All @@ -17,41 +17,43 @@ String testLangNames(String jsonEncoded) {
} else {
locale = Locale(language: 'en');
}
} catch(error) {
} catch (error) {
outputLine.addAll({
'error': 'locale_label: ' + error.toString(),
'label': json['label'],
'test_type': 'display_names',
'error_type': 'unsupported',
'error_detail': 'locale_label',
'error_retry': false // Do not repeat
'error_detail': 'locale_label: $error',
'error_type': 'unsupported',
'error_retry': false // Do not repeat
});
return jsonEncode(outputLine);
}

final languageLabel =
(json['language_label'] as String).replaceAll('_', '-');
final languageLabel = (json['language_label'] as String).replaceAll('_', '-');
Locale languageLabelLocale;
try {
languageLabelLocale = Locale.parse(languageLabel);
} catch (error) {
// Something was not supported in this locale identifier
outputLine.addAll({
'error_type': 'unsupported',
'error_detail': error.toString(),
'error_retry': false // Do not repeat
});
return jsonEncode(outputLine);
}

final options = DisplayNamesOptions(
languageDisplay: LanguageDisplay.standard,
);
try {
final options = DisplayNamesOptions(
languageDisplay: LanguageDisplay.standard,
);
final displayNames = Intl(locale: locale).displayNames(options);
final resultLocale = displayNames.ofLanguage(Locale.parse(languageLabel));
final resultLangName = displayNames.ofLanguage(languageLabelLocale);

outputLine['label'] = json['label'];
outputLine['result'] = resultLocale;
outputLine['result'] = resultLangName;
} catch (error) {
outputLine.addAll({
// 'error': error.toString() + " language_label:" + languageLabel,
'error': 'something went wrong: ' + error.toString(),
'label': json['label'],
'locale_label': locale.toLanguageTag(),
'language_label': languageLabel,
'test_type': 'display_names',
'error_type': 'unsupported',
'error_detail': languageLabel,
'error_retry': false // Do not repeat
'error_type': 'unsupported',
'error_detail': error.toString(),
'actual_options': options,
'error_retry': false // Do not repeat
});
}
return jsonEncode(outputLine);
Expand Down
9 changes: 4 additions & 5 deletions executors/dart_web/bin/likely_subtags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ String testLikelySubtags(String jsonEncoded) {
String resultLocale;
if (testOption == 'maximize') {
resultLocale = locale.maximize().toLanguageTag();
} else if (testOption == 'minimizeFavorScript' ||
} else if (testOption == 'minimizeFavorRegion' ||
testOption == 'minimize') {
resultLocale = locale.minimize().toLanguageTag();
} else if (testOption == 'minimizeFavorRegion') {
} else if (testOption == 'minimizeFavorScript') {
throw UnimplementedError();
} else {
throw ArgumentError('Unknown test option = $testOption');
}
outputLine['result'] = resultLocale;
} catch (error) {
outputLine.addAll({
'error_message': error.toString(),
'unsupported': 'unsupported subtags',
'error_detail': '$localeStr: $testOption',
'unsupported': error.toString(),
'error_type': 'unsupported',
'error': 'Failure in locale subtags.'
});
}
return jsonEncode(outputLine);
Expand Down
1 change: 1 addition & 0 deletions executors/dart_web/bin/make_runnable_by_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Future<void> prepare(String name, ExportFunction function) async {
'-o',
'out/$outFile.js',
]);
print(compile.stdout);
print(compile.stderr);

prepareOutFile(outFile, [function]);
Expand Down

0 comments on commit 6056142

Please sign in to comment.