Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

International surname prefix fixes #13

Closed
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
12 changes: 6 additions & 6 deletions lib/namecase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ def self.nc str, options = {}
end

# Fixes for "son (daughter) of" etc
localstring.gsub!(/\bAl(?=\s+\w)/, 'al') # al Arabic or forename Al.
localstring.gsub!(/\bAl\b(?=.+\w)/, 'al') # al Arabic, but NOT the first name Al.
localstring.gsub!(/\b(Bin|Binti|Binte)\b/,'bin') # bin, binti, binte Arabic
localstring.gsub!(/\bAp\b/, 'ap') # ap Welsh.
localstring.gsub!(/\bBen(?=\s+\w)/,'ben') # ben Hebrew or forename Ben.
localstring.gsub!(/\bBen(?=\s+\w)/,'ben') # ben Hebrew, but NOT the first name Ben.
localstring.gsub!(/\bDell([ae])\b/,'dell\1') # della and delle Italian.
localstring.gsub!(/\bD([aeiou])\b/,'d\1') # da, de, di Italian; du French; do Brasil
localstring.gsub!(/\bD([aeiou'’])\b/,'d\1') # da, de, di Italian; du, d' French; do Brasil
localstring.gsub!(/\bD([ao]s)\b/,'d\1') # das, dos Brasileiros
localstring.gsub!(/\bDe([lr])\b/,'de\1') # del Italian; der Dutch/Flemish.
localstring.gsub!(/\bEl\b/,'el') # el Greek or El Spanish.
localstring.gsub!(/\bLa\b/,'la') # la French or La Spanish.
localstring.gsub!(/\bL([eo])\b/,'l\1') # lo Italian; le French.
localstring.gsub!(/\bVan(?=\s+\w)/,'van') # van German or forename Van.
localstring.gsub!(/\bL([eo'’])\b/,'l\1') # lo Italian; le, l' French.
localstring.gsub!(/\bVan(?=\s+\w)/,'van') # van German, but NOT the first name Van.
localstring.gsub!(/\bVon\b/,'von') # von Dutch/Flemish

# Fix roman numeral names
localstring.gsub!(
/ \b ( (?: [Xx]{1,3} | [Xx][Ll] | [Ll][Xx]{0,3} )?
(?: [Ii]{1,3} | [Ii][VvXx] | [Vv][Ii]{0,3} )? ) \b /x
(?: [Ii]{1,3} | [Ii][VvXx] | [Vv][Ii]{0,3} )? ) \b (?= \s | \z ) /x
) { |m| m.upcase }

if options[:spanish]
Expand Down
6 changes: 4 additions & 2 deletions test/test_namecase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ def setup
"Keith", "Leigh-Williams", "McCarthy",
"O'Callaghan", "St. John", "von Streit",
"van Dyke", "Van", "ap Llwyd Dafydd",
"al Fahd", "Al",
"al Fahd", "al-Fahd", "Al",
"el Grecco",
"ben Gurion", "Ben",
"ben Gurion", "Ben-Gurion", "Ben",
"da Vinci",
"di Caprio", "du Pont", "de Legate",
"d'Alembert", "d’Alembert",
"de l'Hôpital", "de l’Hôpital",
"del Crond", "der Sind", "van der Post",
"von Trapp", "la Poisson", "le Figaro",
"Mack Knife", "Dougal MacDonald",
Expand Down