Sha256: 3810069cb0f34cbd098e067d0ac6a3fc69c6152486874b1bb22baa1960d1d366

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

require 'rake'
require 'lokalise_rails'
# Loads the configuration settings from the lokalise_rails configuration file within the Rails project.
require "#{LokaliseRails::Utils.root}/config/lokalise_rails"

# Namespace for Rake tasks related to the LokaliseRails gem.
# These tasks facilitate the synchronization of localization files between the Rails project and the Lokalise platform.
namespace :lokalise_rails do
  # Imports translation files from Lokalise and integrates them into the current Rails project.
  # This task utilizes the LokaliseManager to handle the import process according to the configuration specified
  # in the GlobalConfig class.
  desc 'Imports translation files from Lokalise to the current Rails project'
  task :import do
    importer = LokaliseManager.importer({}, LokaliseRails::GlobalConfig)
    importer.import!
  rescue StandardError => e
    # Aborts the task and prints the error message.
    # Ensures that any exceptions raised during import are handled gracefully.
    abort "Import failed: #{e.message}"
  end

  # Exports translation files from the current Rails project to Lokalise.
  # Similar to the import task, it leverages the LokaliseManager and uses the GlobalConfig for configuration settings.
  desc 'Exports translation files from the current Rails project to Lokalise'
  task :export do
    exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
    exporter.export!
  rescue StandardError => e
    # Aborts the task and prints the error message. Provides clear feedback on why the export failed.
    abort "Export failed: #{e.message}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lokalise_rails-8.0.0 lib/tasks/lokalise_rails_tasks.rake
lokalise_rails-7.1.0 lib/tasks/lokalise_rails_tasks.rake