mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 06:56:10 +00:00
Localization
This commit is contained in:
parent
6f3a87ac5e
commit
622b6a3196
9 changed files with 218 additions and 60 deletions
|
|
@ -1,8 +1,39 @@
|
||||||
{
|
{
|
||||||
"@@locale": "en",
|
"@@locale": "en",
|
||||||
"title": "Hello World",
|
"app_title": "Hello World",
|
||||||
"@title": {
|
"@app_title": {
|
||||||
"description": "Title for the Demo application",
|
"description": "Title for the application",
|
||||||
"type": "text"
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"library_title": "Library",
|
||||||
|
"@library_title": {
|
||||||
|
"description": "Title for the Library page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"pceditor_title": "Player Characters",
|
||||||
|
"@pceditor_title": {
|
||||||
|
"description": "Title for the Player Characters page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"about_title": "About...",
|
||||||
|
"@about_title": {
|
||||||
|
"description": "Title for the About page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"bookmarks_title": "Bookmarks",
|
||||||
|
"@bookmarks_title": {
|
||||||
|
"description": "Title for the Bookmarks page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"search_title": "Search",
|
||||||
|
"@search_title": {
|
||||||
|
"description": "Title for the Search page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,39 @@
|
||||||
{
|
{
|
||||||
"@@locale": "fr",
|
"@@locale": "fr",
|
||||||
"title": "Bonjour Monde",
|
"app_title": "Bonjour Monde",
|
||||||
"@title": {
|
"@app_title": {
|
||||||
"description": "Title for the Demo application",
|
"description": "Title for the application",
|
||||||
"type": "text"
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"library_title": "Bibliothèque",
|
||||||
|
"@library_title": {
|
||||||
|
"description": "Title for the Library page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"pceditor_title": "Personnages",
|
||||||
|
"@pceditor_title": {
|
||||||
|
"description": "Title for the Player Characters page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"about_title": "A propos de...",
|
||||||
|
"@about_title": {
|
||||||
|
"description": "Title for the About page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"bookmarks_title": "Favoris",
|
||||||
|
"@bookmarks_title": {
|
||||||
|
"description": "Title for the Bookmarks page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"search_title": "Recherche",
|
||||||
|
"@search_title": {
|
||||||
|
"description": "Title for the Search page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,38 @@
|
||||||
{
|
{
|
||||||
"@@last_modified": "2020-03-02T17:18:13.928618",
|
"@@last_modified": "2020-03-02T17:41:08.588343",
|
||||||
"title": "Hello World",
|
"app_title": "Hello World",
|
||||||
"@title": {
|
"@app_title": {
|
||||||
"description": "Title for the Demo application",
|
"description": "Title for the application",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"library_title": "Library",
|
||||||
|
"@library_title": {
|
||||||
|
"description": "Title for the Library page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"pceditor_title": "Player Characters",
|
||||||
|
"@pceditor_title": {
|
||||||
|
"description": "Title for the Player Characters page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"about_title": "About...",
|
||||||
|
"@about_title": {
|
||||||
|
"description": "Title for the About page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"bookmarks_title": "Bookmarks",
|
||||||
|
"@bookmarks_title": {
|
||||||
|
"description": "Title for the Bookmarks page",
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"search_title": "Search",
|
||||||
|
"@search_title": {
|
||||||
|
"description": "Title for the Search page",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
|
|
||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => <String, Function> {
|
static _notInlinedMessages(_) => <String, Function> {
|
||||||
"title" : MessageLookupByLibrary.simpleMessage("Hello World")
|
"about_title" : MessageLookupByLibrary.simpleMessage("About..."),
|
||||||
|
"app_title" : MessageLookupByLibrary.simpleMessage("Hello World"),
|
||||||
|
"bookmarks_title" : MessageLookupByLibrary.simpleMessage("Bookmarks"),
|
||||||
|
"library_title" : MessageLookupByLibrary.simpleMessage("Library"),
|
||||||
|
"pceditor_title" : MessageLookupByLibrary.simpleMessage("Player Characters"),
|
||||||
|
"search_title" : MessageLookupByLibrary.simpleMessage("Search")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||||
|
|
||||||
final messages = _notInlinedMessages(_notInlinedMessages);
|
final messages = _notInlinedMessages(_notInlinedMessages);
|
||||||
static _notInlinedMessages(_) => <String, Function> {
|
static _notInlinedMessages(_) => <String, Function> {
|
||||||
"title" : MessageLookupByLibrary.simpleMessage("Bonjour Monde")
|
"about_title" : MessageLookupByLibrary.simpleMessage("A propos de..."),
|
||||||
|
"app_title" : MessageLookupByLibrary.simpleMessage("Bonjour Monde"),
|
||||||
|
"bookmarks_title" : MessageLookupByLibrary.simpleMessage("Favoris"),
|
||||||
|
"library_title" : MessageLookupByLibrary.simpleMessage("Bibliothèque"),
|
||||||
|
"pceditor_title" : MessageLookupByLibrary.simpleMessage("Personnages"),
|
||||||
|
"search_title" : MessageLookupByLibrary.simpleMessage("Recherche")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ class AppLocalizations {
|
||||||
AppLocalizations(this.localeName);
|
AppLocalizations(this.localeName);
|
||||||
|
|
||||||
static Future<AppLocalizations> load(Locale locale) {
|
static Future<AppLocalizations> load(Locale locale) {
|
||||||
final String name = locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
|
final String name =
|
||||||
|
locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
|
||||||
final String localeName = Intl.canonicalizedLocale(name);
|
final String localeName = Intl.canonicalizedLocale(name);
|
||||||
|
|
||||||
return initializeMessages(localeName).then((_) {
|
return initializeMessages(localeName).then((_) {
|
||||||
|
|
@ -20,11 +21,56 @@ class AppLocalizations {
|
||||||
|
|
||||||
final String localeName;
|
final String localeName;
|
||||||
|
|
||||||
String get title {
|
String get app_title {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'Hello World',
|
'Hello World',
|
||||||
name: 'title',
|
name: 'app_title',
|
||||||
desc: 'Title for the Demo application',
|
desc: 'Title for the application',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get library_title {
|
||||||
|
return Intl.message(
|
||||||
|
'Library',
|
||||||
|
name: 'library_title',
|
||||||
|
desc: 'Title for the Library page',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get pceditor_title {
|
||||||
|
return Intl.message(
|
||||||
|
'Player Characters',
|
||||||
|
name: 'pceditor_title',
|
||||||
|
desc: 'Title for the Player Characters page',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get about_title {
|
||||||
|
return Intl.message(
|
||||||
|
'About...',
|
||||||
|
name: 'about_title',
|
||||||
|
desc: 'Title for the About page',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get bookmarks_title {
|
||||||
|
return Intl.message(
|
||||||
|
'Bookmarks',
|
||||||
|
name: 'bookmarks_title',
|
||||||
|
desc: 'Title for the Bookmarks page',
|
||||||
|
locale: localeName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String get search_title {
|
||||||
|
return Intl.message(
|
||||||
|
'Search',
|
||||||
|
name: 'search_title',
|
||||||
|
desc: 'Title for the Search page',
|
||||||
locale: localeName,
|
locale: localeName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ class MyApp extends StatelessWidget {
|
||||||
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,
|
onGenerateTitle: (BuildContext context) =>
|
||||||
|
AppLocalizations.of(context).app_title,
|
||||||
localizationsDelegates: [
|
localizationsDelegates: [
|
||||||
const AppLocalizationsDelegate(),
|
const AppLocalizationsDelegate(),
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
|
@ -26,4 +27,3 @@ class MyApp extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,15 @@ class HomePage extends StatelessWidget {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).title,
|
AppLocalizations.of(context).app_title,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FlatButton.icon(
|
FlatButton.icon(
|
||||||
label: Text("Bibliothèque"),
|
label: Text(
|
||||||
|
AppLocalizations.of(context).library_title,
|
||||||
|
),
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
"assets/spell-book.svg",
|
"assets/spell-book.svg",
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
|
|
@ -36,7 +38,7 @@ class HomePage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
FlatButton.icon(
|
FlatButton.icon(
|
||||||
label: Text(
|
label: Text(
|
||||||
"Personnages",
|
AppLocalizations.of(context).pceditor_title,
|
||||||
),
|
),
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
"assets/swordman.svg",
|
"assets/swordman.svg",
|
||||||
|
|
@ -53,7 +55,7 @@ class HomePage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
FlatButton.icon(
|
FlatButton.icon(
|
||||||
label: Text(
|
label: Text(
|
||||||
"A propos de...",
|
AppLocalizations.of(context).about_title,
|
||||||
),
|
),
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
"assets/wooden-sign.svg",
|
"assets/wooden-sign.svg",
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import 'package:aidedejeu_flutter/database.dart';
|
import 'package:aidedejeu_flutter/database.dart';
|
||||||
|
import 'package:aidedejeu_flutter/localization.dart';
|
||||||
import 'package:aidedejeu_flutter/models/filters.dart';
|
import 'package:aidedejeu_flutter/models/filters.dart';
|
||||||
import 'package:aidedejeu_flutter/widgets/filters.dart';
|
import 'package:aidedejeu_flutter/widgets/filters.dart';
|
||||||
import 'package:aidedejeu_flutter/models/items.dart';
|
import 'package:aidedejeu_flutter/models/items.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_markdown/flutter_markdown.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
|
@ -43,7 +43,6 @@ class _LibraryPageState extends State<LibraryPage> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
|
||||||
_loadItem().then((item) => setItem(item));
|
_loadItem().then((item) => setItem(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,9 +138,18 @@ class _LibraryPageState extends State<LibraryPage> {
|
||||||
|
|
||||||
List _buildBottomNavigationBarItems() {
|
List _buildBottomNavigationBarItems() {
|
||||||
return <BottomNavigationBarItem>[
|
return <BottomNavigationBarItem>[
|
||||||
_buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
|
_buildBottomNavigationBarItem(
|
||||||
_buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
|
AppLocalizations.of(context).library_title,
|
||||||
_buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
|
"assets/spell-book.svg",
|
||||||
|
),
|
||||||
|
_buildBottomNavigationBarItem(
|
||||||
|
AppLocalizations.of(context).bookmarks_title,
|
||||||
|
"assets/stars-stack.svg",
|
||||||
|
),
|
||||||
|
_buildBottomNavigationBarItem(
|
||||||
|
AppLocalizations.of(context).search_title,
|
||||||
|
"assets/crystal-ball.svg",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue