Skip to content

Commit

Permalink
Merge pull request prat0318#37 from drorata/dev
Browse files Browse the repository at this point in the history
Enable custom locale definitions
  • Loading branch information
prat0318 authored Jan 24, 2018
2 parents 0a5e59e + 837fa4f commit f4cda69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ Support for ``en``, ``ge``, ``es``, ``fi``, ``pl`` and ``pt`` right now. Pull re
$ json_resume convert --locale=es prateek_cv.json
```

It is also possible to define a custom location for locale definitions.
Pass the option `--locale_dir=path/to/defs`.
In this location there should be the definitions available.
The default one is `en.yml`, others may be provided as well.
This is useful if you want to define new headings.

## Markup Language

JSON is parsed as per the `markdown` standards. This implies all this works-
Expand Down
9 changes: 8 additions & 1 deletion bin/json_resume
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class JsonResumeCLI < Thor
desc 'convert /path/to/json/file', 'converts the json to pretty resume format'
option :out, default: 'html', banner: 'output_type', desc: 'html|html_pdf|tex|tex_pdf|md'
option :template, banner: 'template_path', desc: 'path to customized template (optional)'
option :locale_dir, desc: 'path to locale definitions (optional)'
option :locale, default: 'en', banner: 'locale', desc: 'en|ge|es|pl|pt|zh_cn'
option :theme, default: 'default', banner: 'theme', desc: 'default|classic'
option :dest_dir, default: 'current', banner: 'dest_dir', desc: 'location of dest. dir (optional)'
Expand Down Expand Up @@ -185,7 +186,13 @@ class JsonResumeCLI < Thor
end

def assign_i18n(locale)
I18n.load_path = Dir["#{@@orig_locn}/../locale/*.yml"]
if options[:locale_dir]
locale_dir = "#{File.expand_path(options[:locale_dir])}/*.yml"
else
locale_dir = "#{@@orig_locn}/../locale/*.yml"
end
puts "Using #{locale_dir} for locale files"
I18n.load_path = Dir[locale_dir]
I18n.enforce_available_locales = true
I18n.locale = locale.to_sym
end
Expand Down
2 changes: 1 addition & 1 deletion lib/json_resume/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JsonResume
VERSION = '1.0.5'
VERSION = '1.0.6'
end

0 comments on commit f4cda69

Please sign in to comment.