flutter_polyglot_cli 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e0f887cd9f71ec8c78e02f6e91cdea499513dd6832476cb84182331d70a9945
4
- data.tar.gz: a9638484acba81bb61e4450428a75e51ef96857d149062c35b360b638572dd7f
3
+ metadata.gz: fe67c3d215e3779b58be999c98160fd773e6cbdf096f64ba527b748cf00583cb
4
+ data.tar.gz: 4228ba3ec5274785a205e5f2001a03a6096791bb4de21a1fd27db6aecef3044d
5
5
  SHA512:
6
- metadata.gz: d6deee52b4e90c401455f672407e3377c9a211afda52cb50527e38a2c1a3511004d9541bb49d3b54de0de3c24abdc48b0fed85c0a2353d51ecf9edacd471c6da
7
- data.tar.gz: e3013e19e2080dd5e1d6931a3b30b4ade0cff28f9add1e7c07f2f6437b5306e9c9c17d1c7718aaea08b07236f15b83e9e586b9b7361e9d760c72ace4e0f03b65
6
+ metadata.gz: 7340d7ce57278b8fe76c894262ec7cacca2e684d6d1ced5909ef294129b7b2be7ce864b5a1580405ba4ac77f467aee811deafcf08c3b76129171a0c7ce329033
7
+ data.tar.gz: 04f45e84f4ec7c28900475937a9b7b20ffffebddb91fa83bd9de6223a92ad3546a549aac0635426402bab1189ff8a6d721d888dfa0a7b9d22fe445f39b12c615
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flutter_polyglot_cli (1.0.0)
4
+ flutter_polyglot_cli (1.0.1)
5
5
  activesupport
6
6
  commander
7
7
  json_api_client
@@ -117,6 +117,17 @@ module PolyglotFlutter
117
117
  strings[key_name] = translation_key.clean_translation(language)
118
118
  end
119
119
  end
120
+
121
+ def generate_static_locales(languages)
122
+ result_string = ''
123
+ language_locales = languages.each.map { |value| value['locale'].split('_').first }
124
+ locale_names = language_locales.each.map { |value| clean_variable_name("locale_#{value}") }
125
+
126
+ locale_names.each_with_index { |locale, index| result_string += "static Locale get #{locale} => const Locale('#{language_locales[index]}', '');\n\t" }
127
+
128
+ locale_list = locale_names.each.map { |value| "AppLocales.#{value}" }.join(', ')
129
+ result_string += "\n\tstatic List<Locale> get values => <Locale>[#{locale_list}];"
130
+ end
120
131
  end
121
132
  end
122
133
  end
@@ -34,6 +34,10 @@ class LocalizationDelegate extends LocalizationsDelegate<Localization> {
34
34
  @override
35
35
  bool shouldReload(LocalizationDelegate old) => false;
36
36
  }
37
+
38
+ extension AppLocales on Locale {
39
+ <%= generate_static_locales(languages) %>
40
+ }
37
41
  TEMPLATE
38
42
  end
39
43
  end
@@ -12,8 +12,7 @@ module PolyglotFlutter
12
12
 
13
13
  def template
14
14
  <<~TEMPLATE
15
- import 'package:intl/intl.dart';
16
- import 'localization.dart';
15
+ part of 'localization.dart';
17
16
 
18
17
  // AUTO GENERATED FILE. DO NOT CHANGE.
19
18
  extension LocalizationKeys on Localization {
@@ -17,6 +17,8 @@ module PolyglotFlutter
17
17
  import 'package:intl/intl.dart';
18
18
  import 'initialize_i18n/messages_all.dart';
19
19
 
20
+ part 'localization_keys.dart';
21
+
20
22
  // AUTO GENERATED FILE. DO NOT CHANGE.
21
23
  class Localization {
22
24
  Localization(this.localeName);
@@ -1,3 +1,3 @@
1
1
  module PolyglotFlutter
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flutter_polyglot_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maroje Marcelic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler