1

I wish to override a NLS file (dijit/form/validate.js) file with a new one, or replace some of the NLS string mappings. I want this file to be picked up by the standard Dijits.

I do not wish to delete the file in the standard Dojo library. Can I specify a path in djConfig to search directories for NLS files in order so my new file is picked up instead of the the original? If so, how do I do this?

Alternatively how can I mix in a new definition of a string i.e

replace:

missingMessage: "This value is required.",

with:

missingMessage: "My string is here.",
vogomatix
  • 4,856
  • 2
  • 23
  • 46

1 Answers1

1

If you want to do literally what you request and pick an alternate file for the dijit/form/nls/validate i18n modules, you can use the map property to remap the module IDs (1.8+):

var dojoConfig = {
    map: { dijit: {
        'dijit/form/nls/validate': 'my/form/nls/validate',
        'dijit/form/nls/en/validate': 'my/form/nls/en/validate',
        // ... etc
    } }
};

However, the standard and recommended method for overriding the messages on a validation widget are to just set the message properties using your own values:

define([
    'dijit/form/ValidationTextBox',
    'dojo/i18n!my/form/validate'
], function (ValidationTextBox, myI18n) {
    var instance = new ValidationTextBox({ missingMessage: myI18n.missingMessage });
    // ...
});
C Snover
  • 17,908
  • 5
  • 29
  • 39
  • Thanks for your reply - I thought my question was going to go unanswered! I'll try your suggestions out later today :-). I want to replace the message for all instances of the widget so mapping the file might be the 'tidiest' answer. – vogomatix Jul 01 '13 at 05:49
  • Regrettably the first method does not seem to work. I can see it loading up the file, but later on i18n seems to be loading the original file. Its almost as if it loses the map partway through loading the page, or maybe is it because of parsing? – vogomatix Jul 01 '13 at 15:00
  • Are you loading and using the original file as a dependency elsewhere? – C Snover Jul 01 '13 at 15:59
  • I've just joined the company and taken over this code but AFAICT the validate.js file is not referred to except as part of the Dijits. – vogomatix Jul 02 '13 at 05:37