Rand Stats

English

zef:slavenskoj

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

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

Boolean Values

The module provides regional variants for boolean values:

BritishScottishValue
yesayeTrue
nonayFalse

Example Results

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

Complete Function Reference

String Manipulation

String Utilities

Mathematics

Boolean Constants

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:

Contributing

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

License

Artistic License 2.0

Author

Danslav Slavenskoj

See Also