lib/zci/commands/04_export.rb in zci-0.6.1 vs lib/zci/commands/04_export.rb in zci-0.7.0
- old
+ new
@@ -17,17 +17,26 @@
resources_dir = File.join(File.dirname(global_options[:config]), options[:resources_dir])
language = options[:language]
crowdin_supported_languages = @crowdin.supported_languages
- if language == 'all'
- zendesk_locales = @zendesk.locales
- else
- zendesk_locales = @zendesk.locales.select { |locale| locale.locale == language }
- end
-
@cli_config['categories'].each do |category_section|
+ zendesk_url = category.fetch('brand_url', @cli_config['zendesk_base_url'])
+
+ zendesk_client = ZCI.initialize_zendesk_client(
+ zendesk_url,
+ @cli_config['zendesk_username'],
+ @cli_config['zendesk_password'],
+ global_options[:verbose]
+ )
+
+ if language == 'all'
+ zendesk_locales = zendesk_client.locales
+ else
+ zendesk_locales = zendesk_client.locales.select { |locale| locale.locale == language }
+ end
+
zendesk_locales.select { |locale| !locale.default? }.each do |locale|
if lang = category_section['translations'].detect { |tr| tr['zendesk_locale'].casecmp(locale.locale) == 0 }
crowdin_locale = crowdin_supported_languages.detect { |l| l['crowdin_code'] == lang['crowdin_language_code'] }['locale']
category_xml_files = Dir["#{resources_dir}/#{crowdin_locale}/#{category_section['zendesk_category']}/category_*.xml"]
@@ -59,11 +68,11 @@
all_articles << article_xml
end
### Categories
#
- categories = @zendesk.hc_categories
+ categories = zendesk_client.hc_categories
all_categories.each do |category_hash|
if category = categories.find(id: category_hash[:id])
if category_tr = category.translations.detect { |tr| tr.locale.casecmp(locale.locale) == 0 }
category_tr.update(title: category_hash[:name], body: category_hash[:description])
if category_tr.changed?
@@ -78,10 +87,10 @@
end
end
### Sections
#
- sections = @zendesk.sections
+ sections = zendesk_client.sections
all_sections.each do |section_hash|
if section = sections.find(id: section_hash[:id])
if section_tr = section.translations.detect { |tr| tr.locale.casecmp(locale.locale) == 0 }
section_tr.update(title: section_hash[:name], body: section_hash[:description])
if section_tr.changed?