Skip to content

Commit

Permalink
Add PH locales (joke2k#1034)
Browse files Browse the repository at this point in the history
* Add automotive provider for PH locales

* Add ssn provider for PH locales

* Add phone number provider for PH locales

* Add lorem provider for PH locales

* Add date time provider for PH locales

* Add internet provider for PH locales

* Add address provider for PH locales

* Add company provider for PH locales

* Add misc provider for PH locales
  • Loading branch information
malefice authored and fcurella committed Nov 4, 2019
1 parent ec3d8d1 commit 3487c18
Show file tree
Hide file tree
Showing 35 changed files with 1,732 additions and 1 deletion.
475 changes: 475 additions & 0 deletions faker/providers/address/en_PH/__init__.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions faker/providers/address/fil_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..en_PH import Provider as EnPhAddressProvider


class Provider(EnPhAddressProvider):
"""No difference from Address Provider for en_PH locale"""
pass
7 changes: 7 additions & 0 deletions faker/providers/address/tl_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..en_PH import Provider as EnPhAddressProvider


class Provider(EnPhAddressProvider):
"""No difference from Address Provider for en_PH locale"""
pass
49 changes: 49 additions & 0 deletions faker/providers/automotive/en_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding=utf-8
from __future__ import unicode_literals
from string import ascii_uppercase
from ... import BaseProvider


class Provider(BaseProvider):
"""
Provider for Philippine automotive license plates
Vehicle registration in the Philippines has many controversies and is full of quirks. On top of that, some terms are
highly subject to interpretation or to varying definitions when applied colloquially, e.g. "motor" usually refers to
either a machine's motor or a motorcycle, "vehicles" usually means cars, SUVs, vans, and trucks but not motorcycles.
All of these, interestingly, affect how and what kind of license plates are issued. For the purposes of this
provider, the following pointers apply:
- High ranking government officials are entitled to use low numbered protocol license plates.
- Motorcycles and any improvised vehicle with a motorcycle as its base are issued motorcycle license plates.
- Cars, SUVs, vans, trucks, and other 4-wheeled civilian vehicles are considered automobiles.
- Invoking `license_plate()` will never generate protocol plates, because those are plates for specific use cases.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_the_Philippines
"""

protocol_licenses = tuple(str(x) for x in range(1, 18) if x != 15)
motorcycle_license_formats = (
'??####', # 1981 series
'??#####', # 2014 series
)
automobile_license_formats = (
'???###', # 1981 series
'???####', # 2014 series
)
license_formats = motorcycle_license_formats + automobile_license_formats

def _license_plate(self, license_format):
return self.bothify(self.random_element(license_format), ascii_uppercase)

def protocol_license_plate(self):
return self.random_element(self.protocol_licenses)

def motorcycle_license_plate(self):
return self._license_plate(self.motorcycle_license_formats)

def automobile_license_plate(self):
return self._license_plate(self.automobile_license_formats)

def license_plate(self):
return self._license_plate(self.license_formats)
7 changes: 7 additions & 0 deletions faker/providers/automotive/fil_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..en_PH import Provider as EnPhAutomotiveProvider


class Provider(EnPhAutomotiveProvider):
"""No difference from Automotive Provider for en_PH locale"""
pass
7 changes: 7 additions & 0 deletions faker/providers/automotive/tl_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..en_PH import Provider as EnPhAutomotiveProvider


class Provider(EnPhAutomotiveProvider):
"""No difference from Automotive Provider for en_PH locale"""
pass
132 changes: 132 additions & 0 deletions faker/providers/company/en_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# coding=utf-8
from __future__ import unicode_literals
from collections import OrderedDict
from .. import Provider as CompanyProvider


class Provider(CompanyProvider):
"""
Provider for company names for en_PH locale
Company naming scheme and probabilities are inspired by and/or based on existing companies in the Philippines.
Sources:
- https://en.wikipedia.org/wiki/List_of_companies_of_the_Philippines
- https://www.pse.com.ph/stockMarket/listedCompanyDirectory.html
"""

formats = OrderedDict([
('{{random_company_adjective}} {{random_company_noun_chain}} {{company_type}} {{company_suffix}}', 0.24),
('{{random_company_acronym}} {{random_company_noun_chain}} {{company_type}} {{company_suffix}}', 0.24),
('{{last_name}} {{random_company_noun_chain}} {{company_type}} {{company_suffix}}', 0.16),
('{{random_company_adjective}} {{company_type}} {{company_suffix}}', 0.12),
('{{random_company_acronym}} {{company_type}} {{company_suffix}}', 0.12),
('{{last_name}} {{company_type}} {{company_suffix}}', 0.09),
('National {{random_company_product}} Corporation of the Philippines', 0.03),
])
company_suffixes = OrderedDict([
('Inc.', 0.45),
('Corporation', 0.45),
('Limited', 0.1),
])
company_types = (
'Bank',
'Banking',
'Capital',
'Company',
'Construction',
'Development',
'Enterprise',
'Equities',
'Finance',
'Foods',
'Group',
'Holdings',
'Hotel',
'Manufacturing',
'Mining',
'Properties',
'Resorts',
'Resources',
'Services',
'Shipping',
'Solutions',
'Technologies',
'Trust',
'Ventures',
)
company_products = (
'Bottle',
'Coconut',
'Computer',
'Electricity',
'Flour',
'Furniture',
'Glass',
'Newspaper',
'Pillow',
'Water',
)
company_nouns = (
'Century',
'City',
'Crown',
'Dragon',
'Empire',
'Genesis',
'Gold',
'King',
'Liberty',
'Millennium',
'Morning',
'Silver',
'Star',
'State',
'Summit',
'Sun',
'Union',
'World',
)
company_adjectives = (
'Advanced',
'Rising',
'Double',
'Triple',
'Quad',
'Allied',
'Cyber',
'Sovereign',
'Great',
'Far',
'Northern',
'Southern',
'Eastern',
'Western',
'First',
'Filipino',
'Grand',
'Manila',
'Mega',
'Metro',
'Global',
'Pacific',
'Oriental',
'Philippine',
'Prime',
)

def company_type(self):
return self.random_element(self.company_types)

def random_company_adjective(self):
return self.random_element(self.company_adjectives)

def random_company_noun_chain(self):
return ' '.join(self.random_elements(self.company_nouns, length=self.random_int(1, 2), unique=True))

def random_company_product(self):
return self.random_element(self.company_products)

def random_company_acronym(self):
letters = self.random_letters(self.random_int(2, 4))
return ''.join(letters).upper()
86 changes: 86 additions & 0 deletions faker/providers/company/fil_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# coding=utf-8
from __future__ import unicode_literals
from collections import OrderedDict
from ..en_PH import Provider as EnPhProvider


class Provider(EnPhProvider):
"""
Provider for company names for fil_PH locale
Companies in the Philippines rarely have Filipino names, and when they do, the English name is usually used way more
frequently by the locals. In some cases, the Filipino names are more like in Taglish, so for the purposes of this
provider, only English company names will be generated for this locale.
Company and brand taglines in pure Filipino, however, are much more common, so this provider will generate catch
phrases in pure Filipino randomly alongside the English ones.
"""

catch_phrase_formats = OrderedDict([
('{{english_catch_phrase}}', 0.64),
('Ang {{random_noun_ish_good_trait}} ng {{random_object_of_concern}}!', 0.12),
('Serbisyong {{random_good_service_adjective}} para sa {{random_object_of_concern}}!', 0.12),
('Kahit kailan, {{random_good_service_adjective_chain}}!', 0.12),
])
noun_ish_good_traits = (
'bida',
'ginhawa',
'haligi',
'karangalan',
'lingkod',
'liwanag',
'numero uno',
'pag-asa',
'tulay',
)
good_service_adjectives = (
'bida',
'dekalidad',
'hindi umaatras',
'kakaiba',
'maasahan',
'magaling',
'mapatitiwalaan',
'numero uno',
'panalo',
'tagumpay',
'tama',
'tapat',
'totoo',
'tunay',
'walang kapantay',
'walang katulad',
'walang tatalo',
)
objects_of_concern = [
'Filipino',
'Pilipinas',
'Pilipino',
'Pinoy',
'bahay',
'bansa',
'bayan',
'buhay',
'mamamayan',
'mundo',
'tahanan',
]

def random_noun_ish_good_trait(self):
return self.random_element(self.noun_ish_good_traits)

def random_good_service_adjective(self):
return self.random_element(self.good_service_adjectives)

def random_good_service_adjective_chain(self):
adjectives = self.random_elements(self.good_service_adjectives, length=2, unique=True)
return ' at '.join(adjectives)

def random_object_of_concern(self):
return self.random_element(self.objects_of_concern)

def english_catch_phrase(self):
return super(Provider, self).catch_phrase()

def catch_phrase(self):
return self.random_element(self.catch_phrase_formats)
7 changes: 7 additions & 0 deletions faker/providers/company/tl_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..fil_PH import Provider as FilPhProvider


class Provider(FilPhProvider):
"""No difference from Company Provider for fil_PH locale"""
pass
8 changes: 8 additions & 0 deletions faker/providers/date_time/en_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
from __future__ import unicode_literals
from .. import Provider as DateTimeProvider


class Provider(DateTimeProvider):
"""No difference from default DateTimeProvider"""
pass
39 changes: 39 additions & 0 deletions faker/providers/date_time/fil_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding=utf-8
from __future__ import unicode_literals
from .. import Provider as DateTimeProvider


class Provider(DateTimeProvider):
"""Provider for datetimes for fil_PH locale"""

DAY_NAMES = {
'0': 'Linggo',
'1': 'Lunes',
'2': 'Martes',
'3': 'Miyerkules',
'4': 'Huwebes',
'5': 'Biyernes',
'6': 'Sabado',
}
MONTH_NAMES = {
'01': 'Enero',
'02': 'Pebrero',
'03': 'Marso',
'04': 'Abril',
'05': 'Mayo',
'06': 'Hunyo',
'07': 'Hulyo',
'08': 'Agosto',
'09': 'Setyembre',
'10': 'Oktubre',
'11': 'Nobyembre',
'12': 'Disyembre',
}

def day_of_week(self):
day = self.date('%w')
return self.DAY_NAMES[day]

def month_name(self):
month = self.month()
return self.MONTH_NAMES[month]
7 changes: 7 additions & 0 deletions faker/providers/date_time/tl_PH/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
from ..fil_PH import Provider as FilPhProvider


class Provider(FilPhProvider):
"""No difference from DateTime Provider for fil_PH locale"""
pass
Loading

0 comments on commit 3487c18

Please sign in to comment.