{"id":14956012,"url":"https://github.com/encoreshao/china_regions","last_synced_at":"2025-09-09T03:32:34.062Z","repository":{"id":6323366,"uuid":"7558439","full_name":"encoreshao/china_regions","owner":"encoreshao","description":"Ruby Library for China Regions","archived":false,"fork":false,"pushed_at":"2022-07-08T15:59:58.000Z","size":138,"stargazers_count":25,"open_issues_count":0,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-24T02:38:04.968Z","etag":null,"topics":["china","cities","countries","regions","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/encoreshao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-11T10:53:32.000Z","updated_at":"2024-12-17T07:47:58.000Z","dependencies_parsed_at":"2022-09-12T23:42:10.336Z","dependency_job_id":null,"html_url":"https://github.com/encoreshao/china_regions","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/encoreshao/china_regions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encoreshao%2Fchina_regions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encoreshao%2Fchina_regions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encoreshao%2Fchina_regions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encoreshao%2Fchina_regions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/encoreshao","download_url":"https://codeload.github.com/encoreshao/china_regions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encoreshao%2Fchina_regions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274238703,"owners_count":25247110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china","cities","countries","regions","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:12:10.687Z","updated_at":"2025-09-09T03:32:33.787Z","avatar_url":"https://github.com/encoreshao.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChinaRegions\n\n[![Gem Version](https://badge.fury.io/rb/china_regions.svg)](https://badge.fury.io/rb/china_regions)\n[![Build Status](https://travis-ci.org/encoreshao/china_regions.svg?branch=master)](https://travis-ci.org/encoreshao/china_regions)\n[![Coverage Status](https://coveralls.io/repos/github/encoreshao/china_regions/badge.svg)](https://coveralls.io/github/encoreshao/china_regions)\n\n[README](README.md) | [中文文档](README.zh.md)\n\nChinaRegions provides Ruby on Rails code for provinces, cities, and districts [prefecture-level cities] in China. The code need to requires Ruby (\u003e 1.9.x) and Rails (\u003e 4.0).\n\n### Data Sources\n\n*   Ministry of Civil Affairs, National Bureau of Statistics:\n    * [State Statistics Bureau of the People's Republic of China-Statistical Divisions and Urban-Rural Division Codes](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)\n    * [State Statistics Bureau of the People's Republic of China-Statistical Division Codes and Urban-rural Division Codes Compilation Rules](http://www.stats.gov.cn/tjsj/tjbz/200911/t20091125_8667.html)\n*   This item has been updated to:\n    * [2018 zoning code and urban-rural division code for statistics (cut-off time: 2018-10-31, release time: 2019-01-31)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2018/index.html)\n\n### How to update data\n\nIf you are using ChinaRegions version 0.1.x be sure to run:\n\n```\nrails g china_regions:regions\n```\n\nto have the javascript file copied over into your project.\n\n### Installation\n\nAdd it to your Gemfile:\n\n```\ngem 'china_regions'\n```\n\nRun the following command to install it:\n\n```\nbundle install\n```\n\nRun the generator:\n\n```\nrails g china_regions:install\n```\n\nThen you can see the changes that happened to the console:\n\n  - Copy `db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb` to `db/migrate` folder.\n  - Copy `regions.en.yml` and `regions.zh.yml` files to `config/locales` folders\n\nCreate tables (provinces, cities, districts):\n\n```\nrake db:migrate\n```\n\nCopy Models [`Province`, `City`, `District`] into your project:\n\n```\nrails g china_regions:regions\n```\n\nNewly added models:\n\n- create  app/models/province.rb\n- create  app/models/city.rb\n- create  app/models/district.rb\n\nDownload and import the latest regions to your project:\n\n```\nrake china_regions:all\n\nOR\n\nrake china_regions:download\nrake china_regions:import\n```\n\n- Downloading regions from `Administrative-divisions-of-China` to `db/regions` folder.\n  - db/regions/pca-code.json\n- Import the regions into provinces and cities, districts\n\n### Usage\n\nExample:\n\n```\n= form_for @article do |f|\n\n  = f.region_select [:province, :city, :district]\n\n  # form_tag\n  = region_select :article, :province_id\n  = region_select :article, :city_id\n  = region_select :article, :district_id\n\n  OR\n\n  = region_select :article, :province\n  = region_select :article, :city\n  = region_select :article, :district\n\n  = f.submit class: 'btn'\n```\n\nAdd prefix name:\n\n```\n= form_for @article do |f|\n\n  = f.region_select [:province, :city, :district], :prefix =\u003e \"home\"\n  = f.region_select [:province, :city, :district], :prefix =\u003e \"work\"\n```\n\nPre-selected province:\n\n```\n= form_for @article do |f|\n  = f.region_select [:province, :city, :district], province: \"chongqing\"\n\n  OR\n\n  = f.region_select [:province, :city, :district], province: \"重庆市\"\n```\n\nPrior choice:\n\n```\n= form_for @article do |f|\n  = f.region_select [:province, :city, :district],\n          priority: {\n            province: [\"重庆市\"],\n            district: %w(巴南区 北碚区 渝北区)\n          }\n```\n\n### Contributing\n\n  We have a list of valued contributors. Check them all at: https://github.com/encoreshao/china_regions/graphs/contributors\n\n### License\n\nCopyright © 2020-02 Encore Shao. See LICENSE for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencoreshao%2Fchina_regions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fencoreshao%2Fchina_regions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencoreshao%2Fchina_regions/lists"}