translation 0.9.6 → 0.9.7

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
  SHA1:
3
- metadata.gz: 26c222c8c1149a0c4bd21129c4f3a9dd7e723978
4
- data.tar.gz: 739654aa93c95f0ab8e1a1bc8a95bcc44e87fd03
3
+ metadata.gz: 76f06309119b4856d8334ab42dd1a79600415e9b
4
+ data.tar.gz: 97ca726e59f4a331f41f03b6644b0c4accb09298
5
5
  SHA512:
6
- metadata.gz: 7e79d8d3234aa840421148ec31c0d155f91fc3db730eef3d72a5e2de7ccacc348935e522400d65a20ee8159ac727e298bd7ddceae5dce57daaf6b176283fa976
7
- data.tar.gz: d265300164c4341f64929c21f4dbdd79ab3543be228962e2555b37e4dbfb5ee2cb4f60daa8bc77923f0fea96856480778ceab345a9e7e1f4e07df4a63dc76c03
6
+ metadata.gz: 1bee96e7ec136d640da01c9ea420f8c07f9d38ce40d73289059da10890a060345255b8f9d088e400223b492b49cc8a83aee60cfab8e521008c8ff12c198162ff
7
+ data.tar.gz: 50a456aab2431ca613b0233f92bb05ba8a4435fae29d26812b00d87b87d0bdfa9ebfbd0602e894fcb3e241e7e9e4db7924abdc2667d4b35840928987f9551f21
data/README.md CHANGED
@@ -19,19 +19,19 @@ And finish by inititalizing your translation project with :
19
19
 
20
20
  bundle exec rake translation:init
21
21
 
22
- ## Synchronization
22
+ ## Sync
23
23
 
24
24
  To send new translatable keys/strings and get new translations from Translation.io, simply run :
25
25
 
26
26
  bundle exec rake translation:sync
27
27
 
28
- ## Purge
28
+ ## Sync and Purge
29
29
 
30
- If you need to remove unused keys/strings from Translation.io using the current branch as reference :
30
+ If you also need to remove unused keys/strings from Translation.io using the current branch as reference :
31
31
 
32
- bundle exec rake translation:purge
32
+ bundle exec rake translation:sync_and_purge
33
33
 
34
- Note that this operation will also perform a sync at the same time.
34
+ As the name says, this operation will also perform a sync at the same time.
35
35
 
36
36
  Warning : all keys that are not present in the current branch will be **permanently deleted both on Translation.io and in your app**.
37
37
 
@@ -32,11 +32,9 @@ module TranslationIO
32
32
  yaml_path = File.join(@yaml_locales_path, "localization.#{target_locale}.yml")
33
33
 
34
34
  TranslationIO.info yaml_path, 2, 2
35
- flat_translations = {}
36
35
 
37
- source_flat_special_translations.each_pair do |key, value|
38
- target_key = key.gsub(/\A#{@source_locale}\./, "#{target_locale}.")
39
- flat_translations[target_key] = all_flat_special_translations[target_key]
36
+ flat_translations = all_flat_special_translations.select do |key|
37
+ TranslationIO::YamlEntry.from_locale?(key, target_locale) && !TranslationIO::YamlEntry.ignored?(key)
40
38
  end
41
39
 
42
40
  yaml_data = YAMLConversion.get_yaml_data_from_flat_translations(flat_translations)
@@ -19,7 +19,7 @@ module TranslationIO
19
19
  TranslationIO::Client::SyncOperation.new(self).run
20
20
  end
21
21
 
22
- def purge
22
+ def sync_and_purge
23
23
  TranslationIO::Client::SyncOperation.new(self).run(true)
24
24
  end
25
25
  end
@@ -6,17 +6,19 @@ module TranslationIO
6
6
  attr_accessor :verbose
7
7
  attr_accessor :test
8
8
  attr_accessor :ignored_key_prefixes
9
+ attr_accessor :localization_key_prefixes
9
10
  attr_accessor :charset
10
11
 
11
12
  def initialize
12
- self.locales_path = File.join('config', 'locales', 'gettext')
13
- self.source_locale = :en
14
- self.target_locales = []
15
- self.endpoint = 'https://translation.io/api'
16
- self.verbose = 1
17
- self.test = false
18
- self.ignored_key_prefixes = []
19
- self.charset = 'UTF-8'
13
+ self.locales_path = File.join('config', 'locales', 'gettext')
14
+ self.source_locale = :en
15
+ self.target_locales = []
16
+ self.endpoint = 'https://translation.io/api'
17
+ self.verbose = 1
18
+ self.test = false
19
+ self.ignored_key_prefixes = []
20
+ self.localization_key_prefixes = []
21
+ self.charset = 'UTF-8'
20
22
  end
21
23
 
22
24
  def pot_path
@@ -2,9 +2,10 @@ require 'gettext/tools'
2
2
 
3
3
  namespace :translation do
4
4
 
5
- DESCRIPTIONS = { :init => "Initialize your Translation.io project",
6
- :sync => "Send new translatable keys/strings and get new translations from Translation.io",
7
- :purge => "Remove unused keys/strings from Translation.io using the current branch as reference"
5
+ DESCRIPTIONS = {
6
+ :init => "Initialize your Translation.io project",
7
+ :sync => "Send new translatable keys/strings and get new translations from Translation.io",
8
+ :sync_and_purge => "Remove unused keys/strings from Translation.io using the current branch as reference"
8
9
  }
9
10
 
10
11
  desc "Get configuration infos of Translation gem"
@@ -26,4 +27,8 @@ EOS
26
27
  end
27
28
  end
28
29
  end
30
+
31
+ task :purge => :environment do
32
+ TranslationIO.info("Purge is deprecated, please use rake 'translation:sync_and_purge' instead.")
33
+ end
29
34
  end
@@ -1,5 +1,9 @@
1
1
  module TranslationIO
2
- module TranslationIO::YamlEntry
2
+ module YamlEntry
3
+
4
+ IGNORED_KEY_PREFIXES = [
5
+ 'faker.'
6
+ ]
3
7
 
4
8
  LOCALIZATION_KEY_PREFIXES = [
5
9
  'date.formats',
@@ -13,7 +17,8 @@ module TranslationIO
13
17
  'number.human.format',
14
18
  'number.human.storage_units.format',
15
19
  'number.human.decimal_units.format',
16
- 'number.human.decimal_units.units.unit'
20
+ 'number.human.decimal_units.units.unit',
21
+ 'i18n.transliterate'
17
22
  ]
18
23
 
19
24
  class << self
@@ -34,15 +39,27 @@ module TranslationIO
34
39
  end
35
40
 
36
41
  def localization_prefix?(key)
37
- LOCALIZATION_KEY_PREFIXES.any? do |prefix|
42
+ localization_key_prefixes.any? do |prefix|
38
43
  key_without_locale(key).start_with?(prefix)
39
44
  end
40
45
  end
41
46
 
42
47
  private
43
48
 
49
+ def localization_key_prefixes
50
+ if TranslationIO.config
51
+ LOCALIZATION_KEY_PREFIXES + TranslationIO.config.localization_key_prefixes
52
+ else
53
+ LOCALIZATION_KEY_PREFIXES
54
+ end
55
+ end
56
+
44
57
  def ignored_key_prefixes
45
- ['faker.'] + TranslationIO.config.ignored_key_prefixes
58
+ if TranslationIO.config
59
+ IGNORED_KEY_PREFIXES + TranslationIO.config.ignored_key_prefixes
60
+ else
61
+ LOCALIZATION_KEY_PREFIXES
62
+ end
46
63
  end
47
64
 
48
65
  def key_without_locale(key)
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: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurelien Malisart
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-28 00:00:00.000000000 Z
12
+ date: 2014-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.2.0
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Rails translation made _("simple") with YAML and GetText.