<head>
    <title>Evan Pratten</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />

    <!-- Begin Jekyll SEO tag v2.6.1 -->
<title>How I set up ひらがな input on my laptop | Evan Pratten</title>
<meta name="generator" content="Jekyll v3.8.6" />
<meta property="og:title" content="How I set up ひらがな input on my laptop" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="I3wm makes everything 10x harder than it should be" />
<meta property="og:description" content="I3wm makes everything 10x harder than it should be" />
<link rel="canonical" href="http://0.0.0.0:4000/blog/2019/08/12/setting-up-ja" />
<meta property="og:url" content="http://0.0.0.0:4000/blog/2019/08/12/setting-up-ja" />
<meta property="og:site_name" content="Evan Pratten" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2019-08-12T15:40:00-04:00" />
<script type="application/ld+json">
{"headline":"How I set up ひらがな input on my laptop","dateModified":"2019-08-12T15:40:00-04:00","datePublished":"2019-08-12T15:40:00-04:00","@type":"BlogPosting","mainEntityOfPage":{"@type":"WebPage","@id":"http://0.0.0.0:4000/blog/2019/08/12/setting-up-ja"},"url":"http://0.0.0.0:4000/blog/2019/08/12/setting-up-ja","description":"I3wm makes everything 10x harder than it should be","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->



    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="/assets/css/main.css">
    <link rel="stylesheet" href="/assets/css/github-syntax.css">
    <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono:400,400i|IBM+Plex+Sans:100,100i,400,400i,700,700i" rel="stylesheet">
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>

<body>

    <div class="site-ctr">
        <!-- Navbar -->
        <nav class="navbar navbar-dark sticky-top bg-dark navbar-expand-lg">
    <!-- Navbar content -->
    <!-- <div class="container"> -->
    <a class="navbar-brand" href="/">Evan Pratten</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
        <div class="navbar-nav ml-auto">
            <a class="nav-item nav-link" href="/blog">Blog</a>
            <a class="nav-item nav-link" href="/projects">Projects</a>
            <!-- <a class="nav-item nav-link" href="/documentation">Documentation</a> -->
            <a class="nav-item nav-link" href="/about">About</a>
        </div>
        <!-- </div> -->
    </div>
</nav>
        <!-- <div style="height:5vh"></div> -->

        <!-- Header -->
        <!-- <div class="header">
            <div class="container">
                <div class="content">
                </div>
            </div>
            <div class="header-gap"></div>
        </div> -->

        <div class="reactive-bg">
            <div class="post container">
                <h1>How I set up ひらがな input on my laptop

                </h1>
                <h4>I3wm makes everything 10x harder than it should be

                </h4>
                <hr>
                <p><em>2019-08-12 15:40:00 -0400
                        
                    </em></p>

                <br>

                <p>I am currently working with <a href="https://en.wikipedia.org/wiki/Hiragana">ひらがな</a>, <a href="https://en.wikipedia.org/wiki/Katakana">かたかな</a>, and, <a href="https://en.wikipedia.org/wiki/Kanji">かんじ</a> in some projects, and needed a more reliable way to write than running some <a href="https://en.wikipedia.org/wiki/Romanization_of_Japanese">romaji</a> through an online translator. So, this post will detail what I did to enable native inputs on my laptop. This guide is specifically for <a href="https://i3wm.org/">i3wm</a>, because it does not obey system settings for languages and inputs.</p>

<h2 id="adding-font-support-to-linux">Adding font support to Linux</h2>
<p>Firstly, we need fonts. Depending on your system, these may already be installed. For Japanese, I only used <code class="highlighter-rouge">vlgothic</code>, so here in the package for it:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install fonts-vlgothic
</code></pre></div></div>

<h2 id="language-support">Language support</h2>
<p>Im not sure if this matters, but I have seen other people do it, so why not be safe?</p>

<p>I am currently running a stock Ubuntu <a href="">18.04</a> base, which means that everything is pre-configured for Gnome. To set language support in Gnome, pull up the settings panel:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># This line fixes some compatibility issues between </span>
<span class="c"># Gnome and I3 when launching the settings menu. </span>
<span class="c"># I recommend aliasing it.</span>
<span class="nb">env </span><span class="nv">XDG_CURRENT_DESKTOP</span><span class="o">=</span>GNOME gnome-control-center
</code></pre></div></div>

<p><img src="/assets/images/language-settings.png" alt="Gnome language settings"></p>

<p>Next, go to <em>Settings &gt; Language and Region &gt; Input Sources</em>, and click on <em>Manage Installed Languages</em>.
This will bring up a window where you can select a new language to install. From here, I clicked on <em>Install / Remove Language</em>.</p>

<p><img src="/assets/images/language-installation.png" alt="Language installation panel"></p>

<p>In this list, I just selected the languages I wanted (English and Japanese), and applied my changes. You may be asked to enter your password while installing the new languages. Once installation is complete, log out, and in again.</p>

<p>With the new language support installed, return to the <em>Input Sources</em> settings, and press the <code class="highlighter-rouge">+</code> button to add a new language. From here, search the language you want (it may be under <em>Other</em>) and select it. For Japanese, select the <code class="highlighter-rouge">mozc</code> variant.</p>

<p>Gnome’s language settings are now configured. If you are using Gnome (not I3), you can stop here.</p>

<h2 id="configuring-ibus">Configuring ibus</h2>
<p>Don’t get me wrong, I love I3wm, but sometimes it’s configurability drives me crazy.</p>

<p>After searching through various forums and wikis looking for an elegant way to switch languages in I3, I found a link to an <a href="https://wiki.archlinux.org/index.php/IBus">ArchWiki page</a> at the bottom of a mailing list (I blame Google for not showing this sooner). It turns out that a program called <code class="highlighter-rouge">ibus</code> is exactly what I needed. Here is how to set it up:</p>

<p>Remember <code class="highlighter-rouge">mozc</code> from above? If you are not using it, this package may not work. Search for the appropriate <code class="highlighter-rouge">ibus-</code> package for your selected language(s).</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Install ibus-mozc for Japanese (mozc)</span>
<span class="nb">sudo </span>apt <span class="nb">install </span>ibus-mozc
</code></pre></div></div>

<p>Now that <code class="highlighter-rouge">ibus</code> is installed, run the setup script:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ibus-setup
</code></pre></div></div>

<p><img src="/assets/images/ibus-general.png" alt="Ibus settings"></p>

<p>From here, set your shortcut to something not used by I3 (I chose <code class="highlighter-rouge">CTRL+Shift+Space</code>, but most people prefer <code class="highlighter-rouge">Alt+Space</code>), and enable the system tray icon.
Now, go to the <em>Input Method</em> settings.</p>

<p><img src="/assets/images/ibus-input.png" alt="Ibus input settings"></p>

<p>From here, press the <code class="highlighter-rouge">+</code>, and add your language(s).</p>

<h2 id="configuring-profile">Configuring .profile</h2>
<p>According to the Wiki page, I needed to add the following to my <code class="highlighter-rouge">~/.profile</code>:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Language support</span>
<span class="nb">export </span><span class="nv">GTK_IM_MODULE</span><span class="o">=</span>ibus
<span class="nb">export </span><span class="nv">XMODIFIERS</span><span class="o">=</span>@im<span class="o">=</span>ibus
<span class="nb">export </span><span class="nv">QT_IM_MODULE</span><span class="o">=</span>ibus
ibus-daemon <span class="nt">-d</span> <span class="nt">-x</span>
</code></pre></div></div>

<p>It turns out that this <a href="https://github.com/ibus/ibus/issues/2020">causes issues with some browsers</a>, so I actually put <em>this</em> in my <code class="highlighter-rouge">~/.profile</code> instead:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Language support</span>
<span class="nb">export </span><span class="nv">GTK_IM_MODULE</span><span class="o">=</span>xim
<span class="nb">export </span><span class="nv">XMODIFIERS</span><span class="o">=</span>@im<span class="o">=</span>ibus
<span class="nb">export </span><span class="nv">QT_IM_MODULE</span><span class="o">=</span>xim
ibus-daemon <span class="nt">-drx</span>
</code></pre></div></div>

<p>Now, log out and in again to let ibus properly start again, and there should now be a new applet in your bar for language settings.</p>

<h2 id="workflow">Workflow</h2>
<p><code class="highlighter-rouge">ibus</code> runs in the background and will show an indication of your selected language upon pressing the keyboard shortcut set in the <a href="#configuring-ibus">setup tool</a>. For languages like Japanese, where it’s writing systems do not use the English / Latin-based alphabets, <code class="highlighter-rouge">ibus</code> will automatically convert your words as you type (this behavior will be different from language to language).</p>

<p>An example of this is as follows. I want to write the word <em>Computer</em> in Japanese (Katakana to be exact). I would switch to <code class="highlighter-rouge">mozc</code> input, and start typing the romaji word for computer, <em>Pasokon</em>. This will automatically be converted to Hiragana, <em>ぱそこん</em>. <em>Computer</em> is not a word that one would write in Hiragana as far as I know, so Katakana would be a better choice. To convert this word, I just press <code class="highlighter-rouge">Space</code> (This is indicated in the bottom left of my screen by <code class="highlighter-rouge">ibus</code>), and I now have <em>パソコン</em>, the Katakana word for <em>Computer</em>!</p>

<hr>

<h4 id="after-note-languages">After Note: Languages</h4>
<p>In case you can’t tell, English is my native language. If I messed up my spelling or context with the small amount of Japanese in this post, <a href="/about#chat-with-me">let me know</a>!</p>

            </div>
        </div>

    </div>
    <!-- <div id="particles-js"></div> -->

<div class="container foot" style="text-align:center;">
    <br>
    <span class="site-info">
        Site design by: <a href="https://retrylife.ca">Evan Pratten</a> |

        This site was last updated at: 2019-11-17 10:22:12 -0500
    </span>
</div>

<!-- Brython -->
<script src="/assets/js/brython.js"></script>
<script src="/assets/js/brython_stdlib.js"></script>

<script>
    function startPY(){
        
        brython();
        console.log("Started Python")
    }

    window.onload = startPY;
</script>


<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<!-- Offsets for links -->
<script>
    (function ($, window) {
        var adjustAnchor = function () {

            var $anchor = $(':target'),
                fixedElementHeight = 100;

            if ($anchor.length > 0) {

                window.scrollTo(0, $anchor.offset().top - fixedElementHeight);
            }

        };

        $(window).on('hashchange load', function () {
            adjustAnchor();
        });

    })(jQuery, window);
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-74118570-2"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());

    gtag('config', 'UA-74118570-2');
</script>


<!-- particles -->
<script>
    var body = document.body

    var particles = document.getElementById("particles-js")

    particles.style.height  = body.scrollHeight + "px"

    console.log(body.scrollHeight)
</script>
<script src="/assets/js/particles.min.js"></script>
<script>
    particlesJS.load('particles-js', '/assets/js/particles.json', function () {
        console.log('callback - particles.js config loaded');
    });
</script>

<!-- Twitter embeds -->
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> 
    

</body>