How to use the i18n/lang.js.__ function in i18n

To help you get started, we’ve selected a few i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tencent / TSW / bin / proxy / master.js View on Github external
process.on('unhandledRejection', (errorOrReason, currPromise) => {
    const errStr = String(errorOrReason && errorOrReason.stack || JSON.stringify(errorOrReason));
    const key = String(errorOrReason && errorOrReason.message);
    const content = `<p><strong>${lang.__('mail.errorStack')}</strong></p><p></p><pre><code>${errStr}</code></pre><p></p>`;

    // 恢复上下文
    if (currPromise &amp;&amp; currPromise.domain) {
        currPromise.domain.run(function() {
            logger.error(`unhandledRejection reason: ${errStr}`);
            setImmediate(function() {
                require('util/mail/mail.js').SendMail(key, 'js', 600, {
                    'title': key,
                    'runtimeType': 'unhandledRejection',
                    'content': content
                });
            });
        });
    } else {
        logger.error(`unhandledRejection reason: ${errStr}`);
        setImmediate(function() {
github Tencent / TSW / bin / proxy / http.proxy.js View on Github external
}, function(err, data, errData) {   // eslint-disable-line handle-callback-err
        const key = `cpu80.v4:${serverInfo.intranetIp}`;
        let content = `<strong>${lang.__('mail.singleCoreCpu')}${serverInfo.cpu},${lang.__('mail.CPUUsageRate')}:${cpuUsed},${lang.__('mail.UsageRateGreaterThan80%')},${lang.__('mail.fiveSecondsCpuProfiler')}</strong>`;
        let str = '';

        if (data) {
            str = data;
            str = str.replace(/');

            content += `<p><strong>${lang.__('mail.processSnapshot')}:</strong></p><pre style="font-size:12px">${str}</pre>`;
        }


        // 获取本机信息,用来分组
        require('api/cmdb').GetDeviceThisServer().done(function(data) {
            data = data || {};
            const business = data.business &amp;&amp; data.business[0] || {};
            const profCallback = (result) =&gt; {
github Tencent / TSW / bin / proxy / master.js View on Github external
if (currMemory &amp;&amp; currMemory.rss &gt; config.memoryLimit) {
                    logger.error('worker${cpu} pid=${pid} memoryUsage ${memoryUsage}, hit memoryLimit: ${memoryLimit}, kill it', {
                        memoryUsage: currMemory.rss,
                        memoryLimit: config.memoryLimit,
                        pid: worker.process.pid,
                        cpu: cpuid
                    });

                    logger.error(worker.lastMessage);

                    mail.SendMail(key, 'js', 600, {
                        'to': config.mailTo,
                        'cc': config.mailCC,
                        'runtimeType': 'Memory',
                        'msgInfo': `${serverInfo.intranetIp} ${lang.__('mail.memoryExceedingTips')}`,
                        'title': `${serverInfo.intranetIp} ${lang.__('mail.memoryExceedingWaring')}`,
                        'content': `<p><strong>${serverInfo.intranetIp} ${lang.__('mail.memoryExceedingTips')}</strong></p>`
                    });

                    restartWorker(worker);
                }
            }
        }

        if (
            true
            &amp;&amp; (nowDate.getHours() % 8 === 0)
            &amp;&amp; nowDate.getMinutes() === 1
            &amp;&amp; nowDate.getSeconds() &lt;= 10
        ) {
            // 8小时一次
            require('api/keyman/runtimeAdd.js').hello();
github Tencent / TSW / bin / tsw / runtime / CCFinder.js View on Github external
const blackIPList = [];
    let blackIPListText = '';


    maxArr.forEach((max, i) =&gt; {
        blackIPListText += `<pre>[${max.StdX10}%]${max.ip} [${i + 1}/${max.count}]</pre>`;
        blackIPListText += formatCacheList(max.list);

        blackIPList.push(max.ip);
    });

    const key = `v6.AVG_TSW_IP_STD_X10.${serverInfo.intranetIp}`;
    let title = '';

    if (config.CCIPLimitAutoBlock) {
        title = `[${lang.__('mail.IPAggregationNotice')}][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`;
        blackIPList.forEach((ip) =&gt; {
            logger.info(`addBlackList: ${ip}`);
            this.addBlackList(ip);
        });
    } else {
        title = `[${lang.__('mail.IPAggregationWarning')}][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`;
    }

    mail.SendMail(key, 'TSW', 3600, {
        'to': config.mailTo,
        'cc': config.mailCC,
        'title': title,
        'content': `<p><strong>${lang.__('mail.viewDocsForIPAggregation')}: </strong> https://tswjs.org/doc/api/ipCCFinder </p>`
        + `<p><strong>${lang.__('mail.serverIP')}:</strong>${serverInfo.intranetIp}</p>`
        + `<p><strong>${lang.__('mail.maliciousIP')}:</strong></p>`
        + blackIPListText
github Tencent / TSW / bin / tsw / runtime / CCFinder.js View on Github external
logger.info(`addBlackList: ${ip}`);
            this.addBlackList(ip);
        });
    } else {
        title = `[${lang.__('mail.IPAggregationWarning')}][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`;
    }

    mail.SendMail(key, 'TSW', 3600, {
        'to': config.mailTo,
        'cc': config.mailCC,
        'title': title,
        'content': `<p><strong>${lang.__('mail.viewDocsForIPAggregation')}: </strong> https://tswjs.org/doc/api/ipCCFinder </p>`
        + `<p><strong>${lang.__('mail.serverIP')}:</strong>${serverInfo.intranetIp}</p>`
        + `<p><strong>${lang.__('mail.maliciousIP')}:</strong></p>`
        + blackIPListText
        + `<p><strong>${lang.__('mail.autoIntoBlackList')}:</strong>` + (config.CCIPLimitAutoBlock ? `${lang.__('mail.yes')}` : `${lang.__('mail.no')}`) + '</p>'
        + `<p><strong>${lang.__('mail.IPAggregationDegree')}:</strong>${cache.ipCacheLast.StdX10}%</p>`
        + `<p><strong>${lang.__('mail.warningThreshold')}:</strong>${CCIPLimit}</p>`
        + `<p><strong>${lang.__('mail.normalValue')}:</strong>5-50</p>`
        + `<p><strong>${lang.__('mail.testingTimeConsuming')}:</strong>${parseInt((cache.ipCacheLast.end - cache.ipCacheLast.start) / 1000, 10)}s</p>`
        + `<p><strong>${lang.__('mail.evidenceList')}:</strong></p>`
        + content
    });


    return true;
};
github Tencent / TSW / bin / proxy / http.route.js View on Github external
}
            if (err.message.indexOf('ETIMEDOUT') &gt; 0) {
                return;
            }
            if (err.message.indexOf('timeout') &gt; 0) {
                return;
            }
            if (err.message.indexOf('hang up') &gt; 0) {
                return;
            }
            if (err.message.indexOf('error:140943FC') &gt; 0) {
                return;
            }

            const key = err.message;
            const content = `<p><strong>${lang.__('mail.errorStack')}</strong></p><p></p><pre><code>${err.stack}</code></pre><p></p>`;
            mail.SendMail(key, 'js', 600, {
                'title': key,
                'runtimeType': 'Error',
                'msgInfo': err.stack || err.message,
                'content': content
            });
        }
    });
github Tencent / TSW / bin / tsw / runtime / CCFinder.js View on Github external
this.addBlackList(ip);
        });
    } else {
        title = `[${lang.__('mail.IPAggregationWarning')}][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`;
    }

    mail.SendMail(key, 'TSW', 3600, {
        'to': config.mailTo,
        'cc': config.mailCC,
        'title': title,
        'content': `<p><strong>${lang.__('mail.viewDocsForIPAggregation')}: </strong> https://tswjs.org/doc/api/ipCCFinder </p>`
        + `<p><strong>${lang.__('mail.serverIP')}:</strong>${serverInfo.intranetIp}</p>`
        + `<p><strong>${lang.__('mail.maliciousIP')}:</strong></p>`
        + blackIPListText
        + `<p><strong>${lang.__('mail.autoIntoBlackList')}:</strong>` + (config.CCIPLimitAutoBlock ? `${lang.__('mail.yes')}` : `${lang.__('mail.no')}`) + '</p>'
        + `<p><strong>${lang.__('mail.IPAggregationDegree')}:</strong>${cache.ipCacheLast.StdX10}%</p>`
        + `<p><strong>${lang.__('mail.warningThreshold')}:</strong>${CCIPLimit}</p>`
        + `<p><strong>${lang.__('mail.normalValue')}:</strong>5-50</p>`
        + `<p><strong>${lang.__('mail.testingTimeConsuming')}:</strong>${parseInt((cache.ipCacheLast.end - cache.ipCacheLast.start) / 1000, 10)}s</p>`
        + `<p><strong>${lang.__('mail.evidenceList')}:</strong></p>`
        + content
    });


    return true;
};
github Tencent / TSW / bin / proxy / http.proxy.js View on Github external
const profCallback = (result) => {
                mail.SendMail(key, 'js', 600, {
                    'to': config.mailTo,
                    'cc': config.mailCC,
                    'runtimeType': 'CPU',
                    'msgInfo': `${business.module}[CPU]${serverInfo.intranetIp}${lang.__('mail.singleCoreCpu')}${serverInfo.cpu}${lang.__('mail.CPUUsageRate')}${cpuUsed}${lang.__('mail.UsageRateGreaterThan80%')}`,
                    'title': `${business.module}[CPU]${serverInfo.intranetIp}${lang.__('mail.singleCoreCpu')}${serverInfo.cpu}${lang.__('mail.CPUUsageRate')}${cpuUsed}${lang.__('mail.UsageRateGreaterThan80%')}`,
                    'content': content,
                    'attachment': result ? {
                        fileType: true,
                        dispositionType: 'attachment',
                        fileName: 'cpu-profiler.cpuprofile',
                        content: result
                    } : ''
                });
            };