rsamec / business-rules-engine

Business rules engine
Other
92 stars 15 forks source link

How does one specify what language (localization) is used? #4

Open aripalo opened 8 years ago

aripalo commented 8 years ago

I have trouble understanding how to use different translations in my app, I know this is more of a question (which generally should go to StackOverflow), but I think README.md should have an example of using localization.

Let's say I have the following setup:

const FormSchema = require('business-rules-engine/commonjs/FormSchema');
const schema = {
  foo: {
    type: 'string',
    minLength: 100,
    required: true,
    title: 'Foo',
  },
}
const validator = new FormSchema.JsonSchemaRuleFactory(schema).CreateRule('foo');

const result = validator.Validate({ foo: 'not long enough' });
console.log(result.ErrorMessage);

Considering that example code, how would one go and specify that in which language the messages result.ErrorMessage are displayed?