addLocale method

Future<void> addLocale(
  1. String locale,
  2. String direction,
  3. BuildContext? context
)

Adds a new empty locale file.

Implementation

Future<void> addLocale(String locale, String direction, BuildContext? context) async {
  // 1. Optimistic update - immediate UI feedback
  queue.addLocaleOptimistic(locale, direction);
  notifyListeners();

  try {
    await _client.addLocale(locale: locale);
  } catch (e) {
    // 2. On error: rollback and refresh
    await queue.refresh(reloadMeta: true);
    notifyListeners();
    // Error will be shown by the caller
    rethrow;
  }
}