diff --git a/Rakefile b/Rakefile index 6a9ed17..aedd54c 100644 --- a/Rakefile +++ b/Rakefile @@ -22,14 +22,14 @@ end desc "write all languages to output" task :all_languages do I18nData.languages.each_key do |lc| - `rake languages LANGUAGE=#{lc}` + sh "rake languages LANGUAGE=#{lc}" end end -desc "write languages to output/languages_{language}" +desc "write languages to output/languages_{LANGUAGE}" task :languages do - raise unless (language = ENV.fetch('LANGUAGE', nil)) - `mkdir -p output` + language = ENV.fetch('LANGUAGE') + sh "mkdir -p output" data = I18nData.languages(language.upcase) File.write "output/languages_#{language.downcase}.yml", data.to_yaml end @@ -37,14 +37,14 @@ end desc "write all countries to output to debug" task :all_countries do I18nData.languages.each_key do |lc| - `rake countries LANGUAGE=#{lc}` + sh "rake countries LANGUAGE=#{lc}" end end -desc "write countries to output/countries_{language} to debug" +desc "write countries to output/countries_{LANGUAGE} to debug" task :countries do - raise unless (language = ENV.fetch('LANGUAGE', nil)) - `mkdir -p output` + language = ENV.fetch('LANGUAGE') + sh "mkdir -p output" data = I18nData.countries(language.upcase) File.open("output/countries_#{language.downcase}.yml", 'w') { |f| f.puts data.to_yaml } end diff --git a/cache/file_data_provider/countries-NO.txt b/cache/file_data_provider/countries-NO.txt new file mode 100644 index 0000000..bcd5e7f --- /dev/null +++ b/cache/file_data_provider/countries-NO.txt @@ -0,0 +1,249 @@ +AW;;Aruba +AF;;Afghanistan +AO;;Angola +AI;;Anguilla +AX;;Åland +AL;;Albania +AD;;Andorra +AE;;De forente arabiske emirater +AR;;Argentina +AM;;Armenia +AS;;Amerikansk Samoa +AQ;;Antarktika +TF;;Franske sørlige territorier +AG;;Antigua og Barbuda +AU;;Australia +AT;;Østerrike +AZ;;Aserbajdsjan +BI;;Burundi +BE;;Belgia +BJ;;Benin +BQ;;Bonaire, Sint Eustatius og Saba +BF;;Burkina Faso +BD;;Bangladesh +BG;;Bulgaria +BH;;Bahrain +BS;;Bahamas +BA;;Bosnia-Hercegovina +BL;;Saint-Barthélemy +BY;;Hviterussland +BZ;;Belize +BM;;Bermuda +BO;;Bolivia +BR;;Brasil +BB;;Barbados +BN;;Brunei Darussalam +BT;;Bhutan +BV;;Bouvetøya +BW;;Botswana +CF;;Den sentralafrikanske republikk +CA;;Canada +CC;;Kokosøyene +CH;;Sveits +CL;;Chile +CN;;Kina +CI;;Elfenbenskysten +CM;;Kamerun +CD;;Kongo, Den demokratiske republikk +CG;;Kongo +CK;;Cookøyene +CO;;Colombia +KM;;Komorene +CV;;Kapp Verde +CR;;Costa Rica +CU;;Cuba +CW;;Curaçao +CX;;Christmasøya +KY;;Caymanøyene +CY;;Kypros +CZ;;Tsjekkia +DE;;Tyskland +DJ;;Djibouti +DM;;Dominica +DK;;Danmark +DO;;Den dominikanske republikk +DZ;;Algerie +EC;;Ecuador +EG;;Egypt +ER;;Eritrea +EH;;Vest-Sahara +ES;;Spania +EE;;Estland +ET;;Etiopia +FI;;Finland +FJ;;Fiji +FK;;Falklandsøyene +FR;;Frankrike +FO;;Færøyene +FM;;Mikronesia, Føderasjonen +GA;;Gabon +GB;;Storbritannia +GE;;Georgia +GG;;Guernsey +GH;;Ghana +GI;;Gibraltar +GN;;Guinea +GP;;Guadeloupe +GM;;Gambia +GW;;Guinea-Bissau +GQ;;Ekvatorial-Guinea +GR;;Hellas +GD;;Grenada +GL;;Grønland +GT;;Guatemala +GF;;Fransk Guyana +GU;;Guam +GY;;Guyana +HK;;Hongkong +HM;;Heard- og McDonaldøyene +HN;;Honduras +HR;;Kroatia +HT;;Haiti +HU;;Ungarn +ID;;Indonesia +IM;;Man +IN;;India +IO;;Det britiske territoriet i Indiahavet +IE;;Irland +IR;;Iran +IQ;;Irak +IS;;Island +IL;;Israel +IT;;Italia +JM;;Jamaica +JE;;Jersey +JO;;Jordan +JP;;Japan +KZ;;Kasakhstan +KE;;Kenya +KG;;Kirgisistan +KH;;Kambodsja +KI;;Kiribati +KN;;Saint Kitts og Nevis +KR;;Sør-Korea +KW;;Kuwait +LA;;Laos +LB;;Libanon +LR;;Liberia +LY;;Libya +LC;;Saint Lucia +LI;;Liechtenstein +LK;;Sri Lanka +LS;;Lesotho +LT;;Litauen +LU;;Luxembourg +LV;;Latvia +MO;;Macao +MF;;Saint Martin (fransk del) +MA;;Marokko +MC;;Monaco +MD;;Moldova +MG;;Madagaskar +MV;;Maldivene +MX;;Mexico +MH;;Marshalløyene +MK;;Nord-Makedonia +ML;;Mali +MT;;Malta +MM;;Myanmar +ME;;Montenegro +MN;;Mongolia +MP;;Nord-Marianene +MZ;;Mosambik +MR;;Mauritania +MS;;Montserrat +MQ;;Martinique +MU;;Mauritius +MW;;Malawi +MY;;Malaysia +YT;;Mayotte +NA;;Namibia +NC;;Ny-Caledonia +NE;;Niger +NF;;Norfolkøya +NG;;Nigeria +NI;;Nicaragua +NU;;Niue +NL;;Nederland +NO;;Norge +NP;;Nepal +NR;;Nauru +NZ;;New Zealand +OM;;Oman +PK;;Pakistan +PA;;Panama +PN;;Pitcairn +PE;;Peru +PH;;Filippinene +PW;;Palau +PG;;Papua Ny-Guinea +PL;;Polen +PR;;Puerto Rico +KP;;Nord-Korea +PT;;Portugal +PY;;Paraguay +PS;;Palestina, staten +PF;;Fransk Polynesia +QA;;Qatar +RE;;Réunion +RO;;Romania +RU;;Den russiske føderasjon +RW;;Rwanda +SA;;Saudi-Arabia +SD;;Sudan +SN;;Senegal +SG;;Singapore +GS;;Sør-Georgia og Sør-Sandwichøyene +SH;;Saint Helena, Ascension og Tristan da Cunha +SJ;;Svalbard og Jan Mayen +SB;;Salomonøyene +SL;;Sierra Leone +SV;;El Salvador +SM;;San Marino +SO;;Somalia +PM;;Saint-Pierre og Miquelon +RS;;Serbia +SS;;Sør-Sudan +ST;;São Tomé og Príncipe +SR;;Surinam +SK;;Slovakia +SI;;Slovenia +SE;;Sverige +SZ;;Eswatini (tidligere Swasiland) +SX;;Sint Maarten (nederlandsk del) +SC;;Seychellene +SY;;Syria +TC;;Turks- og Caicosøyene +TD;;Tsjad +TG;;Togo +TH;;Thailand +TJ;;Tadsjikistan +TK;;Tokelau +TM;;Turkmenistan +TL;;Øst-Timor +TO;;Tonga +TT;;Trinidad og Tobago +TN;;Tunisia +TR;;Tyrkia +TV;;Tuvalu +TW;;Taiwan +TZ;;Tanzania +UG;;Uganda +UA;;Ukraina +UM;;Mindre utenforliggende øyer til USA +UY;;Uruguay +US;;De forente stater +UZ;;Usbekistan +VA;;Vatikanstaten +VC;;Saint Vincent og Grenadinene +VE;;Venezuela +VG;;Jomfruøyene (Storbritannia) +VI;;Jomfruøyene (USA) +VN;;Vietnam +VU;;Vanuatu +WF;;Wallis og Futunaøyene +WS;;Samoa +YE;;Jemen +ZA;;Sør-Afrika +ZM;;Zambia +ZW;;Zimbabwe \ No newline at end of file diff --git a/cache/file_data_provider/languages-NO.txt b/cache/file_data_provider/languages-NO.txt new file mode 100644 index 0000000..fc06fac --- /dev/null +++ b/cache/file_data_provider/languages-NO.txt @@ -0,0 +1,184 @@ +AA;;afar +AB;;Abkhazian +AF;;Afrikansk +AK;;Akan +AM;;Amharic +AR;;Arabisk +AN;;aragonsk +AS;;assamisk +AV;;Avaric +AE;;avestisk +AY;;aymara +AZ;;Aserbadjansk +BA;;basjkirsk +BM;;bambara +BE;;Hviterussisk +BN;;Bengali +BH;;Bihari +BI;;bislama +BO;;tibetansk +BS;;Bosnisk +BR;;Breton +BG;;Bulgarsk +CA;;Catalan; Valencian +CS;;Tjekkisk +CH;;chamorro +CE;;Chechen +CU;;Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic +CV;;tsjuvansk +KW;;Cornish +CO;;Korsikansk +CR;;Cree +CY;;Walisisk +DA;;Dansk +DE;;Tysk +DV;;Divehi; Dhivehi; Maldivian +DZ;;dzongkha +EL;;Greek, Modern (1453-) +EN;;Engelsk +EO;;Esperanto +ET;;Estonsk +EU;;Baskisk +EE;;ewe +FO;;færøysk +FA;;Persisk +FJ;;fijiansk +FI;;Finsk +FR;;Fransk +FY;;Vestfrisisk +FF;;fulani +GD;;Gaelic; Scottish Gaelic +GA;;Irsk +GL;;Galisisk +GV;;manx +GN;;Guarani +GU;;gujarati +HT;;Haitian; Haitian Creole +HA;;Hausa +HE;;Hebraisk +HZ;;Herero +HI;;hindi +HO;;Hiri Motu +HR;;Kroatsisk +HU;;Ungarsk +HY;;armensk +IG;;ibo +IO;;ido +II;;Sichuan Yi; Nuosu +IU;;inuktitut +IE;;Interlingue; Occidental +IA;;Interlingua (International Auxiliary Language Association) +ID;;Indonesisk +IK;;unupiak +IS;;Islandsk +IT;;Italiensk +JV;;Javanesisk +JA;;Japansk +KL;;Kalaallisut; Greenlandic +KN;;kannada +KS;;kasjmiri +KA;;Georgisk +KR;;Kanuri +KK;;kasakhisk +KM;;Central Khmer +KI;;Kikuyu; Gikuyu +RW;;kinjarwanda +KY;;Kirghiz; Kyrgyz +KV;;komi +KG;;kikongo +KO;;Koreansk +KJ;;Kuanyama; Kwanyama +KU;;Kurdisk +LO;;laotisk +LA;;Latin +LV;;Latvisk +LI;;Limburgan; Limburger; Limburgish +LN;;lingala +LT;;Lituaisk +LB;;Luxembourgish; Letzeburgesch +LU;;luba-katanga +LG;;ganda +MH;;Marshallese +ML;;malayalam +MR;;Marathi +MK;;Makedonsk +MG;;madagassisk +MT;;Maltisk +MN;;Mongolsk +MI;;Maori +MS;;malayisk +MY;;burmesisk +NA;;nauru +NV;;Navajo; Navaho +NR;;Ndebele, South; South Ndebele +ND;;Ndebele, North; North Ndebele +NG;;Ndonga +NE;;nepalsk +NL;;Dutch; Flemish +NN;;Norsk, nynorsk +NB;;Norsk, bokmål +NO;;Norsk +NY;;Chichewa; Chewa; Nyanja +OC;;Occitan (post 1500); Provençal +OJ;;ojibwa +OR;;oriya +OM;;oromo +OS;;Ossetian; Ossetic +PA;;Panjabi; Punjabi +PI;;Pali +PL;;Polsk +PT;;Portugisisk +PS;;Pushto; Pashto +QU;;quechua +RM;;Romansh +RO;;Romanian; Moldavian; Moldovan +RN;;rundi +RU;;Russisk +SG;;sango +SA;;sanskrit +SI;;Sinhala; Sinhalese +SK;;Slovakisk +SL;;Slovensk +SE;;nordsamisk +SM;;samoansk +SN;;Shona +SD;;sindhi +SO;;somalisk +ST;;Sotho, (sørlig) +ES;;Spanish; Castilian +SQ;;Albansk +SC;;Sardinsk +SR;;Serbisk +SS;;swati +SU;;sundanesisk +SW;;swahili +SV;;Svensk +TY;;Tahitisk +TA;;Tamilsk +TT;;tatarisk +TE;;telugu +TG;;Tajik +TL;;tagalog +TH;;Thai +TI;;Tigrinya +TO;;tonga (Tonga-øyene) +TN;;tswana +TS;;tsonga +TK;;turkmensk +TR;;Tyrkisk +TW;;twi +UG;;Uighur; Uyghur +UK;;Ukrainsk +UR;;urdu +UZ;;usbekisk +VE;;venda +VI;;Vietnamesisk +VO;;Volapük +WA;;Vietnamesisk +WO;;wolof +XH;;Xhosa +YI;;jiddisk +YO;;joruba +ZA;;Zhuang; Chuang +ZH;;Kinesisk +ZU;;Zulu \ No newline at end of file diff --git a/lib/i18n_data/live_data_provider.rb b/lib/i18n_data/live_data_provider.rb index eba4f54..83e88ce 100644 --- a/lib/i18n_data/live_data_provider.rb +++ b/lib/i18n_data/live_data_provider.rb @@ -60,12 +60,18 @@ def translate(type, alpha3, to_language_code) def translations(type, language_code) @translations ||= {} @translations["#{type}_#{language_code}"] ||= begin + # FOO_BAR -> foo_BAR code = language_code.split("_") code[0].downcase! code = code.join("_") begin file_path = "#{CLONE_DEST}/#{TRANSLATIONS[type]}#{code}.po" + + # norwegian is somehow special :shrug: + # https://salsa.debian.org/iso-codes-team/iso-codes/-/tree/main/iso_639-2 + file_path = file_path.sub("/no.po", "/nb_no.po") + data = SimplePoParser.parse(file_path) data = data[1..] # Remove the initial info block in the .po file @@ -75,7 +81,10 @@ def translations(type, language_code) fallback_names.merge(common_names) rescue Errno::ENOENT - raise NoTranslationAvailable, "for #{type} and language code = #{code} (#{$!})" + raise( + NoTranslationAvailable, + "No translation available for #{type} and language code = #{code} (#{$!})" + ) end end end