china_regions 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/city.rb +1 -1
- data/app/models/district.rb +5 -5
- data/config/locales/{en.yml → china_regions.en.yml} +6 -1
- data/config/locales/{zh.yml → china_regions.zh.yml} +5 -0
- data/lib/china_regions/version.rb +1 -1
- data/lib/generators/china_regions/install_generator.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72b433dc0d51468a2a5e06c4b51aa450e2e9ff661f13995019e7bc05f99d5b7f
|
4
|
+
data.tar.gz: 748f7542e2a8a7c6267d9bb543505706c1c1104eb08d3d71c4eb5891180d9c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64083c36bff08087d65f17a820cb24245f7279d5d2d10f5973b8dd9e39aba2fb2e57176a3322788af92b9b43c560f4d32664114a3768f0f91edeb6804c29e1f9
|
7
|
+
data.tar.gz: 314f8737b7bdc229d1f442260947ee0f4df14dade593f3a34252cc8497beed94885653ecf22d82f117f6f83d196d76d52b084384140f8c7d24ad0f4031701cc0
|
data/app/models/city.rb
CHANGED
data/app/models/district.rb
CHANGED
@@ -9,19 +9,19 @@ class District < ApplicationRecord
|
|
9
9
|
|
10
10
|
# Relationships
|
11
11
|
belongs_to :city, counter_cache: true
|
12
|
-
delegate :name, to: :city
|
12
|
+
delegate :name, to: :city, prefix: true
|
13
13
|
|
14
14
|
# Filters
|
15
15
|
scope :for_city, ->(city_id) { where(city_id: city_id) }
|
16
16
|
|
17
|
-
def full_name
|
18
|
-
[province.name, city_name, name].compact.join(' - ')
|
19
|
-
end
|
20
|
-
|
21
17
|
def province
|
22
18
|
city.province
|
23
19
|
end
|
24
20
|
|
21
|
+
def full_name
|
22
|
+
[province.name, city_name, name].compact.join(' - ')
|
23
|
+
end
|
24
|
+
|
25
25
|
def short_name
|
26
26
|
@short_name ||= name.gsub(/区|县|市|自治县/, '')
|
27
27
|
end
|
@@ -10,18 +10,23 @@ en:
|
|
10
10
|
attributes:
|
11
11
|
province:
|
12
12
|
name: Name
|
13
|
+
code: Code
|
13
14
|
name_en: English Name
|
14
15
|
name_abbr: Short Name
|
16
|
+
cities_count: Cities Count
|
15
17
|
city:
|
16
|
-
name:
|
18
|
+
name: Name
|
17
19
|
province_id: Province
|
18
20
|
province: Province
|
19
21
|
name_en: English Name
|
20
22
|
name_abbr: Short Name
|
21
23
|
level: Level
|
24
|
+
code: Code
|
25
|
+
districts_count: Districts Count
|
22
26
|
district:
|
23
27
|
name: Name
|
24
28
|
city_id: City
|
25
29
|
city: City
|
26
30
|
name_en: English Name
|
27
31
|
name_abbr: Short Name
|
32
|
+
code: Code
|
@@ -10,8 +10,10 @@ zh:
|
|
10
10
|
attributes:
|
11
11
|
province:
|
12
12
|
name: 名称
|
13
|
+
code: 编码
|
13
14
|
name_en: 拼音
|
14
15
|
name_abbr: 简称
|
16
|
+
cities_count: 城市数
|
15
17
|
city:
|
16
18
|
name: 名称
|
17
19
|
province_id: 省份
|
@@ -19,9 +21,12 @@ zh:
|
|
19
21
|
name_en: 拼音
|
20
22
|
name_abbr: 简称
|
21
23
|
level: 等级
|
24
|
+
code: 编码
|
25
|
+
districts_count: 地区数
|
22
26
|
district:
|
23
27
|
name: 名称
|
24
28
|
city_id: 城市
|
25
29
|
city: 城市
|
26
30
|
name_en: 拼音
|
27
31
|
name_abbr: 简称
|
32
|
+
code: 编码
|
@@ -14,7 +14,7 @@ module ChinaRegions
|
|
14
14
|
def copy_locales
|
15
15
|
%w[en zh].each do |locale|
|
16
16
|
config_file = "config/locales/regions.#{locale}.yml"
|
17
|
-
copy_file "../../../../config/locales
|
17
|
+
copy_file "../../../../config/locales/china_regions.#{locale}.yml", config_file unless File.exist?(config_file)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: china_regions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
@@ -120,8 +120,8 @@ files:
|
|
120
120
|
- bin/console
|
121
121
|
- bin/setup
|
122
122
|
- china_regions.gemspec
|
123
|
-
- config/locales/en.yml
|
124
|
-
- config/locales/zh.yml
|
123
|
+
- config/locales/china_regions.en.yml
|
124
|
+
- config/locales/china_regions.zh.yml
|
125
125
|
- config/routes.rb
|
126
126
|
- lib/china_regions.rb
|
127
127
|
- lib/china_regions/engine.rb
|