README

English Language Module for Raku

A Raku module that provides UK English spelling variants alongside US English spellings, allowing developers to write code using their preferred spelling conventions while maintaining full compatibility.

Overview

This module bridges the spelling gap between UK and US English in programming. Rather than forcing developers to adapt to one spelling convention, it provides both variants for common programming terms, making code more natural to write for developers from different English-speaking regions.

Installation

zef install English

Or install from source:

zef install .

Quick Start

use English;

# Both UK and US spellings work identically
say capitalise("hello world");    # UK spelling -> Hello World
say capitalize("hello world");    # US spelling -> Hello World

# Mathematical operations
my $result = maths_add(5, 3);     # UK: "maths" -> 8
my $same = math_add(5, 3);        # US: "math" -> 8

# Boolean values
if yes { say "Affirmative!" }     # British -> True
if aye { say "Och aye!" }         # Scottish -> True

Features

String Functions

All string functions have both UK and US variants:

UK SpellingUS SpellingDescription
capitalisecapitalizeConvert string to title case
lower_caselowercaseConvert to lowercase
upper_caseuppercaseConvert to uppercase
centrecenterCenter text with padding
colour_codecolor_codeGet ANSI color codes
normalisenormalizeClean and standardize strings
emphasiseemphasizeAdd emphasis markers
serialiseserializeConvert data to string format
analyse_textanalyze_textGet text statistics

Example Results

  • capitalise("london bridge") โ†’ "London Bridge"

  • upper_case("whisper") โ†’ "WHISPER"

  • centre("UK", 10) โ†’ " UK "

  • center("US", 10, "*") โ†’ "US"

  • colour_code("red") ~ "Error!" ~ "\e[0m" โ†’ Displays "Error!" in red

  • normalise(" Hello World ") โ†’ "hello-world"

  • analyse_text("Hello\nWorld") โ†’ {chars => 11, words => 2, lines => 2}

Mathematical Functions

Mathematical functions use "maths" (UK) vs "math" (US):

UK SpellingUS SpellingDescription
maths_addmath_addAddition
maths_subtractmath_subtractSubtraction
maths_multiplymath_multiplyMultiplication
maths_dividemath_divideDivision
maths_roundmath_roundRound to nearest integer
maths_floormath_floorRound down
maths_ceilingmath_ceilingRound up
maths_absmath_absAbsolute value
maths_sqrtmath_sqrtSquare root
maths_powermath_powerExponentiation

Example Results

  • maths_add(10, 5) โ†’ 15

  • math_multiply(3, 7) โ†’ 21

  • maths_round(3.7) โ†’ 4

  • math_floor(3.7) โ†’ 3

  • maths_ceiling(3.2) โ†’ 4

  • maths_sqrt(144) โ†’ 12

  • math_power(2, 8) โ†’ 256

  • maths_abs(-42) โ†’ 42

Boolean Values

The module provides regional variants for boolean values:

BritishScottishValue
yesayeTrue
nonayFalse

Example Results

  • Conditions: if yes { ... } or if aye { ... } โŸถ Code executes

  • Negation: unless no { ... } or unless nay { ... } โŸถ Code executes

  • Boolean operations:

    • yes && aye โŸถ True

    • no || nay โŸถ False

    • !nay โŸถ True

Design Philosophy

This module follows several key principles:

  1. Equal Treatment: Neither UK nor US spelling is treated as "primary" - both are first-class citizens

  2. Functional Implementation: Every exported function is fully implemented, no placeholders

  3. Consistency: Function pairs always behave identically regardless of spelling variant used

  4. Practical Focus: Includes commonly used functions where UK/US spelling differences occur

Use Cases

  • International Teams: Teams with members from different English-speaking countries can use their preferred spellings

  • Educational Settings: Students can use familiar spellings while learning programming

  • Code Migration: Gradually transition codebases between spelling conventions

  • Personal Preference: Individual developers can choose their preferred style

Complete Function Reference

String Manipulation

  • capitalise/capitalize($str) - Convert to title case

  • lower_case/lowercase($str) - Convert to lowercase

  • upper_case/uppercase($str) - Convert to uppercase

  • centre/center($str, $width, $fill = ' ') - Center with padding

  • normalise/normalize($str) - Clean and standardize

  • emphasise/emphasize($str) - Add emphasis (text)

  • serialise/serialize($data) - Convert to string representation

String Utilities

  • colour_code/color_code($name) - ANSI color codes

    • Supports: red, green, blue, grey/gray

  • analyse_text/analyze_text($text) - Returns hash with:

    • chars: Character count

    • words: Word count

    • lines: Line count

Mathematics

  • maths_add/math_add($a, $b) - Addition (a + b)

  • maths_subtract/math_subtract($a, $b) - Subtraction (a - b)

  • maths_multiply/math_multiply($a, $b) - Multiplication (a ร— b)

  • maths_divide/math_divide($a, $b) - Division (a รท b)

  • maths_round/math_round($n) - Round to nearest integer

  • maths_floor/math_floor($n) - Round down

  • maths_ceiling/math_ceiling($n) - Round up

  • maths_abs/math_abs($n) - Absolute value

  • maths_sqrt/math_sqrt($n) - Square root

  • maths_power/math_power($base, $exp) - Exponentiation (base^exp)

Boolean Constants

  • yes = aye = True

  • no = nay = False

Testing

The module includes a comprehensive test suite to ensure all functions work correctly:

# Run all tests
raku t/run-all-tests.raku

# Or run individual test files
raku t/01-basic.rakutest
raku t/02-text-processing.rakutest

The tests verify all functionality including:

  • String manipulation functions

  • Math/Maths functions

  • Boolean values and operations

  • Text processing utilities

Contributing

https://github.com/raku-multilingual/raku-english

License

Artistic License 2.0

Author

Danslav Slavenskoj

See Also

English v0.0.4

English language programming for Raku - UK and US spelling variants

Authors

  • Danslav Slavenskoj

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • English

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.