text_expressions 1.1.0 text_expressions: ^1.1.0 copied to clipboard
Tiny, simple and complete tool to supercharge your string files with dynamic user-defined expressions.
import 'translation.dart';
final Translation translation = Translation();
void main() {
translation.load(Language.english);
print(translation.translate('ageCheck', named: {'age': 10}));
print(translation.translate('ageCheck', named: {'age': 17}));
print(translation.translate('ageCheck', named: {'age': 68}));
print(translation.translate('ageCheck', named: {'age': 40}));
testGreetings();
translation.load(Language.polish);
testGreetings();
translation.load(Language.romanian);
testGreetings();
}
void testGreetings() {
print(translation.translate('userGreeting', named: {'number': 1}));
print(translation.translate('userGreeting', named: {'number': 4}));
print(translation.translate('userGreeting', named: {'number': 11}));
print(translation.translate('userGreeting', named: {'number': 23}));
}