getLanguage method
Retrieves the current language based on URI, session, or settings.
Implementation
String getLanguage() {
var ln = uri.pathSegments.isNotEmpty ? uri.pathSegments[0] : '';
if (ln.isNotEmpty && WaServer.config.languages.contains(ln)) {
changeLanguege(ln);
return ln;
}
if (isApiEndpoint && hasData('lang')) {
return data('lang', def: 'en');
}
ln = getCookie(
'language',
safe: false,
def: getSession(
'language',
def: _setting['language'] ?? 'en',
).toString(),
);
return ln.trim().toLowerCase();
}