// commonjs code goes here
import i18next from 'i18next';
import localstorage from './localstorage';

window.i18n = i18next;

i18next.init({
    lng: 'lang',
    resources: {
        lang: {
            translation: page_params.translation_data,
        },
    },
    nsSeparator: false,
    keySeparator: false,
    interpolation: {
        prefix: "__",
        suffix: "__",
    },
    returnEmptyString: false,  // Empty string is not a valid translation.
});

// garbage collect all old-style i18n translation maps in localStorage.
$(function () {
    if (!localstorage.supported()) {
        return;
    }

    // this collects all localStorage keys that match the format of:
    //   i18next:dddddddddd:w+ => 1484902202:en
    // these are all language translation strings.
    const translations = Object.keys(localStorage).filter(function (key) {
        return /^i18next:\d{10}:\w+$/.test(key);
    });

    // remove cached translations of older versions.
    translations.forEach(function (translation_key) {
        localStorage.removeItem(translation_key);
    });
    return this;
});

@@ -1,31 +1,4 @@
-// commonjs code goes here%0A
 impo
@@ -27,75 +27,8 @@
 xt';
-%0Aimport localstorage from './localstorage';%0A%0Awindow.i18n = i18next;
 %0A%0Ai1
@@ -368,639 +368,27 @@
 );%0A%0A
-// garbage collect all old-style i18n translation maps in localStorage.%0A$(function () %7B%0A    if (!localstorage.supported()) %7B%0A        return;%0A    %7D%0A%0A    // this collects all localStorage keys that match the format of:%0A    //   i18next:dddddddddd:w+ =%3E 1484902202:en%0A    // these are all language translation strings.%0A    const translations = Object.keys(localStorage).filter(function (key) %7B%0A        return /%5Ei18next:%5Cd%7B10%7D:%5Cw+$/.test(key);%0A    %7D);%0A%0A    // remove cached translations of older versions.%0A    translations.forEach(function (translation_key) %7B%0A        localStorage.removeItem(translation_key);%0A    %7D);%0A    return this;%0A%7D)
+window.i18n = i18next
 ;%0A

Remove code to sweep local storage.