class PolyglotFlutter::Command::Setup
Public Class Methods
init(options = Commander::Command::Options.new)
click to toggle source
# File lib/flutter_polyglot_cli/commands/setup.rb, line 10 def self.init(options = Commander::Command::Options.new) new(options).call end
new(options = Commander::Command::Options.new)
click to toggle source
# File lib/flutter_polyglot_cli/commands/setup.rb, line 14 def initialize(options = Commander::Command::Options.new) @options = options end
Public Instance Methods
call()
click to toggle source
# File lib/flutter_polyglot_cli/commands/setup.rb, line 18 def call project_id = project_id_prompt flutter_instance = flutter_instance_prompt l10n_path = './l10n.yaml' output_localization_file = 'app_localizations' set_default_langauge = false translations_path = translations_path_prompt sources_path = sources_path_prompt mandatory_language = mandatory_language_prompt project = { id: project_id, flutterInstance: flutter_instance, mandatoryLanguage: mandatory_language, path: translations_path, l10nFilePath: l10n_path, sourceFilesPath: sources_path, outputLocalizationFile: output_localization_file, setDefaultLangauge: set_default_langauge, } config = { projects: [project], } PolyglotFlutter::IO::Config.write(config) success end
Private Instance Methods
flutter_instance_prompt()
click to toggle source
Flutter instaince
# File lib/flutter_polyglot_cli/commands/setup.rb, line 55 def flutter_instance_prompt prompt.ask('What Flutter instance are you using (flutter/fvm flutter/...)?', default: 'flutter') end
mandatory_language_prompt()
click to toggle source
Mandatory language
# File lib/flutter_polyglot_cli/commands/setup.rb, line 73 def mandatory_language_prompt prompt.ask('What is the mandatory (main) language on polyglot?', default: 'en') end
project_id_prompt()
click to toggle source
Project ID
# File lib/flutter_polyglot_cli/commands/setup.rb, line 49 def project_id_prompt prompt.select('Choose a project: ', filtered_projects) end
sources_path_prompt()
click to toggle source
Sources path
# File lib/flutter_polyglot_cli/commands/setup.rb, line 67 def sources_path_prompt prompt.ask('Where would you like to store source files?', default: './lib/util/localization/') end
translations_path_prompt()
click to toggle source
Translations path
# File lib/flutter_polyglot_cli/commands/setup.rb, line 61 def translations_path_prompt prompt.ask('Where would you like to store translation files (.arb)?', default: './assets/i18n/') end