accordproject / concerto

Business schema language and runtime
https://concerto.accordproject.org
Apache License 2.0
119 stars 105 forks source link

Text variant annotation for model enumerations #26

Closed jeromesimeon closed 5 years ago

jeromesimeon commented 5 years ago

To support textual variants of the same enumeration element in a model, the model definition should allow annotations that enumerate text alternatives.

The annotation could also be used to capture language-specific variants of a model element.

This would clean up model enumerations so that they only need to define a single element per semantic element. Logic that operates on enumerations (for example match statements in Ergo) would then also not need to match multiple values

Where an annotation is not provided, the String value of the element would be used.

For example:

enum TemporalUnit {
  @alternativeText('day','days','jour','jours')
  o DAY
  //...
}

We could even consider something like a .language file to externalize language definitions, e.g.

enum TemporalUnit {
  @languageKey('DAY')
  o DAY
  //...
}

and in model.en.language

{
  "DAY": ["day", "days"]
}

Context

This is a feature request. Original issue was posted by @mttrbrts here: https://github.com/accordproject/cicero/issues/111

jeromesimeon commented 5 years ago

From @dselman https://github.com/accordproject/cicero/issues/111:

My inclination is:

enum TemporalUnit {
  @localization_en( 'day', 'days')
  @localization_fr( 'jour', 'jours')
  o DAY
  //...
}

With the second key (plural) optional.

Note that in its current state Composer doesn't support multiple decorators with the same name on the same element.

Also, note that while an external localization file would be very nice for translation purposes it would be tricky to make it work with models that are loaded from URLs.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs in the next 14 days. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically closed because no further activity occurred. If you believe the issue is still relevant, please either reopen this issue, open a new issue, or contact one of the project maintainers