https://github.com/katzer/ext.ux.localemanager
Simple localization support for Extjs and SenchaTouch
https://github.com/katzer/ext.ux.localemanager
Last synced: over 1 year ago
JSON representation
Simple localization support for Extjs and SenchaTouch
- Host: GitHub
- URL: https://github.com/katzer/ext.ux.localemanager
- Owner: katzer
- License: mit
- Created: 2013-12-12T21:41:58.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-18T22:19:59.000Z (over 12 years ago)
- Last Synced: 2025-01-28T12:42:08.240Z (over 1 year ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ext.ux.LocaleManager
====================
Simple localization support for [Extjs](http://www.sencha.com/products/extjs/) and [SenchaTouch](http://www.sencha.com/products/touch/) components.
## Adding the Plugin to your project
The plugin has to be required within `app.js` and the locals has to be added before any localized view component can be loaded.
```javascript
// app.js
Ext.application({
requires: [
'Ext.ux.LocaleManager'
]
})
```
## Using the plugin
You can either use the `Ext.ux.LocalMgr.localize(key)` or the global `l(key)` to localize a given key.
```javascript
Ext.define('MyLocalizedApp.view.Example', {
items: [{
label: l('firstname')
},{
label: l('color', 'red')
},{
label: l('my-name-is', 'Sebastián', 'Katzer')
},{
label: l('msg-was-forwarded-to-sap', msg.getData())
}]
});
```
## Adding locales
```javascript
Ext.ux.LocaleMgr.addLocales(['en', 'en-US', 'en-GB'], {
// Single key-value pair
firstname: 'Firstname',
// Key with multiple values
color: { black: 'Black', red: 'Red', default: 'Gold' }
// Value as a string with placeholders
'my-name-is': 'My name is {0} {1}.',
// Value as an Ext.XTemplate
'msg-was-forwarded-to-sap': ['The message {id} has been forwarded to SAP.']
})
```
## License
This source code is released under the [MIT License](http://opensource.org/licenses/MIT).