translation 1.33 → 1.34

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: 12f034c3516c755d4e16fba0c8da4d25156107274d632369bc5fa2c8b85d1197
4
- data.tar.gz: a6411bb6fa5ec979ed5d1677ec097bddba656c51354a4e212963bf581965213d
3
+ metadata.gz: 61a215cc27f4bfd0954d910e4d76f956e4b6fe54d9cb9caf74ba40cf665dcf83
4
+ data.tar.gz: e708d5f92493b6085d6062ce1588fa39927795e21805b0413cdcb0723b61ff94
5
5
  SHA512:
6
- metadata.gz: 0afec24d64ce82af45eb9d5abec7d60f1fde605dab0db823477a8a5c68690ad98301ca888388b17bc42a323fdd2be34e5646cce83c24f99037a3592c6946478f
7
- data.tar.gz: e992ce43fef4c41ccc53294224ba6cbba154e481bed5e2410964c7daad6a99a22ef8d070b849c652214c68a660d701af2a6615a1b297b2be8e6d043d7faac3a6
6
+ metadata.gz: 5e0e61144155c587eb7d031691d906bafd3611df7566b35adfce44b390b903e6a9c20a0bb8d37f71349c2a8f12731f834bfcc96ed1ffadeed44520197bdfab54
7
+ data.tar.gz: 6ac7e7b30dea348362b067fcf1a5a12240b60366941431ff5a4b25dcdad47574e33c428b4728dd49bf06ad1fe4b3785fd1238a2ae01a8d4b9a5149cda7675a17
@@ -34,19 +34,27 @@ module TranslationIO
34
34
  # Create source locale PO file, with identical source and target
35
35
  # => Useful for correct fallbacks (cf. discussion https://github.com/translation/rails/issues/48)
36
36
  def create_source_po(text_domain)
37
- source_locale = Locale::Tag.parse(@source_locale).to_s
37
+ source_locale = Locale::Tag.parse(@source_locale)
38
38
 
39
39
  pot_path = File.join(@locales_path, "#{text_domain}.pot")
40
- po_path = File.join(@locales_path, source_locale, "#{text_domain}.po")
40
+ po_path = File.join(@locales_path, source_locale.to_s, "#{text_domain}.po")
41
41
 
42
42
  FileUtils.mkdir_p(File.dirname(po_path))
43
43
  FileUtils.rm(po_path) if File.exist?(po_path)
44
44
 
45
45
  # Generate source PO from POT and parse it
46
- GetText::Tools::MsgInit.run('-i', pot_path, '-o', po_path, '-l', source_locale, '--no-translator')
46
+ GetText::Tools::MsgInit.run('-i', pot_path, '-o', po_path, '-l', source_locale.to_s, '--no-translator')
47
47
  po_entries = GetText::PO.new
48
48
  GetText::POParser.new.parse(File.read(po_path), po_entries)
49
49
 
50
+ # With GetText after 3.3.9 and the introduction of optional `red-datasets` dependency, we need to complete the plural forms manually
51
+ # Source languages must have only 2 plural forms, and only 2 different pluralization rules exist for these languages
52
+ if %w(ak am as bn fa fr gu hi hy kn ln mg nso pa si ti zu).include?(source_locale.language)
53
+ po_entries[''].msgstr.gsub!('Plural-Forms: nplurals=; plural=;', 'Plural-Forms: nplurals=2; plural=n > 1;') # 0 and 1 are singular
54
+ else
55
+ po_entries[''].msgstr.gsub!('Plural-Forms: nplurals=; plural=;', 'Plural-Forms: nplurals=2; plural=n != 1;') # only 1 is singular
56
+ end
57
+
50
58
  # Fill with same target as source and save it
51
59
  po_entries.each do |po_entry|
52
60
  if po_entry.msgid != '' # header
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.33'
4
+ version: '1.34'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hoste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-07 00:00:00.000000000 Z
12
+ date: 2022-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext