This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
en_GB localization #9
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
edfc530
Added initial en_GB files from en_US
applestump 4baf28a
Changed postcode() function to use bothify() instead of numerify() so…
applestump cf73d81
Updated street suffixes
applestump d934904
Added UK counties
applestump 5473a8f
Removed references to states from Address class
applestump 52897b8
Added UK postcode formats - as per wikipedia definition
applestump 2453341
Added en_GB PhoneNumber provider
applestump b2f2b93
Fixed bug to make postcodes uppercase
applestump dc9e7ae
Made building numbers more reasonable
applestump 853896d
Added ability for letter names in flats, such as 324a
applestump 3f500ff
Changed address formatting to match en_GB locale
applestump 4c07fa0
Added .co.uk domains to Internet provider
applestump 7a1685e
Removed unnecessary files
applestump File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_GB; | ||
|
||
require_once __DIR__ . '/../Address.php'; | ||
|
||
class Address extends \Faker\Provider\Address | ||
{ | ||
protected static $cityPrefix = array('North', 'East', 'West', 'South', 'New', 'Lake', 'Port'); | ||
protected static $citySuffix = array('town', 'ton', 'land', 'ville', 'berg', 'burgh', 'borough', 'bury', 'view', 'port', 'mouth', 'stad', 'furt', 'chester', 'mouth', 'fort', 'haven', 'side', 'shire'); | ||
protected static $buildingNumber = array('###', '##', '#'); | ||
protected static $streetSuffix = array( | ||
'Alley','Avenue','Branch','Bridge','Brook','Brooks','Burg','Burgs','Bypass','Camp','Canyon','Cape','Causeway','Center','Centers','Circle','Circles','Cliff','Cliffs','Club','Common','Corner','Corners','Course','Court','Courts','Cove','Coves','Creek','Crescent','Crest','Crossing','Crossroad','Curve','Dale','Dam','Divide','Drive','Drive','Drives','Estate','Estates','Expressway','Extension','Extensions','Fall','Falls','Ferry','Field','Fields','Flat','Flats','Ford','Fords','Forest','Forge','Forges','Fork','Forks','Fort','Garden','Gardens','Gateway','Glen','Glens','Green','Greens','Grove','Groves','Harbour','Harbours','Haven','Heights','Highway','Hill','Hills','Hollow','Inlet', 'Island','Islands', 'Isle','Junction','Junctions','Key','Keys','Knoll','Knolls','Lake','Lakes','Land','Landing','Lane','Light','Lights','Loaf','Lock','Locks','Locks','Lodge','Lodge','Loop','Manor','Manors','Meadow','Meadows','Mews','Mill','Mills','Motorway','Mount','Mountain','Mountains','Neck','Orchard','Oval','Overpass','Park','Parks','Parkway','Parkways','Pass','Passage','Path','Pike','Pine','Pines','Place','Plain','Plains','Plaza','Point','Points','Port','Ports','Radial','Ramp','Ranch','Rapid','Rapids','Rest','Ridge','Ridges','River','Road','Road','Roads','Roads','Route','Row','Rue','Run','Shoal','Shoals','Shore','Shores','Spring','Springs','Springs','Spur','Spurs','Square','Square','Squares','Squares','Station','Station','Stream','Stream','Street','Streets','Summit','Terrace','Throughway','Trace','Track','Trafficway','Trail','Tunnel','Turnpike','Underpass','Union','Unions','Valley','Valleys','Via','Viaduct','View','Views','Village','Villages','Ville','Vista','Vista','Walk','Walks','Wall','Way','Ways','Well','Wells' | ||
); | ||
protected static $postcode = array('?# #??', '?## #??', '??# #??', '??## #??', '?#? #??', '??#? #??'); | ||
|
||
protected static $county = array( | ||
'Aberdeenshire', 'Anglesey', 'Angus', 'Argyll', 'Ayrshire', 'Banffshire', 'Bedfordshire', 'Berwickshire', 'Breconshire', 'Buckinghamshire', 'Bute', 'Caernarvonshire', 'Caithness', 'Cambridgeshire', 'Cardiganshire', 'Carmarthenshire', 'Cheshire', 'Clackmannanshire', 'Cornwall', 'Isles of Scilly', 'Cumbria', 'Denbighshire', 'Derbyshire', 'Devon', 'Dorset', 'Dumbartonshire', 'Dumfriesshire', 'Durham', 'East Lothian', 'East Sussex', 'Essex', 'Fife', 'Flintshire', 'Glamorgan', 'Gloucestershire', 'Greater London', 'Greater Manchester', 'Hampshire', 'Hertfordshire', 'Inverness', 'Kent', 'Kincardineshire', 'Kinross-shire', 'Kirkcudbrightshire', 'Lanarkshire', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'London', 'Merionethshire', 'Merseyside', 'Midlothian', 'Monmouthshire', 'Montgomeryshire', 'Moray', 'Nairnshire', 'Norfolk', 'North Yorkshire', 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Orkney', 'Oxfordshire', 'Peebleshire', 'Pembrokeshire', 'Perthshire', 'Radnorshire', 'Renfrewshire', 'Ross & Cromarty', 'Roxburghshire', 'Selkirkshire', 'Shetland', 'Shropshire', 'Somerset', 'South Yorkshire', 'Staffordshire', 'Stirlingshire', 'Suffolk', 'Surrey', 'Sutherland', 'Tyne and Wear', 'Warwickshire', 'West Lothian', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wigtownshire', 'Wiltshire', 'Worcestershire' | ||
); | ||
|
||
protected static $country = array( | ||
'Afghanistan','Albania','Algeria','American Samoa','Andorra','Angola','Anguilla','Antarctica (the territory South of 60 deg S)','Antigua and Barbuda','Argentina','Armenia','Aruba','Australia','Austria','Azerbaijan', | ||
'Bahamas','Bahrain','Bangladesh','Barbados','Belarus','Belgium','Belize','Benin','Bermuda','Bhutan','Bolivia','Bosnia and Herzegovina','Botswana','Bouvet Island (Bouvetoya)','Brazil','British Indian Ocean Territory (Chagos Archipelago)','British Virgin Islands','Brunei Darussalam','Bulgaria','Burkina Faso','Burundi', | ||
'Cambodia','Cameroon','Canada','Cape Verde','Cayman Islands','Central African Republic','Chad','Chile','China','Christmas Island','Cocos (Keeling) Islands','Colombia','Comoros','Congo','Congo','Cook Islands','Costa Rica','Cote d\'Ivoire','Croatia','Cuba','Cyprus','Czech Republic', | ||
'Denmark','Djibouti','Dominica','Dominican Republic', | ||
'Ecuador','Egypt','El Salvador','Equatorial Guinea','Eritrea','Estonia','Ethiopia', | ||
'Faroe Islands','Falkland Islands (Malvinas)','Fiji','Finland','France','French Guiana','French Polynesia','French Southern Territories', | ||
'Gabon','Gambia','Georgia','Germany','Ghana','Gibraltar','Greece','Greenland','Grenada','Guadeloupe','Guam','Guatemala','Guernsey','Guinea','Guinea-Bissau','Guyana', | ||
'Haiti','Heard Island and McDonald Islands','Holy See (Vatican City State)','Honduras','Hong Kong','Hungary', | ||
'Iceland','India','Indonesia','Iran','Iraq','Ireland','Isle of Man','Israel','Italy', | ||
'Jamaica','Japan','Jersey','Jordan', | ||
'Kazakhstan','Kenya','Kiribati','Korea','Korea','Kuwait','Kyrgyz Republic', | ||
'Lao People\'s Democratic Republic','Latvia','Lebanon','Lesotho','Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania','Luxembourg', | ||
'Macao','Macedonia','Madagascar','Malawi','Malaysia','Maldives','Mali','Malta','Marshall Islands','Martinique','Mauritania','Mauritius','Mayotte','Mexico','Micronesia','Moldova','Monaco','Mongolia','Montenegro','Montserrat','Morocco','Mozambique','Myanmar', | ||
'Namibia','Nauru','Nepal','Netherlands Antilles','Netherlands','New Caledonia','New Zealand','Nicaragua','Niger','Nigeria','Niue','Norfolk Island','Northern Mariana Islands','Norway', | ||
'Oman', | ||
'Pakistan','Palau','Palestinian Territory','Panama','Papua New Guinea','Paraguay','Peru','Philippines','Pitcairn Islands','Poland','Portugal','Puerto Rico', | ||
'Qatar', | ||
'Reunion','Romania','Russian Federation','Rwanda', | ||
'Saint Barthelemy','Saint Helena','Saint Kitts and Nevis','Saint Lucia','Saint Martin','Saint Pierre and Miquelon','Saint Vincent and the Grenadines','Samoa','San Marino','Sao Tome and Principe','Saudi Arabia','Senegal','Serbia','Seychelles','Sierra Leone','Singapore','Slovakia (Slovak Republic)','Slovenia','Solomon Islands','Somalia','South Africa','South Georgia and the South Sandwich Islands','Spain','Sri Lanka','Sudan','Suriname','Svalbard & Jan Mayen Islands','Swaziland','Sweden','Switzerland','Syrian Arab Republic', | ||
'Taiwan','Tajikistan','Tanzania','Thailand','Timor-Leste','Togo','Tokelau','Tonga','Trinidad and Tobago','Tunisia','Turkey','Turkmenistan','Turks and Caicos Islands','Tuvalu', | ||
'Uganda','Ukraine','United Arab Emirates','United Kingdom','United States of America','United States Minor Outlying Islands','United States Virgin Islands','Uruguay','Uzbekistan', | ||
'Vanuatu','Venezuela','Vietnam', | ||
'Wallis and Futuna','Western Sahara', | ||
'Yemen', | ||
'Zambia','Zimbabwe' | ||
); | ||
protected static $cityFormats = array( | ||
'{{cityPrefix}} {{firstName}}{{citySuffix}}', | ||
'{{cityPrefix}} {{firstName}}', | ||
'{{firstName}}{{citySuffix}}', | ||
'{{lastName}}{{citySuffix}}', | ||
); | ||
protected static $streetNameFormats = array( | ||
'{{firstName}} {{streetSuffix}}', | ||
'{{lastName}} {{streetSuffix}}' | ||
); | ||
protected static $streetAddressFormats = array( | ||
'{{buildingNumber}} {{streetName}}', | ||
'{{buildingNumber}} {{streetName}}', | ||
"{{secondaryAddress}}\n{{streetName}}", | ||
); | ||
protected static $addressFormats = array( | ||
"{{streetAddress}}\n{{city}}\n{{postcode}}", | ||
); | ||
protected static $secondaryAddressFormats = array('Flat ##', 'Flat ##?', 'Studio ##', 'Studio ##?'); | ||
|
||
/** | ||
* @example 'East' | ||
*/ | ||
public static function cityPrefix() | ||
{ | ||
return static::randomElement(static::$cityPrefix); | ||
} | ||
|
||
/** | ||
* @example 'Flat 350' | ||
*/ | ||
public static function secondaryAddress() | ||
{ | ||
return static::bothify(static::randomElement(static::$secondaryAddressFormats)); | ||
} | ||
|
||
/** | ||
* @example 'Hampshire' | ||
*/ | ||
public static function county() | ||
{ | ||
return static::randomElement(static::$county); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_GB; | ||
|
||
require_once __DIR__ . '/../Internet.php'; | ||
|
||
class Internet extends \Faker\Provider\Internet | ||
{ | ||
protected static $safeEmailTld = array('org', 'com', 'net', 'co.uk'); | ||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'gmail.co.uk', 'yahoo.co.uk', 'hotmail.co.uk'); | ||
protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org', 'co.uk'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_GB; | ||
|
||
require_once __DIR__ . '/../PhoneNumber.php'; | ||
|
||
class PhoneNumber extends \Faker\Provider\PhoneNumber | ||
{ | ||
protected static $formats = array( | ||
'+44(0)##########', | ||
'+44(0)#### ######', | ||
'+44(0)#########', | ||
'+44(0)#### #####', | ||
'0##########', | ||
'0#########', | ||
'0#### ######', | ||
'0#### #####', | ||
'(0####) ######', | ||
'(0####) #####', | ||
|
||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add flexibility to allow postcodes such as AB12 3CD but still parse US zip codes