immosquare-yaml 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 036dbd81c5acc9b557da4d9765e2b2ebf24d5f574943461d6bd544cf33ab5f20
4
- data.tar.gz: fd3c98b6489a5072191a99fffe9e16605b90221b72d85c29a3bc405f0fa47df9
3
+ metadata.gz: 34fe15584e7edf73f2dec2857095829c4beb6a680913dc78e045401f23c7cd71
4
+ data.tar.gz: b8c4daa1be8c56c243b2699e3871f15d5169ff8e19ce4b099b6e825494ff5ab1
5
5
  SHA512:
6
- metadata.gz: 107c708c81effd4afb3118aa77faff2a99861aa6ad2a91adc66344264351fc060ee73bbe873478c0bd5c2d3042e3236b2ed1f2fa9462594e77e773fffc7f7f16
7
- data.tar.gz: 546f425d1df76736a6986345f4375cd3d4cf8a597ed364ba06f3757e2be584805be90f9124babdc8af16d298bcc002f4902674f376e51358f343c3affe26140e
6
+ metadata.gz: 55beab9ea32cfd5d2643c9785b3f9bfa5023c406aa5cdc7d843a84afb2fa537d649823c25b7ebea199a961ec64d7cf46ef3ca66ab142e54b128f004566fe9177
7
+ data.tar.gz: d5c3144daba11a689d746fb0ccc7265da0fea8a2787415336d13662b9d16b3c550c7baffe89075f4def8db989faaa4834c52e3904d2d1a7199a0e91aca9235a9
@@ -234,7 +234,7 @@ module ImmosquareYaml
234
234
  "- Do not escape apostrophes in translated strings; leave them as they are.\n" \
235
235
  "- Special characters, except apostrophes, that need to be escaped in translated strings should be escaped using a single backslash (\\), not double (\\\\).\n" \
236
236
  "- If a string cannot be translated use the string '#{cant_be_translated}' translated as the translation value witouth quote (simple or double) quote, just the string\n" \
237
- "- If you dont know the correct translatation but the original word seems to make sense in the original language use it for the translated field otherwise use the #{cant_be_translated} strategy of the preceding point\n" \
237
+ "- If you dont know the correct translatation use the #{cant_be_translated} strategy of the preceding point\n" \
238
238
  "- Use only doubles quotes (\") to enclose translated strings and avoid using single quotes (').\n" \
239
239
  "- Your output must ONLY be an array with the same number of pairs as the input, without any additional text or explanation.\n" \
240
240
  "- You need to check that the globle array is correctly closed at the end of the response. (the response must therefore end with ]] to to be consistent)"
@@ -1,3 +1,3 @@
1
1
  module ImmosquareYaml
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.5".freeze
3
3
  end
@@ -2,15 +2,25 @@ namespace :immosquare_yaml do
2
2
 
3
3
  ##============================================================##
4
4
  ## Function to translate translation files in rails app
5
+ ## rake immosquare_yaml:translate SOURCE_LOCALE=fr
5
6
  ##============================================================##
6
7
  desc "Translate translation files in rails app"
7
8
  task :translate => :environment do
8
- source_locale = "fr"
9
- locales = I18n.available_locales.map(&:to_s).reject {|l| l == source_locale }
10
- Dir.glob("#{Rails.root}/config/locales/**/*#{source_locale}.yml").each do |file|
11
- locales.each do |locale|
12
- ImmosquareYaml::Translate.translate(file, locale)
9
+ begin
10
+ source_locale = ENV.fetch("SOURCE_LOCALE", nil) || "fr"
11
+ reset_translations = ENV.fetch("RESET_TRANSLATIONS", nil) || false
12
+ raise("Please provide a valid locale") if !I18n.available_locales.map(&:to_s).include?(source_locale)
13
+ raise("Please provide a valid boolean for reset_translations") if ![true, false].include?(reset_translations)
14
+
15
+ locales = I18n.available_locales.map(&:to_s).reject {|l| l == source_locale }
16
+ puts("Translating #{source_locale} to #{locales.join(", ")} with reset_translations=#{reset_translations}")
17
+ Dir.glob("#{Rails.root}/config/locales/**/*#{source_locale}.yml").each do |file|
18
+ locales.each do |locale|
19
+ ImmosquareYaml::Translate.translate(file, locale, reset_translations)
20
+ end
13
21
  end
22
+ rescue StandardError => e
23
+ puts(e.message)
14
24
  end
15
25
  end
16
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE