-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionals #323
base: master
Are you sure you want to change the base?
Conditionals #323
Conversation
e.g.: [[[This %0 allows %1 to have %2|||regex|||nuggets|||(((recursive %0|||(((parameters///comment3)))///comment2)))///comment1]]] -> This regex allows nuggets to have recursive parameters
…de other nuggets): README, Unit test and bug fix.
With **conditionals** you can use a single nugget tag and have different translations according to the value of parameters. [[[%0_PRODUCTS_ADDED_TO_ORDER]]] -> "%0{0:No products were added|1:1 product was added|%0 products were added} to your order" [[[DEAR_SIR_OR_MADAM|||@ViewBag.Gender]]] -> "Dear %0{M:Sir|F:Madam|user}"
If I understand this code correctly, you want to move some conditional logic from outside the nugget into the nugget? Can you elaborate on the benefit of doing that? Thanks. |
It's Monday morning and I'm struggling to understand what you mean in your examples, for instance:
Can you help? |
No problem, actually I didn't make myself clear on this.
It follows a simple pattern: @variable { possiblevalue1:text | possiblevalue2: text | .... | default text)
This example is very simple, and one could just have different nuggets for each possible text. However, when it comes to inflections that do not exist in in your base language (e.g. gender inflection does not exist in English) then conditionals are necessary (#323) which allied to extension attributes (#324) allow you to make whatever flections are needed. In other words, one may always have a nugget for every possible sentence: However, if someone has a more reusable structure like In portuguese language for example, invoice (nota fiscal) is a feminine noun, and order (pedido) is a masculine noun. So the translations depend on that attribute (the gender of the argument): Does that make sense? Many languages have even more complex inflections (multiple types of plural, more than 2 genders), and I think #324 could cover all that. In other words #323 alone could be described as you did (moving conditional logic from outside the nugget to inside it), but #324 covers a real word requirement for inflections. Hope it's more clear now. |
With conditionals we can use a single nugget tag and have different translations according to the value of parameters.: