mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-01 13:37:29 +01:00
Add country name download script.
This commit is contained in:
parent
1bee3dc451
commit
f6f2c4b5e1
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.73.0",
|
"version": "0.74.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -32,6 +32,7 @@
|
|||||||
"format-lang": "node scripts/format-lang.js",
|
"format-lang": "node scripts/format-lang.js",
|
||||||
"compile-lang": "formatjs compile-folder --ast build lang-compiled",
|
"compile-lang": "formatjs compile-folder --ast build lang-compiled",
|
||||||
"check-lang": "node scripts/check-lang.js",
|
"check-lang": "node scripts/check-lang.js",
|
||||||
|
"download-country-names": "node scripts/download-country-names.js",
|
||||||
"loadtest": "node scripts/loadtest.js",
|
"loadtest": "node scripts/loadtest.js",
|
||||||
"loadtest:medium": "node scripts/loadtest.js --weight=medium",
|
"loadtest:medium": "node scripts/loadtest.js --weight=medium",
|
||||||
"loadtest:heavy": "node scripts/loadtest.js --weight=heavy --verbose"
|
"loadtest:heavy": "node scripts/loadtest.js --weight=heavy --verbose"
|
||||||
|
1
public/country/id-ID.json
Normal file
1
public/country/id-ID.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"AF":"Afganistan","ZA":"Afrika Selatan","AL":"Albania","DZ":"Aljazair","US":"Amerika Serikat","AD":"Andorra","AO":"Angola","AI":"Anguilla","AQ":"Antarktika","AG":"Antigua dan Barbuda","SA":"Arab Saudi","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BS":"Bahama","BH":"Bahrain","BD":"Bangladesh","BB":"Barbados","NL":"Belanda","BQ":"Belanda Karibia","BY":"Belarus","BE":"Belgia","BZ":"Belize","BJ":"Benin","BM":"Bermuda","BT":"Bhutan","BO":"Bolivia","BA":"Bosnia dan Herzegovina","BW":"Botswana","BR":"Brasil","BN":"Brunei","BG":"Bulgaria","BF":"Burkina Faso","BI":"Burundi","TD":"Cad","CZ":"Ceko","CL":"Cile","CI":"C\u00f4te d\u2019Ivoire","CW":"Cura\u00e7ao","DK":"Denmark","DM":"Dominika","EC":"Ekuador","SV":"El Salvador","ER":"Eritrea","EE":"Estonia","SZ":"eSwatini","ET":"Etiopia","FJ":"Fiji","PH":"Filipina","FI":"Finlandia","GA":"Gabon","GM":"Gambia","GE":"Georgia","GS":"Georgia Selatan & Kep. Sandwich Selatan","GH":"Ghana","GI":"Gibraltar","GD":"Grenada","GL":"Grinlandia","GP":"Guadeloupe","GU":"Guam","GT":"Guatemala","GG":"Guernsey","GN":"Guinea","GQ":"Guinea Ekuatorial","GW":"Guinea-Bissau","GY":"Guyana","GF":"Guyana Prancis","HT":"Haiti","HN":"Honduras","HK":"Hong Kong DAK Tiongkok","HU":"Hungaria","IN":"India","ID":"Indonesia","GB":"Inggris Raya","IQ":"Irak","IR":"Iran","IE":"Irlandia","IS":"Islandia","IL":"Israel","IT":"Italia","JM":"Jamaika","JP":"Jepang","DE":"Jerman","JE":"Jersey","DJ":"Jibuti","NC":"Kaledonia Baru","KH":"Kamboja","CM":"Kamerun","CA":"Kanada","KZ":"Kazakstan","KE":"Kenya","AX":"Kepulauan Aland","KY":"Kepulauan Cayman","CC":"Kepulauan Cocos (Keeling)","CK":"Kepulauan Cook","FK":"Kepulauan Falkland","FO":"Kepulauan Faroe","MP":"Kepulauan Mariana Utara","MH":"Kepulauan Marshall","NF":"Kepulauan Norfolk","PN":"Kepulauan Pitcairn","SB":"Kepulauan Solomon","SJ":"Kepulauan Svalbard dan Jan Mayen","UM":"Kepulauan Terluar A.S.","TC":"Kepulauan Turks dan Caicos","VI":"Kepulauan Virgin Amerika Serikat","VG":"Kepulauan Virgin Britania Raya","WF":"Kepulauan Wallis dan Futuna","KG":"Kirgistan","KI":"Kiribati","CO":"Kolombia","KM":"Komoro","CG":"Kongo - Brazzaville","CD":"Kongo - Kinshasa","KR":"Korea Selatan","KP":"Korea Utara","CR":"Kosta Rika","HR":"Kroasia","CU":"Kuba","KW":"Kuwait","LA":"Laos","LV":"Latvia","LB":"Lebanon","LS":"Lesotho","LR":"Liberia","LY":"Libia","LI":"Liechtenstein","LT":"Lituania","LU":"Luksemburg","MG":"Madagaskar","MO":"Makau DAK Tiongkok","MK":"Makedonia Utara","MV":"Maladewa","MW":"Malawi","MY":"Malaysia","ML":"Mali","MT":"Malta","MA":"Maroko","MQ":"Martinik","MR":"Mauritania","MU":"Mauritius","YT":"Mayotte","MX":"Meksiko","EG":"Mesir","FM":"Mikronesia","MD":"Moldova","MC":"Monako","MN":"Mongolia","ME":"Montenegro","MS":"Montserrat","MZ":"Mozambik","MM":"Myanmar (Burma)","NA":"Namibia","NR":"Nauru","NP":"Nepal","NE":"Niger","NG":"Nigeria","NI":"Nikaragua","NU":"Niue","NO":"Norwegia","OM":"Oman","PK":"Pakistan","PW":"Palau","PA":"Panama","PG":"Papua Nugini","PY":"Paraguay","PE":"Peru","PL":"Polandia","PF":"Polinesia Prancis","PT":"Portugal","FR":"Prancis","PR":"Puerto Riko","BV":"Pulau Bouvet","HM":"Pulau Heard dan Kepulauan McDonald","IM":"Pulau Man","CX":"Pulau Natal","QA":"Qatar","CF":"Republik Afrika Tengah","DO":"Republik Dominika","RE":"R\u00e9union","RO":"Rumania","RU":"Rusia","RW":"Rwanda","EH":"Sahara Barat","BL":"Saint Barth\u00e9lemy","SH":"Saint Helena","KN":"Saint Kitts dan Nevis","LC":"Saint Lucia","MF":"Saint Martin","PM":"Saint Pierre dan Miquelon","VC":"Saint Vincent dan Grenadine","WS":"Samoa","AS":"Samoa Amerika","SM":"San Marino","ST":"Sao Tome dan Principe","NZ":"Selandia Baru","SN":"Senegal","RS":"Serbia","SC":"Seychelles","SL":"Sierra Leone","SG":"Singapura","SX":"Sint Maarten","CY":"Siprus","SK":"Slovakia","SI":"Slovenia","SO":"Somalia","ES":"Spanyol","LK":"Sri Lanka","SD":"Sudan","SS":"Sudan Selatan","SY":"Suriah","SR":"Suriname","SE":"Swedia","CH":"Swiss","TW":"Taiwan","TJ":"Tajikistan","CV":"Tanjung Verde","TZ":"Tanzania","TH":"Thailand","TL":"Timor Leste","CN":"Tiongkok","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad dan Tobago","TN":"Tunisia","TR":"Turki","TM":"Turkimenistan","TV":"Tuvalu","UG":"Uganda","UA":"Ukraina","AE":"Uni Emirat Arab","UY":"Uruguay","UZ":"Uzbekistan","VU":"Vanuatu","VA":"Vatikan","VE":"Venezuela","VN":"Vietnam","IO":"Wilayah Inggris di Samudra Hindia","PS":"Wilayah Palestina","TF":"Wilayah Selatan Perancis","YE":"Yaman","JO":"Yordania","GR":"Yunani","ZM":"Zambia","ZW":"Zimbabwe"}
|
1
public/country/uk-UA.json
Normal file
1
public/country/uk-UA.json
Normal file
File diff suppressed because one or more lines are too long
39
scripts/download-country-names.js
Normal file
39
scripts/download-country-names.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const https = require('https');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
|
||||||
|
const src = path.resolve(__dirname, '../lang');
|
||||||
|
const dest = path.resolve(__dirname, '../public/country');
|
||||||
|
const files = fs.readdirSync(src);
|
||||||
|
|
||||||
|
const getUrl = locale =>
|
||||||
|
`https://raw.githubusercontent.com/umpirsky/country-list/master/data/${locale}/country.json`;
|
||||||
|
|
||||||
|
const asyncForEach = async (array, callback) => {
|
||||||
|
for (let index = 0; index < array.length; index++) {
|
||||||
|
await callback(array[index], index, array);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!fs.existsSync(dest)) {
|
||||||
|
fs.mkdirSync(dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
const download = async files => {
|
||||||
|
await asyncForEach(files, async file => {
|
||||||
|
const locale = file.replace('-', '_').replace('.json', '');
|
||||||
|
|
||||||
|
const filename = path.join(dest, file);
|
||||||
|
if (!fs.existsSync(filename)) {
|
||||||
|
await new Promise(resolve => {
|
||||||
|
https.get(getUrl(locale), res => {
|
||||||
|
console.log('Downloaded', chalk.greenBright('->'), filename);
|
||||||
|
resolve(res.pipe(fs.createWriteStream(filename)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
download(files);
|
Loading…
Reference in New Issue
Block a user