immosquare-yaml 0.1.4 → 0.1.6

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: 50e7d05885b777e715b408072108ddcaae7936b709389813b8887d92f5184f15
4
- data.tar.gz: ff4a85e7b21ac1e42b7a702be0e8b1fa597bc23ed4cf016690cdad703fc7ca47
3
+ metadata.gz: 8e39eee2713828adde11a2fdb8a826e5c55c780825cd792c36e918aa0dbd74d5
4
+ data.tar.gz: bc26fdf1d10d0f47e165cf18f97289468cae487b06e3ce28cf48ffdc03ca623f
5
5
  SHA512:
6
- metadata.gz: bcac3817a355e9a734e4d4686d54716c86eef5fcb399c5644ed55a3a4dc14a4d6f453045c739dfbfb9a061812d9d5ef0322d94144568143f3a051729e18f5036
7
- data.tar.gz: a64600294f32924511fbd9ede26f83469ba0497a44986c7573053d8cd2c2f16807b5dabe3db4e5624ceaaa45bf8c73ea036acf2987aa8ae1499edf119ebd8b4f
6
+ metadata.gz: acb1b0d5b998ed536bb0c0f806a19fd601f85edfe4f919cd73dcebc725f5ea4d6530f4612f121c9c55481a3addb076235f4b7f35db5bdc641af4cd52c1e99da2
7
+ data.tar.gz: d2a8d191cb8b9f7269f8db02b019076df06bf0fa64e327b0fcb34ea7704dfa02e991a168ef50da3d44a455fe18d577972841facedc681132b1fb279a71d4c0c2
@@ -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.4".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
@@ -2,18 +2,23 @@ namespace :immosquare_yaml do
2
2
 
3
3
  ##============================================================##
4
4
  ## Function to translate translation files in rails app
5
- ## rake immosquare_yaml:translate LOCALE=fr
5
+ ## rake immosquare_yaml:translate SOURCE_LOCALE=fr
6
6
  ##============================================================##
7
7
  desc "Translate translation files in rails app"
8
8
  task :translate => :environment do
9
9
  begin
10
- source_locale = ENV.fetch("LOCALE", nil) || "fr"
11
- raise("Please provide a valid locale") if !I18n.available_locales.map(&:to_s).include?(source_locale)
12
-
10
+ source_locale = ENV.fetch("SOURCE_LOCALE", nil) || "fr"
11
+ reset_translations = ENV.fetch("RESET_TRANSLATIONS", nil) || false
12
+ reset_translations = reset_translations == "true"
13
+
14
+ raise("Please provide a valid locale") if !I18n.available_locales.map(&:to_s).include?(source_locale)
15
+ raise("Please provide a valid boolean for reset_translations") if ![true, false].include?(reset_translations)
16
+
13
17
  locales = I18n.available_locales.map(&:to_s).reject {|l| l == source_locale }
18
+ puts("Translating #{source_locale} to #{locales.join(", ")} with reset_translations=#{reset_translations}")
14
19
  Dir.glob("#{Rails.root}/config/locales/**/*#{source_locale}.yml").each do |file|
15
20
  locales.each do |locale|
16
- ImmosquareYaml::Translate.translate(file, locale)
21
+ ImmosquareYaml::Translate.translate(file, locale, reset_translations)
17
22
  end
18
23
  end
19
24
  rescue StandardError => e
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.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE