From 9bfb3754c1bc0d1033afda97f2884e721d1ab3d8 Mon Sep 17 00:00:00 2001 From: lain Date: Sat, 13 Jun 2020 11:47:34 +0200 Subject: ServiceWorker: Use loader to only notification messages. This keeps the translation size very small and makes it easy to integrate all the languages, as dynamically loading them isn't easy in the service worker. --- src/lib/notification-i18n-loader.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/lib/notification-i18n-loader.js (limited to 'src/lib/notification-i18n-loader.js') diff --git a/src/lib/notification-i18n-loader.js b/src/lib/notification-i18n-loader.js new file mode 100644 index 00000000..a61755c8 --- /dev/null +++ b/src/lib/notification-i18n-loader.js @@ -0,0 +1,9 @@ +// This somewhat mysterious module +module.exports = function(source) { + var object = JSON.parse(source) + var smol = { + notifications: object.notifications || {} + } + + return JSON.stringify(smol) +} -- cgit v1.2.3-70-g09d2 From 1e57adf6d4a46ab5be677bba7ae3c7f0ba0fc520 Mon Sep 17 00:00:00 2001 From: lain Date: Sat, 13 Jun 2020 11:53:16 +0200 Subject: Linting + docs --- src/lib/notification-i18n-loader.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lib/notification-i18n-loader.js') diff --git a/src/lib/notification-i18n-loader.js b/src/lib/notification-i18n-loader.js index a61755c8..71f9156a 100644 --- a/src/lib/notification-i18n-loader.js +++ b/src/lib/notification-i18n-loader.js @@ -1,5 +1,8 @@ -// This somewhat mysterious module -module.exports = function(source) { +// This somewhat mysterious module will load a json string +// and then extract only the 'notifications' part. This is +// meant to be used to load the partial i18n we need for +// the service worker. +module.exports = function (source) { var object = JSON.parse(source) var smol = { notifications: object.notifications || {} -- cgit v1.2.3-70-g09d2