Skip to content

Commit

Permalink
Update i18n and use correct locales
Browse files Browse the repository at this point in the history
Closes #180
  • Loading branch information
schasse authored and stympy committed Jul 3, 2014
1 parent 574f70a commit 9d47686
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PATH
GEM
remote: http://rubygems.org/
specs:
i18n (0.6.5)
i18n (0.6.9)
rake (10.1.0)
test-unit (2.5.5)

Expand Down
2 changes: 1 addition & 1 deletion lib/faker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Config
class << self
attr_writer :locale
def locale
@locale || I18n.locale.downcase
@locale || I18n.locale
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/de-at.yml → lib/locales/de-AT.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
de-at:
de-AT:
faker:
address:
country: [Ägypten, Äquatorialguinea, Äthiopien, Österreich, Afghanistan, Albanien, Algerien, Amerikanisch-Samoa, Amerikanische Jungferninseln, Andorra, Angola, Anguilla, Antarktis, Antigua und Barbuda, Argentinien, Armenien, Aruba, Aserbaidschan, Australien, Bahamas, Bahrain, Bangladesch, Barbados, Belarus, Belgien, Belize, Benin, die Bermudas, Bhutan, Bolivien, Bosnien und Herzegowina, Botsuana, Bouvetinsel, Brasilien, Britische Jungferninseln, Britisches Territorium im Indischen Ozean, Brunei Darussalam, Bulgarien, Burkina Faso, Burundi, Chile, China, Cookinseln, Costa Rica, Dänemark, Demokratische Republik Kongo, Demokratische Volksrepublik Korea, Deutschland, Dominica, Dominikanische Republik, Dschibuti, Ecuador, El Salvador, Eritrea, Estland, Färöer, Falklandinseln, Fidschi, Finnland, Frankreich, Französisch-Guayana, Französisch-Polynesien, Französische Gebiete im südlichen Indischen Ozean, Gabun, Gambia, Georgien, Ghana, Gibraltar, Grönland, Grenada, Griechenland, Guadeloupe, Guam, Guatemala, Guinea, Guinea-Bissau, Guyana, Haiti, Heard und McDonaldinseln, Honduras, Hongkong, Indien, Indonesien, Irak, Iran, Irland, Island, Israel, Italien, Jamaika, Japan, Jemen, Jordanien, Jugoslawien, Kaimaninseln, Kambodscha, Kamerun, Kanada, Kap Verde, Kasachstan, Katar, Kenia, Kirgisistan, Kiribati, Kleinere amerikanische Überseeinseln, Kokosinseln, Kolumbien, Komoren, Kongo, Kroatien, Kuba, Kuwait, Laos, Lesotho, Lettland, Libanon, Liberia, Libyen, Liechtenstein, Litauen, Luxemburg, Macau, Madagaskar, Malawi, Malaysia, Malediven, Mali, Malta, ehemalige jugoslawische Republik Mazedonien, Marokko, Marshallinseln, Martinique, Mauretanien, Mauritius, Mayotte, Mexiko, Mikronesien, Monaco, Mongolei, Montserrat, Mosambik, Myanmar, Nördliche Marianen, Namibia, Nauru, Nepal, Neukaledonien, Neuseeland, Nicaragua, Niederländische Antillen, Niederlande, Niger, Nigeria, Niue, Norfolkinsel, Norwegen, Oman, Osttimor, Pakistan, Palau, Panama, Papua-Neuguinea, Paraguay, Peru, Philippinen, Pitcairninseln, Polen, Portugal, Puerto Rico, Réunion, Republik Korea, Republik Moldau, Ruanda, Rumänien, Russische Föderation, São Tomé und Príncipe, Südafrika, Südgeorgien und Südliche Sandwichinseln, Salomonen, Sambia, Samoa, San Marino, Saudi-Arabien, Schweden, Schweiz, Senegal, Seychellen, Sierra Leone, Simbabwe, Singapur, Slowakei, Slowenien, Somalien, Spanien, Sri Lanka, St. Helena, St. Kitts und Nevis, St. Lucia, St. Pierre und Miquelon, St. Vincent und die Grenadinen, Sudan, Surinam, Svalbard und Jan Mayen, Swasiland, Syrien, Türkei, Tadschikistan, Taiwan, Tansania, Thailand, Togo, Tokelau, Tonga, Trinidad und Tobago, Tschad, Tschechische Republik, Tunesien, Turkmenistan, Turks- und Caicosinseln, Tuvalu, Uganda, Ukraine, Ungarn, Uruguay, Usbekistan, Vanuatu, Vatikanstadt, Venezuela, Vereinigte Arabische Emirate, Vereinigte Staaten, Vereinigtes Königreich, Vietnam, Wallis und Futuna, Weihnachtsinsel, Westsahara, Zentralafrikanische Republik, Zypern]
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/de-ch.yml → lib/locales/de-CH.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
de-ch:
de-CH:
faker:
address:
country_code: [CH, CH, CH, DE, AT, US, LI, US, HK, VN]
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/en-au.yml → lib/locales/en-AU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Using Top 200 Australian baby names of 2010
# 286 Surnames familiar to Australian population

en-au:
en-AU:
faker:
name:
first_name: [William, Jack, Oliver, Joshua, Thomas, Lachlan, Cooper, Noah, Ethan, Lucas, James, Samuel, Jacob, Liam, Alexander, Benjamin, Max, Isaac, Daniel, Riley, Ryan, Charlie, Tyler, Jake, Matthew, Xavier, Harry, Jayden, Nicholas, Harrison, Levi, Luke, Adam, Henry, Aiden, Dylan, Oscar, Michael, Jackson, Logan, Joseph, Blake, Nathan, Connor, Elijah, Nate, Archie, Bailey, Marcus, Cameron, Jordan, Zachary, Caleb, Hunter, Ashton, Toby, Aidan, Hayden, Mason, Hamish, Edward, Angus, Eli, Sebastian, Christian, Patrick, Andrew, Anthony, Luca, Kai, Beau, Alex, George, Callum, Finn, Zac, Mitchell, Jett, Jesse, Gabriel, Leo, Declan, Charles, Jasper, Jonathan, Aaron, Hugo, David, Christopher, Chase, Owen, Justin, Ali, Darcy, Lincoln, Cody, Phoenix, Sam, John, Joel, Isabella, Ruby, Chloe, Olivia, Charlotte, Mia, Lily, Emily, Ella, Sienna, Sophie, Amelia, Grace, Ava, Zoe, Emma, Sophia, Matilda, Hannah, Jessica, Lucy, Georgia, Sarah, Abigail, Zara, Eva, Scarlett, Jasmine, Chelsea, Lilly, Ivy, Isla, Evie, Isabelle, Maddison, Layla, Summer, Annabelle, Alexis, Elizabeth, Bella, Holly, Lara, Madison, Alyssa, Maya, Tahlia, Claire, Hayley, Imogen, Jade, Ellie, Sofia, Addison, Molly, Phoebe, Alice, Savannah, Gabriella, Kayla, Mikayla, Abbey, Eliza, Willow, Alexandra, Poppy, Samantha, Stella, Amy, Amelie, Anna, Piper, Gemma, Isabel, Victoria, Stephanie, Caitlin, Heidi, Paige, Rose, Amber, Audrey, Claudia, Taylor, Madeline, Angelina, Natalie, Charli, Lauren, Ashley, Violet, Mackenzie, Abby, Skye, Lillian, Alana, Lola, Leah, Eve, Kiara]
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/en-bork.yml → lib/locales/en-BORK.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
en-bork:
en-BORK:
faker:
lorem:
words: [Boot, I, Nu, Nur, Tu, Um, a, becoose-a, boot, bork, burn, chuuses, cumplete-a, cun, cunseqooences, curcoomstunces, dee, deeslikes, denuoonceeng, desures, du, eccuoont, ectooel, edfuntege-a, efueeds, egeeen, ell, ere-a, feend, foolt, frum, geefe-a, gesh, greet, heem, heppeeness, hes, hoo, hoomun, idea, ifer, in, incuoonter, injuy, itselff, ixcept, ixemple-a, ixerceese-a, ixpleeen, ixplurer, ixpuoond, ixtremely, knoo, lebureeuoos, lufes, meestekee, mester-booeelder, moost, mun, nu, nut, oobteeen, oocceseeunelly, ooccoor, ooff, oone-a, oor, peeen, peeenffool, physeecel, pleesoore-a, poorsooe-a, poorsooes, preeesing, prucoore-a, prudooces, reeght, reshunelly, resooltunt, sume-a, teecheengs, teke-a, thees, thet, thuse-a, treefiel, troot, tu, tueel, und, undertekes, unnuyeeng, uny, unyune-a, us, veell, veet, ves, vheech, vhu, yuoo, zee, zeere-a]
2 changes: 1 addition & 1 deletion lib/locales/en-ca.yml → lib/locales/en-CA.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
en-ca:
en-CA:
faker:
address:
postcode: ['?#? #?#', '?#?#?#']
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/en-gb.yml → lib/locales/en-GB.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
en-gb:
en-GB:
faker:
address:
postcode: /[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? [0-9][ABD-HJLN-UW-Z]{2}/
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/en-ind.yml → lib/locales/en-IND.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# India formatted data types
# first_names and last_names courtesy http://www.indianhindunames.com

en-ind:
en-IND:
faker:
name:
first_name: [Aadrika, Aanandinii, Aaratrika, Aarya, Arya, Aashritha, Aatmaja, Atmaja, Abhaya, Adwitiya, Agrata, Ahilya, Ahalya, Aishani, Akshainie, Akshata, Akshita, Akula, Ambar, Amodini, Amrita, Amritambu, Anala, Anamika, Ananda, Anandamayi, Ananta, Anila, Anjali, Anjushri, Anjushree, Annapurna, Anshula, Anuja, Anusuya, Anasuya, Anasooya, Anwesha, Apsara, Aruna, Asha, Aasa, Aasha, Aslesha, Atreyi, Atreyee, Avani, Abani, Avantika, Ayushmati, Baidehi, Vaidehi, Bala, Baala, Balamani, Basanti, Vasanti, Bela, Bhadra, Bhagirathi, Bhagwanti, Bhagwati, Bhamini, Bhanumati, Bhaanumati, Bhargavi, Bhavani, Bhilangana, Bilwa, Bilva, Buddhana, Chakrika, Chanda, Chandi, Chandni, Chandini, Chandani, Chandra, Chandira, Chandrabhaga, Chandrakala, Chandrakin, Chandramani, Chandrani, Chandraprabha, Chandraswaroopa, Chandravati, Chapala, Charumati, Charvi, Chatura, Chitrali, Chitramala, Chitrangada, Daksha, Dakshayani, Damayanti, Darshwana, Deepali, Dipali, Deeptimoyee, Deeptimayee, Devangana, Devani, Devasree, Devi, Daevi, Devika, Daevika, Dhaanyalakshmi, Dhanalakshmi, Dhana, Dhanadeepa, Dhara, Dharani, Dharitri, Dhatri, Diksha, Deeksha, Divya, Draupadi, Dulari, Durga, Durgeshwari, Ekaparnika, Elakshi, Enakshi, Esha, Eshana, Eshita, Gautami, Gayatri, Geeta, Geetanjali, Gitanjali, Gemine, Gemini, Girja, Girija, Gita, Hamsini, Harinakshi, Harita, Heema, Himadri, Himani, Hiranya, Indira, Jaimini, Jaya, Jyoti, Jyotsana, Kali, Kalinda, Kalpana, Kalyani, Kama, Kamala, Kamla, Kanchan, Kanishka, Kanti, Kashyapi, Kumari, Kumuda, Lakshmi, Laxmi, Lalita, Lavanya, Leela, Lila, Leela, Madhuri, Malti, Malati, Mandakini, Mandaakin, Mangala, Mangalya, Mani, Manisha, Manjusha, Meena, Mina, Meenakshi, Minakshi, Menka, Menaka, Mohana, Mohini, Nalini, Nikita, Ojaswini, Omana, Oormila, Urmila, Opalina, Opaline, Padma, Parvati, Poornima, Purnima, Pramila, Prasanna, Preity, Prema, Priya, Priyala, Pushti, Radha, Rageswari, Rageshwari, Rajinder, Ramaa, Rati, Rita, Rohana, Rukhmani, Rukmin, Rupinder, Sanya, Sarada, Sharda, Sarala, Sarla, Saraswati, Sarisha, Saroja, Shakti, Shakuntala, Shanti, Sharmila, Shashi, Shashikala, Sheela, Shivakari, Shobhana, Shresth, Shresthi, Shreya, Shreyashi, Shridevi, Shrishti, Shubha, Shubhaprada, Siddhi, Sitara, Sloka, Smita, Smriti, Soma, Subhashini, Subhasini, Sucheta, Sudeva, Sujata, Sukanya, Suma, Suma, Sumitra, Sunita, Suryakantam, Sushma, Swara, Swarnalata, Sweta, Shwet, Tanirika, Tanushree, Tanushri, Tanushri, Tanya, Tara, Trisha, Uma, Usha, Vaijayanti, Vaijayanthi, Baijayanti, Vaishvi, Vaishnavi, Vaishno, Varalakshmi, Vasudha, Vasundhara, Veda, Vedanshi, Vidya, Vimala, Vrinda, Vrund, Aadi, Aadidev, Aadinath, Aaditya, Aagam, Aagney, Aamod, Aanandaswarup, Anand Swarup, Aanjaneya, Anjaneya, Aaryan, Aryan, Aatmaj, Aatreya, Aayushmaan, Aayushman, Abhaidev, Abhaya, Abhirath, Abhisyanta, Acaryatanaya, Achalesvara, Acharyanandana, Acharyasuta, Achintya, Achyut, Adheesh, Adhiraj, Adhrit, Adikavi, Adinath, Aditeya, Aditya, Adityanandan, Adityanandana, Adripathi, Advaya, Agasti, Agastya, Agneya, Aagneya, Agnimitra, Agniprava, Agnivesh, Agrata, Ajit, Ajeet, Akroor, Akshaj, Akshat, Akshayakeerti, Alok, Aalok, Amaranaath, Amarnath, Amaresh, Ambar, Ameyatma, Amish, Amogh, Amrit, Anaadi, Anagh, Anal, Anand, Aanand, Anang, Anil, Anilaabh, Anilabh, Anish, Ankal, Anunay, Anurag, Anuraag, Archan, Arindam, Arjun, Arnesh, Arun, Ashlesh, Ashok, Atmanand, Atmananda, Avadhesh, Baalaaditya, Baladitya, Baalagopaal, Balgopal, Balagopal, Bahula, Bakula, Bala, Balaaditya, Balachandra, Balagovind, Bandhu, Bandhul, Bankim, Bankimchandra, Bhadrak, Bhadraksh, Bhadran, Bhagavaan, Bhagvan, Bharadwaj, Bhardwaj, Bharat, Bhargava, Bhasvan, Bhaasvan, Bhaswar, Bhaaswar, Bhaumik, Bhaves, Bheeshma, Bhisham, Bhishma, Bhima, Bhoj, Bhramar, Bhudev, Bhudeva, Bhupati, Bhoopati, Bhoopat, Bhupen, Bhushan, Bhooshan, Bhushit, Bhooshit, Bhuvanesh, Bhuvaneshwar, Bilva, Bodhan, Brahma, Brahmabrata, Brahmanandam, Brahmaanand, Brahmdev, Brajendra, Brajesh, Brijesh, Birjesh, Budhil, Chakor, Chakradhar, Chakravartee, Chakravarti, Chanakya, Chaanakya, Chandak, Chandan, Chandra, Chandraayan, Chandrabhan, Chandradev, Chandraketu, Chandramauli, Chandramohan, Chandran, Chandranath, Chapal, Charak, Charuchandra, Chaaruchandra, Charuvrat, Chatur, Chaturaanan, Chaturbhuj, Chetan, Chaten, Chaitan, Chetanaanand, Chidaakaash, Chidaatma, Chidambar, Chidambaram, Chidananda, Chinmayanand, Chinmayananda, Chiranjeev, Chiranjeeve, Chitraksh, Daiwik, Daksha, Damodara, Dandak, Dandapaani, Darshan, Datta, Dayaamay, Dayamayee, Dayaananda, Dayaanidhi, Kin, Deenabandhu, Deepan, Deepankar, Dipankar, Deependra, Dipendra, Deepesh, Dipesh, Deeptanshu, Deeptendu, Diptendu, Deeptiman, Deeptimoy, Deeptimay, Dev, Deb, Devadatt, Devagya, Devajyoti, Devak, Devdan, Deven, Devesh, Deveshwar, Devi, Devvrat, Dhananjay, Dhanapati, Dhanpati, Dhanesh, Dhanu, Dhanvin, Dharmaketu, Dhruv, Dhyanesh, Dhyaneshwar, Digambar, Digambara, Dinakar, Dinkar, Dinesh, Divaakar, Divakar, Deevakar, Divjot, Dron, Drona, Dwaipayan, Dwaipayana, Eekalabya, Ekalavya, Ekaksh, Ekaaksh, Ekaling, Ekdant, Ekadant, Gajaadhar, Gajadhar, Gajbaahu, Gajabahu, Ganak, Ganaka, Ganapati, Gandharv, Gandharva, Ganesh, Gangesh, Garud, Garuda, Gati, Gatik, Gaurang, Gauraang, Gauranga, Gouranga, Gautam, Gautama, Goutam, Ghanaanand, Ghanshyam, Ghanashyam, Giri, Girik, Girika, Girindra, Giriraaj, Giriraj, Girish, Gopal, Gopaal, Gopi, Gopee, Gorakhnath, Gorakhanatha, Goswamee, Goswami, Gotum, Gautam, Govinda, Gobinda, Gudakesha, Gudakesa, Gurdev, Guru, Hari, Harinarayan, Harit, Himadri, Hiranmay, Hiranmaya, Hiranya, Inder, Indra, Indra, Jagadish, Jagadisha, Jagathi, Jagdeep, Jagdish, Jagmeet, Jahnu, Jai, Javas, Jay, Jitendra, Jitender, Jyotis, Kailash, Kama, Kamalesh, Kamlesh, Kanak, Kanaka, Kannan, Kannen, Karan, Karthik, Kartik, Karunanidhi, Kashyap, Kiran, Kirti, Keerti, Krishna, Krishnadas, Krishnadasa, Kumar, Lai, Lakshman, Laxman, Lakshmidhar, Lakshminath, Lal, Laal, Mahendra, Mohinder, Mahesh, Maheswar, Mani, Manik, Manikya, Manoj, Marut, Mayoor, Meghnad, Meghnath, Mohan, Mukesh, Mukul, Nagabhushanam, Nanda, Narayan, Narendra, Narinder, Naveen, Navin, Nawal, Naval, Nimit, Niranjan, Nirbhay, Niro, Param, Paramartha, Pran, Pranay, Prasad, Prathamesh, Prayag, Prem, Puneet, Purushottam, Rahul, Raj, Rajan, Rajendra, Rajinder, Rajiv, Rakesh, Ramesh, Rameshwar, Ranjit, Ranjeet, Ravi, Ritesh, Rohan, Rohit, Rudra, Sachin, Sameer, Samir, Sanjay, Sanka, Sarvin, Satish, Satyen, Shankar, Shantanu, Shashi, Sher, Shiv, Siddarth, Siddhran, Som, Somu, Somnath, Subhash, Subodh, Suman, Suresh, Surya, Suryakant, Suryakanta, Sushil, Susheel, Swami, Swapnil, Tapan, Tara, Tarun, Tej, Tejas, Trilochan, Trilochana, Trilok, Trilokesh, Triloki, Triloki Nath, Trilokanath, Tushar, Udai, Udit, Ujjawal, Ujjwal, Umang, Upendra, Uttam, Vasudev, Vasudeva, Vedang, Vedanga, Vidhya, Vidur, Vidhur, Vijay, Vimal, Vinay, Vishnu, Bishnu, Vishwamitra, Vyas, Yogendra, Yoginder, Yogesh]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/locales/en-us.yml → lib/locales/en-US.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
en-us:
en-US:
faker:
internet:
domain_suffix: [com, us, biz, info, name, net, org]
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/nb-no.yml → lib/locales/nb-NO.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
nb-no:
nb-NO:
faker:
address:
city_root: ["Fet", "Gjes", "Høy", "Inn", "Fager", "Lille", "Lo", "Mal", "Nord", "Nær", "Sand", "Sme", "Stav", "Stor", "Tand", "Ut", "Vest"]
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/pt-br.yml → lib/locales/pt-BR.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pt-br:
pt-BR:
faker:
address:
city_prefix: [Nova, Velha, Grande, Vila, Município de]
Expand Down
4 changes: 2 additions & 2 deletions test/test_en_us_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_subscriber_number_method
end

def test_us_phone_methods_with_en_us_locale
Faker::Config.locale = 'en-us'
Faker::Config.locale = 'en-US'

assert Faker::PhoneNumber.area_code.is_a? String
assert Faker::PhoneNumber.area_code.to_i.is_a? Integer
Expand All @@ -34,7 +34,7 @@ def test_us_phone_methods_with_en_us_locale
end

def test_validity_of_phone_method_output
Faker::Config.locale = 'en-us'
Faker::Config.locale = 'en-US'

# got the following regex from http://stackoverflow.com/a/123666/1210055 as an expression of the NANP standard.
us_number_validation_regex = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_street.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_street_address_optionally_provides_secondary_address
end

def test_street_address_with_locale_fallback
I18n.with_locale('en-gb') do
I18n.with_locale('en-GB') do
assert_match(/^\d+ \w+ \w+/, Faker::Address.street_address)
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
require 'yaml'
YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
require File.expand_path(File.dirname(__FILE__) + '/../lib/faker')

# configure I18n
locales_path = File.expand_path(File.dirname(__FILE__) + '../lib/locales')
I18n.available_locales = Dir[locales_path + '/*'].map do |file|
file.split('.').first
end
I18n.enforce_available_locales = true
18 changes: 11 additions & 7 deletions test/test_locale.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')

LoadedYaml = ['en', 'en-bork'].inject({}) do |h, locale|
LoadedYaml = ['en', 'en-BORK'].inject({}) do |h, locale|
h[locale] = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/../lib/locales/#{locale}.yml"))[locale]['faker']
h
end
Expand All @@ -18,24 +18,28 @@ def test_locale_separate_from_i18n
end

def test_configured_locale_translation
Faker::Config.locale = 'en-bork'
assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-bork']['lorem']['words'].first
Faker::Config.locale = 'en-BORK'
assert_equal Faker::Base.translate('faker.lorem.words').first, LoadedYaml['en-BORK']['lorem']['words'].first
end

def test_locale_override_when_calling_translate
Faker::Config.locale = 'en-bork'
Faker::Config.locale = 'en-BORK'
assert_equal Faker::Base.translate('faker.lorem.words', :locale => :en).first, LoadedYaml['en']['lorem']['words'].first
end

def test_translation_fallback
Faker::Config.locale = 'en-bork'
assert_nil LoadedYaml['en-bork']['name']
Faker::Config.locale = 'en-BORK'
assert_nil LoadedYaml['en-BORK']['name']
assert_equal Faker::Base.translate('faker.name.first_name').first, LoadedYaml['en']['name']['first_name'].first
end

def test_regex
Faker::Config.locale = 'en-gb'
Faker::Config.locale = 'en-GB'
re = /[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}/
assert re.match(result = Faker::Address.postcode), "#{result} didn't match #{re}"
end

def test_available_locales
assert I18n.locale_available?('en-GB')
end
end

0 comments on commit 9d47686

Please sign in to comment.