简体   繁体   中英

Centralize messages in properties file in Extjs

I have multiple Extjs projects, and each of them have common messages (eg the confirmation / warning messages for alert dialog). I would like to centralize all these messages into a file (eg properties file). Please tell me how to implement this in Extjs.

Create a Sencha CMD package to hold common stuff for your projects. Include that package in each project's app.json file:

"requires": [
    "my-common",
   // other packages
],

Put the messages in a singleton:

Ext.define('MyCommon.Messages', {
    singleton: true,
    foo: 'Bar'
    // .....

Use it in your projects:

alert(MyCommon.Messages.foo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM