Results 1 to 6 of 6

Thread: Validation error message localization

  1. #1
    Sencha Premium Member
    Join Date
    Jul 2013
    Posts
    43

    Default Validation error message localization

    When configuring maxValue or minValue the validation error message does not format the value following localization.

    The below code will show up error message:
    "The maximum value for this field is 2147483647."

    Whereas it should follow the localization:
    "The maximum value for this field is 2,147,483,647."

    Please provide details if any other configuration can change this message as expected.

    Code:
    Ext.create('Ext.form.Panel', {
        title: 'On The Wall',
        width: 300,
        bodyPadding: 10,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'numberfield',
            anchor: '100%',
            name: 'bottles',
            fieldLabel: 'Bottles of Beer',
            value: 2147483648,
            maxValue: 2147483647,
            minValue: -2147483647
        }],
        buttons: [{
            text: 'Take one down, pass it around',
            handler: function() {
                this.up('form').down('[name=bottles]').spinDown();
            }
        }]
    });

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    For which language are you localizing the text?

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2013
    Posts
    43

    Default

    What option do I have to target any specific localized culture?

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    You can use the maxText and minText.

    You can specify these per instance as configs or globally using an override:

    Code:
    Ext.define('Override.form.field.Number', {
        override : 'Ext.form.field.Number',
    
        minText : 'Some text here, minimum is {0}',
        maxText : 'Some text here, maximum is {0}'
    });
    The {0} will be replaced with the minValue and maxValue.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  5. #5
    Sencha Premium Member
    Join Date
    Jul 2013
    Posts
    43

    Default

    minText and maxText config helps in rephrasing the entire message along with minValue and maxValue using place holder "{0}". But here along with message text I would like the number to follow the localized format.

    e.g.
    https://en.wikipedia.org/wiki/Decima...xamples_of_use

  6. #6
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    I see, you'd have to override the getErrors method in order to use something like Ext.util.Format.number as Ext JS only does this:

    Code:
    errors.push(format(me.maxText, me.maxValue));
    format === Ext.String.format

    so it doesn't parse the maxValue at all.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Similar Threads

  1. Replies: 1
    Last Post: 18 Sep 2014, 11:10 AM
  2. Datefield error message localization
    By senacle in forum Ext 3.x: Bugs
    Replies: 2
    Last Post: 2 Jan 2012, 11:46 PM
  3. Style of Validation Error Message
    By shane.miller in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 25 Sep 2009, 10:11 AM
  4. Form validation error message
    By Chods in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 24 Jul 2009, 7:47 AM
  5. how to display validation error message
    By vinothini in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 1 Jun 2009, 5:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •