Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
chore: backup
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 4, 2023
1 parent 7410141 commit c6a200c
Show file tree
Hide file tree
Showing 46 changed files with 358 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .phrasey/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ format = "toml"
[output]
dir = "../assets/translations"
format = "json"
stringFormat = "format-string"
stringFormat = "python-positional-format-string"

[hooks]
files = ["./hooks/dart-sync.js"]
22 changes: 9 additions & 13 deletions .phrasey/hooks/dart-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,30 @@ async function createTranslationDart(phrasey, state, log) {
.join(", ");
const callArgs = x.parameters.join(", ");
dynamicKeys.push(
` String ${cname}(${params}) => StringUtils.formatPositional(_json['keys']['${x.name}'], <String>[${callArgs}]);`
` String ${cname}(${params}) => StringUtils.formatPositional(_key('${x.name}'), <String>[${callArgs}]);`
);
} else {
staticKeys.push(
` String ${cname} get => _json['keys']['${x.name}'];`
);
staticKeys.push(` String get ${cname} => _key('${x.name}');`);
}
}

const content = `
import 'dart:convert';
import 'package:utilx/locale.dart';
import 'package:utilx/utilx.dart';
part of 'translator.dart';
class Translation {
const Translation(this._json);
final Map<dynamic, dynamic> _json;
String localeDisplayName get => json['locale']['display'];
String localeNativeName get => json['locale']['native'];
String localeCode get => json['locale']['code'];
Locale locale get => Locale(localeDisplayName, localeNativeName, localeCode);
JsonMap get _localeJson => _json['locale'] as JsonMap;
String get localeDisplayName => _localeJson['display'];
String get localeNativeName => _localeJson['native'];
String get localeCode => _localeJson['code'];
Locale get locale => Locale(localeDisplayName, localeNativeName, localeCode);
JsonMap get _keysJson => _json['keys'] as JsonMap;
String _key(final String name) => _keysJson[name] as String;
${staticKeys.join("\n")}
${dynamicKeys.join("\n")}
static const List<String> availableLocales = <String>[${locales
Expand Down
68 changes: 68 additions & 0 deletions .phrasey/schema.toml
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,71 @@ description = "Chapters read"
[[keys]]
name = "VolumesRead"
description = "Volumes read"

[[keys]]
name = "Red"
description = "Red"

[[keys]]
name = "Orange"
description = "Orange"

[[keys]]
name = "Amber"
description = "Amber"

[[keys]]
name = "Yellow"
description = "Yellow"

[[keys]]
name = "Lime"
description = "Lime"

[[keys]]
name = "Green"
description = "Green"

[[keys]]
name = "Emerald"
description = "Emerald"

[[keys]]
name = "Teal"
description = "Teal"

[[keys]]
name = "Cyan"
description = "Cyan"

[[keys]]
name = "Sky"
description = "Sky"

[[keys]]
name = "Blue"
description = "Blue"

[[keys]]
name = "Indigo"
description = "Indigo"

[[keys]]
name = "Violet"
description = "Violet"

[[keys]]
name = "Purple"
description = "Purple"

[[keys]]
name = "Fuchsia"
description = "Fuchsia"

[[keys]]
name = "Pink"
description = "Pink"

[[keys]]
name = "Rose"
description = "Rose"
2 changes: 2 additions & 0 deletions cli/prerequisites.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'tasks/build_runner.dart' as build_runner;
import 'tasks/i18n.dart' as i18n;
import 'tasks/icon.dart' as icon;
import 'tasks/meta.dart' as meta;

Future<void> main(final List<String> args) async {
await i18n.main(args);
await build_runner.main(args);
await meta.main();
await icon.main();
Expand Down
11 changes: 11 additions & 0 deletions cli/tasks/i18n.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'dart:io';

Future<void> main(final List<String> args) async {
final ProcessResult result = await Process.run(
'npm',
<String>['run', 'i18n:build'],
);
if (result.exitCode != 0) {
throw Exception('i18n builder failed with error code $exitCode');
}
}
2 changes: 1 addition & 1 deletion cli/tasks/meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<void> main() async {
Future<String> getGeneratedAppMetaContent() async => '''
part of 'meta.dart';
abstract class _GeneratedAppMeta {
abstract class GeneratedAppMeta {
static const String version = '${await getVersion()}';
static const int builtAtMs = ${DateTime.now().millisecondsSinceEpoch};
}
Expand Down
17 changes: 17 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ TimeSpent = "Time spent"
TotalManga = "Total manga"
ChaptersRead = "Chapters read"
VolumesRead = "Volumes read"
Red = "Red"
Orange = "Orange"
Amber = "Amber"
Yellow = "Yellow"
Lime = "Lime"
Green = "Green"
Emerald = "Emerald"
Teal = "Teal"
Cyan = "Cyan"
Sky = "Sky"
Blue = "Blue"
Indigo = "Indigo"
Violet = "Violet"
Purple = "Purple"
Fuchsia = "Fuchsia"
Pink = "Pink"
Rose = "Rose"
52 changes: 26 additions & 26 deletions lib/core/anilist/translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,39 @@ extension TenkaTypeAnilistUtils on TenkaType {
}

extension AnimeSeasonsTUtils on AnimeSeasons {
String getTitleCase(final Translation translations) {
String getTitleCase(final Translation translation) {
switch (this) {
case AnimeSeasons.winter:
return translations.winter;
return translation.winter;

case AnimeSeasons.spring:
return translations.spring;
return translation.spring;

case AnimeSeasons.summer:
return translations.summer;
return translation.summer;

case AnimeSeasons.fall:
return translations.fall;
return translation.fall;
}
}
}

extension AnilistMediaTUtils on AnilistMedia {
String getWatchtime(final Translation translations) {
String getWatchtime(final Translation translation) {
switch (type) {
case AnilistMediaType.anime:
if (format == AnilistMediaFormat.movie) {
return duration != null
? PrettyDurations.prettyHoursMinutesShort(
translations,
translation,
Duration(minutes: duration!),
)
: translations.nMins(Translation.unk);
: translation.nMins(Translation.unk);
}
return translations.nEps(episodes?.toString() ?? Translation.unk);
return translation.nEps(episodes?.toString() ?? Translation.unk);

case AnilistMediaType.manga:
return translations.nChs(chapters?.toString() ?? Translation.unk);
return translation.nChs(chapters?.toString() ?? Translation.unk);
}
}

Expand All @@ -78,32 +78,32 @@ extension AnilistMediaTUtils on AnilistMedia {
}

extension AnilistRelationTypeTUtils on AnilistRelationType {
String getTitleCase(final Translation translations) =>
String getTitleCase(final Translation translation) =>
StringCase(name).titleCase;
}

extension AnilistCharacterRoleTUtils on AnilistCharacterRole {
String getTitleCase(final Translation translations) =>
String getTitleCase(final Translation translation) =>
StringCase(name).titleCase;
}

extension AnilistMediaStatusTUtils on AnilistMediaStatus {
String getTitleCase(final Translation translations) {
String getTitleCase(final Translation translation) {
switch (this) {
case AnilistMediaStatus.cancelled:
return translations.cancelled;
return translation.cancelled;

case AnilistMediaStatus.releasing:
return translations.releasing;
return translation.releasing;

case AnilistMediaStatus.notYetReleased:
return translations.notYetReleased;
return translation.notYetReleased;

case AnilistMediaStatus.finished:
return translations.finished;
return translation.finished;

case AnilistMediaStatus.hiatus:
return translations.hiatus;
return translation.hiatus;
}
}
}
Expand All @@ -123,30 +123,30 @@ const Map<AnilistMediaFormat, String> _anilistMediaFormatTitleMap =
};

extension AnilistMediaFormatTUtils on AnilistMediaFormat {
String getTitleCase(final Translation translations) =>
String getTitleCase(final Translation translation) =>
_anilistMediaFormatTitleMap[this]!;
}

extension AnilistMediaListStatusTUtils on AnilistMediaListStatus {
String getTitleCase(final Translation translations) {
String getTitleCase(final Translation translation) {
switch (this) {
case AnilistMediaListStatus.current:
return translations.current;
return translation.current;

case AnilistMediaListStatus.planning:
return translations.planning;
return translation.planning;

case AnilistMediaListStatus.completed:
return translations.completed;
return translation.completed;

case AnilistMediaListStatus.dropped:
return translations.dropped;
return translation.dropped;

case AnilistMediaListStatus.paused:
return translations.paused;
return translation.paused;

case AnilistMediaListStatus.repeating:
return translations.repeating;
return translation.repeating;
}
}
}
4 changes: 2 additions & 2 deletions lib/core/app/meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class AppMeta {
static const String scheme = 'kazahana';
static const String yuki = '雪';

static const String version = _GeneratedAppMeta.version;
static const String version = GeneratedAppMeta.version;
static final DateTime builtAt =
DateTime.fromMillisecondsSinceEpoch(_GeneratedAppMeta.builtAtMs);
DateTime.fromMillisecondsSinceEpoch(GeneratedAppMeta.builtAtMs);
}
6 changes: 3 additions & 3 deletions lib/core/tenka/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'package:tenka/tenka.dart';
import '../translator/exports.dart';

extension TenkaTypeUtils on TenkaType {
String getTitleCase(final Translation translations) {
String getTitleCase(final Translation translation) {
switch (this) {
case TenkaType.anime:
return translations.anime;
return translation.anime;

case TenkaType.manga:
return translations.manga;
return translation.manga;
}
}
}
Loading

0 comments on commit c6a200c

Please sign in to comment.