Countdown plugin spanish translation

3 replies · opened Sep 28, 2020

AarsdinamicaSep 28, 2020

Hi!
I follow the steps of the documentation to change the language of the countdown plugin, but it does not appear to run well.

This is the code of my "plugins.countdown.js" file:

/** Abstract base class for collection plugins.
	Written by Keith Wood (kbwood{at}iinet.com.au) December 2013.
	Licensed under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. */
(function(){var j=false;window.JQClass=function(){};JQClass.classes={};JQClass.extend=function extender(f){var  ...  }})(jQuery);

/*! http://keith-wood.name/countdown.html
	Countdown for jQuery v2.1.0.
	Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2008.
	Available under the MIT (http://keith-wood.name/licence.html) license.
	Please attribute the author if you use it.
*/

!function(a){"use strict";var b="countdown",c=0,d=1,e=2,f=3,g=4,h=5,i=6;a.JQPlugin.createPlugin({ ... }})}(jQuery);

	/* http://keith-wood.name/countdown.html
	 * Spanish initialisation for the jQuery countdown extension
	 * Written by Sergio Carracedo Martinez webmaster@neodisenoweb.com (2008) */
	(function ($) {
		'use strict';
		$.countdown.regionalOptions.es = {
			labels: ['Años', 'Meses', 'Semanas', 'Dí­as', 'Horas', 'Minutos', 'Segundos'],
			labels1: ['Año', 'Mes', 'Semana', 'Dí­a', 'Hora', 'Minuto', 'Segundo'],
			compactLabels: ['a', 'm', 's', 'd'],
			whichLabels: null,
			digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
			timeSeparator: ':',
			isRTL: false
		};
		$.countdown.setDefaults($.countdown.regionalOptions.es);
	})(jQuery);

window.SEMICOLON_countdownInit = function( $countdownEl ){

	$countdownEl = $countdownEl.filter(':not(.customjs)');

	if( $countdownEl.length < 1 ){
		return true;
	}

	$countdownEl.each(function(){

		let element		= $(this),
			elFormat	= element.attr( 'data-format' ) || 'dHMS',
			elSince		= element.attr( 'data-since' ),
			elYear		= element.attr( 'data-year' ),
			elMonth		= element.attr( 'data-month' ),
			elDay		= element.attr( 'data-day' ),
			elHour		= element.attr( 'data-hour' ),
			elMin		= element.attr( 'data-minute' ),
			elSec		= element.attr( 'data-second' ),
			elRedirect	= element.attr( 'data-redirect' ),
			dateFormat	= '';

		if( elYear ){
			dateFormat = elYear;
		}

		if( elMonth && elMonth < 13 ){
			dateFormat = dateFormat +"-"+ ( elMonth < 10 ? '0'+elMonth : elMonth);
		} else {
			if( elYear ) {
				dateFormat = dateFormat +"-01";
			}
		}

		if( elDay && elDay < 32 ){
			dateFormat = dateFormat +"-"+ ( elDay < 10 ? '0'+elDay : elDay);
		} else {
			if( elYear ) {
				dateFormat = dateFormat +"-01";
			}
		}

		setDate = dateFormat != '' ? new Date( moment( dateFormat ) ) : new Date();

		if( elHour && elHour < 25 ){
			setDate.setHours( setDate.getHours() + Number( elHour ) );
		}

		if( elMin && elMin < 60 ){
			setDate.setMinutes( setDate.getMinutes() + Number( elMin ) );
		}

		if( elSec && elSec < 60 ){
			setDate.setSeconds( setDate.getSeconds() + Number( elSec ) );
		}

		if( !elRedirect ) {
			elRedirect = false;
		}

		if( elSince == 'true' ) {
			element.countdown({
				since: setDate,
				format: elFormat,
				expiryUrl: elRedirect,
			});
		} else {
			element.countdown({
				until: setDate,
				format: elFormat,
				expiryUrl: elRedirect,
			});
		}

	});

};

Am I doing something wrong?

Thank you very much for your support and have a nice day!
Sergio.

SSemicolon WebSTAFFSep 29, 2020

Hello,

This could be due to the js/plugins.min.js File used on the Page. Since you are using this File, you will need copy the Codes from the js/plugins.countdown.js File and add them in the js/plugins.js File and then minify it to js/plugins.min.js File.

However, if you would like to change the Language of your Countdowns without changing any Files, you can simply add the following code just after the js/plugins.min.js JS File Linking on your HTML Page:
[ch_pre][/ch_pre]

This will definitely work fine. We will add this shortly in the Documentations as well. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

AarsdinamicaSep 29, 2020

Hi!

Solved it!
Thank you for your help!

Have a nice day!
Sergio.

SSemicolon WebSTAFFSep 30, 2020

Hello,

Very Happy to Help!

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard