tenderlove / namecase Goto Github PK
View Code? Open in Web Editor NEWProperly case people's names
License: GNU General Public License v2.0
Properly case people's names
License: GNU General Public License v2.0
Hello, @tenderlove! Thank you for porting this library!
While using this library, I received feedback that the way it handle the Arabic definite article 'al-' is not quite right.
Currently the rule looks like:
localstring.gsub!(/\bAl(?=\s+\w)/, 'al') # al Arabic or forename Al.
The corresponding test asserts al Fahd
is the accepted standard.
It seems common to hyphenate the definite article (al-Fahd
).
"Al-" and its variants (ash-, ad-, ar-, etc.) are always written in lower case (unless beginning a sentence), and a hyphen separates it from the following word.
https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Arabic#Definite_article
Looking closer at the regular expressions fixing "son (daughter) of" etc
, they seem to have different terminators based on whether the prefix can also be a 'forename' (Ben, Al, or Van). In those cases, rather than using \b
, it uses (?=\s+\w)
. If \b(?=.+\w)
were used instead, I think it would fix the Arabic issue.
Hebrew seems to also be not quite up to the current standard, as the test case 'ben Gurion' is actually more commonly seen as Ben-Gurion
:
I'm not sure if this is actually a bug, given possible real-world inputs, but it certainly seems wrong.
>> NameCase("mcfoo mcbar")
=> "McFoo McFoo"
>> NameCase("MCFOO MCBAR")
=> "McFoo McFoo"
The "McBar" has been clobbered by "McFoo" because the replacement is global across the whole string. This gem seems to support passing a full first+last name input, so this looks like a bug to me.
Note this working case, though:
>> NameCase("McFoo McBar")
=> "McFoo McBar"
Names like 'MARÍA' are converted to 'MarÍa', but I would expect 'María'.
To get around this I needed to do something like NameCase(name.mb_chars.downcase.to_s) in rails, but this is not ideal.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.