SyoTimer icon indicating copy to clipboard operation
SyoTimer copied to clipboard

Syo timer on a multilingual site

Open vistad opened this issue 2 years ago • 2 comments

I have a multilingual site that may be simultaneously operated by multilingual users who need a multilingual timer. So, I need not 1, but 3 languages simultaneously, depending on whether the page language is defined as en or ru or anything else. E.g. {{ .Site.Language.Lang }} returns the language object for the given page.

vistad avatar Feb 07 '24 11:02 vistad

You can use the following steps:

  1. Declare all missing languages in the js code
  2. Save the page language in a variable
  3. Use the saved variable in the options of the syotimer method
// declare missing languages
$.syotimerLang.spa = {
  seconds: ["segundo", "segundos"],
  minute: ["minuto", "minutos"],
  hour: ["hora", "horas"],
  day: ["dia", "dias"],
};

$.syotimerLangheb = {
  second: ['שניה', 'שניות'],
  minute: ['דקה', 'דקות'],
  hour: ['שעה', 'שעות'],
  day: ['יום', 'ימים'],
};

// save page language in variable
const language = "{{ .Site.Language.Lang }}";

// init countdown
$('.selector').syotimer({
  date: new Date(2024, 4, 9, 20, 30),
  // use language variable
  lang: language,
});

You can also update the language in runtime (after the countdown is initialized):

// init countdown
$('.selector').syotimer({
  date: new Date(2024, 4, 9, 20, 30),
});

// some event
$('.button').on( "click", function() {
  // change language
  $('.selector').syotimer("setOption", "lang", "spa")
});

mrfratello avatar Feb 17 '24 19:02 mrfratello

Dear John, thank you for the assistance. I considered this version, but still decided to stay with 2.0 as more convenient for me. Unminified js, added the new language (georgian), changed language codes to 2-letter ones, minified again. Works great! Best of luck!

Victor

On Sat, Feb 17, 2024 at 11:11 AM John Syomochkin @.***> wrote:

You can use the following steps:

  1. Declare all missing languages in the js code
  2. Save the page language in a variable
  3. Use the saved variable in the options of the syotimer method

// declare missing languages$.syotimerLang.spa = { seconds: ["segundo", "segundos"], minute: ["minuto", "minutos"], hour: ["hora", "horas"], day: ["dia", "dias"],}; $.syotimerLangheb = { second: ['שניה', 'שניות'], minute: ['דקה', 'דקות'], hour: ['שעה', 'שעות'], day: ['יום', 'ימים'],}; // save page language in variableconst language = "{{ .Site.Language.Lang }}"; // init countdown$('.selector').syotimer({ date: new Date(2024, 4, 9, 20, 30), // use language variable lang: language,});

You can also update the language in runtime (after the countdown is initialized):

// init countdown$('.selector').syotimer({ date: new Date(2024, 4, 9, 20, 30),}); // some event$('.button').on( "click", function() { // change language $('.selector').syotimer("setOption", "lang", "spa")});

— Reply to this email directly, view it on GitHub https://github.com/mrfratello/SyoTimer/issues/19#issuecomment-1950286325, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWAM5W3ACV24BY6QCDKQVTYUD6E5AVCNFSM6AAAAABC5TQ63CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJQGI4DMMZSGU . You are receiving this because you authored the thread.Message ID: @.***>

vistad avatar Feb 25 '24 16:02 vistad

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 25 '24 23:04 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar May 03 '24 23:05 github-actions[bot]