accordproject / ergo

Programming Language for Smart Legal Contracts
https://accordproject.org/projects/ergo
Apache License 2.0
158 stars 55 forks source link

Globalization for strings #269

Open mttrbrts opened 6 years ago

mttrbrts commented 6 years ago

Ergo should allow for strings in messages, such as in enforce statements, to be globalized / localized.

https://github.com/hyperledger/composer/blob/master/packages/composer-common/lib/globalize.js

jeromesimeon commented 6 years ago

@mttrbrts Could you provide an example of how it might look like at the Ergo language level?

mttrbrts commented 6 years ago

Perhaps something like :

enforce count(request.shipment.sensorReadings) > 0.0
    otherwise localize("no-readings", "fr-FR") ;

Could the locale even be an implicit property of the contract instance? This would allow something like:

enforce count(request.shipment.sensorReadings) > 0.0
    otherwise localize("no-readings") ;

Where localize uses state.locale for the lookup?

We should have this discussion in the context of globalization of Cicero templates too. For example, specifying the locale for a template should select the correct template grammar and propagate through to the logic.

jeromesimeon commented 6 years ago

Thanks this is helpful.

kach commented 6 years ago

Localization can be implemented as a library, I imagine?

jeromesimeon commented 6 years ago

I think @kach is correct about using a library, except for the implicit use of state.locale?