Results 1 to 9 of 9

Thread: How to localize Yesno button in Ext 4.1 ?

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    78
    Answers
    1

    Default How to localize Yesno button in Ext 4.1 ?

    I want to localize the yes no text of button in extjs 4.1. I tried to change ext-lang-xx.js file but it doesn't work. Any suggestions please?

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    Yes and No buttons for which component?

  3. #3
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Posts
    78
    Answers
    1

    Default

    I have this message.
    Code:
    Ext.Msg.show({
    			title: "test",
    			msg: "test", 
    			buttons: Ext.MessageBox.YESNOCANCEL,
    			closable: true,
    			fn: function( ){
    	
    			}
    		});
    I want to localize the yes, no, cancel of buttons. I have modified the ext-lang-xx.js file by adding this:
    Code:
                Ext.MessageBox.msgButtons['cancel'].text = "test";
    	     Ext.MessageBox.msgButtons['yes'].text = "test";
    	     Ext.MessageBox.msgButtons['no'].text = "test";
    But the change isnot reflected in the message box buttons. How can I resolve this?

  5. #5
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    the way you are doing it is working in ExtJS 4.0.7 but not in 4.1.x. Change like this:

    Code:
    // Add this to your locale file; remove the lines which you have posted above! they were meant to be removed for ExtJS 4.1.x
    if(Ext.MessageBox){
            Ext.MessageBox.buttonText = {
                ok     : "TestOK",
                cancel : "TestCancel",
                yes    : "TestYes",
                no     : "TestNo"
            };
        }
    
    // Now you can create a message box like this in your app:
    Ext.Msg.show({
        title:'Messagebox Title',
        msg: 'Are you sure want to delete?',
        buttons: Ext.Msg.YESNOCANCEL
    });

  6. #6
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    the locale file has the following comments:

    // As of 4.0.4, setting the buttonText above does not take effect properly. This should be removable in 4.1.0
    // (see issue EXTJSIV-3909)
    Because of an earlier issue, the following 4 lines were added below these comments (which are no longer needed for ExtJS 4.1.x:

    Code:
            Ext.MessageBox.msgButtons['ok'].text = Ext.MessageBox.buttonText.ok;
            Ext.MessageBox.msgButtons['cancel'].text = Ext.MessageBox.buttonText.cancel;
            Ext.MessageBox.msgButtons['yes'].text = Ext.MessageBox.buttonText.yes;
            Ext.MessageBox.msgButtons['no'].text = Ext.MessageBox.buttonText.no;

  7. #7
    Sencha User
    Join Date
    Sep 2011
    Posts
    78
    Answers
    1

    Default

    Thanks for the reply. I have removed those lines. But still the buttons yes, no , cancel are coming in English eventhough the message is coming in another language. Do I have to add something to the file where I have written the code for message or in some other file ?

  8. #8
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    no you dont have to add anything else. Just remove those 4 lines and change the text in that object in the locale file. then you can just create a message box like this:

    Code:
    Ext.Msg.show({
                 title: "test",
                 msg: "test", 
                buttons: Ext.MessageBox.YESNOCANCEL,
                 closable: true,
                 fn: function( ){
                      }
             });

  9. #9
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    add this code in your app JS file before creating any message boxes and see if it changes anything:

    Code:
    if(Ext.MessageBox){
             Ext.MessageBox.buttonText = {
                 ok     : "TestOK",
                 cancel : "TestCancel",
                 yes    : "TestYes",
                no     : "TestNo"
             };
         }
    If this works, then there may be a problem in loading the locale file. It might not be loaded before the message box is being created...

Posting Permissions

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