Skip to content
Snippets Groups Projects
Select Git revision
  • de060cc11d40c9091d04bbd7157f3829039ca1a5
  • master default protected
  • 1.31
  • 4.38.5
  • 4.38.4
  • 4.38.3
  • 4.38.2
  • 4.38.1
  • 4.38.0
  • 4.37.2
  • 4.37.1
  • 4.37.0
  • 4.36.0
  • 4.35.0
  • 4.34.1
  • 4.34.0
  • 4.33.1
  • 4.33.0
  • 4.32.2
  • 4.32.1
  • 4.32.0
  • 4.31.0
  • 4.30.1
23 results

tutorial-browser-compatibility.html

Blame
  • main.mjs 1.78 KiB
    import {Fetch} from '../../../application/source/i18n/providers/fetch.mjs';
    import {Updater} from '../../../application/source/dom/updater.mjs';
    import {CustomElement, registerCustomElement} from '../../../application/source/dom/customelement.mjs';
    import {domReady} from '../../../application/source/dom/ready.mjs';
    import {Embed} from '../../../application/source/i18n/providers/embed.mjs';
    
    
    class Monster1 extends CustomElement {
    
    
        get defaults() {
            return Object.assign(
                {},
                super.defaults,
                {
                    labels: {
                        theListContainsNoEntries: "The list contains no entries",
                        multi: {
                            zero: "Zero",
                            one: "One",
                            two: "Two",
                            few: "Few",
                            many: "Many",
                            other: "Other"
                            
                        }
                    }
                });
        };
    
        /**
         *
         * @return {string}
         */
        static getTag() {
            return "monster-1";
        }
    
    }
    
    
    domReady.then(() => {
    
        Embed.assignTranslationsToElement().then(() => {
            m1.updateI18n();
            console.log(m1.getOption('labels'));
            console.log(m1.getOption('labels.multi.two'));
        });
    
        const translation = new Embed('i18n');
        const m1 = document.querySelector("monster-1");
    
    
    // read from scritp tag with id i18n
    
    
    });
    
    registerCustomElement(Monster1);
    
    //
    // const provider = new Fetch('translation.json', {
    //     method: 'GET',
    //     headers: {
    //         'Content-Type': 'application/json',
    //     },
    // });
    //
    // provider
    //     .assignToElement()
    //     .then(() => {
    //         new Updater(document.body, {}).run();
    //     })
    //     .catch((e) => {
    //         console.error(e);
    //     });