Mottie/Keyboard

Czech diacritics

vaclavvanik opened this issue · 2 comments

Hi @Mottie,

could you help me, why diacritics combo is not working? Default combos like "a turns into ä. I am unable to setup czech conventions. Eg caron c turning into č.

My current setup is:

$('.keyboard-normal').keyboard({
    layout: 'ms-Czech',
    autoAccept: true,
    usePreview: false,
    initialized : function(e, keyboard, el) {
        keyboard.regex = /([`\'~\^\"ao\u02c7\u00b4])([a-z])/mig;
    },
    combos: {
        // caron
        '\u02c7': { e: '\u011b', E: '\u011a', s: '\u0161', S: '\u0160', c: '\u010d', C: '\u010c', r: '\u0159',
                R: '\u0158', z: '\u017e', Z: '\u017d', d: '\u010f', D: '\u010e', t: '\u0165', T: '\u0164', n: '\u0148', N: '\u0147'},
        // acute
        '\u00b4': { a: '\u00e1', A: '\u00c1', e: '\u00e9', E: '\u00c9', i: '\u00ed', I: '\u00cd', o: '\u00f3',
                     O: '\u00d3', u: '\u00fa', U: '\u00da', y: '\u00fd', Y: '\u00dd'}
    }
});

Thanks for your advise.

Hi @vaclavvanik!

It looks like this is a bug in this library with setting the keyboard.regex. Since the layout has the language is set to cs and it can't find that language file, it's reverting the regex back to the default stored in $.keyboard.comboRegex.

To get around that for now, set your regex in $.keyboard.comboRegex (demo):

$(function() {
  $.keyboard.comboRegex = /([`\'~\^\"ao\u02c7\u00b4])([a-z])/gim;

  $("#keyboard")
    .keyboard({
      layout: "ms-Czech",
      autoAccept: true,
      usePreview: false,
      combos: {
        // caron
        ˇ: {
          e: "\u011b",
          E: "\u011a",
          s: "\u0161",
          S: "\u0160",
          c: "\u010d",
          C: "\u010c",
          r: "\u0159",
          R: "\u0158",
          z: "\u017e",
          Z: "\u017d",
          d: "\u010f",
          D: "\u010e",
          t: "\u0165",
          T: "\u0164",
          n: "\u0148",
          N: "\u0147"
        },
        // acute
        "\u00b4": {
          a: "\u00e1",
          A: "\u00c1",
          e: "\u00e9",
          E: "\u00c9",
          i: "\u00ed",
          I: "\u00cd",
          o: "\u00f3",
          O: "\u00d3",
          u: "\u00fa",
          U: "\u00da",
          y: "\u00fd",
          Y: "\u00dd"
        }
      }
    })
    // activate the typing extension
    .addTyping({
      showTyping: true,
      delay: 250
    });
});

And it would be of great help to me and others if you would consider contributing a translated language file for Czech. I noticed I didn't have one in place, so in the next release I'll fix this bug and I'll include a language/cs.untranslated.js file.

New release is now available!

You can now include the cs.untranslated.js file and not have to include the comboRegex or combo while initializing.