Class: Danger::DangerLocalizationlinter
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerLocalizationlinter
- Defined in:
- lib/localizationlinter/plugin.rb
Overview
Verify consistency over your project localizable files (localizable.strings and Localizable.stringdict)
It uses Swiftgen to generate a localizables output per target and language and compare the output with
a reference language one.
The comparison ensure:
- missing keys
- additional keys
- wrong parameters in string format
Instance Attribute Summary collapse
-
#clean_after_execution ⇒ void
Keep or clean derived data after execution.
-
#derived_data_path ⇒ void
Path to derived data, default value is localization_linter_derived_data.
-
#inline_mode ⇒ void
Print inline or as markdown.
-
#language_configuration_path ⇒ void
Path to language configuration yml, defining main language per target example: “‘yml My_target: en My_other_target: fr “` Default value is `Configuration/Defaults/all_target_main_language.yml` If no file is provided, the default language for each target is `en`.
-
#project_path ⇒ void
Path to xcode project, default is taking the first project in root folder.
-
#resource_path ⇒ void
Path to derived data, default value is Resources.
-
#swift_gen_path ⇒ void
Path to swift gen, default value is Pods/SwiftGen/bin/swiftgen.
-
#verbose ⇒ void
Print execution logs.
Instance Method Summary collapse
-
#lint ⇒ void
Verify the localizable files integrity over the project rubocop:disable Metrics/MethodLength.
-
#linter ⇒ LocalizationLinter
Returns the object in charge of verification.
Instance Attribute Details
#clean_after_execution ⇒ void
This method returns an undefined value.
Keep or clean derived data after execution
23 24 25 |
# File 'lib/localizationlinter/plugin.rb', line 23 def clean_after_execution @clean_after_execution end |
#derived_data_path ⇒ void
This method returns an undefined value.
Path to derived data, default value is localization_linter_derived_data
50 51 52 |
# File 'lib/localizationlinter/plugin.rb', line 50 def derived_data_path @derived_data_path end |
#inline_mode ⇒ void
This method returns an undefined value.
Print inline or as markdown
27 28 29 |
# File 'lib/localizationlinter/plugin.rb', line 27 def inline_mode @inline_mode end |
#language_configuration_path ⇒ void
This method returns an undefined value.
Path to language configuration yml, defining main language per target example: “‘yml My_target: en My_other_target: fr “` Default value is `Configuration/Defaults/all_target_main_language.yml` If no file is provided, the default language for each target is `en`
42 43 44 |
# File 'lib/localizationlinter/plugin.rb', line 42 def language_configuration_path @language_configuration_path end |
#project_path ⇒ void
This method returns an undefined value.
Path to xcode project, default is taking the first project in root folder
58 59 60 |
# File 'lib/localizationlinter/plugin.rb', line 58 def project_path @project_path end |
#resource_path ⇒ void
This method returns an undefined value.
Path to derived data, default value is Resources
54 55 56 |
# File 'lib/localizationlinter/plugin.rb', line 54 def resource_path @resource_path end |
#swift_gen_path ⇒ void
This method returns an undefined value.
Path to swift gen, default value is Pods/SwiftGen/bin/swiftgen
46 47 48 |
# File 'lib/localizationlinter/plugin.rb', line 46 def swift_gen_path @swift_gen_path end |
#verbose ⇒ void
This method returns an undefined value.
Print execution logs
31 32 33 |
# File 'lib/localizationlinter/plugin.rb', line 31 def verbose @verbose end |
Instance Method Details
#lint ⇒ void
This method returns an undefined value.
Verify the localizable files integrity over the project rubocop:disable Metrics/MethodLength
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/localizationlinter/plugin.rb', line 63 def lint differences = linter.find_differences if differences.empty? linter.log "Localization Linter finished with no error" elsif inline_mode differences.each do |issue| warn( issue[:message], file: issue[:filename], line: issue[:line] ) end else = differences.map do |difference| "#{difference[:filename]}:#{difference[:line]} #{difference[:message]}" end markdown "Localization Linter errors:\n#{message.join("\n")}" end end |
#linter ⇒ LocalizationLinter
Returns the object in charge of verification
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/localizationlinter/plugin.rb', line 86 def linter LocalizationLinter.new( @verbose, @clean_after_execution, @language_configuration_path, @swift_gen_path, @derived_data_path, @resource_path, @project_path ) end |