en16931 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bbd210e0095f8219bcd4986120584bfba05a5bba5a19e5a070c2bbfa54fc20a
4
- data.tar.gz: 744699d446e6aa6a8fa5778a78cd1e3d665ae7e4178daa634dee99609a76c18a
3
+ metadata.gz: 7be715d5bb4855f1931a991eb15d996170d645e94b6df75bcbfbb53326387dc6
4
+ data.tar.gz: 6e01c51f98b6d2129cff0773e58d12bed8b2262e2392b10ccf155de7e871641a
5
5
  SHA512:
6
- metadata.gz: 110226e91fb731c786161418a360eff39dce7b4f1ccc2ef01b67eed1768c5aed49a04b6500f26cc766b1e55a38b0ea9175d435ab75f06ec8acfdc169f632a71a
7
- data.tar.gz: a0964ab315fc8989ab53e2191f00d5ec3a9249afa5215b63ab20810fbb20e21798211088827eb154c483f5d3f3fa389eac70f51feb55b5ece0176f9036a62781
6
+ metadata.gz: 205460c6eff6e40a81d3d3b0e790726aa3ef34bf95738a159008dbe5277682022e1a16b8313a4708c12980ada01acfcd75fa9a8ba96742a723d3a52cf7bb0a55
7
+ data.tar.gz: c85b7cfb3d0a19f03e2e5f296edce4891e1848780f35107e09c6955782d70d552df0c7c37e068f6c1917753c53a968c5b073393f8b8fc75ba8e1f97709fbc75d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2026-10-22
4
+
5
+ - The buyer's country is named in the invoice language for every ISO country, from the Unicode CLDR (`data/countries.yml`, `rake countries`). Before, only nine countries had a name, in German.
6
+
3
7
  ## [0.2.0] - 2026-10-22
4
8
 
5
9
  - **Breaking:** amounts, quantities and rates (`Line#unit_price`, `Line#quantity`, `AllowanceCharge#amount`, `Tax#rate`, `Invoice#prepaid`) refuse a `Float` with an `ArgumentError`. Pass a `BigDecimal`, an `Integer` or a decimal `String`.
data/README.md CHANGED
@@ -92,7 +92,7 @@ branding = EN16931::Branding.new(
92
92
  pdf = EN16931::PDF.render(invoice, branding:, locale: :de)
93
93
  ```
94
94
 
95
- `locale:` sets the labels, number and date formats of the layout: `:de`, `:en`, `:cs`, `:da`, `:es`, `:et`, `:fi`, `:fr`, `:it`, `:lv`, `:nl`, `:pl`, `:pt`, `:ro`, `:ru`, `:sv`, `:tr` or `:zh` (a string works too; anything else falls back to German). DejaVu Sans covers every one of them but Chinese: for `:zh` pass a TrueType font with CJK glyphs as the branding font. Glyphs a branding font lacks, such as `€` in a subset, are taken from DejaVu Sans.
95
+ `locale:` sets the labels, number and date formats and the buyer's country name of the layout: `:de`, `:en`, `:cs`, `:da`, `:es`, `:et`, `:fi`, `:fr`, `:it`, `:lv`, `:nl`, `:pl`, `:pt`, `:ro`, `:ru`, `:sv`, `:tr` or `:zh` (a string works too; anything else falls back to German). DejaVu Sans covers every one of them but Chinese: for `:zh` pass a TrueType font with CJK glyphs as the branding font. Glyphs a branding font lacks, such as `€` in a subset, are taken from DejaVu Sans.
96
96
 
97
97
  `Branding.new` rejects what would break PDF/A at construction time: CMYK JPEGs, interlaced PNGs, unknown image data. The GiroCode is drawn as vectors, so it adds no raster image; it carries the holder, IBAN, BIC, the amount due and the payment reference (or the invoice title) and is left out when the invoice is not in euro, has no IBAN or nothing is due.
98
98
 
@@ -155,4 +155,4 @@ git tag v0.2.0 && git push origin v0.2.0
155
155
 
156
156
  ## Licences
157
157
 
158
- MIT. Bundled: DejaVu Sans (Bitstream Vera licence, `fonts/LICENSE-DejaVu.txt`) and the sRGB profile from [Compact ICC Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles) (CC0).
158
+ MIT. Bundled: DejaVu Sans (Bitstream Vera licence, `fonts/LICENSE-DejaVu.txt`), the country names from the [Unicode CLDR](https://cldr.unicode.org) (Unicode licence, `data/LICENSE-CLDR.txt`) and the sRGB profile from [Compact ICC Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles) (CC0).
data/Rakefile CHANGED
@@ -40,3 +40,22 @@ task :validate do
40
40
  end
41
41
  abort "validation failed" if failed
42
42
  end
43
+
44
+ CLDR_VERSION = "45.0.0"
45
+
46
+ desc "Fetch the country names in every invoice language from CLDR #{CLDR_VERSION} into data/countries.yml"
47
+ task :countries do
48
+ require "json"
49
+ require "net/http"
50
+ require "yaml"
51
+ $LOAD_PATH.unshift File.expand_path("lib", __dir__)
52
+ require "en16931"
53
+ short = %w[HK MO PS] # the full names ("Sonderverwaltungsregion Hongkong") do not fit an address
54
+ names = EN16931::PDF::Renderer::LABELS.keys.to_h do |locale|
55
+ url = URI("https://cdn.jsdelivr.net/npm/cldr-localenames-full@#{CLDR_VERSION}/main/#{locale}/territories.json")
56
+ territories = JSON.parse(Net::HTTP.get(url)).dig("main", locale.to_s, "localeDisplayNames", "territories")
57
+ countries = territories.keys.grep(/\A[A-Z]{2}\z/) - %w[EU EZ UN QO XA XB ZZ]
58
+ [locale.to_s, countries.sort.to_h { |code| [code, territories[short.include?(code) ? "#{code}-alt-short" : code]] }]
59
+ end
60
+ File.write("data/countries.yml", "# Generated by `rake countries` from CLDR #{CLDR_VERSION}, do not edit.\n#{names.to_yaml}")
61
+ end
@@ -0,0 +1,41 @@
1
+ UNICODE LICENSE V3
2
+
3
+ COPYRIGHT AND PERMISSION NOTICE
4
+
5
+ Copyright © 2004-2024 Unicode, Inc.
6
+
7
+ NOTICE TO USER: Carefully read the following legal agreement. BY
8
+ DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
9
+ SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
10
+ TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
11
+ DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a
14
+ copy of data files and any associated documentation (the "Data Files") or
15
+ software and any associated documentation (the "Software") to deal in the
16
+ Data Files or Software without restriction, including without limitation
17
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
18
+ copies of the Data Files or Software, and to permit persons to whom the
19
+ Data Files or Software are furnished to do so, provided that either (a)
20
+ this copyright and permission notice appear with all copies of the Data
21
+ Files or Software, or (b) this copyright and permission notice appear in
22
+ associated Documentation.
23
+
24
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
27
+ THIRD PARTY RIGHTS.
28
+
29
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
30
+ BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
31
+ OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
32
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
33
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
34
+ FILES OR SOFTWARE.
35
+
36
+ Except as contained in this notice, the name of a copyright holder shall
37
+ not be used in advertising or otherwise to promote the sale, use or other
38
+ dealings in these Data Files or Software without prior written
39
+ authorization of the copyright holder.
40
+
41
+ SPDX-License-Identifier: Unicode-3.0