Skip to content

Commit

Permalink
ccm.dms.js v5.2.0: multilingualism for user content
Browse files Browse the repository at this point in the history
  • Loading branch information
akless committed Apr 24, 2024
1 parent 31629f2 commit cfd2199
Show file tree
Hide file tree
Showing 7 changed files with 649 additions and 12 deletions.
22 changes: 12 additions & 10 deletions ccm.dms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* @overview ccmjs-based web component for a digital makerspace
* @author André Kless <andre.kless@web.de> 2018-2022, 2024
* @license The MIT License (MIT)
* @version latest (5.1.0)
* @version latest (5.2.0)
* @changes
* version 5.2.0 (24.04.2024): multilingualism for user content
* version 5.1.0 (17.04.2024): added register form
* version 5.0.0 (03.03.2022): reimplementation
* (for older version changes see ccm.dms-4.5.0.js)
Expand Down Expand Up @@ -98,12 +99,12 @@
this.dark === 'auto' && this.element.classList.add( 'dark_auto' );
this.dark === true && this.element.classList.add( 'dark_mode' );

// listen to language change event
// listen to language change event => reload page with new language
this.lang && this.lang.observe( lang => {
$.params( { lang: lang } ); // change language in URL parameter
element.querySelector( '.timestamp' ) && this.refresh(); // translate timestamps
$.setContent( this.element, '' );
$.params( { lang } );
location.reload();
} );

};

/**
Expand All @@ -112,6 +113,8 @@
*/
this.start = async () => {

$.setContent( this.element, '' );

// logging of 'start' event
this.logger && this.logger.log( 'start' );

Expand All @@ -120,6 +123,9 @@
this.components.get( { deleted: false } ),
this.apps.get( { deleted: false } )
] );
if (this.lang) {
data[0].forEach(component => this.lang.translate(component));
}
data = {
components: {
arr: data[ 0 ],
Expand Down Expand Up @@ -465,11 +471,7 @@
this.refresh = () => {
const params = $.params();
const lang = this.lang && this.lang.active;
if ( lang )
if ( params.lang )
params.lang !== lang && this.lang.switch( params.lang );
else
$.params( { lang: lang } );
if ( this.lang ) $.params( { lang: lang } );
switch ( params.view ) {
case 'home':
return this.render.home();
Expand Down
2 changes: 2 additions & 0 deletions ccm.dms.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ccm.dms.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<title>Digital Makerspace</title>
<style>body { margin: 0; background-color: rgb( 248, 249, 250 ) }</style>
<script src="https://ccmjs.github.io/digital-makerspace/versions/ccm.dms-5.1.0.js"></script>
<ccm-dms-5-1-0 src='["ccm.load","https://ccmjs.github.io/digital-makerspace/resources/resources.mjs#live"]'></ccm-dms-5-1-0>
<script src="https://ccmjs.github.io/digital-makerspace/versions/ccm.dms-5.2.0.min.js"></script>
<ccm-dms-5-2-0 src='["ccm.load","https://ccmjs.github.io/digital-makerspace/resources/resources.mjs#live"]'></ccm-dms-5-2-0>
Loading

0 comments on commit cfd2199

Please sign in to comment.