Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set language #355

Open
jolleman opened this issue Jun 3, 2015 · 9 comments
Open

Set language #355

jolleman opened this issue Jun 3, 2015 · 9 comments

Comments

@jolleman
Copy link

jolleman commented Jun 3, 2015

How do i set a default keyset language?

I want to set the default keyset to swedish.

i tried with language : 'sv', but it doesnt work.

Here is my code:

<script>
    $(function(){

        var t,
            o = '',
            layouts = [];

        // Change display language, if the definitions are available
        showKb = function(layout){
            var kb = $('#multi').getkeyboard();
            kb.options.layout = layout;
            // true flag causes a keyboard refresh
            kb.reveal(true);
        };

        $.each(jQuery.keyboard.layouts, function(i, l){
            if (l.name) {
                layouts.push([i,l.name]);
            }
        });
        // sort select options by language name, not
        layouts.sort( function( a, b ) {
            return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
        });
        $.each(layouts, function(i, l){
            o += '<option value="' + l[0] + '">' + l[1] + '</option>';
        });

            $('#multi').keyboard({
                layout: 'qwerty',
                usePreview: false,
                autoAccept: 'true',
                language: 'sv',
                css: {
        // input & preview
                input: 'form-control input-sm',
        // keyboard container
                container: 'structure', // jumbotron
        // default state
                buttonDefault: 'btn btn-default',
        // hovered button
                buttonHover: 'btn-primary',
        // Action keys (e.g. Accept, Cancel, Tab, etc);
        // this replaces "actionClass" option
                buttonAction: 'active',
        // used when disabling the decimal button {dec}
        // when a decimal exists in the input area
        buttonDisabled: 'disabled'
    }

            })
        // activate the typing extension
        .addTyping({
            showTyping: true,
            delay: 200
        })
        .previewKeyset();

        $('#lang')
            .html(o)
            .change(function(){
                var kb = $('#multi'),
                    $this = $(this),
                    $opt = $this.find('option:selected'),
                    layout = $this.val();
                $('h2').text( $opt.text() );
                showKb( layout );
            }).trigger('change');

    });
    </script>

Any help would be appreciated.

Regards Joel

@Mottie
Copy link
Owner

Mottie commented Jun 3, 2015

Hi @jolleman!

This project is still in it's infancy and although it has support for languages, it is lacking the actual translations. If you look at the swedish language definitions, you'll see that it's still all in English.

I would appreciate any help with translations and/or feedback.

Thanks!
Rob

@jolleman
Copy link
Author

jolleman commented Jun 4, 2015

Is this a issue when i use the keyboard-layouts-greywyvern.min.js library?

Regards Joel

@Mottie
Copy link
Owner

Mottie commented Jun 4, 2015

None of the greywyvern layouts include the language definitions... I haven't thought about how to combine the original layouts, Microsoft layouts and greywyvern layouts and include the language definitions. What should someone do if they want to use their own? Maybe I should separate out the language definitions from the layouts...

@Mottie
Copy link
Owner

Mottie commented Jun 6, 2015

I just pushed an update where all the language files have been separated from the layout files.

During a grunt build, the translated language files are added to the following files:

  • "layouts/keyboard-layouts-combined.js"
  • "layouts/keyboard-layouts-microsoft.js"
  • "dist/layouts/keyboard-layouts-combined.min.js"
  • "dist/layouts/keyboard-layouts-greywyvern.min.js"
  • "dist/layouts/keyboard-layouts-microsoft.min.js"

I would really appreciate it if you would be willing and able to add a translation for any of language files.

@klausenbusk
Copy link

I'm trying to using the danish keyboard layout, which I understand was added in 1.8.6a.
But it still use the default layout, can you see what I do wrong?

This is my current code:

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
    <link href="http://127.0.0.1:8000/Keyboard/css/keyboard.css" rel="stylesheet">
    <script src="http://127.0.0.1:8000/Keyboard/js/jquery.keyboard.js"></script>
</head>
<body>
    <textarea></textarea>
    <textarea></textarea>

<script>
$(":input").keyboard({ language: ["da"], layout: 'qwerty', usePreview: false, autoAccept: true}).addTyping();
</script>
</body>
</html>

@Mottie
Copy link
Owner

Mottie commented Nov 6, 2016

Hi @klausenbusk!

There is a Danish language file that needs to be loaded (see da.untranslated.js), but it is currently untranslated and will only show the English equivalent language.

@klausenbusk
Copy link

There is a Danish language file that needs to be loaded (see da.untranslated.js), but it is currently untranslated and will only show the English equivalent language.

That isn't the problem, the problem is that I can't use the Danish keyboard layout. That file only seems to contain "translation" of different important keys..

@klausenbusk
Copy link

klausenbusk commented Nov 6, 2016

The layout seems to be here, but I can't figure out how I use it.
https://github.com/Mottie/Keyboard/blob/master/layouts/danish.js

Edit: Stupid me, not sure why I didn't read the info in that file.. :/ Sorry for wasting your time ...

@Mottie
Copy link
Owner

Mottie commented Nov 6, 2016

No worries! I'm glad you are finding this plugin useful!

@Mottie Mottie mentioned this issue May 5, 2017
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants