translate method
Call this function at where you want to translate the app like by pressing the button or any actions.
Implementation
void translate(
String languageCode, {
bool save = true,
}) {
if (languageCode == _currentLocale?.languageCode) return;
final countryCode = _getCountryCode(languageCode);
final scriptCode = _getScriptCode(languageCode);
if (save) PreferenceUtil.setLocale(languageCode, countryCode, scriptCode);
_currentLocale = Locale.fromSubtags(
languageCode: languageCode,
countryCode: countryCode,
scriptCode: scriptCode,
);
_delegate = FlutterLocalizationDelegate(_currentLocale);
onTranslatedLanguage?.call(_currentLocale);
}