Showing
2 changed files
with
22 additions
and
1 deletions
@@ -348,6 +348,27 @@ var products = []; | @@ -348,6 +348,27 @@ var products = []; | ||
348 | Text('singularKey'.trPlural('pluralKey', products.length, Args)); | 348 | Text('singularKey'.trPlural('pluralKey', products.length, Args)); |
349 | ``` | 349 | ``` |
350 | 350 | ||
351 | +#### Using translation with parameters | ||
352 | + | ||
353 | +```dart | ||
354 | +import 'package:get/get.dart'; | ||
355 | + | ||
356 | + | ||
357 | +Map<String, Map<String, String>> get keys => { | ||
358 | + 'en_US': { | ||
359 | + 'logged_in': 'logged in as @name with email @email', | ||
360 | + }, | ||
361 | + 'es_ES': { | ||
362 | + 'logged_in': 'iniciado sesión como @name con e-mail @email', | ||
363 | + } | ||
364 | +}; | ||
365 | + | ||
366 | +Text('logged_in'.trParams({ | ||
367 | + 'name': 'Jhon', | ||
368 | + 'email': 'jhon@example.com' | ||
369 | + })); | ||
370 | +``` | ||
371 | + | ||
351 | ### Locales | 372 | ### Locales |
352 | 373 | ||
353 | Pass parameters to `GetMaterialApp` to define the locale and translations. | 374 | Pass parameters to `GetMaterialApp` to define the locale and translations. |
@@ -59,7 +59,7 @@ extension Trans on String { | @@ -59,7 +59,7 @@ extension Trans on String { | ||
59 | if (params.isNotEmpty) { | 59 | if (params.isNotEmpty) { |
60 | params.forEach((key, value) { | 60 | params.forEach((key, value) { |
61 | print(key); | 61 | print(key); |
62 | - trans = trans.replaceAll('\$$key', value); | 62 | + trans = trans.replaceAll('@$key', value); |
63 | }); | 63 | }); |
64 | } | 64 | } |
65 | return trans; | 65 | return trans; |
-
Please register or login to post a comment