Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
CpdnCristiano
2020-12-23 19:16:13 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ed40fa89b5b5d2531ff1b668a406a6c77d20f403
ed40fa89
1 parent
e47231ae
add example trParams
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
README.md
lib/get_utils/src/extensions/internacionalization.dart
README.md
View file @
ed40fa8
...
...
@@ -348,6 +348,27 @@ var products = [];
Text
(
'singularKey'
.
trPlural
(
'pluralKey'
,
products
.
length
,
Args
));
```
#### Using translation with parameters
```
dart
import
'package:get/get.dart'
;
Map
<
String
,
Map
<
String
,
String
>>
get
keys
=>
{
'en_US'
:
{
'logged_in'
:
'logged in as @name with email @email'
,
},
'es_ES'
:
{
'logged_in'
:
'iniciado sesión como @name con e-mail @email'
,
}
};
Text
(
'logged_in'
.
trParams
({
'name'
:
'Jhon'
,
'email'
:
'jhon@example.com'
}));
```
### Locales
Pass parameters to
`GetMaterialApp`
to define the locale and translations.
...
...
lib/get_utils/src/extensions/internacionalization.dart
View file @
ed40fa8
...
...
@@ -59,7 +59,7 @@ extension Trans on String {
if
(
params
.
isNotEmpty
)
{
params
.
forEach
((
key
,
value
)
{
print
(
key
);
trans
=
trans
.
replaceAll
(
'
\$
$key
'
,
value
);
trans
=
trans
.
replaceAll
(
'
@
$key
'
,
value
);
});
}
return
trans
;
...
...
Please
register
or
login
to post a comment