Module: ZendeskAppsSupport::Validations::Translations

Defined in:
lib/zendesk_apps_support/validations/translations.rb

Defined Under Namespace

Classes: TranslationFormatError

Constant Summary collapse

TRANSLATIONS_PATH =
%r{^translations/(.*)\.json$}
VALID_LOCALE =
/^[a-z]{2}(-\w{2,3})?$/

Class Method Summary collapse

Class Method Details

.call(package) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/zendesk_apps_support/validations/translations.rb', line 16

def call(package)
  package.files.each_with_object([]) do |file, errors|
    path_match = TRANSLATIONS_PATH.match(file.relative_path)
    next unless path_match
    errors << locale_error(file, path_match[1]) << json_error(file) << format_error(file)
    next unless errors.compact.empty?
    errors.push(*validate_marketplace_content(file, package)) if file.relative_path == 'translations/en.json'
  end.compact
end