@sharpee/lang-en-us
v5.4.1
Published
English language implementation for Sharpee IF Engine
Downloads
1,990
Readme
@sharpee/lang-en-us
English (US) language plugin for the Sharpee Interactive Fiction engine.
Installation
npm install @sharpee/lang-en-usUsage
In a Story
import { EnglishLanguageProvider } from '@sharpee/lang-en-us';
// Register with the engine during story setup
const languageProvider = new EnglishLanguageProvider();In most cases you don't construct this directly — the build toolchain and
clients select it automatically when a story's config sets language: 'en-US',
passing it to the engine alongside the matching parser.
Features
- Complete verb mappings for all standard IF actions
- English language data and helpers:
- Word lists (directions, prepositions, determiners, articles, etc.)
- Lemmatization (word normalization)
- Abbreviation expansion
- Phrase-template parsing (ADR-192)
- List formatting ("a, b, and c")
- Message templates for all actions and events
- Proper article handling (a/an/the)
- Pluralization support
- Direction abbreviations (n/s/e/w)
Architecture
This package implements the ParserLanguageProvider contract from @sharpee/if-domain:
EnglishLanguageProviderprovides verbs, words, message templates, and the formatter chain (ADR-095/ADR-158).- The matching grammar/parser lives in the companion
@sharpee/parser-en-uspackage.
Extending
You can extend the English language provider for regional variants or custom games — override message templates and add verbs/words in the subclass:
import { EnglishLanguageProvider } from '@sharpee/lang-en-us';
class BritishEnglishProvider extends EnglishLanguageProvider {
readonly languageCode = 'en-GB';
readonly languageName = 'English (UK)';
// Override or add templates, verbs, and words as needed.
}Data Exports
The package exports its data for customization:
englishWords- Word lists (articles, prepositions, etc.)irregularPlurals- Irregular plural mappingsabbreviations- Common abbreviationsdirectionMap,cardinalNumbers,ordinalNumbers- Movement and number vocabulary
License
MIT
