diff --git a/lib/poeditor/commands/pull_command.rb b/lib/poeditor/commands/pull_command.rb index 03868d6..8a2af67 100644 --- a/lib/poeditor/commands/pull_command.rb +++ b/lib/poeditor/commands/pull_command.rb @@ -42,6 +42,7 @@ def get_configuration(argv) project_id: get_or_raise(yaml, "project_id"), type: get_or_raise(yaml, "type"), tags: yaml["tags"], + filters: yaml["filters"], languages: get_or_raise(yaml, "languages"), language_alias: yaml["language_alias"], path: get_or_raise(yaml, "path"), diff --git a/lib/poeditor/configuration.rb b/lib/poeditor/configuration.rb index 2003a03..de65e81 100644 --- a/lib/poeditor/configuration.rb +++ b/lib/poeditor/configuration.rb @@ -12,6 +12,9 @@ class Configuration # @return [Array] Tag filters (optional) attr_accessor :tags + + # @return [Array] Filters by 'translated', 'untranslated', 'fuzzy', 'not_fuzzy', 'automatic', 'not_automatic', 'proofread', 'not_proofread' (optional) + attr_accessor :filters # @return [Array] The languages codes attr_accessor :languages @@ -26,12 +29,13 @@ class Configuration attr_accessor :path_replace def initialize(api_key:, project_id:, type:, tags:nil, - languages:, language_alias:nil, + filters:nil, languages:, language_alias:nil, path:, path_replace:nil) @api_key = from_env(api_key) @project_id = from_env(project_id.to_s) @type = type @tags = tags || [] + @filters = filters || [] @languages = languages @language_alias = language_alias || {} @@ -53,6 +57,7 @@ def to_s values = { "type" => self.type, "tags" => self.tags, + "filters" => self.filters, "languages" => self.languages, "language_alias" => self.language_alias, "path" => self.path, diff --git a/lib/poeditor/core.rb b/lib/poeditor/core.rb index 6705731..26e252c 100644 --- a/lib/poeditor/core.rb +++ b/lib/poeditor/core.rb @@ -39,7 +39,8 @@ def pull() :project_id => @configuration.project_id, :language => language, :type => @configuration.type, - :tags => @configuration.tags) + :tags => @configuration.tags, + :filters => @configuration.filters) write(language, content) for alias_to, alias_from in @configuration.language_alias @@ -57,14 +58,16 @@ def pull() # @param language [String] # @param type [String] # @param tags [Array] + # @param filters [Array] # # @return Downloaded translation content - def export(api_key:, project_id:, language:, type:, tags:nil) + def export(api_key:, project_id:, language:, type:, tags:nil, filters:nil) options = { "id" => project_id, "language" => convert_to_poeditor_language(language), "type" => type, "tags" => (tags || []).join(","), + "filters" => (filters || []).join(","), } response = self.api("projects/export", api_key, options) data = JSON(response.body) diff --git a/test/test_core.rb b/test/test_core.rb index 611075f..0795eaf 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -41,6 +41,7 @@ def get_client(type:, :project_id => 12345, :type => type, :tags => nil, + :filters => nil, :languages => languages, :language_alias => language_alias, :path_replace => path_replace,