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



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

def call(package)
  package.files.each_with_object([]) do |file, errors|
    path_match = TRANSLATIONS_PATH.match(file.relative_path)
    if path_match
      errors << locale_error(file, path_match[1]) << json_error(file)
      errors << required_keys(file) if errors.compact.empty?
    end
  end.compact
end