mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-28 22:15:37 +00:00
Localization
This commit is contained in:
parent
dece242a54
commit
6f3a87ac5e
15 changed files with 268 additions and 56 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -266,3 +266,4 @@ __pycache__/
|
||||||
/AideDeJeu/AideDeJeuWeb/Properties/PublishProfiles/AideDeJeuWeb - Web Deploy.pubxml
|
/AideDeJeu/AideDeJeuWeb/Properties/PublishProfiles/AideDeJeuWeb - Web Deploy.pubxml
|
||||||
*.lock
|
*.lock
|
||||||
*.lock
|
*.lock
|
||||||
|
*.lock
|
||||||
|
|
|
||||||
1
aidedejeu_flutter/buildarb.bat
Normal file
1
aidedejeu_flutter/buildarb.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
call C:\dev\flutter\bin\flutter.bat pub pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/localization.dart
|
||||||
1
aidedejeu_flutter/buildarben.bat
Normal file
1
aidedejeu_flutter/buildarben.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
call C:\dev\flutter\bin\flutter.bat pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/localization.dart lib/l10n/intl_en.arb
|
||||||
1
aidedejeu_flutter/buildarbfr.bat
Normal file
1
aidedejeu_flutter/buildarbfr.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
call C:\dev\flutter\bin\flutter.bat pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/localization.dart lib/l10n/intl_fr.arb
|
||||||
8
aidedejeu_flutter/lib/l10n/intl_en.arb
Normal file
8
aidedejeu_flutter/lib/l10n/intl_en.arb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"@@locale": "en",
|
||||||
|
"title": "Hello World",
|
||||||
|
"@title": {
|
||||||
|
"description": "Title for the Demo application",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
8
aidedejeu_flutter/lib/l10n/intl_fr.arb
Normal file
8
aidedejeu_flutter/lib/l10n/intl_fr.arb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"@@locale": "fr",
|
||||||
|
"title": "Bonjour Monde",
|
||||||
|
"@title": {
|
||||||
|
"description": "Title for the Demo application",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
aidedejeu_flutter/lib/l10n/intl_messages.arb
Normal file
9
aidedejeu_flutter/lib/l10n/intl_messages.arb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"@@last_modified": "2020-03-02T17:18:13.928618",
|
||||||
|
"title": "Hello World",
|
||||||
|
"@title": {
|
||||||
|
"description": "Title for the Demo application",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
aidedejeu_flutter/lib/l10n/messages_all.dart
Normal file
63
aidedejeu_flutter/lib/l10n/messages_all.dart
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||||
|
// This is a library that looks up messages for specific locales by
|
||||||
|
// delegating to the appropriate library.
|
||||||
|
|
||||||
|
// Ignore issues from commonly used lints in this file.
|
||||||
|
// ignore_for_file:implementation_imports, file_names, unnecessary_new
|
||||||
|
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
|
||||||
|
// ignore_for_file:argument_type_not_assignable, invalid_assignment
|
||||||
|
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
|
||||||
|
// ignore_for_file:comment_references
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:intl/message_lookup_by_library.dart';
|
||||||
|
import 'package:intl/src/intl_helpers.dart';
|
||||||
|
|
||||||
|
import 'messages_fr.dart' as messages_fr;
|
||||||
|
|
||||||
|
typedef Future<dynamic> LibraryLoader();
|
||||||
|
Map<String, LibraryLoader> _deferredLibraries = {
|
||||||
|
'fr': () => new Future.value(null),
|
||||||
|
};
|
||||||
|
|
||||||
|
MessageLookupByLibrary _findExact(String localeName) {
|
||||||
|
switch (localeName) {
|
||||||
|
case 'fr':
|
||||||
|
return messages_fr.messages;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// User programs should call this before using [localeName] for messages.
|
||||||
|
Future<bool> initializeMessages(String localeName) async {
|
||||||
|
var availableLocale = Intl.verifiedLocale(
|
||||||
|
localeName,
|
||||||
|
(locale) => _deferredLibraries[locale] != null,
|
||||||
|
onFailure: (_) => null);
|
||||||
|
if (availableLocale == null) {
|
||||||
|
return new Future.value(false);
|
||||||
|
}
|
||||||
|
var lib = _deferredLibraries[availableLocale];
|
||||||
|
await (lib == null ? new Future.value(false) : lib());
|
||||||
|
initializeInternalMessageLookup(() => new CompositeMessageLookup());
|
||||||
|
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
|
||||||
|
return new Future.value(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _messagesExistFor(String locale) {
|
||||||
|
try {
|
||||||
|
return _findExact(locale) != null;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageLookupByLibrary _findGeneratedMessagesFor(String locale) {
|
||||||
|
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
|
||||||
|
onFailure: (_) => null);
|
||||||
|
if (actualLocale == null) return null;
|
||||||
|
return _findExact(actualLocale);
|
||||||
|
}
|
||||||
26
aidedejeu_flutter/lib/l10n/messages_en.dart
Normal file
26
aidedejeu_flutter/lib/l10n/messages_en.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||||
|
// This is a library that provides messages for a en locale. All the
|
||||||
|
// messages from the main program should be duplicated here with the same
|
||||||
|
// function name.
|
||||||
|
|
||||||
|
// Ignore issues from commonly used lints in this file.
|
||||||
|
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
|
||||||
|
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
|
||||||
|
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
|
||||||
|
// ignore_for_file:unused_import, file_names
|
||||||
|
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:intl/message_lookup_by_library.dart';
|
||||||
|
|
||||||
|
final messages = new MessageLookup();
|
||||||
|
|
||||||
|
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
|
||||||
|
|
||||||
|
class MessageLookup extends MessageLookupByLibrary {
|
||||||
|
String get localeName => 'en';
|
||||||
|
|
||||||
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
|
static _notInlinedMessages(_) => <String, Function> {
|
||||||
|
"title" : MessageLookupByLibrary.simpleMessage("Hello World")
|
||||||
|
};
|
||||||
|
}
|
||||||
26
aidedejeu_flutter/lib/l10n/messages_fr.dart
Normal file
26
aidedejeu_flutter/lib/l10n/messages_fr.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
|
||||||
|
// This is a library that provides messages for a fr locale. All the
|
||||||
|
// messages from the main program should be duplicated here with the same
|
||||||
|
// function name.
|
||||||
|
|
||||||
|
// Ignore issues from commonly used lints in this file.
|
||||||
|
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
|
||||||
|
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
|
||||||
|
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
|
||||||
|
// ignore_for_file:unused_import, file_names
|
||||||
|
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:intl/message_lookup_by_library.dart';
|
||||||
|
|
||||||
|
final messages = new MessageLookup();
|
||||||
|
|
||||||
|
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
|
||||||
|
|
||||||
|
class MessageLookup extends MessageLookupByLibrary {
|
||||||
|
String get localeName => 'fr';
|
||||||
|
|
||||||
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
|
static _notInlinedMessages(_) => <String, Function> {
|
||||||
|
"title" : MessageLookupByLibrary.simpleMessage("Bonjour Monde")
|
||||||
|
};
|
||||||
|
}
|
||||||
44
aidedejeu_flutter/lib/localization.dart
Normal file
44
aidedejeu_flutter/lib/localization.dart
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'l10n/messages_all.dart';
|
||||||
|
|
||||||
|
class AppLocalizations {
|
||||||
|
AppLocalizations(this.localeName);
|
||||||
|
|
||||||
|
static Future<AppLocalizations> load(Locale locale) {
|
||||||
|
final String name = locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
|
||||||
|
final String localeName = Intl.canonicalizedLocale(name);
|
||||||
|
|
||||||
|
return initializeMessages(localeName).then((_) {
|
||||||
|
return AppLocalizations(localeName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static AppLocalizations of(BuildContext context) {
|
||||||
|
return Localizations.of<AppLocalizations>(context, AppLocalizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String localeName;
|
||||||
|
|
||||||
|
String get title {
|
||||||
|
return Intl.message(
|
||||||
|
'Hello World',
|
||||||
|
name: 'title',
|
||||||
|
desc: 'Title for the Demo application',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||||
|
const AppLocalizationsDelegate();
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isSupported(Locale locale) => ['en', 'fr'].contains(locale.languageCode);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<AppLocalizations> load(Locale locale) => AppLocalizations.load(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldReload(AppLocalizationsDelegate old) => false;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
import 'package:aidedejeu_flutter/localization.dart';
|
||||||
import 'package:aidedejeu_flutter/theme.dart';
|
import 'package:aidedejeu_flutter/theme.dart';
|
||||||
import 'package:aidedejeu_flutter/widgets/homepage.dart';
|
import 'package:aidedejeu_flutter/widgets/homepage.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
void main() => runApp(MyApp());
|
||||||
|
|
||||||
|
|
@ -8,9 +10,20 @@ class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Haches & Dés',
|
//title: 'Haches & Dés',
|
||||||
|
onGenerateTitle: (BuildContext context) => AppLocalizations.of(context).title,
|
||||||
|
localizationsDelegates: [
|
||||||
|
const AppLocalizationsDelegate(),
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
supportedLocales: [
|
||||||
|
const Locale('en', ''),
|
||||||
|
const Locale('fr', ''),
|
||||||
|
],
|
||||||
theme: mainTheme(),
|
theme: mainTheme(),
|
||||||
home: HomePage(),
|
home: HomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
import 'package:aidedejeu_flutter/database.dart';
|
import 'package:aidedejeu_flutter/localization.dart';
|
||||||
import 'package:aidedejeu_flutter/models/filters.dart';
|
|
||||||
import 'package:aidedejeu_flutter/widgets/filters.dart';
|
|
||||||
import 'package:aidedejeu_flutter/models/items.dart';
|
|
||||||
import 'package:aidedejeu_flutter/widgets/library.dart';
|
import 'package:aidedejeu_flutter/widgets/library.dart';
|
||||||
import 'package:aidedejeu_flutter/widgets/pceditor.dart';
|
import 'package:aidedejeu_flutter/widgets/pceditor.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
|
|
@ -15,52 +10,67 @@ class HomePage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text("Haches & Dés"),),
|
appBar: AppBar(
|
||||||
|
title: Text(
|
||||||
|
AppLocalizations.of(context).title,
|
||||||
|
),
|
||||||
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FlatButton.icon(
|
FlatButton.icon(
|
||||||
label: Text("Bibliothèque"),
|
label: Text("Bibliothèque"),
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
"assets/spell-book.svg",
|
"assets/spell-book.svg",
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
width: 100.0,
|
width: 100.0,
|
||||||
allowDrawingOutsideViewBox: true,
|
allowDrawingOutsideViewBox: true,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.push(
|
onPressed: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => LibraryPage(id: 'index.md')),
|
builder: (context) => LibraryPage(
|
||||||
),
|
id: 'index.md',
|
||||||
),
|
),
|
||||||
FlatButton.icon(
|
),
|
||||||
label: Text("Personnages"),
|
),
|
||||||
icon: SvgPicture.asset(
|
),
|
||||||
"assets/swordman.svg",
|
FlatButton.icon(
|
||||||
height: 100.0,
|
label: Text(
|
||||||
width: 100.0,
|
"Personnages",
|
||||||
allowDrawingOutsideViewBox: true,
|
),
|
||||||
),
|
icon: SvgPicture.asset(
|
||||||
onPressed: () => Navigator.push(
|
"assets/swordman.svg",
|
||||||
context,
|
height: 100.0,
|
||||||
MaterialPageRoute(
|
width: 100.0,
|
||||||
builder: (context) => PCEditorPage()),
|
allowDrawingOutsideViewBox: true,
|
||||||
),
|
),
|
||||||
),
|
onPressed: () => Navigator.push(
|
||||||
FlatButton.icon(
|
context,
|
||||||
label: Text("A propos de..."),
|
MaterialPageRoute(
|
||||||
icon: SvgPicture.asset(
|
builder: (context) => PCEditorPage(),
|
||||||
"assets/wooden-sign.svg",
|
),
|
||||||
height: 100.0,
|
),
|
||||||
width: 100.0,
|
),
|
||||||
allowDrawingOutsideViewBox: true,
|
FlatButton.icon(
|
||||||
),
|
label: Text(
|
||||||
onPressed: () => Navigator.push(
|
"A propos de...",
|
||||||
context,
|
),
|
||||||
MaterialPageRoute(
|
icon: SvgPicture.asset(
|
||||||
builder: (context) => LibraryPage(id: 'index.md')),
|
"assets/wooden-sign.svg",
|
||||||
),
|
height: 100.0,
|
||||||
),
|
width: 100.0,
|
||||||
],
|
allowDrawingOutsideViewBox: true,
|
||||||
));
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => LibraryPage(
|
||||||
|
id: 'index.md',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,14 +157,14 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.16.1"
|
version: "0.16.1"
|
||||||
intl_translation:
|
intl_translation:
|
||||||
dependency: "direct dev"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl_translation
|
name: intl_translation
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ dependencies:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
intl:
|
||||||
|
intl_translation:
|
||||||
flutter_markdown: ^0.3.3
|
flutter_markdown: ^0.3.3
|
||||||
sqflite:
|
sqflite:
|
||||||
path:
|
path:
|
||||||
|
|
@ -34,7 +36,6 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
intl_translation:
|
|
||||||
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue