Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { initReactI18next } from 'react-i18next';
import { en_US, ko_KR, pt_BR, zh_CN } from './locales';
// Couldn't import this fucking module, require it
const i18n = require('i18next').default;
const LanguageDetector = require('i18next-browser-languagedetector');
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en-US',
debug: true,
ns: ['translation', 'settings'],
defaultNS: 'translation'
})
.then(() => console.debug('i18n initialized successfully'))
.catch((error: any) => console.debug('i18n initialization failed', error));
i18n.addResourceBundle('en-US', 'translation', en_US);
i18n.addResourceBundle('zh-CN', 'translation', zh_CN);
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
const { renderToString } = require('react-dom/server');
const i18n = require('i18next').default;
const { initReactI18next } = require('react-i18next');
const Backend = require('i18next-sync-fs-backend');
exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
i18n
.use(initReactI18next)
.use(Backend)
.init({
initImmediate: false,
backend: {
loadPath: 'site/locales/{{lng}}.json',
},
});
// load the common namespace
i18n.loadLanguages([], () => {
replaceBodyHTMLString(renderToString(bodyComponent));
initialI18nStore[l][ns] =
(req.i18n.services.resourceStore.data[l] || {})[ns] || {};
});
});
return {
i18n: req.i18n, // use the instance on req - fixed language on request (avoid issues in race conditions with lngs of different users)
initialI18nStore,
initialLanguage: req.i18n.language
};
};
module.exports = {
getInitialProps,
i18nInstance,
I18n: i18next.default
};
const i18next = require('i18next');
const XHR = require('i18next-xhr-backend');
const LanguageDetector = require('i18next-browser-languagedetector');
const config = require('./config');
const i18n = i18next.default ? i18next.default : i18next;
const options = {
fallbackLng: config.translation.defaultLanguage,
load: 'languageOnly', // we only provide en, de -> no region specific locals like en-US, de-DE
// have a common namespace used around the full app
ns: ['common', 'report'],
defaultNS: 'common',
debug: false, // process.env.NODE_ENV !== 'production',
saveMissing: true,
interpolation: {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
format: (value, format, lng) => {
const i18next = require("i18next").default;
module.exports.i18next = i18next;
module.exports.initLocale = async function () {
await i18next.init({
debug: false,
interpolation: {
defaultVariables: {
homepageUrl: "http://git.io/nightscoutstatus"
}
},
resources: {
da: require("./languages/da.json"),
fr: require("./languages/fr.json"),
pl: require("./languages/pl.json"),
pt: require("./languages/pt.json"),
var freezeObject = require("terriajs-cesium/Source/Core/freezeObject").default;
var GeoJsonCatalogItem = require("./GeoJsonCatalogItem");
var inherit = require("../Core/inherit");
var KmlCatalogItem = require("./KmlCatalogItem");
var loadJson = require("../Core/loadJson");
var Metadata = require("./Metadata");
var TerriaError = require("../Core/TerriaError");
var proxyCatalogItemUrl = require("./proxyCatalogItemUrl");
var Rectangle = require("terriajs-cesium/Source/Core/Rectangle").default;
var URI = require("urijs");
var WebMapServiceCatalogGroup = require("./WebMapServiceCatalogGroup");
var WebMapServiceCatalogItem = require("./WebMapServiceCatalogItem");
var WebFeatureServiceCatalogGroup = require("./WebFeatureServiceCatalogGroup");
var WebFeatureServiceCatalogItem = require("./WebFeatureServiceCatalogItem");
var when = require("terriajs-cesium/Source/ThirdParty/when").default;
var i18next = require("i18next").default;
/**
* A {@link CatalogItem} that queries a CKAN server for a resource, and then accesses
* that resource as WMS, GeoJSON, etc. depending on what it finds.
*
* @alias CkanCatalogItem
* @constructor
* @extends CatalogItem
*
* @param {Terria} terria The Terria instance.
*/
function CkanCatalogItem(terria) {
CatalogItem.call(this, terria);
/**
* Gets or sets the ID of the CKAN resource referred to by this catalog item. Either this property
var formatError = require("terriajs-cesium/Source/Core/formatError").default;
var freezeObject = require("terriajs-cesium/Source/Core/freezeObject").default;
var knockout = require("terriajs-cesium/Source/ThirdParty/knockout").default;
var loadJson = require("../Core/loadJson");
var loadText = require("../Core/loadText");
var when = require("terriajs-cesium/Source/ThirdParty/when").default;
var CkanCatalogItem = require("./CkanCatalogItem");
var createRegexDeserializer = require("./createRegexDeserializer");
var createRegexSerializer = require("./createRegexSerializer");
var TerriaError = require("../Core/TerriaError");
var CatalogGroup = require("./CatalogGroup");
var inherit = require("../Core/inherit");
var proxyCatalogItemUrl = require("./proxyCatalogItemUrl");
var xml2json = require("../ThirdParty/xml2json");
var i18next = require("i18next").default;
/**
* A {@link CatalogGroup} representing a collection of layers from a [CKAN](http://ckan.org) server.
*
* @alias CkanCatalogGroup
* @constructor
* @extends CatalogGroup
*
* @param {Terria} terria The Terria instance.
*/
var CkanCatalogGroup = function(terria) {
CatalogGroup.call(this, terria, "ckan");
/**
* Gets or sets the URL of the CKAN server. This property is observable.
* @type {String}
namespaces.forEach(ns => {
initialI18nStore[l][ns] = (req.i18n.services.resourceStore.data[l] || {})[ns] || {};
});
});
return {
i18n: req.i18n,
initialI18nStore,
initialLanguage: req.i18n.language,
};
};
module.exports = {
getInitialProps,
i18nInstance,
I18n: i18next.default,
};