Skip to content

Commit

Permalink
Adapt example
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Jan 8, 2025
1 parent d484326 commit 320eae6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
24 changes: 10 additions & 14 deletions pkgs/messages/example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,26 @@
import 'dart:io';

import 'package:example/AboutPage_messages.g.dart';
import 'package:example/HomePage_messages.g.dart';

Future<void> main(List<String> arguments) async {
final messages = AboutPageMessages(
(id) => File(id.split('/').skip(2).join('/')).readAsString(),
);
// final index = AboutPageMessagesEnum.aboutMessage;
final messages = AboutPageMessages(_assetLoader);

await messages.loadLocale('en');
print('AboutMessage en:');
print('\t${messages.aboutMessage('typesafe.en')}');

///To enable this, add `generateFindById: true` to the pubspec section
// print('\t${messages.getById('aboutMessage', ['get-by-id.en'])}');

///To enable this, add `generateFindBy: enumerate` to the pubspec section
// print('\t${messages.getByEnum(index, ['get-by-index.en'])}');

await messages.loadLocale('fr');
print('AboutMessage fr:');
print('\t${messages.aboutMessage('typesafe.fr')}');

///To enable this, add `generateFindById: true` to the pubspec section
// print('\t${messages.getById('aboutMessage', ['get-by-id.fr'])}');
final messages2 = HomePageMessages(_assetLoader);

await messages2.loadLocale('en');

///To enable this, add `generateFindBy: enumerate` to the pubspec section
// print('\t${messages.getByEnum(index, ['get-by-index.fr'])}');
print('AboutMessage en:');
print('\t${messages2.helloAndWelcome('Paul', 'Erdős')}');
}

Future<String> _assetLoader(String id) =>
File(id.split('/').skip(2).join('/')).readAsString();
2 changes: 0 additions & 2 deletions pkgs/messages/example/lib/AboutPage_en_empty.g.dart

This file was deleted.

2 changes: 0 additions & 2 deletions pkgs/messages/example/lib/AboutPage_fr_empty.g.dart

This file was deleted.

2 changes: 0 additions & 2 deletions pkgs/messages/example/lib/HomePage_de_empty.g.dart

This file was deleted.

2 changes: 0 additions & 2 deletions pkgs/messages/example/lib/HomePage_en_empty.g.dart

This file was deleted.

0 comments on commit 320eae6

Please sign in to comment.