EggJS provides the features of configuration and i18n at project level. CabloyJS extends the features provided by EggJS, realizing the configuration and i18n features at the module level

  1. Module can implement its own configuration and i18n
  2. The configuration and i18n of project level can override the ones of module level


Definition of Config


module.exports = appInfo => {
  const config = {};

  config.message = 'Hello World';

  return config;

Usage of Config


async echo2() {
  const message = this.ctx.config.message;

Override Config

Use project level config to override module level config, thereby changing Hello World to Hello World!


// modules
config.modules = {
  'test-party': {
    message: 'Hello World!',


Definition of Language Resources

The default language for CabloyJS is en-us. If support Chinese, you need to add zh-cn resource file


module.exports = {
  'Hello World': '世界,您好',

Usage of Language Resources

CabloyJS uses the method ctx.text to dynamically get the specified language resources according to the locale configuration of the client


async echo3() {
  const message = this.ctx.text('Hello World');

How to change the locale configuration of the client?

  • Open the home page, entry Mine->Info,update the field of Locale, and save, then refresh the page

Override Language Resources

Use project level language resources to override module level language resources, thereby changing 世界,您好 to 您好,世界


module.exports = {
  'Hello World': '您好,世界',