Search code examples
htmlcssfontstextareafont-face

how can i change default language and font of html textarea and disable other languages and font?


I have a comment box(textarea).I want to change default language of the textarea and default font at first without the client be able to change the language or font. http://www.haveeru.com.mv/dhivehi/business/126135 go to this link and click Post comment button below.a textarea will appear.it is exactly how i wish to do.same languge(divehi) same font.i tried in many ways.but it use english at start.thank you.


Solution

  • They are using their own font, every time you want to see what font/size/color someone is using look at view-source, in this case the css

    eg:

    @charset "utf-8";
    @font-face {
        font-family: "MV Waheed";
        src: local("MV Waheed"), url(/dhivehi/fonts/mv_waheed.otf) format("opentype");
    }
    @font-face {
        font-family: "MV Faseyha";
        src: local("MV Faseyha"), url(/dhivehi/fonts/mv_faseyha.otf) format("opentype");
    } 
    

    or Javascript extend

    (function ($) {
        $.fn.thaana = function (options) {
            var settings = {
                keyboard: 'phonetic'
            };
            return this.each(function () {
                if (options) {
                    $.extend(settings, options);
                }
                var keyboards = {
                    'phonetic': {
                        33: '!',
                        34: '"',
                        35: '#',
                        36: '$',
                        37: '%',
                        38: '&',
                        39: '\'',
                        40: ')',
                        41: '(',
                        42: '*',
                        43: '+',
                        44: '،',
                        45: '-',
                        46: '.',
                        47: '/',
                        58: ':',
                        59: '؛',
                        60: '>',
                        61: '=',
                        62: '<',
                        63: '؟',
                        64: '@',
                        65: 'ާ',
                        66: 'ޞ',
                        67: 'ޝ',
                        68: 'ޑ',
                        69: 'ޭ',
                        70: 'ﷲ',
                        71: 'ޣ',
                        72: 'ޙ',
                        73: 'ީ',
                        74: 'ޛ',
                        75: 'ޚ',
                        76: 'ޅ',
                        77: 'ޟ',
                        78: 'ޏ',
                        79: 'ޯ',
                        80: '÷',
                        81: 'ޤ',
                        82: 'ޜ',
                        83: 'ށ',
                        84: 'ޓ',
                        85: 'ޫ',
                        86: 'ޥ',
                        87: 'ޢ',
                        88: 'ޘ',
                        89: 'ޠ',
                        90: 'ޡ',
                        91: ']',
                        92: '\\',
                        93: '[',
                        94: '^',
                        95: '_',
                        96: '`',
                        97: 'ަ',
                        98: 'ބ',
                        99: 'ޗ',
                        100: 'ދ',
                        101: 'ެ',
                        102: 'ފ',
                        103: 'ގ',
                        104: 'ހ',
                        105: 'ި',
                        106: 'ޖ',
                        107: 'ކ',
                        108: 'ލ',
                        109: 'މ',
                        110: 'ނ',
                        111: 'ޮ',
                        112: 'ޕ',
                        113: 'ް',
                        114: 'ރ',
                        115: 'ސ',
                        116: 'ތ',
                        117: 'ު',
                        118: 'ވ',
                        119: 'އ',
                        120: '×',
                        121: 'ޔ',
                        122: 'ޒ',
                        123: '}',
                        124: '|',
                        125: '{',
                        126: '~'
                    },
                    'typewriter': {
                        33: '!',
                        34: '؛',
                        35: '#',
                        36: '$',
                        37: '%',
                        38: '&',
                        39: 'ﷲ',
                        40: ')',
                        41: '(',
                        42: '*',
                        43: '+',
                        44: 'ށ',
                        45: '-',
                        46: 'ޓ',
                        47: 'ޯ',
                        58: 'ޡ',
                        59: 'ފ',
                        60: '\\',
                        61: '=',
                        62: 'ޞ',
                        63: '؟',
                        64: '@',
                        65: '<',
                        66: 'ޟ',
                        67: 'ޏ',
                        68: '.',
                        69: '“',
                        70: '،',
                        71: '"',
                        72: 'ޥ',
                        73: 'ޣ',
                        74: 'ޢ',
                        75: 'ޘ',
                        76: 'ޚ',
                        77: 'ޝ',
                        78: 'ޛ',
                        79: 'ޠ',
                        80: 'ޙ',
                        81: '×',
                        82: '/',
                        83: '>',
                        84: ':',
                        85: 'ޜ',
                        86: 'ޗ',
                        87: '’',
                        88: 'ޕ',
                        89: 'ޤ',
                        90: 'ޖ',
                        91: 'ލ',
                        92: ']',
                        93: '[',
                        94: '^',
                        95: '_',
                        96: '`',
                        97: 'ި',
                        98: 'ޅ',
                        99: 'ސ',
                        100: 'ް',
                        101: 'ާ',
                        102: 'ަ',
                        103: 'ެ',
                        104: 'ވ',
                        105: 'މ',
                        106: 'އ',
                        107: 'ނ',
                        108: 'ކ',
                        109: 'ބ',
                        110: 'ދ',
                        111: 'ތ',
                        112: 'ހ',
                        113: 'ޫ',
                        114: 'ީ',
                        115: 'ު',
                        116: 'ޭ',
                        117: 'ރ',
                        118: 'ޔ',
                        119: 'ޮ',
                        120: 'ޑ',
                        121: 'ގ',
                        122: 'ޒ',
                        123: '÷',
                        124: '}',
                        125: '{',
                        126: '~'
                    }
                };
                $(this).keypress(function (e) {
                    if (e.ctrlKey) {
                        return true;
                    } else if (e.which == 16) {
                        return true;
                    } else {
                        if (keyboards[settings.keyboard][e.which]) {
                            var current, sTop = $(this).scrollTop();
                            if ($(this).get(0).selectionStart || $(this).get(0).selectionStart == 0) {
                                var selected = $(this).get(0).selectionStart + 1;
                                current = $(this).val().substring(0, $(this).get(0).selectionStart) + keyboards[settings.keyboard][e.which] + $(this).val().substring($(this).get(0).selectionEnd, $(this).val().length);
                                $(this).val(current);
                                $(this).get(0).setSelectionRange(selected, selected);
                                $(this).get(0).focus();
                            } else if (document.selection) {
                                var selected = document.selection.createRange();
                                selected.text = keyboards[settings.keyboard][e.which];
                                $(this).focus();
                            } else {
                                current = $(this).val();
                                current += keyboards[settings.keyboard][e.which];
                                $(this).val(current);
                            }
                            $(this).scrollTop(sTop);
                            return false;
                        } else {
                            return true;
                        }
                    }
                });
            });
        };
    })(jQuery);
    
    $(selector).thaana();
    

    JSFiddle

    It's not that they can change the language, but if you change the font, and the font produces the language behavior.

    Take a look at Google WebFonts