reloadTranslation method

void reloadTranslation(
  1. String name
)

Reloads a specific translation by its name for the current locale.

This function retrieves a translation matching the given name from the list of supported locales and then reloads it using the localization manager (locManager).

Parameters:

  • name String: The name of the translation to reload.

Implementation

void reloadTranslation(String name) {
  // Retrieves the translations for the current locale.
  var translation = locManager.supportedLocales
      // Finds the locale that matches the current locale.
      .firstWhere((l) => l.locale == locManager.currentLocale)
      // From the matched locale, find the translation by its name.
      .translations
      .firstWhere((t) => t.name == name);
  // Reloads the specific translation found above.
  locManager.reLoadTranslation(this, translation);
}