Class: PolyglotFlutter::Serializer::Localization::LocalizationKeys

Inherits:
Base
  • Object
show all
Defined in:
lib/flutter_polyglot_cli/serializers/localizations/localization_keys_serializer.rb

Constant Summary

Constants included from Helper::General

Helper::General::ESCAPE_KEYWORDS

Instance Attribute Summary

Attributes inherited from Base

#languages, #translation_keys

Instance Method Summary collapse

Methods inherited from Base

#initialize, #render

Methods included from Helper::General

#clean_enum_name, #clean_variable_name, #config, #escape_keyword_if_needed, #escape_with_underscore_if_needed, #extract_translations, #generate_locales, #generate_localization_keys, #indent, #mandatory_language, #programming_language, #project_configs, #token, #use_old_naming

Constructor Details

This class inherits a constructor from PolyglotFlutter::Serializer::Localization::Base

Instance Method Details

#save(sources_path) ⇒ Object



7
8
9
10
11
# File 'lib/flutter_polyglot_cli/serializers/localizations/localization_keys_serializer.rb', line 7

def save(sources_path)
  FileUtils.mkdir_p sources_path unless File.exist? sources_path
  output_path = File.join(sources_path, 'localization_keys.dart')
  File.write(output_path, render)
end

#templateObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flutter_polyglot_cli/serializers/localizations/localization_keys_serializer.rb', line 13

def template
  <<~TEMPLATE
    import 'package:intl/intl.dart';
    import 'localization.dart';

    // AUTO GENERATED FILE. DO NOT CHANGE.
    extension LocalizationKeys on Localization {

    <%= generate_localization_keys(languages, translation_keys, mandatory_language) %>}
  TEMPLATE
end