accordproject / template-archive

Smart Legal Contracts & Templating System
https://accordproject.org/projects/cicero/
Apache License 2.0
281 stars 119 forks source link

Support multi-locale templates #174

Open dselman opened 6 years ago

dselman commented 6 years ago

The template specification must be extended to support locale-specific template grammar text.

This would allow a template developer to create a single template that had legal text in multiple natural languages, with a single data model and Ergo logic.

At present, a template can have multiple sample.txt instances (one per locale) but the grammar generation doe not take a locale as input.

This should take into account locale specific formatting for monetary amounts and date/times. https://github.com/accordproject/cicero/issues/389

Docs for date/time formats: https://docs.accordproject.org/docs/markup-variables.html

dselman commented 5 years ago

To fix #63 we need to be able to specify the locale for a template, with the default date/time format for the template based on the locale for the template.

This requires refactoring how we manage the template grammars within a template.

/grammar/template.tem <-- default template. This is for the en-US locale /sample.txt <-- sample.txt for the en-US locale /README.md <-- readme file for the en-US locale

/grammar/en-GB/template.tem <-- a locale specific template /grammar/en-GB/sample.txt <-- sample.txt for the en-GB locale /grammar/en-GB/README.md <-- readme file for the en-GB locale

Locales are specified using IETF BCP 47 language tags.

A template may contain any number of locale specific sub-folders.

Note that the name of the template and the description of the template specified in package.json are not localisable.

Template and Clause APIs that parse text and generate text will be extended to take an (optional) locale specifier.

Question: when we validate a template, do we validate all locales?

jeromesimeon commented 5 years ago

This proposal should be updated to reflect the new template directory structure from #435