From 1d710752eb8b295a741379d1b511787fda4603c7 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Fri, 10 Jun 2022 16:45:03 +0200 Subject: [PATCH] Expose i18nPromise through radio channel for access from views (#451) --- frontend/src/global/i18n.ts | 4 ++++ frontend/src/i18n/radio.ts | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 frontend/src/i18n/radio.ts diff --git a/frontend/src/global/i18n.ts b/frontend/src/global/i18n.ts index e1700f31..1a8094e1 100644 --- a/frontend/src/global/i18n.ts +++ b/frontend/src/global/i18n.ts @@ -1,8 +1,10 @@ +import { constant } from 'lodash'; import * as i18next from 'i18next'; import * as languageDetector from 'i18next-browser-languagedetector'; import * as english from '../i18n/en/translation.json'; import * as french from '../i18n/fr/translation.json'; +import channel from '../i18n/radio'; const i18nPromise = new Promise(function(resolve, reject) { i18next.use( @@ -26,4 +28,6 @@ const i18nPromise = new Promise(function(resolve, reject) { }); }); +channel.reply('i18next', constant(i18nPromise)); + export { i18nPromise, i18next }; diff --git a/frontend/src/i18n/radio.ts b/frontend/src/i18n/radio.ts new file mode 100644 index 00000000..13829f3a --- /dev/null +++ b/frontend/src/i18n/radio.ts @@ -0,0 +1,5 @@ +import { channel } from 'backbone.radio'; + +export const channelName = 'readit-i18n'; + +export default channel(channelName);