turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Extensionattributes #324

Open Drizin opened 7 years ago

Drizin commented 7 years ago

Extension Attributes

Conditionals allow you to create conditional translations depending on the argument itself, but sometimes the decision must not be made on something that you know in advance but rather on some language-specific attribute. For example, "map" in portuguese is masculine gender but in french it's feminine gender.

Portuguese:

[[[The %0 is being exported.]]] -> "%0_GENDER{M:O %0 está sendo exportado.|A %0 está sendo exportada.}" 
[[[map]]] -> "mapa"
[[[map_GENDER]]] -> "M"
[[[The %0 is being exported.|||(((map)))]]]  -> "O mapa está sendo exportado" (masculine)

French:

[[[The %0 is being exported.]]] -> "%0_GENDER{M:Le %0 a été exporté.|F:La %0 a été exporté.}"
[[[map]]] -> "carte"
[[[map_GENDER]]] -> "F"
[[[The %0 is being exported.|||(((map)))]]]  -> "Le carte a été exporté" (feminine)

This is based on https://github.com/siefca/i18n-inflector

tOmoness commented 7 years ago

This contains the same commits as #323 - would it be easier to push it all as one pull request?

Do these changes support plural forms or is it just a conditional statement?

Drizin commented 7 years ago

Yes, #324 supports number inflections (plural forms) and gender inflections by using conditional statements. Although #323 isolated may look simple and unnecessary, it's crucial for #324 to work (that's why #324 contains #323 commits). I submitted #323 individually because I think the purpose of conditionals (#323) is much easier to understand than the purpose of extension attributes (#324).

BTW: #322 is completely unrelated. THAT shouldn't be part of this pull request. Sorry.

tOmoness commented 7 years ago

So the way you handle plurals here is by using a conditional statement and not the way described here? How does this look in the generated pot files, does it generate an entry per conditional statement?