Ryuu - a Japanese dragon
Tags: rakulang, l10n, japanese
Published: 2024-01-30 18:30:58

> A follow up to [the Welsh dragon](https://dev.to/finanalyst/creating-a-new-programming-language-draig-503p). 


## Table of Contents
[Firing up another localisation](#firing-up-another-localisation)  
[Steps to Ryuu](#steps-to-ryuu)  
[Comments on the Raku program](#comments-on-the-raku-program)  
[More generally about localisation of coding](#more-generally-about-localisation-of-coding)  
[If you want to make Ryuu better?](#if-you-want-to-make-ryuu-better?)  

----
## Firing up another localisation
In my previous blog about Y Ddraig, I created a localisation of the Raku Language in Welsh. During a recent conversation, someone mentioned there may be interest in a Japanese localisation, so I thought I would try the same techniques.

> I do not speak or read or have ever studied Japanese. The localisation given below will be about as clunky and awkward as any can be. I imagine there may be some hilarious stupidities as well.

So to be clear, this article is about a proof of concept rather than a real effort to create a production-ready program.

However, it took me 40 minutes from start to finish, including setting up [the github repo](https://github.com/finanalyst/rakuast-L10N-JA).

Since I like dragons, I named the Japanese cousin to Raku 'Ryuu'. It's a whimsy, not to be treated with much seriousness.

## Steps to Ryuu
Basically I created a github repo, copied my existing [Welsh localisation](https://github.com/finanalyst/rakuast-L10N-CY) and changed **CY** to **JA**, and **draig** to **ryuu**.

Within the `automation/` directory I used the translation technique explained for Welsh to create the `JA` file from the template. The `translated.txt` file needed some manual cleaning, because the English word _for_ has multiple Japanese equivalents. I chose one more or less at random. In addition, Google translate did some strange things to the order of words and numbers in a line.

After adapting the files in the `bin/` directory, and installing the distribution with Raku's `zef` utility, I ran `tr2ryuu` on the Raku program `simple.raku`.

A comment about my Welsh blog was that the program in Y Ddraig was not all in Welsh. And here the program is not all in Japanese.

Remember that the user-facing part of a program will be in the language of the user, in this case it is English. However, the coder-facing part of the program will be in the language of the coder. Below, the coder interface is in Japanese (or rather my ham-fisted attempt at Japanese).

The following is the result (which I put in a file called simple.ryuu):

```
私の $choice;
私の $continue;
私の @bad = <damn stupid nutcase>;
リピート {
    $choice = プロンプト "Type something, like a number, or a string: ";
    言う "You typed in ｢" ~ ($choice ~~ 任意(@bad) ?? "*" × $choice.文字 !! $choice) ~ "｣";
    与えられた $choice {
        いつ "dragon" {
            言う "which is 'draig' in Welsh"
        }
        いつ 任意(@bad) {
            言う "wash your mouth with soap"
        }
        いつ IntStr {
            言う "which evaluates to an integer ", $choice
        }
        いつ RatStr {
            言う "which evaluates to a rational number ", $choice
        }
        デフォルト {
            言う "which does not evaluate to a number "
        }
    }
    $continue = プロンプト "Try again? If not type N: "
} まで $continue 当量 任意(<N n>)

```
What is amazing to me is that when I ran `ryuu simple.ryuu `, the program ran without error.

## Comments on the Raku program
The `simple.raku` program is obviously trivial, but what I wanted to show are some interesting Raku features. Note how I created an array of words with `@bad = <damn stupid nutcase>; `, and then later I tested to see whether an input word was one of the array elements.

The Raku idiom `いつ 任意(@bad) ` or in English `when any( @bad )` compares the topic variable, in this case the input value, with each array element and creates a junction of Boolean results. The 'any' effectively `or`'s the result to collapse the junction.

Junctions are not common in programming languages, so I thought if there would be problems, then it would be there. So I was surprised to find my Raku program works without error in another language.

## More generally about localisation of coding
All the major coding languages are in English. There are, however, coders from all over the world, and the majority of those from non-English speaking nations would have needed to learn English before (or at the same time as) they learnt coding.

We are thus creating a new technological elite: those who can understand English (or some subset of it), and those who cannot. The more coding becomes an essential part of life, the greater the ability divide between coders (who speak English) and non-coders will become.

The aim of localising a programming language is to provide an entry into coding in a form that is more accessible to every human being, whatever their natural language.

However, the aim of this approach is not to eliminate English at every level of complexity, but to provide a sufficiently rich language for most normal coding and educational needs.

In addition, by having a canonical language (Raku, which is based on English) into which all localised languages can be translated, what we get is a universal auxiliary language together with a universality of being able to code.

Having a single auxiliary language means that a non-English speaking person writing in a localised coding language can translate the program with the problem into Raku, have a developer on the other side of the globe find the problem, and suggest a solution in code, then for that solution to be translated back into the local language.

Naturally, a person who wants to learn more about coding, or who needs to delve deeper into the workings of a module, will need to learn English. Learning wider to learn deeper is a normal part of the educational experience.

## If you want to make Ryuu better?
Ryuu or however it should be called, absolutely is in need of Tender loving care. Please feel free to use the github issues or PR processes to suggest better translations.

At some stage, Ryuu will join the official Raku localisations.