flutter_polyglot_cli 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +34 -37
- data/bin/console +0 -1
- data/lib/flutter_polyglot_cli.rb +1 -3
- data/lib/flutter_polyglot_cli/commands/pull.rb +24 -37
- data/lib/flutter_polyglot_cli/commands/setup.rb +17 -4
- data/lib/flutter_polyglot_cli/helpers/general.rb +0 -12
- data/lib/flutter_polyglot_cli/io/l10n.rb +19 -0
- data/lib/flutter_polyglot_cli/serializers/localizations/localization_serializer.rb +47 -28
- data/lib/flutter_polyglot_cli/serializers/translations/translations_serializer.rb +16 -1
- data/lib/flutter_polyglot_cli/version.rb +1 -1
- metadata +4 -6
- data/lib/flutter_polyglot_cli/serializers/localizations/localization_delegate_serializer.rb +0 -43
- data/lib/flutter_polyglot_cli/serializers/localizations/localization_keys_serializer.rb +0 -26
- data/lib/flutter_polyglot_cli/serializers/localizations/localization_strings_serializer.rb +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 651d0b0af0df1635b92bb6bae1ea81801d8f578bde0f72835e13c28ac2714f4c
|
|
4
|
+
data.tar.gz: 2dfdb9e39b20c6ffc481ffdfef6d28b9bf732ea340bc8de6fc11b9043610dac7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 297a3d60d28e54f1fea3f92292e7f52825c1b2c2724a83eb5afd0cbcc46127f127c24426c25d2163cdc6263a8fe707b99568ceb2a536a7a8f98d22f3d5ee3b19
|
|
7
|
+
data.tar.gz: ca1eb64a9653625ea87673025bde895ab220733fd56aed8885a1cdb3e61bf28e3aae9cec17a27df716393611b69e9bbaff82b808b67cb85a369aa7a39f3bc349
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
flutter_polyglot_cli (1.
|
|
4
|
+
flutter_polyglot_cli (1.2.0)
|
|
5
5
|
activesupport
|
|
6
6
|
commander
|
|
7
7
|
json_api_client
|
|
@@ -14,44 +14,42 @@ GEM
|
|
|
14
14
|
RubyInline (3.12.5)
|
|
15
15
|
ZenTest (~> 4.3)
|
|
16
16
|
ZenTest (4.12.0)
|
|
17
|
-
activemodel (6.
|
|
18
|
-
activesupport (= 6.
|
|
19
|
-
activesupport (6.
|
|
17
|
+
activemodel (6.1.3)
|
|
18
|
+
activesupport (= 6.1.3)
|
|
19
|
+
activesupport (6.1.3)
|
|
20
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
21
|
-
i18n (>=
|
|
22
|
-
minitest (
|
|
23
|
-
tzinfo (~>
|
|
24
|
-
zeitwerk (~> 2.
|
|
21
|
+
i18n (>= 1.6, < 2)
|
|
22
|
+
minitest (>= 5.1)
|
|
23
|
+
tzinfo (~> 2.0)
|
|
24
|
+
zeitwerk (~> 2.3)
|
|
25
25
|
addressable (2.7.0)
|
|
26
26
|
public_suffix (>= 2.0.2, < 5.0)
|
|
27
27
|
byebug (11.0.1)
|
|
28
28
|
coderay (1.1.2)
|
|
29
|
-
commander (4.
|
|
29
|
+
commander (4.5.2)
|
|
30
30
|
highline (~> 2.0.0)
|
|
31
|
-
concurrent-ruby (1.1.
|
|
32
|
-
|
|
33
|
-
faraday (0.17.0)
|
|
31
|
+
concurrent-ruby (1.1.8)
|
|
32
|
+
faraday (1.1.0)
|
|
34
33
|
multipart-post (>= 1.2, < 3)
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
ruby2_keywords
|
|
35
|
+
faraday_middleware (1.0.0)
|
|
36
|
+
faraday (~> 1.0)
|
|
37
37
|
highline (2.0.3)
|
|
38
|
-
i18n (1.
|
|
38
|
+
i18n (1.8.9)
|
|
39
39
|
concurrent-ruby (~> 1.0)
|
|
40
|
-
json_api_client (1.
|
|
40
|
+
json_api_client (1.18.0)
|
|
41
41
|
activemodel (>= 3.2.0)
|
|
42
42
|
activesupport (>= 3.2.0)
|
|
43
43
|
addressable (~> 2.2)
|
|
44
|
-
faraday (
|
|
45
|
-
faraday_middleware (
|
|
44
|
+
faraday (>= 0.15.2, < 1.2.0)
|
|
45
|
+
faraday_middleware (>= 0.9.0, < 1.2.0)
|
|
46
46
|
rack (>= 0.2)
|
|
47
47
|
method_source (0.9.2)
|
|
48
48
|
minitest (5.14.1)
|
|
49
49
|
multipart-post (2.1.1)
|
|
50
|
-
necromancer (0.5.0)
|
|
51
50
|
osx_keychain (1.0.2)
|
|
52
51
|
RubyInline (~> 3)
|
|
53
|
-
pastel (0.
|
|
54
|
-
equatable (~> 0.6)
|
|
52
|
+
pastel (0.8.0)
|
|
55
53
|
tty-color (~> 0.5)
|
|
56
54
|
pry (0.12.2)
|
|
57
55
|
coderay (~> 1.1.0)
|
|
@@ -59,25 +57,24 @@ GEM
|
|
|
59
57
|
pry-byebug (3.7.0)
|
|
60
58
|
byebug (~> 11.0)
|
|
61
59
|
pry (~> 0.10)
|
|
62
|
-
public_suffix (4.0.
|
|
63
|
-
rack (2.
|
|
60
|
+
public_suffix (4.0.6)
|
|
61
|
+
rack (2.2.3)
|
|
64
62
|
rake (10.5.0)
|
|
65
|
-
|
|
66
|
-
tty-color (0.
|
|
67
|
-
tty-cursor (0.7.
|
|
68
|
-
tty-prompt (0.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
tty-reader (0.6.0)
|
|
63
|
+
ruby2_keywords (0.0.4)
|
|
64
|
+
tty-color (0.6.0)
|
|
65
|
+
tty-cursor (0.7.1)
|
|
66
|
+
tty-prompt (0.23.0)
|
|
67
|
+
pastel (~> 0.8)
|
|
68
|
+
tty-reader (~> 0.8)
|
|
69
|
+
tty-reader (0.9.0)
|
|
73
70
|
tty-cursor (~> 0.7)
|
|
74
|
-
tty-screen (~> 0.
|
|
75
|
-
wisper (~> 2.0
|
|
76
|
-
tty-screen (0.
|
|
77
|
-
tzinfo (
|
|
78
|
-
|
|
71
|
+
tty-screen (~> 0.8)
|
|
72
|
+
wisper (~> 2.0)
|
|
73
|
+
tty-screen (0.8.1)
|
|
74
|
+
tzinfo (2.0.4)
|
|
75
|
+
concurrent-ruby (~> 1.0)
|
|
79
76
|
wisper (2.0.1)
|
|
80
|
-
zeitwerk (2.
|
|
77
|
+
zeitwerk (2.4.2)
|
|
81
78
|
|
|
82
79
|
PLATFORMS
|
|
83
80
|
ruby
|
data/bin/console
CHANGED
data/lib/flutter_polyglot_cli.rb
CHANGED
|
@@ -20,15 +20,13 @@ require 'flutter_polyglot_cli/api/translation_key'
|
|
|
20
20
|
|
|
21
21
|
# File Accessors
|
|
22
22
|
require 'flutter_polyglot_cli/io/token'
|
|
23
|
+
require 'flutter_polyglot_cli/io/l10n'
|
|
23
24
|
require 'flutter_polyglot_cli/io/config'
|
|
24
25
|
|
|
25
26
|
# Serializers
|
|
26
27
|
require 'flutter_polyglot_cli/serializers/translations/translations_serializer'
|
|
27
28
|
require 'flutter_polyglot_cli/serializers/localizations/loc_serializer'
|
|
28
29
|
require 'flutter_polyglot_cli/serializers/localizations/localization_serializer'
|
|
29
|
-
require 'flutter_polyglot_cli/serializers/localizations/localization_delegate_serializer'
|
|
30
|
-
require 'flutter_polyglot_cli/serializers/localizations/localization_keys_serializer'
|
|
31
|
-
require 'flutter_polyglot_cli/serializers/localizations/localization_strings_serializer'
|
|
32
30
|
|
|
33
31
|
# Commands
|
|
34
32
|
require 'flutter_polyglot_cli/commands/login'
|
|
@@ -10,30 +10,34 @@ module PolyglotFlutter
|
|
|
10
10
|
|
|
11
11
|
def call
|
|
12
12
|
prompt.say('Fetching translations...')
|
|
13
|
-
generate_translations(project_configs
|
|
13
|
+
generate_translations(project_configs)
|
|
14
14
|
success('Translations successfully generated!')
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
private
|
|
18
18
|
|
|
19
|
-
def generate_translations(projects
|
|
19
|
+
def generate_translations(projects)
|
|
20
20
|
projects.each do |project|
|
|
21
21
|
project_id = project[:id]
|
|
22
|
+
flutter_instance = project[:flutterInstance]
|
|
23
|
+
mandatory_language = project[:mandatoryLanguage]
|
|
24
|
+
arb_path = project[:path]
|
|
25
|
+
l10n_path = project[:l10nFilePath]
|
|
26
|
+
directory_path = project[:sourceFilesPath]
|
|
27
|
+
output_localization_file = project[:outputLocalizationFile]
|
|
28
|
+
set_default_langauge = project[:setDefaultLangauge]
|
|
29
|
+
|
|
22
30
|
languages = pull_languages(project_id)
|
|
23
31
|
translation_keys = pull_translation_keys(project_id)
|
|
32
|
+
|
|
33
|
+
write_translations(translation_keys, languages, arb_path)
|
|
34
|
+
write_l10n_yaml(l10n_path, arb_path, mandatory_language, output_localization_file)
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
write_translations(translation_keys, languages, project[:path])
|
|
27
|
-
write_localization(directory_path)
|
|
28
|
-
write_localization_delegate(languages, directory_path)
|
|
29
|
-
write_localization_keys(translation_keys, languages, directory_path, mandatory_language)
|
|
30
|
-
|
|
31
|
-
FileUtils.mkdir_p "#{directory_path}initialize_i18n"
|
|
32
|
-
script = "flutter pub pub run intl_translation:generate_from_arb --output-dir=#{directory_path}initialize_i18n --no-use-deferred-loading #{project[:sourceFilesPath]}localization_keys.dart #{project[:path]}intl_*.arb"
|
|
36
|
+
script = "#{flutter_instance} packages get"
|
|
33
37
|
`#{script}`
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
write_localization(directory_path, languages, output_localization_file, set_default_langauge, mandatory_language)
|
|
40
|
+
|
|
37
41
|
end
|
|
38
42
|
end
|
|
39
43
|
|
|
@@ -48,36 +52,19 @@ module PolyglotFlutter
|
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
54
|
|
|
51
|
-
def
|
|
52
|
-
return if
|
|
55
|
+
def write_l10n_yaml(l10n_path, arb_path, mandatory_language, output_localization_file)
|
|
56
|
+
return if l10n_path.to_s.empty?
|
|
53
57
|
|
|
54
|
-
PolyglotFlutter::
|
|
55
|
-
.
|
|
56
|
-
.save(translations_path)
|
|
58
|
+
PolyglotFlutter::IO::L10n
|
|
59
|
+
.write(l10n_path, arb_path, mandatory_language, output_localization_file)
|
|
57
60
|
end
|
|
58
61
|
|
|
59
|
-
def
|
|
60
|
-
return if
|
|
62
|
+
def write_localization(directory_path, languages, output_localization_file, set_default_langauge, mandatory_language)
|
|
63
|
+
return if directory_path.to_s.empty?
|
|
61
64
|
|
|
62
|
-
PolyglotFlutter::Serializer::Localization::
|
|
65
|
+
PolyglotFlutter::Serializer::Localization::Localization
|
|
63
66
|
.new(languages: languages)
|
|
64
|
-
.
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def write_localization_keys(translation_keys, languages, translations_path, mandatory_language)
|
|
68
|
-
return if translations_path.to_s.empty?
|
|
69
|
-
|
|
70
|
-
PolyglotFlutter::Serializer::Localization::LocalizationKeys
|
|
71
|
-
.new(languages: languages, translation_keys: translation_keys, mandatory_language: mandatory_language)
|
|
72
|
-
.save(translations_path)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def write_localization_strings(translation_keys, languages, translations_path, mandatory_language)
|
|
76
|
-
return if translations_path.to_s.empty?
|
|
77
|
-
|
|
78
|
-
PolyglotFlutter::Serializer::Localization::LocalizationStrings
|
|
79
|
-
.new(languages: languages, translation_keys: translation_keys, mandatory_language: mandatory_language)
|
|
80
|
-
.save(translations_path)
|
|
67
|
+
.write(directory_path, output_localization_file, set_default_langauge, mandatory_language)
|
|
81
68
|
end
|
|
82
69
|
|
|
83
70
|
# Pulling data
|
|
@@ -17,19 +17,26 @@ module PolyglotFlutter
|
|
|
17
17
|
|
|
18
18
|
def call
|
|
19
19
|
project_id = project_id_prompt
|
|
20
|
-
|
|
20
|
+
flutter_instance = flutter_instance_prompt
|
|
21
|
+
l10n_path = './l10n.yaml'
|
|
22
|
+
output_localization_file = 'app_localizations'
|
|
23
|
+
set_default_langauge = false
|
|
21
24
|
translations_path = translations_path_prompt
|
|
25
|
+
|
|
22
26
|
sources_path = sources_path_prompt
|
|
23
27
|
mandatory_language = mandatory_language_prompt
|
|
24
28
|
project = {
|
|
25
29
|
id: project_id,
|
|
30
|
+
flutterInstance: flutter_instance,
|
|
31
|
+
mandatoryLanguage: mandatory_language,
|
|
26
32
|
path: translations_path,
|
|
27
|
-
|
|
33
|
+
l10nFilePath: l10n_path,
|
|
34
|
+
sourceFilesPath: sources_path,
|
|
35
|
+
outputLocalizationFile: output_localization_file,
|
|
36
|
+
setDefaultLangauge: set_default_langauge,
|
|
28
37
|
}
|
|
29
38
|
config = {
|
|
30
|
-
language: language,
|
|
31
39
|
projects: [project],
|
|
32
|
-
mandatory_language: mandatory_language
|
|
33
40
|
}
|
|
34
41
|
PolyglotFlutter::IO::Config.write(config)
|
|
35
42
|
success
|
|
@@ -43,6 +50,12 @@ module PolyglotFlutter
|
|
|
43
50
|
prompt.select('Choose a project: ', filtered_projects)
|
|
44
51
|
end
|
|
45
52
|
|
|
53
|
+
# Flutter instaince
|
|
54
|
+
|
|
55
|
+
def flutter_instance_prompt
|
|
56
|
+
prompt.ask('What is flutter instance that is ussed (flutter/fvm flutter/...)?', default: 'flutter')
|
|
57
|
+
end
|
|
58
|
+
|
|
46
59
|
# Translations path
|
|
47
60
|
|
|
48
61
|
def translations_path_prompt
|
|
@@ -25,18 +25,6 @@ module PolyglotFlutter
|
|
|
25
25
|
@project_configs ||= config[:projects]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def programming_language
|
|
29
|
-
@programming_language ||= config[:language]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def mandatory_language
|
|
33
|
-
@mandatory_language ||= config[:mandatory_language]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def use_old_naming
|
|
37
|
-
@useOldNaming ||= config[:useOldNaming]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
28
|
def indent(level = 0, initial = '')
|
|
41
29
|
(1..level)
|
|
42
30
|
.to_a.reduce('') { |result, _value| result + ' ' }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module PolyglotFlutter
|
|
2
|
+
module IO
|
|
3
|
+
class L10n
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def write(l10n_path, arb_path, mandatory_language, output_localization_file)
|
|
7
|
+
data = {
|
|
8
|
+
'arb-dir' => arb_path,
|
|
9
|
+
'template-arb-file' => "intl_#{mandatory_language.downcase}.arb",
|
|
10
|
+
'output-localization-file' => "#{output_localization_file}.dart",
|
|
11
|
+
}
|
|
12
|
+
File.open(l10n_path, 'w') { |file| YAML.dump(data, file) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
@@ -4,43 +4,62 @@ module PolyglotFlutter
|
|
|
4
4
|
module Serializer
|
|
5
5
|
module Localization
|
|
6
6
|
class Localization < Base
|
|
7
|
-
def
|
|
7
|
+
def write(sources_path, output_localization_file, set_default_langauge, mandatory_language)
|
|
8
|
+
@output_localization_file = output_localization_file
|
|
9
|
+
@set_default_langauge = set_default_langauge
|
|
10
|
+
@mandatory_language = mandatory_language
|
|
11
|
+
|
|
8
12
|
FileUtils.mkdir_p sources_path unless File.exist? sources_path
|
|
9
|
-
output_path = File.join(sources_path, '
|
|
13
|
+
output_path = File.join(sources_path, 'strings.dart')
|
|
10
14
|
File.write(output_path, render)
|
|
11
15
|
end
|
|
12
16
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import 'package:intl/intl.dart';
|
|
18
|
-
import 'initialize_i18n/messages_all.dart';
|
|
19
|
-
|
|
20
|
-
part 'localization_strings.dart';
|
|
21
|
-
|
|
22
|
-
// AUTO GENERATED FILE. DO NOT CHANGE.
|
|
23
|
-
class Localization {
|
|
24
|
-
Localization(this.localeName);
|
|
25
|
-
|
|
26
|
-
static Future<Localization> load(Locale locale) {
|
|
27
|
-
final String name =
|
|
28
|
-
locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
|
|
29
|
-
final String localeName = Intl.canonicalizedLocale(name);
|
|
17
|
+
def import_default_language()
|
|
18
|
+
return '' unless @set_default_langauge
|
|
19
|
+
%{import 'package:flutter_gen/gen_l10n/#{@output_localization_file}_#{@mandatory_language.downcase}.dart';}
|
|
20
|
+
end
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
22
|
+
def latest_localizations()
|
|
23
|
+
return 'static AppLocalizations? _latestLocalizations;' unless @set_default_langauge
|
|
24
|
+
%{static AppLocalizations? _latestLocalizations = AppLocalizations#{@mandatory_language.capitalize}(); }
|
|
25
|
+
end
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
def template
|
|
28
|
+
<<~TEMPLATE
|
|
29
|
+
import 'package:flutter/material.dart';
|
|
30
|
+
import 'package:flutter_gen/gen_l10n/<%= @output_localization_file %>.dart';
|
|
31
|
+
<%= import_default_language %>
|
|
32
|
+
|
|
33
|
+
class Strings {
|
|
34
|
+
Strings._();
|
|
35
|
+
<%= latest_localizations %>
|
|
36
|
+
|
|
37
|
+
static AppLocalizations of(BuildContext context) => AppLocalizations.of(context) ?? latest;
|
|
38
|
+
|
|
39
|
+
static AppLocalizations get latest {
|
|
40
|
+
final appLocalizations = _latestLocalizations;
|
|
41
|
+
if (appLocalizations == null) {
|
|
42
|
+
throw 'Unable to load App Localizations';
|
|
39
43
|
}
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
return appLocalizations;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class StringsLocaleWidget extends StatelessWidget {
|
|
49
|
+
const StringsLocaleWidget({Key? key, required this.child}) : super(key: key);
|
|
50
|
+
final Widget child;
|
|
51
|
+
|
|
52
|
+
@override
|
|
53
|
+
Widget build(BuildContext context) {
|
|
54
|
+
Strings._latestLocalizations = AppLocalizations.of(context);
|
|
55
|
+
return child;
|
|
42
56
|
}
|
|
57
|
+
}
|
|
43
58
|
|
|
59
|
+
extension AppLocales on Locale {
|
|
60
|
+
<%= generate_static_locales(@languages) %>
|
|
61
|
+
}
|
|
62
|
+
|
|
44
63
|
TEMPLATE
|
|
45
64
|
end
|
|
46
65
|
end
|
|
@@ -3,12 +3,27 @@ module PolyglotFlutter
|
|
|
3
3
|
class Translation
|
|
4
4
|
class << self
|
|
5
5
|
include Helper::General
|
|
6
|
+
|
|
7
|
+
def create_trainslation(key, value)
|
|
8
|
+
key = clean_variable_name(key)
|
|
9
|
+
value = value.gsub(/\n/, '\\n').gsub(/"/, '\\"')
|
|
10
|
+
args = value.scan(/{arg\d+}/).map { |arg| %{"#{arg[1..-2]}": {}} }
|
|
11
|
+
args_part = ''
|
|
12
|
+
unless args.empty?
|
|
13
|
+
args_part = args.join ', '
|
|
14
|
+
args_part = %{, "placeholders": {#{args_part} }}
|
|
15
|
+
end
|
|
16
|
+
return %{
|
|
17
|
+
"#{key}": "#{value}",
|
|
18
|
+
"@#{key}": { "type": "text"#{args_part}}}
|
|
19
|
+
end
|
|
20
|
+
|
|
6
21
|
def write(translation_keys, language, translations_path)
|
|
7
22
|
translations = extract_translations(translation_keys, language)
|
|
8
23
|
|
|
9
24
|
data = translations
|
|
10
25
|
.sort
|
|
11
|
-
.map { |key, value|
|
|
26
|
+
.map { |key, value| create_trainslation(key, value) }
|
|
12
27
|
.join(",\n")
|
|
13
28
|
.concat("\n")
|
|
14
29
|
data = "{\n\t\"@@locale\": \"#{language['locale'].split('_').first}\",\n#{data}}"
|
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.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maroje Marcelic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -156,12 +156,10 @@ files:
|
|
|
156
156
|
- lib/flutter_polyglot_cli/helpers/general.rb
|
|
157
157
|
- lib/flutter_polyglot_cli/helpers/terminal.rb
|
|
158
158
|
- lib/flutter_polyglot_cli/io/config.rb
|
|
159
|
+
- lib/flutter_polyglot_cli/io/l10n.rb
|
|
159
160
|
- lib/flutter_polyglot_cli/io/token.rb
|
|
160
161
|
- lib/flutter_polyglot_cli/serializers/localizations/loc_serializer.rb
|
|
161
|
-
- lib/flutter_polyglot_cli/serializers/localizations/localization_delegate_serializer.rb
|
|
162
|
-
- lib/flutter_polyglot_cli/serializers/localizations/localization_keys_serializer.rb
|
|
163
162
|
- lib/flutter_polyglot_cli/serializers/localizations/localization_serializer.rb
|
|
164
|
-
- lib/flutter_polyglot_cli/serializers/localizations/localization_strings_serializer.rb
|
|
165
163
|
- lib/flutter_polyglot_cli/serializers/translations/translations_serializer.rb
|
|
166
164
|
- lib/flutter_polyglot_cli/version.rb
|
|
167
165
|
homepage: https://github.com/infinum/flutter-polyglot-cli
|
|
@@ -184,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
184
182
|
- !ruby/object:Gem::Version
|
|
185
183
|
version: '0'
|
|
186
184
|
requirements: []
|
|
187
|
-
rubygems_version: 3.
|
|
185
|
+
rubygems_version: 3.1.4
|
|
188
186
|
signing_key:
|
|
189
187
|
specification_version: 4
|
|
190
188
|
summary: A CLI for pulling polyglot translations and generating Flutter Source Files
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require_relative 'loc_serializer'
|
|
2
|
-
|
|
3
|
-
module PolyglotFlutter
|
|
4
|
-
module Serializer
|
|
5
|
-
module Localization
|
|
6
|
-
class LocalizationDelegate < Base
|
|
7
|
-
def save(sources_path)
|
|
8
|
-
FileUtils.mkdir_p sources_path unless File.exist? sources_path
|
|
9
|
-
output_path = File.join(sources_path, 'localization_delegate.dart')
|
|
10
|
-
File.write(output_path, render)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def template()
|
|
14
|
-
<<-TEMPLATE
|
|
15
|
-
import 'dart:async';
|
|
16
|
-
import 'dart:ui';
|
|
17
|
-
import 'package:flutter/foundation.dart';
|
|
18
|
-
import 'package:flutter/material.dart';
|
|
19
|
-
import 'localization.dart';
|
|
20
|
-
|
|
21
|
-
// AUTO GENERATED FILE. DO NOT CHANGE.
|
|
22
|
-
class LocalizationDelegate extends LocalizationsDelegate<Localization> {
|
|
23
|
-
const LocalizationDelegate();
|
|
24
|
-
|
|
25
|
-
@override
|
|
26
|
-
bool isSupported(Locale locale) => <String><%= generate_locales(languages) %>.contains(locale.languageCode);
|
|
27
|
-
|
|
28
|
-
@override
|
|
29
|
-
Future<Localization> load(Locale locale) async => SynchronousFuture<Localization>(await Localization.load(locale));
|
|
30
|
-
|
|
31
|
-
@override
|
|
32
|
-
bool shouldReload(LocalizationDelegate old) => false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
extension AppLocales on Locale {
|
|
36
|
-
<%= generate_static_locales(languages) %>
|
|
37
|
-
}
|
|
38
|
-
TEMPLATE
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require_relative 'loc_serializer'
|
|
2
|
-
|
|
3
|
-
module PolyglotFlutter
|
|
4
|
-
module Serializer
|
|
5
|
-
module Localization
|
|
6
|
-
class LocalizationKeys < Base
|
|
7
|
-
def save(sources_path)
|
|
8
|
-
FileUtils.mkdir_p sources_path unless File.exist? sources_path
|
|
9
|
-
output_path = File.join(sources_path, 'localization_keys.dart')
|
|
10
|
-
File.write(output_path, render)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def template
|
|
14
|
-
<<~TEMPLATE
|
|
15
|
-
part of 'localization.dart';
|
|
16
|
-
|
|
17
|
-
// AUTO GENERATED FILE. DO NOT CHANGE.
|
|
18
|
-
extension LocalizationKeys on Localization {
|
|
19
|
-
|
|
20
|
-
<%= generate_localization_keys(languages, translation_keys, mandatory_language) %>}
|
|
21
|
-
TEMPLATE
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require_relative 'loc_serializer'
|
|
2
|
-
|
|
3
|
-
module PolyglotFlutter
|
|
4
|
-
module Serializer
|
|
5
|
-
module Localization
|
|
6
|
-
class LocalizationStrings < Base
|
|
7
|
-
def save(sources_path)
|
|
8
|
-
FileUtils.mkdir_p sources_path unless File.exist? sources_path
|
|
9
|
-
output_path = File.join(sources_path, 'localization_strings.dart')
|
|
10
|
-
File.write(output_path, render)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def template
|
|
14
|
-
<<~TEMPLATE
|
|
15
|
-
part of 'localization.dart';
|
|
16
|
-
|
|
17
|
-
// AUTO GENERATED FILE. DO NOT CHANGE.
|
|
18
|
-
enum Strings {
|
|
19
|
-
<%= generate_strings(languages, translation_keys, mandatory_language) %>}
|
|
20
|
-
|
|
21
|
-
extension StringsValue on Strings {
|
|
22
|
-
String value() => toString().split('.').last;
|
|
23
|
-
|
|
24
|
-
String localized({BuildContext context, List<Object> args}) {
|
|
25
|
-
if (context != null) {
|
|
26
|
-
Localizations.of<Localization>(context, Localization);
|
|
27
|
-
}
|
|
28
|
-
return Intl.message('', name: value(), args: args);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
TEMPLATE
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|