Skip to content

Commit 3b0b224

Browse files
committed
style: format
1 parent 2700847 commit 3b0b224

15 files changed

+30
-53
lines changed

slang/example/lib/i18n/strings_de.g.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ class _TranslationsMainScreenDe implements TranslationsMainScreenEn {
6767
/// so the map is split into smaller functions (512 entries each).
6868
extension on TranslationsDe {
6969
dynamic _flatMapFunction(String path) {
70-
return _flatMapFunction$0(path);
71-
}
72-
73-
dynamic _flatMapFunction$0(String path) {
7470
return switch (path) {
7571
'mainScreen.title' => 'Ein deutscher Titel',
7672
'mainScreen.counter' => ({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('de'))(n, one: 'Du hast einmal gedrückt.', other: 'Du hast ${n} mal gedrückt.', ),
@@ -82,4 +78,3 @@ extension on TranslationsDe {
8278
};
8379
}
8480
}
85-

slang/example/lib/i18n/strings_en.g.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ class TranslationsMainScreenEn {
7676
/// so the map is split into smaller functions (512 entries each).
7777
extension on Translations {
7878
dynamic _flatMapFunction(String path) {
79-
return _flatMapFunction$0(path);
80-
}
81-
82-
dynamic _flatMapFunction$0(String path) {
8379
return switch (path) {
8480
'mainScreen.title' => 'An English Title',
8581
'mainScreen.counter' => ({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('en'))(n, one: 'You pressed ${n} time.', other: 'You pressed ${n} times.', ),
@@ -91,4 +87,3 @@ extension on Translations {
9187
};
9288
}
9389
}
94-

slang/example/lib/i18n/strings_fr_FR.g.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ class _TranslationsMainScreenFrFr implements TranslationsMainScreenEn {
6767
/// so the map is split into smaller functions (512 entries each).
6868
extension on TranslationsFrFr {
6969
dynamic _flatMapFunction(String path) {
70-
return _flatMapFunction$0(path);
71-
}
72-
73-
dynamic _flatMapFunction$0(String path) {
7470
return switch (path) {
7571
'mainScreen.title' => 'Le titre français',
7672
'mainScreen.counter' => ({required num n}) => (_root.$meta.cardinalResolver ?? PluralResolvers.cardinal('fr'))(n, one: 'Vous avez appuyé une fois.', other: 'Vous avez appuyé ${n} fois.', ),
@@ -82,4 +78,3 @@ extension on TranslationsFrFr {
8278
};
8379
}
8480
}
85-

slang/lib/src/builder/generator/generate_translation_map.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ String generateTranslationMap(
3434

3535
// Generate split functions
3636
for (var i = 0; i < flatListSplits.length; i++) {
37-
final returnOrIfNull = switch (i) { 0 => '\t\treturn', _ => ' ??' };
37+
if (i == 0) {
38+
buffer.write('\t\treturn ');
39+
} else {
40+
buffer.write(' ?? ');
41+
}
3842

39-
buffer.writeln('$returnOrIfNull switch (path) {');
43+
buffer.writeln('switch (path) {');
4044

4145
_generateTranslationMap(
4246
buffer: buffer,
@@ -45,14 +49,13 @@ String generateTranslationMap(
4549
language: localeData.locale.language,
4650
);
4751

48-
buffer.write('\t\t\t_ => null}');
52+
buffer.write('\t\t\t_ => null,\n\t\t}');
4953
}
5054

5155
buffer.writeln(';');
5256

5357
buffer.writeln('\t}');
54-
buffer.writeln('}');
55-
buffer.writeln('');
58+
buffer.write('}');
5659

5760
return buffer.toString();
5861
}

slang/test/integration/resources/main/_expected_de.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ extension on TranslationsDe {
217217
'end.pages.1.with space' => 'Ein Fehler',
218218
'end.pages.1.with second space' => 'Ein 2. Fehler',
219219
'advancedPlural' => ({required num count, required InlineSpan Function(num) countBuilder, required GenderContext gender}) => RichPluralResolvers.bridge( n: count, resolver: _root.$meta.cardinalResolver ?? PluralResolvers.cardinal('de'), one: () => TextSpan(children: [ const TextSpan(text: 'Eins'), ]), other: () => TextSpan(children: [ const TextSpan(text: 'Andere '), countBuilder(count), TextSpan(text: ', ${_root.onboarding.greet2(gender: gender)}'), ]), ),
220-
_ => null};
220+
_ => null,
221+
};
221222
}
222223
}
223-
224-

slang/test/integration/resources/main/_expected_en.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ extension on Translations {
262262
'end.pages.1.with space' => 'An Error',
263263
'end.pages.1.with second space' => 'An 2nd Error',
264264
'advancedPlural' => ({required num count, required InlineSpan Function(num) countBuilder, required GenderContext gender}) => RichPluralResolvers.bridge( n: count, resolver: _root.$meta.cardinalResolver ?? PluralResolvers.cardinal('en'), one: () => TextSpan(children: [ const TextSpan(text: 'One'), ]), other: () => TextSpan(children: [ const TextSpan(text: 'Other '), countBuilder(count), TextSpan(text: ', ${_root.onboarding.greet2(gender: gender)}'), ]), ),
265-
_ => null};
265+
_ => null,
266+
};
266267
}
267268
}
268-
269-

slang/test/integration/resources/main/_expected_fallback_base_locale_de.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ extension on TranslationsDe {
219219
'end.pages.1.with space' => 'Ein Fehler',
220220
'end.pages.1.with second space' => 'Ein 2. Fehler',
221221
'advancedPlural' => ({required num count, required InlineSpan Function(num) countBuilder, required GenderContext gender}) => RichPluralResolvers.bridge( n: count, resolver: _root.$meta.cardinalResolver ?? PluralResolvers.cardinal('de'), one: () => TextSpan(children: [ const TextSpan(text: 'Eins'), ]), other: () => TextSpan(children: [ const TextSpan(text: 'Andere '), countBuilder(count), TextSpan(text: ', ${_root.onboarding.greet2(gender: gender)}'), ]), ),
222-
_ => null};
222+
_ => null,
223+
};
223224
}
224225
}
225-
226-

slang/test/integration/resources/main/_expected_fallback_base_locale_en.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ extension on Translations {
262262
'end.pages.1.with space' => 'An Error',
263263
'end.pages.1.with second space' => 'An 2nd Error',
264264
'advancedPlural' => ({required num count, required InlineSpan Function(num) countBuilder, required GenderContext gender}) => RichPluralResolvers.bridge( n: count, resolver: _root.$meta.cardinalResolver ?? PluralResolvers.cardinal('en'), one: () => TextSpan(children: [ const TextSpan(text: 'One'), ]), other: () => TextSpan(children: [ const TextSpan(text: 'Other '), countBuilder(count), TextSpan(text: ', ${_root.onboarding.greet2(gender: gender)}'), ]), ),
265-
_ => null};
265+
_ => null,
266+
};
266267
}
267268
}
268-
269-

slang/test/integration/resources/main/_expected_fallback_base_locale_special_de.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ extension on TranslationsDe {
5858
dynamic _flatMapFunction(String path) {
5959
return switch (path) {
6060
'greet' => ({required Gender context}) { switch (context) { case Gender.male: return 'Hallo Herr'; case Gender.female: return 'Hello Mrs'; } },
61-
_ => null};
61+
_ => null,
62+
};
6263
}
6364
}
64-
65-

slang/test/integration/resources/main/_expected_fallback_base_locale_special_en.output

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ extension on Translations {
6161
dynamic _flatMapFunction(String path) {
6262
return switch (path) {
6363
'greet' => ({required Gender context}) { switch (context) { case Gender.male: return 'Hello Mr'; case Gender.female: return 'Hello Mrs'; } },
64-
_ => null};
64+
_ => null,
65+
};
6566
}
6667
}
67-
68-

0 commit comments

Comments
 (0)