Skip to content

Commit

Permalink
Merge pull request #173 from filipeforattini:feature/locale-pt-br
Browse files Browse the repository at this point in the history
feat: added base enums and pt-BR vocabulary
  • Loading branch information
icebob committed May 20, 2021
2 parents afa00f0 + 8fd83b2 commit 2a359e9
Show file tree
Hide file tree
Showing 15 changed files with 976 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ hu-HU | Hungarian | `Fakerator("hu-HU");` | [Icebob](https://git
it-IT | Italian | `Fakerator("it-IT");` | [faker.js](https://github.com/Marak/faker.js)
nb-NO | Norwegian | `Fakerator("nb-NO");` | [faker.js](https://github.com/Marak/faker.js)
pl-PL | Polish | `Fakerator("pl-PL");` | [faker.js](https://github.com/Marak/faker.js)
pt-BR | Brazilian Portuguese | `Fakerator("pt-BR");` | [Filipe Forattini](https://github.com/filipeforattini)
ru-RU | Russian | `Fakerator("ru-RU");` | [faker.js](https://github.com/Marak/faker.js)
sk-SK | Slovakian | `Fakerator("sk-SK");` | [faker.js](https://github.com/Marak/faker.js)
sv-SE | Swedish | `Fakerator("sv-SE");` | [faker.js](https://github.com/Marak/faker.js)
Expand Down Expand Up @@ -411,6 +412,6 @@ fakerator is available under the [MIT license](https://tldrlegal.com/license/mit

## Contact

Copyright (C) 2016 Icebob
Copyright (C) 2021 Icebob

[![@icebob](https://img.shields.io/badge/github-icebob-green.svg)](https://github.com/icebob) [![@icebob](https://img.shields.io/badge/twitter-Icebobcsi-blue.svg)](https://twitter.com/Icebobcsi)
253 changes: 253 additions & 0 deletions lib/locales/pt-BR/address/countryWithCodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
/* Datasource: https://github.com/umpirsky/country-list */

module.exports = {
"AF ": "Afeganistão",
"ZA": "África do Sul",
"AL": "Albânia",
"DE": "Alemanha",
"AD": "Andorra",
"AO": "Angola",
"AI": "Anguila",
"AQ": "Antártida",
"AG": "Antígua e Barbuda",
"SA": "Arábia Saudita",
"DZ": "Argélia",
"AR": "Argentina",
"AM": "Armênia",
"AW": "Aruba",
"AU": "Austrália",
"AT": "Áustria",
"AZ": "Azerbaijão",
"BS": "Bahamas",
"BH": "Bahrein",
"BD": "Bangladesh",
"BB": "Barbados",
"BE": "Bélgica",
"BZ": "Belize",
"BJ": "Benin",
"BM": "Bermudas",
"BY": "Bielorrússia",
"BO": "Bolívia",
"BA": "Bósnia e Herzegovina",
"BW": "Botsuana",
"BR": "Brasil",
"BN": "Brunei",
"BG": "Bulgária",
"BF": "Burquina Faso",
"BI": "Burundi",
"BT": "Butão",
"CV": "Cabo Verde",
"CM": "Camarões",
"KH": "Camboja",
"CA": "Canadá",
"QA": "Catar",
"KZ": "Cazaquistão",
"TD": "Chade",
"CL": "Chile",
"CN": "China",
"CY": "Chipre",
"VA": "Cidade do Vaticano",
"CO": "Colômbia",
"KM": "Comores",
"CD": "Congo - Kinshasa",
"KP": "Coreia do Norte",
"KR": "Coreia do Sul",
"CI": "Costa do Marfim",
"CR": "Costa Rica",
"HR": "Croácia",
"CU": "Cuba",
"CW": "Curaçao",
"DK": "Dinamarca",
"DJ": "Djibuti",
"DM": "Dominica",
"EG": "Egito",
"SV": "El Salvador",
"AE": "Emirados Árabes Unidos",
"EC": "Equador",
"ER": "Eritreia",
"SK": "Eslováquia",
"SI": "Eslovênia",
"ES": "Espanha",
"SZ": "Essuatíni",
"US": "Estados Unidos",
"EE": "Estônia",
"ET": "Etiópia",
"FJ": "Fiji",
"PH": "Filipinas",
"FI": "Finlândia",
"FR": "França",
"GA": "Gabão",
"GM": "Gâmbia",
"GH": "Gana",
"GE": "Geórgia",
"GI": "Gibraltar",
"GD": "Granada",
"GR": "Grécia",
"GL": "Groenlândia",
"GP": "Guadalupe",
"GU": "Guam",
"GT": "Guatemala",
"GG": "Guernsey",
"GY": "Guiana",
"GF": "Guiana Francesa",
"GN": "Guiné",
"GQ": "Guiné Equatorial",
"GW": "Guiné-Bissau",
"HT": "Haiti",
"HN": "Honduras",
"HK": "Hong Kong, RAE da China",
"HU": "Hungria",
"YE": "Iêmen",
"BV": "Ilha Bouvet",
"CX": "Ilha Christmas",
"IM": "Ilha de Man",
"NF": "Ilha Norfolk",
"AX": "Ilhas Aland",
"KY": "Ilhas Cayman",
"CC": "Ilhas Cocos: Keeling)",
"CK": "Ilhas Cook",
"FO": "Ilhas Faroe",
"GS": "Ilhas Geórgia do Sul e Sandwich do Sul",
"HM": "Ilhas Heard e McDonald",
"FK": "Ilhas Malvinas",
"MP": "Ilhas Marianas do Norte",
"MH": "Ilhas Marshall",
"UM": "Ilhas Menores Distantes dos EUA",
"PN": "Ilhas Pitcairn",
"SB": "Ilhas Salomão",
"TC": "Ilhas Turcas e Caicos",
"VI": "Ilhas Virgens Americanas",
"VG": "Ilhas Virgens Britânicas",
"IN": "Índia",
"ID": "Indonésia",
"IR": "Irã",
"IQ": "Iraque",
"IE": "Irlanda",
"IS": "Islândia",
"IL": "Israel",
"IT": "Itália",
"JM": "Jamaica",
"JP": "Japão",
"JE": "Jersey",
"JO": "Jordânia",
"KW": "Kuwait",
"LA": "Laos",
"LS": "Lesoto",
"LV": "Letônia",
"LB": "Líbano",
"LR": "Libéria",
"LY": "Líbia",
"LI": "Liechtenstein",
"LT": "Lituânia",
"LU": "Luxemburgo",
"MO": "Macau, RAE da China",
"MK": "Macedônia do Norte",
"MG": "Madagascar",
"MY": "Malásia",
"MW": "Malaui",
"MV": "Maldivas",
"ML": "Mali",
"MT": "Malta",
"MA": "Marrocos",
"MQ": "Martinica",
"MU": "Maurício",
"MR": "Mauritânia",
"YT": "Mayotte",
"MX": "México",
"MM": "Mianmar: Birmânia)",
"FM": "Micronésia",
"MZ": "Moçambique",
"MD": "Moldova",
"MC": "Mônaco",
"MN": "Mongólia",
"ME": "Montenegro",
"MS": "Montserrat",
"NA": "Namíbia",
"NR": "Nauru",
"NP": "Nepal",
"NI": "Nicarágua",
"NE": "Níger",
"NG": "Nigéria",
"NU": "Niue",
"NO": "Noruega",
"NC": "Nova Caledônia",
"NZ": "Nova Zelândia",
"OM": "Omã",
"NL": "Países Baixos",
"BQ": "Países Baixos Caribenhos",
"PW": "Palau",
"PA": "Panamá",
"PG": "Papua-Nova Guiné",
"PK": "Paquistão",
"PY": "Paraguai",
"PE": "Peru",
"PF": "Polinésia Francesa",
"PL": "Polônia",
"PR": "Porto Rico",
"PT": "Portugal",
"KE": "Quênia",
"KG": "Quirguistão",
"KI": "Quiribati",
"GB": "Reino Unido",
"CF": "República Centro-Africana",
"CG": "República do Congo",
"DO": "República Dominicana",
"RE": "Reunião",
"RO": "Romênia",
"RW": "Ruanda",
"RU": "Rússia",
"EH": "Saara Ocidental",
"WS": "Samoa",
"AS": "Samoa Americana",
"SM": "San Marino",
"SH": "Santa Helena",
"LC": "Santa Lúcia",
"BL": "São Bartolomeu",
"KN": "São Cristóvão e Névis",
"MF": "São Martinho",
"PM": "São Pedro e Miquelão",
"ST": "São Tomé e Príncipe",
"VC": "São Vicente e Granadinas",
"SC": "Seicheles",
"SN": "Senegal",
"SL": "Serra Leoa",
"RS": "Sérvia",
"SG": "Singapura",
"SX": "Sint Maarten",
"SY": "Síria",
"SO": "Somália",
"LK": "Sri Lanka",
"SD": "Sudão",
"SS": "Sudão do Sul",
"SE": "Suécia",
"CH": "Suíça",
"SR": "Suriname",
"SJ": "Svalbard e Jan Mayen",
"TJ": "Tadjiquistão",
"TH": "Tailândia",
"TW": "Taiwan",
"TZ": "Tanzânia",
"CZ": "Tchéquia",
"IO": "Território Britânico do Oceano Índico",
"TF": "Territórios Franceses do Sul",
"PS": "Territórios palestinos",
"TL": "Timor-Leste",
"TG": "Togo",
"TK": "Tokelau",
"TO": "Tonga",
"TT": "Trinidad e Tobago",
"TN": "Tunísia",
"TM": "Turcomenistão",
"TR": "Turquia",
"TV": "Tuvalu",
"UA": "Ucrânia",
"UG": "Uganda",
"UY": "Uruguai",
"UZ": "Uzbequistão",
"VU": "Vanuatu",
"VE": "Venezuela",
"VN": "Vietnã",
"WF": "Wallis e Futuna",
"ZM": "Zâmbia",
"ZW": "Zimbábue",
};
102 changes: 102 additions & 0 deletions lib/locales/pt-BR/address/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import countries from "./countryWithCodes";

module.exports = {
countryAndCode() {
let country = this.random.objectElement(countries);
return {
code: Object.keys(country)[0],
name: country[Object.keys(country)[0]]
};
},

geoLocation() {
return {
latitude: (this.random.number(180 * 10000) / 10000.0 - 90.0),
longitude: (this.random.number(360 * 10000) / 10000.0 - 180.0)
};
},

state: [
"Acre",
"Alagoas",
"Amazonas",
"Amapá",
"Bahia",
"Ceará",
"Distrito Federal",
"Espírito Santo",
"Goiás",
"Maranhão",
"Minas Gerais",
"Mato Grosso do Sul",
"Mato Grosso",
"Pará",
"Paraíba",
"Pernambuco",
"Piauí",
"Paraná",
"Rio de Janeiro",
"Rio Grande do Norte",
"Rondônia",
"Roraima",
"Rio Grande do Sul",
"Santa Catarina",
"Sergipe",
"São Paulo",
"Tocantins",
],

stateAbbr: [
"AC",
"AL",
"AM",
"AP",
"BA",
"CE",
"DF",
"ES",
"GO",
"MA",
"MG",
"MS",
"MT",
"PA",
"PB",
"PE",
"PI",
"PR",
"RJ",
"RN",
"RO",
"RR",
"RS",
"SC",
"SE",
"SP",
"TO",
],

postCode: [
"#####-###"
],

street: [
"#{address.streetName} #{address.buildingNumber}",
"#{address.streetName} #{address.buildingNumber}",
"#{address.streetName} #{address.buildingNumber} Apto ###",
"#{address.streetName} #{address.buildingNumber} Casa ###"
],

streetName: [
"#{address.streetSuffix} #{names.firstName}",
"#{address.streetSuffix} #{names.lastName}"
],

streetSuffix: [
"Alameda",
"Avenida",
"Praça",
"Rodovia",
"Rua",
],
};
24 changes: 24 additions & 0 deletions lib/locales/pt-BR/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import isNil from "lodash/isNil";
import isArray from "lodash/isArray";
import isFunction from "lodash/isFunction";
import isObject from "lodash/isObject";
import mergeWith from "lodash/mergeWith";

import Fakerator from "lib/fakerator";

module.exports = function() {
let locale = require("lib/locales/pt-BR");
let fbLocale = require("lib/locales/default");

// Merge locale and fallback
locale = mergeWith(locale, fbLocale, (objValue) => {
// DON'T MERGE ARRAYS
if (isArray(objValue) || isFunction(objValue))
return objValue;

if (!isNil(objValue) && !isObject(objValue))
return objValue;
});

return new Fakerator(locale);
};
Loading

0 comments on commit 2a359e9

Please sign in to comment.