Created
August 22, 2011 17:48
-
-
Save quickredfox/1163022 to your computer and use it in GitHub Desktop.
en.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load this file for the english version | |
var i18n_strings = { | |
"{0} is a great friend of mine": "{0} is a great friend of mine" | |
"some_key": "A string of text" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Like Ext.String.format() except it translates the first argument before formating. | |
*/ | |
Ext.apply( Ext.String, { | |
translate: function(){ | |
var strkey = arguments[0]; | |
arguments[0] = i18n_strings[ strkey ] || strkey; | |
return Ext.String.format.apply( null, arguments ); | |
} | |
}); | |
/// And you can setup some shortcut function | |
var __ = Ext.String.translate | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load this file instead for the french version | |
var i18n_strings = { | |
"{0} is a great friend of mine": "C'est mon grand ami {0}" | |
"some_key": "Un peut de texte" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// examples usage: | |
Ext.create('Ext.panel.Panel', { | |
title: Ext.String.translate( "{0} is a great friend of mine", 'Roger' ) | |
}); | |
// or... | |
Ext.create('Ext.panel.Panel', { | |
title: __( "{0} is a great friend of mine", 'Roger' ) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment