1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-29 16:26:27 +00:00
comunicmobile/lib/utils/intl_utils.dart

20 lines
492 B
Dart
Raw Normal View History

2019-04-21 09:44:07 +00:00
/// Internationalization utilities
///
/// @author Pierre HUBERT
/// Translate a string
///
/// Translate a given [string] into the current language, if available
2019-04-23 12:35:41 +00:00
///
/// Then apply the list of [args] to the string, each argument name is
/// surrounded by '%'
String tr(String string, {Map<String, String> args}) {
2019-04-21 09:44:07 +00:00
//TODO : create translation system
2019-04-23 12:35:41 +00:00
//Apply arguments
if(args != null)
args.forEach((key, value) => string = string.replaceAll("%$key%", value));
2019-04-21 09:44:07 +00:00
return string;
2019-04-23 12:35:41 +00:00
}