Module: Locallingo::Quality::BritishSpellings

Defined in:
lib/locallingo/quality/british_spellings.rb

Overview

American -> British spelling drift, applied to the source locale only. Opt-in via quality.british_spellings: true. Ported from zazu/app.

Constant Summary collapse

SPELLINGS =
{
  "organization" => "organisation",
  "color" => "colour",
  "center" => "centre",
  "favor" => "favour",
  "honor" => "honour",
  "labor" => "labour",
  "analyze" => "analyse",
  "optimize" => "optimise",
  "recognize" => "recognise",
  "realize" => "realise",
  "apologize" => "apologise",
  "authorize" => "authorise",
  "personalize" => "personalise",
  "familiarize" => "familiarise"
}.freeze

Class Method Summary collapse

Class Method Details

.check(key, text, locale) ⇒ Object

Auto-fixable British-spelling suggestions for one key/text pair.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/locallingo/quality/british_spellings.rb', line 28

def check(key, text, locale)
  SPELLINGS.filter_map do |american, british|
    next unless text.match?(/\b#{Regexp.escape(american)}\b/i)

    {
      key:, text:, locale:,
      category: :british_spelling,
      issue: "Use British spelling '#{british}' instead of '#{american}'",
      match: american,
      fix: { from: american, to: british },
      severity: :warning,
      source: :static
    }
  end
end