Cookie consent when i18n ready
This commit is contained in:
parent
8f73025215
commit
4674b48069
2 changed files with 11 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Tracker } from 'meteor/tracker';
|
import { Tracker } from 'meteor/tracker';
|
||||||
|
import { ReactiveVar } from 'meteor/reactive-var';
|
||||||
import backend from 'i18next-xhr-backend';
|
import backend from 'i18next-xhr-backend';
|
||||||
import LngDetector from 'i18next-browser-languagedetector';
|
import LngDetector from 'i18next-browser-languagedetector';
|
||||||
import Cache from 'i18next-localstorage-cache';
|
import Cache from 'i18next-localstorage-cache';
|
||||||
|
|
@ -28,6 +29,8 @@ const detectorOptions = {
|
||||||
excludeCacheFor: ['cimode'] // languages to not persist (cookie, localStorage)
|
excludeCacheFor: ['cimode'] // languages to not persist (cookie, localStorage)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const i18nReady = new ReactiveVar(false);
|
||||||
|
|
||||||
const cacheOptions = {
|
const cacheOptions = {
|
||||||
// turn on or off
|
// turn on or off
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
@ -68,6 +71,7 @@ i18n.use(backend)
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
i18nReady.set(true);
|
||||||
document.title = t('AppName');
|
document.title = t('AppName');
|
||||||
// Accounts translation
|
// Accounts translation
|
||||||
// https://github.com/softwarerero/meteor-accounts-t9n
|
// https://github.com/softwarerero/meteor-accounts-t9n
|
||||||
|
|
@ -86,7 +90,7 @@ i18n.use(backend)
|
||||||
showLink: false,
|
showLink: false,
|
||||||
position: 'bottom',
|
position: 'bottom',
|
||||||
linkText: 'Lee más',
|
linkText: 'Lee más',
|
||||||
linkRouteName: '/',
|
linkRouteName: '/privacy',
|
||||||
acceptButtonText: 'Aceptar',
|
acceptButtonText: 'Aceptar',
|
||||||
html: false,
|
html: false,
|
||||||
expirationInDays: 70,
|
expirationInDays: 70,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { Roles } from 'meteor/alanning:roles';
|
||||||
// https://github.com/gadicc/meteor-blaze-react-component/
|
// https://github.com/gadicc/meteor-blaze-react-component/
|
||||||
import Blaze from 'meteor/gadicc:blaze-react-component';
|
import Blaze from 'meteor/gadicc:blaze-react-component';
|
||||||
// i18n
|
// i18n
|
||||||
import i18n from '/imports/startup/client/i18n';
|
import i18n, { i18nReady } from '/imports/startup/client/i18n';
|
||||||
import '/imports/startup/client/ravenLogger';
|
import '/imports/startup/client/ravenLogger';
|
||||||
import '/imports/startup/client/geolocation';
|
import '/imports/startup/client/geolocation';
|
||||||
import '/imports/startup/client/piwik-start.js';
|
import '/imports/startup/client/piwik-start.js';
|
||||||
|
|
@ -88,8 +88,9 @@ const App = props => (
|
||||||
</Grid>
|
</Grid>
|
||||||
<Footer />
|
<Footer />
|
||||||
<Reconnect />
|
<Reconnect />
|
||||||
|
{props.i18nReady.get() &&
|
||||||
<Blaze template="cookieConsent" />
|
<Blaze template="cookieConsent" />
|
||||||
{/* <Blaze template="cookieConsentImply" /> */}
|
}
|
||||||
</div> : ''}
|
</div> : ''}
|
||||||
</Router>
|
</Router>
|
||||||
</I18nextProvider>
|
</I18nextProvider>
|
||||||
|
|
@ -102,6 +103,7 @@ App.defaultProps = {
|
||||||
|
|
||||||
App.propTypes = {
|
App.propTypes = {
|
||||||
loading: PropTypes.bool.isRequired,
|
loading: PropTypes.bool.isRequired,
|
||||||
|
i18nReady: PropTypes.object.isRequired,
|
||||||
userId: PropTypes.string,
|
userId: PropTypes.string,
|
||||||
emailAddress: PropTypes.string,
|
emailAddress: PropTypes.string,
|
||||||
emailVerified: PropTypes.bool.isRequired
|
emailVerified: PropTypes.bool.isRequired
|
||||||
|
|
@ -119,10 +121,11 @@ export default withTracker(() => {
|
||||||
const loading = !Roles.subscription.ready();
|
const loading = !Roles.subscription.ready();
|
||||||
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
|
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
|
||||||
const emailAddress = user && user.emails && user.emails[0].address;
|
const emailAddress = user && user.emails && user.emails[0].address;
|
||||||
|
console.log(`i18n ready?: ${i18nReady.get()}`);
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
loggingIn,
|
loggingIn,
|
||||||
|
i18nReady,
|
||||||
authenticated: !loggingIn && !!userId,
|
authenticated: !loggingIn && !!userId,
|
||||||
name: name || emailAddress,
|
name: name || emailAddress,
|
||||||
roles: !loading && Roles.getRolesForUser(userId),
|
roles: !loading && Roles.getRolesForUser(userId),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue