From 59d9c22fd1e689086afa4adafb0e31477661bbb3 Mon Sep 17 00:00:00 2001 From: leadcodedev Date: Sun, 11 Dec 2022 13:46:11 +0100 Subject: [PATCH] docs: Improve readme --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 58049ca..2a7145a 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,15 @@ Then we can use the `t()` function to translate our key path. ```dart import 'package:mineral_i18n/mineral_i18n.dart'; -final String sentence = t(Lang.fr, 'foo.bar'); -print(sentence); // bar en français ! +class Foo extends MineralEvent with Translation { + Future handle (Ready event) async { + final String sentence = t(Lang.fr, 'foo.bar'); + print(sentence); // bar en français ! -final String sentence = t(Lang.en_GB, 'foo.bar'); -print(sentence); // bar in english ! + final String sentence = t(Lang.en_GB, 'foo.bar'); + print(sentence); // bar in english ! + } +} ``` ## Injecting variables @@ -61,6 +65,10 @@ Our string is now waiting for a variable named xx which we will give it when we ```dart import 'package:mineral_i18n/mineral_i18n.dart'; -final String sentence = t(Lang.en_GB, 'foo.bar', { 'framework': 'Mineral' }); -print(sentence); // Mineral is my favourite framework ! +class Foo extends MineralEvent with Translation { + Future handle (Ready event) async { + final String sentence = t(Lang.en_GB, 'foo.bar', { 'framework': 'Mineral' }); + print(sentence); // Mineral is my favourite framework ! + } +} ```