Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
construct: function(self, options) {
var i18nOptions = self.options || {};
_.defaults(i18nOptions, {
locales: ['en'],
cookie: 'apos_language',
directory: self.apos.rootDir + '/locales'
});
i18n.configure(i18nOptions);
// Make the i18n instance available globally in Apostrophe
console.log('initial');
self.apos.i18n = i18n;
}
};
function initialize() {
const shouldQuit = makeSingleInstance();
if (shouldQuit) {
return app.exit(0);
}
i18n.configure({
locales: localeArray,
directory: `${__dirname}/locales`,
objectNotation: true
});
function createWindow() {
const windowOptions = {
width: 1080,
minWidth: 680,
height: 840,
icon: path.join(__dirname, `${process.platform === 'win32' ? '/public/image/hostsdock.ico' : '/public/image/hostsdock.png'}`),
show: false
};
// Create the browser window.
mainWindow = new BrowserWindow(windowOptions);
express = require('express');
var global = require('./global.js');
// the translation middleware
var config = {
locales: ['en-US','pt-BR','cs-CZ','fr-CA'],
defaultLocale: 'en-US',
directory: libpath.resolve(__dirname,'..','locales'),
extension: '.json',
updateFiles: false,
objectNotation: true,
cookie: 'preferredLang'
};
i18n.configure(config);
exports.detect = function(req,res,next)
{
res.i18n = new MyI18n();
res.redirect = function(url)
{
if( this.i18n.pathLocale ){
return express.response.redirect.call(this, '/'+this.i18n.pathLocale+url);
}
else {
return express.response.redirect.call(this, url);
}
}.bind(res);
var pathLang = detectPathLocale(req.url, req);
var cookieLang = detectCookieLocale(req.cookies[config.cookie]);
'use strict'
// NPM dependencies
const _ = require('lodash')
const changeCase = require('change-case')
const AWSXRay = require('aws-xray-sdk')
const { getNamespace } = require('continuation-local-storage')
const i18n = require('i18n')
// Local dependencies
const logger = require('../utils/logger')(__filename)
const cardIdClient = require('../services/clients/cardid_client')
const { NAMESPACE_NAME, XRAY_SEGMENT_KEY_NAME } = require('../../config/cls')
const i18nConfig = require('../../config/i18n')
i18n.configure(i18nConfig)
const checkCard = function (cardNo, allowed, language, correlationId, subSegment) {
return new Promise(function (resolve, reject) {
const startTime = new Date()
const data = { cardNumber: parseInt(cardNo) }
i18n.setLocale(language || 'en')
// Use a subSegment if passed, otherwise get our main segment
if (!subSegment) {
const namespace = getNamespace(NAMESPACE_NAME)
subSegment = namespace.get(XRAY_SEGMENT_KEY_NAME)
}
AWSXRay.captureAsyncFunc('cardIdClient_post', function (postSubsegment) {
if (cardNo.length > 0 && cardNo.length < 11) {
const currentLocale = globalConfig.get('locale') || defaults.locale;
const i18nConfig: I18nConfig$ = {
locales: ['en_US', 'zh_CN'],
defaultLocale:
supports.findIndex(v => v === currentLocale) >= 0
? currentLocale
: defaults.locale,
directory: paths.project + '/locales',
extension: '.json',
register: global,
objectNotation: true
};
i18n.configure(i18nConfig);
}
function initialisei18n (app) {
i18n.configure(i18nConfig)
app.use(i18n.init)
app.use(i18nPayTranslation)
}
import bodyParser from 'body-parser'
import Express from 'express'
import * as http from 'http'
import Knex from 'knex'
import { Model } from 'objection'
import * as os from 'os'
import * as path from 'path'
import knexConfig from '../../knexfile'
import l from './logger'
import swagger from './swagger'
import morgan from 'morgan'
import cors from 'cors'
import i18n from 'i18n'
i18n.configure({
locales: ['en', 'nl'],
defaultLocale: 'nl',
register: global,
objectNotation: true,
syncFiles: true,
directory: __dirname + '/../i18n',
})
const env = process.env.NODE_ENV || process.env.APP_ENV
const knex = Knex(knexConfig[env])
Model.knex(knex)
const app = Express()
export default class ExpressServer {
public constructor() {
function localize(key) {
const vscodeOptions = JSON.parse(process.env.VSCODE_NLS_CONFIG).locale.toLowerCase();
let i18n = require('i18n');
let locales = ['en', 'pt-br'];
i18n.configure({
locales: locales,
directory: __dirname + '\\locales'
});
i18n.setLocale(locales.indexOf(vscodeOptions) + 1 ? vscodeOptions : 'en');
return i18n.__(key);
}
function localize(key: string) {
const vscodeOptions = JSON.parse(
process.env.VSCODE_NLS_CONFIG
).locale.toLowerCase();
let i18n = require('i18n');
let locales = ['en', 'pt-br'];
i18n.configure({
locales: locales,
directory: __dirname + '\\locales'
});
i18n.setLocale(locales.indexOf(vscodeOptions) + 1 ? vscodeOptions : 'en');
return i18n.__(key);
}