mledoze / countries
世界国家列表,提供JSON、CSV、XML和Yaml格式
Requires
- php: >=8.1
- ext-dom: *
- ext-gettext: *
- symfony/console: ~5.4|~6.3
- symfony/yaml: ~5.4|~6.3
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-08-29 22:56:54 UTC
README
国家数据
此仓库包含按照ISO标准3166-1定义的世界国家列表,提供JSON、CSV、XML和YAML格式。注意:本项目中的某些实体并非独立国家;请参考independent
属性以了解国家是否被视为主权国家。
每行包含一个国家的信息
名称
common
- 英文常用名称official
- 英文官方名称native
- 所有本地名称列表- key: 三字母ISO 639-3语言代码
- value: 名称对象
- key:
official
- 官方名称翻译 - key:
common
- 常用名称翻译
- key:
- 顶级域名(
tld
) - ISO 3166-1 alpha-2代码(
cca2
) - ISO 3166-1数字代码(
ccn3
) - ISO 3166-1 alpha-3代码(
cca3
) - 国际奥委会代码(
cioc
) - ISO 3166-1独立状态(
independent
)(表示国家被视为主权国家) - ISO 3166-1分配状态(
status
) - 联合国成员状态(
unMember
) currencies
- 所有货币列表- key: ISO 4217货币代码
- value: 货币对象
- key:
name
货币名称 - key:
symbol
货币符号
- key:
- 国际直拨电话信息(
idd
)root
- 地理代码前缀。例如,新西兰为+6,英国为+4。suffixes
- 分配给该国家的前缀列表。新西兰为4,多米尼加共和国为809、829和849。
- 首都(
capital
) - 备选拼写(
altSpellings
) - 地区
- 子地区
- 官方语言列表(
languages
)- key: 三字母ISO 639-3语言代码
- value: 英文名称的语言
- 名称翻译列表(
translations
)- key: 三字母ISO 639-3语言代码
- value: 名称对象
- key: official - 官方名称翻译
- key: common - 常用名称翻译
- 纬度和经度(
latlng
) demonyms
- 居民名称,翻译并按性别分类- key: 三字母ISO 639-3语言代码
- value: 性别分类的名称对象
- key:
f
(女性)或m
(男性) - value: 性别分类的名称翻译
- key:
- 内陆状态(
landlocked
) - 陆界(
borders
) - 平方公里土地面积(
area
) - 表情旗(
flag
) - 电话区号(
callingCodes
)
附加数据
数据文件夹data包含额外的数据,例如国家的GeoJSON轮廓和SVG格式的国旗。
示例
JSON
{ "name": { "common": "Austria", "official": "Republic of Austria", "native": { "bar": { "official": "Republik Österreich", "common": "Österreich" } } }, "tld": [".at"], "cca2": "AT", "ccn3": "040", "cca3": "AUT", "cioc": "AUT", "independent": true, "status": "officially-assigned", "unMember": true, "currencies": {"EUR": {"name": "Euro", "symbol": "\u20ac"}}, "idd": { "root": "+4", "suffixes": ["3"] }, "capital": ["Vienna"], "altSpellings": ["AT", "Osterreich", "Oesterreich"], "region": "Europe", "subregion": "Western Europe", "languages": { "bar": "Austro-Bavarian German" }, "translations": { "cym": {"official": "Republic of Austria", "common": "Awstria"}, "deu": {"official": "Republik Österreich", "common": "Österreich"}, "fra": {"official": "République d'Autriche", "common": "Autriche"}, "hrv": {"official": "Republika Austrija", "common": "Austrija"}, "ita": {"official": "Repubblica d'Austria", "common": "Austria"}, "jpn": {"official": "オーストリア共和国", "common": "オーストリア"}, "nld": {"official": "Republiek Oostenrijk", "common": "Oostenrijk"}, "por": {"official": "República da Áustria", "common": "Áustria"}, "rus": {"official": "Австрийская Республика", "common": "Австрия"}, "spa": {"official": "República de Austria", "common": "Austria"} }, "latlng": [47.33333333, 13.33333333], "demonyms": { "fra": { "f": "Autrichienne", "m": "Autrichien" }, "spa": { "f": "Austriaco", "m": "Austriaca" } }, "landlocked": true, "borders": ["CZE", "DEU", "HUN", "ITA", "LIE", "SVK", "SVN", "CHE"], "area": 83871, "callingCodes": ["+43"] "flag": "\ud83c\udde6\ud83c\uddf9" }
GeoJSON和TopoJSON轮廓
查看德国示例:[GeoJSON](https://github.com/mledoze/countries/blob/bb61a1cddfefd09ad5c92ad0a1effbfceba39930/data/deu.geo.json) 或 [TopoJSON](https://github.com/mledoze/countries/blob/442472de98e80f4a44f1028960dbb0dfb1d942fe/data/deu.topo.json)。
CSV
"name";"tld";"cca2";"ccn3";"cca3";"cioc";"currency";"idd";"capital";"altSpellings";"region";"subregion";"languages";"translations";"latlng";"demonym";"landlocked";"borders";"area"
⋮
"Aruba,Aruba,Aruba,Aruba,Aruba,Aruba";".aw";"AW";"533";"ABW";"ARU";"AWG";"+2,97";"Oranjestad";"AW";"Americas";"Caribbean";"Dutch,Papiamento";"Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,アルバ,アルバ,Aruba,Aruba,Aruba,Aruba,Аруба,Аруба,Aruba,Aruba";"12.5,-69.96666666";"Aruban";"";"";"180"
"Afghanistan,Islamic Republic of Afghanistan,جمهوری اسلامی افغانستان,افغانستان,د افغانستان اسلامي جمهوریت,افغانستان,Owganystan Yslam Respublikasy,Owganystan";".af";"AF";"004";"AFG";"AFG";"AFN";"+9,3";"Kabul";"AF,Afġānistān";"Asia";"Southern Asia";"Dari,Pashto,Turkmen";"Islamic Republic of Afghanistan,Affganistan,Islamischen Republik Afghanistan,Afghanistan,Afganistanin islamilainen tasavalta,Afganistan,République islamique d'Afghanistan,Afghanistan,Islamska Republika Afganistan,Afganistan,Repubblica islamica dell'Afghanistan,Afghanistan,アフガニスタン·イスラム共和国,アフガニスタン,Islamitische Republiek Afghanistan,Afghanistan,República Islâmica do Afeganistão,Afeganistão,Исламская Республика Афганистан,Афганистан,República Islámica de Afganistán,Afganistán";"33,65";"Afghan";"1";"IRN,PAK,TKM,UZB,TJK,CHN";"652230"
"Angola,Republic of Angola,República de Angola,Angola";".ao";"AO";"024";"AGO";"ANG";"AOA";"+2,44";"Luanda";"AO,República de Angola,ʁɛpublika de an'ɡɔla";"Africa";"Middle Africa";"Portuguese";"Republic of Angola,Angola,Republik Angola,Angola,Angolan tasavalta,Angola,République d'Angola,Angola,Republika Angola,Angola,Repubblica dell'Angola,Angola,アンゴラ共和国,アンゴラ,Republiek Angola,Angola,República de Angola,Angola,Республика Ангола,Ангола,República de Angola,Angola";"-12.5,18.5";"Angolan";"";"COG,COD,ZMB,NAM";"1246700"
⋮
XML
<?xml version="1.0" encoding="UTF-8"?> <countries> <country name="Aruba,Aruba,Aruba,Aruba,Aruba,Aruba" tld=".aw" cca2="AW" ccn3="533" cca3="ABW" cioc="ARU" currency="AWG" idd="+2,97" capital="Oranjestad" altSpellings="AW" region="Americas" subregion="Caribbean" languages="Dutch,Papiamento" translations="Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,Aruba,アルバ,アルバ,Aruba,Aruba,Aruba,Aruba,Аруба,Аруба,Aruba,Aruba" latlng="12.5,-69.96666666" demonym="Aruban" landlocked="" borders="" area="180"/> <country name="Afghanistan,Islamic Republic of Afghanistan,جمهوری اسلامی افغانستان,افغانستان,د افغانستان اسلامي جمهوریت,افغانستان,Owganystan Yslam Respublikasy,Owganystan" tld=".af" cca2="AF" ccn3="004" cca3="AFG" cioc="AFG" currency="AFN" idd="+9,3" capital="Kabul" altSpellings="AF,Afġānistān" region="Asia" subregion="Southern Asia" languages="Dari,Pashto,Turkmen" translations="Islamic Republic of Afghanistan,Affganistan,Islamischen Republik Afghanistan,Afghanistan,Afganistanin islamilainen tasavalta,Afganistan,République islamique d'Afghanistan,Afghanistan,Islamska Republika Afganistan,Afganistan,Repubblica islamica dell'Afghanistan,Afghanistan,アフガニスタン·イスラム共和国,アフガニスタン,Islamitische Republiek Afghanistan,Afghanistan,República Islâmica do Afeganistão,Afeganistão,Исламская Республика Афганистан,Афганистан,República Islámica de Afganistán,Afganistán" latlng="33,65" demonym="Afghan" landlocked="1" borders="IRN,PAK,TKM,UZB,TJK,CHN" area="652230"/> <country name="Angola,Republic of Angola,República de Angola,Angola" tld=".ao" cca2="AO" ccn3="024" cca3="AGO" cioc="ANG" currency="AOA" idd="+2,44" capital="Luanda" altSpellings="AO,República de Angola,ʁɛpublika de an'ɡɔla" region="Africa" subregion="Middle Africa" languages="Portuguese" translations="Republic of Angola,Angola,Republik Angola,Angola,Angolan tasavalta,Angola,République d'Angola,Angola,Republika Angola,Angola,Repubblica dell'Angola,Angola,アンゴラ共和国,アンゴラ,Republiek Angola,Angola,República de Angola,Angola,Республика Ангола,Ангола,República de Angola,Angola" latlng="-12.5,18.5" demonym="Angolan" landlocked="" borders="COG,COD,ZMB,NAM" area="1246700"/> ⋮ <countries>
YAML
- { name: { common: Aruba, official: Aruba, native: { nld: { official: Aruba, common: Aruba }, pap: { official: Aruba, common: Aruba } } }, tld: [.aw], cca2: AW, ccn3: '533', cca3: ABW, cioc: ARU, currency: [AWG], idd: { root: '+2', suffixes: ['97'] }, capital: Oranjestad, altSpellings: [AW], region: Americas, subregion: Caribbean, languages: { nld: Dutch, pap: Papiamento }, translations: { deu: { official: Aruba, common: Aruba }, fin: { official: Aruba, common: Aruba }, fra: { official: Aruba, common: Aruba }, hrv: { official: Aruba, common: Aruba }, ita: { official: Aruba, common: Aruba }, jpn: { official: アルバ, common: アルバ }, nld: { official: Aruba, common: Aruba }, por: { official: Aruba, common: Aruba }, rus: { official: Аруба, common: Аруба }, spa: { official: Aruba, common: Aruba } }, latlng: [12.5, -69.96666666], demonym: Aruban, landlocked: false, borders: { }, area: 180 }
- { name: { common: Afghanistan, official: 'Islamic Republic of Afghanistan', native: { prs: { official: 'جمهوری اسلامی افغانستان', common: افغانستان }, pus: { official: 'د افغانستان اسلامي جمهوریت', common: افغانستان }, tuk: { official: 'Owganystan Yslam Respublikasy', common: Owganystan } } }, tld: [.af], cca2: AF, ccn3: '004', cca3: AFG, cioc: AFG, currency: [AFN], idd: { root: '+9', suffixes: ['3'] }, capital: Kabul, altSpellings: [AF, Afġānistān], region: Asia, subregion: 'Southern Asia', languages: { prs: Dari, pus: Pashto, tuk: Turkmen }, translations: { cym: { official: 'Islamic Republic of Afghanistan', common: Affganistan }, deu: { official: 'Islamischen Republik Afghanistan', common: Afghanistan }, fin: { official: 'Afganistanin islamilainen tasavalta', common: Afganistan }, fra: { official: 'République islamique d''Afghanistan', common: Afghanistan }, hrv: { official: 'Islamska Republika Afganistan', common: Afganistan }, ita: { official: 'Repubblica islamica dell''Afghanistan', common: Afghanistan }, jpn: { official: アフガニスタン·イスラム共和国, common: アフガニスタン }, nld: { official: 'Islamitische Republiek Afghanistan', common: Afghanistan }, por: { official: 'República Islâmica do Afeganistão', common: Afeganistão }, rus: { official: 'Исламская Республика Афганистан', common: Афганистан }, spa: { official: 'República Islámica de Afganistán', common: Afganistán } }, latlng: [33, 65], demonym: Afghan, landlocked: true, borders: [IRN, PAK, TKM, UZB, TJK, CHN], area: 652230 }
- { name: { common: Angola, official: 'Republic of Angola', native: { por: { official: 'República de Angola', common: Angola } } }, tld: [.ao], cca2: AO, ccn3: '024', cca3: AGO, cioc: ANG, currency: [AOA], idd: { root: '+2', suffixes: ['44'] }, capital: Luanda, altSpellings: [AO, 'República de Angola', 'ʁɛpublika de an''ɡɔla'], region: Africa, subregion: 'Middle Africa', languages: { por: Portuguese }, translations: { cym: { official: 'Republic of Angola', common: Angola }, deu: { official: 'Republik Angola', common: Angola }, fin: { official: 'Angolan tasavalta', common: Angola }, fra: { official: 'République d''Angola', common: Angola }, hrv: { official: 'Republika Angola', common: Angola }, ita: { official: 'Repubblica dell''Angola', common: Angola }, jpn: { official: アンゴラ共和国, common: アンゴラ }, nld: { official: 'Republiek Angola', common: Angola }, por: { official: 'República de Angola', common: Angola }, rus: { official: 'Республика Ангола', common: Ангола }, spa: { official: 'República de Angola', common: Angola } }, latlng: [-12.5, 18.5], demonym: Angolan, landlocked: false, borders: [COG, COD, ZMB, NAM], area: 1246700 }
自定义输出
dist目录中提供的数据文件包含所有可用字段,也可以构建排除某些字段的定制数据版本。
要完成此操作,您首先需要一个工作的PHP安装、composer以及此仓库的本地副本。一旦您拥有了这些,请打开终端,进入此项目根目录的本地版本,并运行以下命令以安装必要的依赖项
composer install
完成后,运行以下命令(这里我们将排除输出中的tld
字段,但您可以排除任何您想要的字段)
php countries.php convert --exclude-field=tld
您还可以排除多个字段
php countries.php convert --exclude-field=tld --exclude-field=cca2
# Or using the shorter `-x` syntax:
php countries.php convert -x tld -x cca2
如果您只想包含一些字段(这不能与--exclude-field
组合)
php countries.php convert --include-field=name --include-field=area
# or using the shorter `-i` syntax:
php countries.php convert -i name -i area
生成的文件将放入dist
目录,但您可以将其更改为其他现有目录
mkdir foobar php countries.php convert --output-dir=foobar
您还可以选择只生成一些输出格式
mkdir foobar
php countries.php convert --format=json_unescaped --format=csv
# or using the shorter `-f` syntax:
php countries.php convert -f json_unescaped -f csv
展示
使用此数据集的项目
如何贡献?
请参阅CONTRIBUTING。
待办事项
- 添加国家的类型(国家、主权国家、公共机构、领土等)
- 在构建时自动从CLDR拉取数据(灵感来自@Munter,见#108)
来源
https://www.currency-iso.org/用于货币代码。
地区和子地区来自https://github.com/hexorx/countries。
GeoJSON轮廓来自http://thematicmapping.org/downloads/world_borders.php。
其余内容来自维基百科。
鸣谢
感谢
- @Glazz帮助处理国家区号
- @hexorx的工作(https://github.com/hexorx/countries)
- @frederik-jacques提供首都城市
- @fayer提供人口、地理定位、通称和面积数据
- @ancosen帮助处理边界数据
- @herrjemand提供国家名称和各种修复
- 所有贡献者:https://github.com/mledoze/countries/graphs/contributors
许可
请参阅LICENSE。
旗帜不在ODbL许可下;有关更多信息,请参阅https://en.wikipedia.org/wiki/Wikipedia:Copyright_on_emblems。