Easy_localization: Add named arguments

Created on 18 Mar 2020  路  12Comments  路  Source: aissat/easy_localization

Some translates need swap arguments, but I can't do that without named arguments.

enhancement

Most helpful comment

For example translator using lokalise service do not understand what word I meant:
'{} lesson for student {} on {} will be deleted'
Phrase variant: weekly lesson for student Alex on 31 December will be deleted
For web front-end they use arguments like:
'{lesson_type} lesson for student {student_name} on {lesson_time} will be deleted'

All 12 comments

@marinat plz examlpe

For example translator using lokalise service do not understand what word I meant:
'{} lesson for student {} on {} will be deleted'
Phrase variant: weekly lesson for student Alex on 31 December will be deleted
For web front-end they use arguments like:
'{lesson_type} lesson for student {student_name} on {lesson_time} will be deleted'

One more example: in turkish words in sentence may be in different order than in english. So it's hard to save unnamed parameters order.

@aissat I see that it now supports named arguments but I can't figure out how to use it. In the example code I don't see it being used right?

@vinnytwice today will be available dev version

@vinnytwice @marinat try this

dependencies:
  easy_localization: ^2.2.0-dev

example:

"msg_named": "{} are written in the {lang} language",
 Text(LocaleKeys.msg_named).tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),

@aissat I was having a look at the sample app trying to understand a bit everything and I saw it. For version ^2.2.0-dev then tr. method accepts named args? is it just one or a list of args?
Thank you very much for the repo!

@vinnytwice. It accepted tow type
Named argument and list argument

"msg_named": "{} are written in the {lang} language",

How can i give the argument values specific style, for example the whole line is not bold except the argument value be bold.

@AlaaEldeenYsr I think you should separate your string for now, and display them using RichText widget.

other option, add a token inside the string and split it inside your code to be stylized before adding it to the RichText widget

Alright is the named arguments feature version is on the pub or on a specific branch here ?
@3ace

@AlaaEldeenYsr please refer to the above reply by @aissat

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Xgamefactory picture Xgamefactory  路  4Comments

KirillArtemenko picture KirillArtemenko  路  6Comments

AdelMahmoudHussein picture AdelMahmoudHussein  路  7Comments

necipk picture necipk  路  5Comments

Wilson13 picture Wilson13  路  7Comments