Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ A selection of quality-of-life tools for use with [pre-commit](https://github.co
- [2.6.1 Configuration](#261-configuration)
- [`.pre-commit-config.yaml` Configuration](#pre-commit-configyaml-configuration-1)
- [Inline ignores](#inline-ignores)
- [The Dictionary](#the-dictionary)
- [3. Development](#3-development)
- [3.1 Testing](#31-testing)
- [3.1.1 Testing scheme](#311-testing-scheme)
Expand Down Expand Up @@ -381,6 +382,11 @@ def initialise(): # pragma: no americanise
```


##### The Dictionary

The default dictionary is stored in `src/americanise_hook/americanise_dictionary.py`. To add words, please open an MR on this repo.


## 3. Development

### 3.1 Testing
Expand Down
49 changes: 1 addition & 48 deletions src/americanise_hook/americanise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,7 @@
from typing import Union

from src._shared import print_diff, resolvers

DICTIONARY = {
# -se -> -ize
"characterise": "characterize",
"initialise": "initialize",
"instantiater": "instantiator",
"parametrise": "parametrize",
"prioritise": "prioritize",
"specialise": "specialize",
"organise": "organize",
# -yse -> -yze
"analyse": "analyze",
"catalyse": "catalyze",
# -our -> -or
"armour": "armor",
"behaviour": "behavior",
"colour": "color",
"flavour": "flavor",
"neighbour": "neighbor",
# -re -> -er
"centre": "center",
"fibre": "fiber",
"litre": "liter",
# -ae, -oe -> -e
"amoeba": "amoebae",
"anaesthesia": "anesthesia",
"caesium": "cesium",
# -ce -> -se
"defence": "defense",
# british uses "practice" as the noun and "practise" as the verb. US uses "practice" for both.
"practise": "practice",
# british uses "licence" as the noun and "license" as the verb. US uses "license" for both.
"licence": "license",
# -ge -> -g
"ageing": "aging",
"acknowledgement": "acknowledgment",
"judgement": "judgment",
# -ogue -> -og
"analogue": "analog",
"dialogue": "dialog",
# -l -> -ll
"fulfil": "fulfill",
"enrol": "enroll",
"skilful": "skillful",
# -ll -> -l
"labelled": "labeled",
"signalling": "signaling",
}
from src.americanise_hook.americanise_dictionary import DICTIONARY


def _copy_case(target_string: str, input_string: str) -> str:
Expand Down
51 changes: 51 additions & 0 deletions src/americanise_hook/americanise_dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) 2025-2026 Benjamin Mummery

"""The underlying dictionary for the Americanise hook."""

DICTIONARY = {
# -se -> -ize
"characterise": "characterize",
"initialise": "initialize",
"instantiater": "instantiator",
"parametrise": "parametrize",
"prioritise": "prioritize",
"specialise": "specialize",
"organise": "organize",
# -yse -> -yze
"analyse": "analyze",
"catalyse": "catalyze",
# -our -> -or
"armour": "armor",
"behaviour": "behavior",
"colour": "color",
"flavour": "flavor",
"neighbour": "neighbor",
# -re -> -er
"centre": "center",
"fibre": "fiber",
"litre": "liter",
# -ae, -oe -> -e
"amoeba": "amoebae",
"anaesthesia": "anesthesia",
"caesium": "cesium",
# -ce -> -se
"defence": "defense",
# british uses "practice" as the noun and "practise" as the verb. US uses "practice" for both.
"practise": "practice",
# british uses "licence" as the noun and "license" as the verb. US uses "license" for both.
"licence": "license",
# -ge -> -g
"ageing": "aging",
"acknowledgement": "acknowledgment",
"judgement": "judgment",
# -ogue -> -og
"analogue": "analog",
"dialogue": "dialog",
# -l -> -ll
"fulfil": "fulfill",
"enrol": "enroll",
"skilful": "skillful",
# -ll -> -l
"labelled": "labeled",
"signalling": "signaling",
}