pubid-itu 1.15.16 → 1.15.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/i18n.yaml +24 -1
- data/lib/pubid/itu/identifier/base.rb +20 -0
- data/lib/pubid/itu/renderer/base.rb +55 -16
- data/lib/pubid/itu/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75cf2bd0db5b8886773447a81ce45b3d504613e5bec7ab44aec53230c3fdf993
|
|
4
|
+
data.tar.gz: c1767e747034ed893f5df74ab4431f4fe69f6fb1a2f14a30a10764830b9f71d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7fe022744f0e235c3562a23411d50cedd8514f54029e407328cb0197e6dbddaedf7382c714d4056fd26a011a1f9c6b8c1a6efce8c33b812ff73abfd828288414
|
|
7
|
+
data.tar.gz: 1045e68b4f6e16ecbeb2c36d7da3c0d28609707ac597b3a58cb1dee237f7502955b03e41d204108f2787ed4243ec0c7897a1ad59d5684cc2870ea8fcd442f764
|
data/i18n.yaml
CHANGED
|
@@ -9,5 +9,28 @@ type:
|
|
|
9
9
|
ru: Рек.
|
|
10
10
|
es: Rec.
|
|
11
11
|
fr: Rec.
|
|
12
|
-
|
|
12
|
+
zh: 建议书
|
|
13
13
|
ar: "التوصية"
|
|
14
|
+
|
|
15
|
+
# Translation of the "Annex to" prefix used when an annex has no number
|
|
16
|
+
# (i.e. the document IS the annex of a Special Publication, not a sub-annex).
|
|
17
|
+
# For Arabic the value is positioned as a postfix instead of a prefix.
|
|
18
|
+
# Languages with an annex_long entry below (fr/es/ru/zh) intentionally have
|
|
19
|
+
# no entry here — they use the long-form template for short rendering too,
|
|
20
|
+
# so French short matches French long etc. This avoids mixing the English
|
|
21
|
+
# "OB" abbreviation with localized text; ITU itself uses the localized
|
|
22
|
+
# abbreviation (e.g. "BE" in French/Spanish).
|
|
23
|
+
# German is not an official ITU language so no long template exists.
|
|
24
|
+
annex_to:
|
|
25
|
+
ar: "ملحق"
|
|
26
|
+
de: Anhang zum
|
|
27
|
+
|
|
28
|
+
# Long-form (title-style) templates for "Annex to ..." identifiers.
|
|
29
|
+
# Used both for to_s(format: :long) and for short rendering when no
|
|
30
|
+
# annex_to entry exists for the language.
|
|
31
|
+
annex_long:
|
|
32
|
+
fr: "Annexe au BE de l'UIT %{number}"
|
|
33
|
+
es: "Anexo al BE de la UIT N.º %{number}"
|
|
34
|
+
ar: "ملحق ابلنشرة التشغيلية رقم %{number}"
|
|
35
|
+
ru: "Приложение к ОБ МСЭ %{number}"
|
|
36
|
+
zh: "国际电联操作公报附件 第 %{number} 期"
|
|
@@ -17,6 +17,11 @@ module Pubid::Itu
|
|
|
17
17
|
def initialize(publisher: "ITU", series: nil, sector: nil, part: nil,
|
|
18
18
|
date: nil, amendment: nil, subseries: nil, number: nil,
|
|
19
19
|
second_number: nil, annex: nil, range: nil, **opts)
|
|
20
|
+
if series.to_s == "OB" && sector
|
|
21
|
+
raise ArgumentError,
|
|
22
|
+
"OB (Operational Bulletin) is a cross-bureau ITU publication; " \
|
|
23
|
+
"sector must not be set"
|
|
24
|
+
end
|
|
20
25
|
|
|
21
26
|
super(**opts.merge(publisher: publisher, number: number))
|
|
22
27
|
@series = series
|
|
@@ -30,7 +35,17 @@ module Pubid::Itu
|
|
|
30
35
|
@range = range
|
|
31
36
|
end
|
|
32
37
|
|
|
38
|
+
# Render identifier as a string.
|
|
39
|
+
#
|
|
40
|
+
# @param i18n_lang [Symbol, String] language for identifier text
|
|
41
|
+
# translation (e.g. :fr renders "Annex to" as "Annexe au"). Distinct
|
|
42
|
+
# from the identifier's `language` attribute, which is the document's
|
|
43
|
+
# own language and produces the trailing suffix like "-F".
|
|
44
|
+
# @param language [Symbol, String] deprecated alias for i18n_lang.
|
|
45
|
+
# @param format [Symbol] :long for title-style rendering of supported
|
|
46
|
+
# identifiers, otherwise the default short form.
|
|
33
47
|
def to_s(**opts)
|
|
48
|
+
opts[:i18n_lang] = opts.delete(:language) if opts.key?(:language) && !opts.key?(:i18n_lang)
|
|
34
49
|
self.class.get_renderer_class.new(to_h(deep: false)).render(**opts)
|
|
35
50
|
end
|
|
36
51
|
|
|
@@ -68,6 +83,11 @@ module Pubid::Itu
|
|
|
68
83
|
get_transformer_class.new.apply(k => v)
|
|
69
84
|
end.inject({}, :merge)
|
|
70
85
|
|
|
86
|
+
# OB is a cross-bureau ITU publication; legacy strings like
|
|
87
|
+
# "ITU-T OB.1096" round-trip by silently dropping the bureau here.
|
|
88
|
+
# Direct Identifier.create with sector+OB still raises.
|
|
89
|
+
identifier_params.delete(:sector) if identifier_params[:series].to_s == "OB"
|
|
90
|
+
|
|
71
91
|
%i(supplement amendment corrigendum annex addendum appendix).each do |type|
|
|
72
92
|
return transform_supplements(type, identifier_params) if identifier_params[type]
|
|
73
93
|
end
|
|
@@ -2,6 +2,8 @@ module Pubid::Itu::Renderer
|
|
|
2
2
|
class Base < Pubid::Core::Renderer::Base
|
|
3
3
|
TYPE_PREFIX = "".freeze
|
|
4
4
|
|
|
5
|
+
LANGUAGES = Pubid::Core::Renderer::Base::LANGUAGES.merge("zh" => "C").freeze
|
|
6
|
+
|
|
5
7
|
def render(**args)
|
|
6
8
|
render_base_identifier(**args) + @prerendered_params[:language].to_s
|
|
7
9
|
end
|
|
@@ -20,28 +22,64 @@ module Pubid::Itu::Renderer
|
|
|
20
22
|
# can prepend entity, can postpend, can use item holder
|
|
21
23
|
|
|
22
24
|
def render_identifier(params, opts)
|
|
23
|
-
postfix = prefix = ""
|
|
24
25
|
if @params[:annex] && @params[:annex][:number].nil?
|
|
25
|
-
|
|
26
|
-
elsif opts[:language] &&
|
|
27
|
-
(type_translation = Pubid::Itu::I18N["type"][@params[:type]]&.fetch(opts[:language].to_s, nil))
|
|
28
|
-
if opts[:language] == :cn
|
|
29
|
-
postfix =+ type_translation
|
|
30
|
-
elsif opts[:language] == :ar
|
|
31
|
-
postfix += " #{type_translation}"
|
|
32
|
-
else
|
|
33
|
-
prefix += "#{type_translation} "
|
|
34
|
-
end
|
|
26
|
+
return render_annex_to_identifier(params, opts)
|
|
35
27
|
end
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
prefix, postfix = type_translation_affixes(opts)
|
|
30
|
+
"#{prefix}#{render_structural(params)}#{postfix}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Render "Annex to ..." identifier (annex of a Special Publication, where
|
|
34
|
+
# the annex itself has no number). Three forms:
|
|
35
|
+
# * default (no language): English structural, "Annex to ITU OB No. 1000"
|
|
36
|
+
# * short with language: structural translation using annex_to
|
|
37
|
+
# * long with language: per-language annex_long template (title-style)
|
|
38
|
+
# Languages without an annex_to entry (ru, zh) use the long template for
|
|
39
|
+
# the short form too.
|
|
40
|
+
def render_annex_to_identifier(params, opts)
|
|
41
|
+
lang = opts[:i18n_lang]&.to_s
|
|
42
|
+
long_template = lang && Pubid::Itu::I18N["annex_long"]&.fetch(lang, nil)
|
|
43
|
+
|
|
44
|
+
if opts[:format] == :long && long_template
|
|
45
|
+
return long_template % { number: @params[:number] }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
annex_translation = lang && Pubid::Itu::I18N["annex_to"]&.fetch(lang, nil)
|
|
49
|
+
|
|
50
|
+
if annex_translation
|
|
51
|
+
return "#{render_structural(params)} #{annex_translation}" if lang == "ar"
|
|
52
|
+
|
|
53
|
+
return "#{annex_translation} #{render_structural(params)}"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return long_template % { number: @params[:number] } if long_template
|
|
57
|
+
|
|
58
|
+
"Annex to #{render_structural(params)}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def render_structural(params)
|
|
62
|
+
pub_sector = params[:sector].to_s.empty? ? "%{publisher}" : "%{publisher}-%{sector}"
|
|
63
|
+
"#{pub_sector} #{render_type_series(params)}%{number}%{subseries}"\
|
|
38
64
|
"%{part}%{second_number}%{range}%{annex}%{amendment}%{corrigendum}%{supplement}"\
|
|
39
|
-
"%{addendum}%{appendix}%{date}
|
|
65
|
+
"%{addendum}%{appendix}%{date}" % params
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def type_translation_affixes(opts)
|
|
69
|
+
type_translation = opts[:i18n_lang] &&
|
|
70
|
+
Pubid::Itu::I18N["type"][@params[:type]]&.fetch(opts[:i18n_lang].to_s, nil)
|
|
71
|
+
return ["", ""] unless type_translation
|
|
72
|
+
|
|
73
|
+
case opts[:i18n_lang]
|
|
74
|
+
when :zh then ["", type_translation]
|
|
75
|
+
when :ar then ["", " #{type_translation}"]
|
|
76
|
+
else ["#{type_translation} ", ""]
|
|
77
|
+
end
|
|
40
78
|
end
|
|
41
79
|
|
|
42
80
|
def render_publisher(publisher, opts, params)
|
|
43
|
-
if opts[:
|
|
44
|
-
(publisher_translation = Pubid::Itu::I18N["publisher"][publisher]&.fetch(opts[:
|
|
81
|
+
if opts[:i18n_lang] &&
|
|
82
|
+
(publisher_translation = Pubid::Itu::I18N["publisher"][publisher]&.fetch(opts[:i18n_lang].to_s, nil))
|
|
45
83
|
return super(publisher_translation, opts, params)
|
|
46
84
|
end
|
|
47
85
|
|
|
@@ -121,7 +159,8 @@ module Pubid::Itu::Renderer
|
|
|
121
159
|
end
|
|
122
160
|
|
|
123
161
|
def render_language(language, _opts, _params)
|
|
124
|
-
|
|
162
|
+
code = LANGUAGES[language]
|
|
163
|
+
code ? "-#{code}" : nil
|
|
125
164
|
end
|
|
126
165
|
end
|
|
127
166
|
end
|
data/lib/pubid/itu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid-itu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.15.
|
|
4
|
+
version: 1.15.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: parslet
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.15.
|
|
33
|
+
version: 1.15.18
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.15.
|
|
40
|
+
version: 1.15.18
|
|
41
41
|
description: Library to generate, parse and manipulate ITU PubID.
|
|
42
42
|
email:
|
|
43
43
|
- open.source@ribose.com
|