Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend lokalise with export empty parameter #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Parameters:
- `languages`. Languages to download *(must be passed as array of strings, leave empty to download all)*.
- `include_comments`. Include comments in exported files.
- `use_original`. Use original filenames/formats.
- `export_empty`. How to export empty strings. Allowed values: `empty`, `base`, `skip`. Default value: `base`.
- `export_sort`. Export key sort mode. Allowed values: 'first_added', 'last_added', 'last_updated', 'a_z', 'z_a'. Default value: `a_z`.

## lokalise_metadata

Expand Down
26 changes: 21 additions & 5 deletions lokalise.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def self.run(params)
clean_destination = params[:clean_destination]
include_comments = params[:include_comments] ? 1 : 0
use_original = params[:use_original] ? 1 : 0
export_empty = params[:export_empty]
export_sort = params[:export_sort]

request_data = {
api_token: token,
Expand All @@ -19,8 +21,9 @@ def self.run(params)
bundle_filename: "Localization.zip",
bundle_structure: "%LANG_ISO%.lproj/Localizable.%FORMAT%",
ota_plugin_bundle: 0,
export_empty: "base",
include_comments: include_comments
export_empty: export_empty,
include_comments: include_comments,
export_sort: export_sort
}

languages = params[:languages]
Expand All @@ -36,7 +39,6 @@ def self.run(params)
http.use_ssl = true
response = http.request(request)


jsonResponse = JSON.parse(response.body)
UI.error "Bad response 🉐\n#{response.body}" unless jsonResponse.kind_of? Hash
if jsonResponse["response"]["status"] == "success" && jsonResponse["bundle"]["file"].kind_of?(String) then
Expand Down Expand Up @@ -68,7 +70,6 @@ def self.run(params)
end
end


def self.unzip_file(file, destination, clean_destination)
require 'zip'
require 'rubygems'
Expand All @@ -88,7 +89,6 @@ def self.unzip_file(file, destination, clean_destination)
}
end


#####################################################
# @!group Documentation
#####################################################
Expand Down Expand Up @@ -147,6 +147,22 @@ def self.available_options
default_value: false,
verify_block: proc do |value|
UI.user_error! "Use original should be true of false." unless [true, false].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :export_empty,
description: "How to export empty strings",
optional: true,
is_string: true,
default_value: "base",
verify_block: proc do |value|
UI.user_error! "Use one of options: empty, base, skip." unless ['empty', 'base', 'skip'].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :export_sort,
description: "Export key sort mode",
optional: true,
is_string: true,
default_value: "a_z",
verify_block: proc do |value|
UI.user_error! "Use one of options: first_added, last_added, last_updated, a_z, z_a." unless ['first_added', 'last_added', 'last_updated', 'a_z', 'z_a'].include?(value)
end)
]
end
Expand Down