Modular package
Go to file
2024-11-03 09:34:52 +08:00
infrastructure.js Added Localization 2016-07-03 00:04:00 +08:00
localization.js Return string for unresloved string was wrong 2016-07-03 21:29:43 +08:00
README.md Template string function 2016-07-03 17:41:59 +08:00
redisclient.js Fixed socket already open issue 2024-11-03 09:34:52 +08:00
session.js Updated HGETALL return type 2023-02-01 07:53:28 +08:00

botansx-modular

The Botanical Simply eXtended modular package

Localization.js

Translation is made easy by the Localization module

global.lang = "en-US"; // This is the default language

// Folder structure
//   MyApp/locale
//   MyApp/locale/en-US
//   MyApp/locale/en-US/Error.js
//   MyApp/locale/zh-TW/Error.js
//   .
//   .
//   .
AppNS.define( "LocaleSX", "./MyApp/locale" );

var Locale = cl.load( "botansx.modular.localization" );
console.log( Locale.Error.ERROR1 ); // LocaleString[ Locale.Error.ERROR1 ]
console.log( Locale.Error.ERROR1 + "" ); // Error Message 1
console.log( Locale.Error.ERROR1( "zh-TW" ) ); // 錯誤訊息 1

MyApp/locale/en-US/Error.js

module.exports = {
    "ERROR1": "Error Message 1"
};

MyApp/locale/zh-TW/Error.js

module.exports = {
    "ERROR1": " 錯誤訊息 1"
};

Templated String

String.L

"%s world".L( "hello" ); // hello world
"%%s world".L( "hello" ); // %s world