Skip to content

Commit

Permalink
Use i18n-tasks for YAML files update
Browse files Browse the repository at this point in the history
Remove the old code of the solidus_i18n:sync task and document the use of
i18n-tasks.
  • Loading branch information
alepore committed May 22, 2017
1 parent 2b3fbb5 commit a3fe42b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 82 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ you want your users to be able to select from the locale toggle on the frontend.

---

## Updating Translations

If you want to improve the translations on your language, run the tasks:

bundle exec rake solidus_i18n:update_default
bundle exec i18n-tasks add-missing --nil-value --locale <LOCALE>

Substitute <LOCALE> with your locale code (e.g: `it`).

This will do a cleanup and prepare `<LOCALE>.yml` with all the missing keys.
You can then write the translations and open a pull request.

---

## Model Translations

We **removed** support for translating models into [a separate Gem](https://github.com/solidusio-contrib/solidus_globalize).
Expand Down
25 changes: 0 additions & 25 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,7 @@ namespace :solidus_i18n do
end
end

desc 'Syncronize translation files with latest en (adds comments with fallback en value)'
task :sync do
puts 'Starting syncronization...'
words = translation_keys

Dir["#{locales_dir}/*.yml"].each do |filename|
basename = File.basename(filename, '.yml')
(comments, other) = SolidusI18n::Utils.read_file(filename, basename)
# Initializing hash variable as en fallback if it does not exist
words.each { |k, _v| other[k] ||= "#{words[k]}" }
# Remove if not defined in en locale
other.delete_if { |k, _v| !words[k] }
SolidusI18n::Utils.write_file(filename, basename, comments, other, false)
end
end

def translation_keys
(dummy_comments, words) = SolidusI18n::Utils.read_file(File.dirname(__FILE__) + '/default/solidus_core.yml', 'en')
words
end

def locales_dir
File.join File.dirname(__FILE__), 'config/locales'
end

def env_locale
ENV['LOCALE'].presence
end
end
1 change: 0 additions & 1 deletion lib/solidus_i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
require 'solidus_i18n/engine'
require 'solidus_i18n/locale'
require 'solidus_i18n/version'
require 'solidus_i18n/utils'
require 'coffee_script'
require 'deface'
56 changes: 0 additions & 56 deletions lib/solidus_i18n/utils.rb

This file was deleted.

0 comments on commit a3fe42b

Please sign in to comment.