1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 06:26:02 +00:00

Localization

This commit is contained in:
Yan Maniez 2020-03-02 17:46:30 +01:00
parent 6f3a87ac5e
commit 622b6a3196
9 changed files with 218 additions and 60 deletions

View file

@ -1,8 +1,39 @@
{
"@@locale": "en",
"title": "Hello World",
"@title": {
"description": "Title for the Demo application",
"type": "text"
"app_title": "Hello World",
"@app_title": {
"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",
"placeholders": {}
}
}

View file

@ -1,8 +1,39 @@
{
"@@locale": "fr",
"title": "Bonjour Monde",
"@title": {
"description": "Title for the Demo application",
"type": "text"
"app_title": "Bonjour Monde",
"@app_title": {
"description": "Title for the application",
"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": {}
}
}

View file

@ -1,8 +1,38 @@
{
"@@last_modified": "2020-03-02T17:18:13.928618",
"title": "Hello World",
"@title": {
"description": "Title for the Demo application",
"@@last_modified": "2020-03-02T17:41:08.588343",
"app_title": "Hello World",
"@app_title": {
"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",
"placeholders": {}
}

View file

@ -21,6 +21,11 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
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")
};
}

View file

@ -21,6 +21,11 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
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")
};
}

View file

@ -6,7 +6,8 @@ class AppLocalizations {
AppLocalizations(this.localeName);
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);
return initializeMessages(localeName).then((_) {
@ -20,11 +21,56 @@ class AppLocalizations {
final String localeName;
String get title {
String get app_title {
return Intl.message(
'Hello World',
name: 'title',
desc: 'Title for the Demo application',
name: 'app_title',
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,
);
}

View file

@ -11,7 +11,8 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
//title: 'Haches & Dés',
onGenerateTitle: (BuildContext context) => AppLocalizations.of(context).title,
onGenerateTitle: (BuildContext context) =>
AppLocalizations.of(context).app_title,
localizationsDelegates: [
const AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
@ -26,4 +27,3 @@ class MyApp extends StatelessWidget {
);
}
}

View file

@ -12,13 +12,15 @@ class HomePage extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(
AppLocalizations.of(context).title,
AppLocalizations.of(context).app_title,
),
),
body: Column(
children: <Widget>[
FlatButton.icon(
label: Text("Bibliothèque"),
label: Text(
AppLocalizations.of(context).library_title,
),
icon: SvgPicture.asset(
"assets/spell-book.svg",
height: 100.0,
@ -36,7 +38,7 @@ class HomePage extends StatelessWidget {
),
FlatButton.icon(
label: Text(
"Personnages",
AppLocalizations.of(context).pceditor_title,
),
icon: SvgPicture.asset(
"assets/swordman.svg",
@ -53,7 +55,7 @@ class HomePage extends StatelessWidget {
),
FlatButton.icon(
label: Text(
"A propos de...",
AppLocalizations.of(context).about_title,
),
icon: SvgPicture.asset(
"assets/wooden-sign.svg",

View file

@ -1,9 +1,9 @@
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:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_svg/flutter_svg.dart';
@ -29,8 +29,8 @@ class _LibraryPageState extends State<LibraryPage> {
}
this.markdown =
item.markdown.replaceAllMapped(RegExp(r'<!--.*?-->'), (match) {
return '';
});
return '';
});
});
}
@ -43,7 +43,6 @@ class _LibraryPageState extends State<LibraryPage> {
void initState() {
super.initState();
_loadItem().then((item) => setItem(item));
}
@ -139,9 +138,18 @@ class _LibraryPageState extends State<LibraryPage> {
List _buildBottomNavigationBarItems() {
return <BottomNavigationBarItem>[
_buildBottomNavigationBarItem("Bibliothèque", "assets/spell-book.svg"),
_buildBottomNavigationBarItem("Favoris", "assets/stars-stack.svg"),
_buildBottomNavigationBarItem("Recherche", "assets/crystal-ball.svg"),
_buildBottomNavigationBarItem(
AppLocalizations.of(context).library_title,
"assets/spell-book.svg",
),
_buildBottomNavigationBarItem(
AppLocalizations.of(context).bookmarks_title,
"assets/stars-stack.svg",
),
_buildBottomNavigationBarItem(
AppLocalizations.of(context).search_title,
"assets/crystal-ball.svg",
),
];
}
@ -154,11 +162,11 @@ class _LibraryPageState extends State<LibraryPage> {
filter.selectedValues = choices;
});
loadChildrenItems(item, filters).then((value) => {
setState(() {
this.item = item;
this.filters = filters;
})
});
setState(() {
this.item = item;
this.filters = filters;
})
});
},
);
}
@ -172,11 +180,11 @@ class _LibraryPageState extends State<LibraryPage> {
filter.rangeValues = values;
});
loadChildrenItems(item, filters).then((value) => {
setState(() {
this.item = item;
this.filters = filters;
})
});
setState(() {
this.item = item;
this.filters = filters;
})
});
});
}
@ -238,30 +246,30 @@ class _LibraryPageState extends State<LibraryPage> {
),
endDrawer: filters != null
? Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: _buildFilterList()),
)
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: _buildFilterList()),
)
: null,
appBar: AppBar(
title: Text(widget.id),
actions: filters != null
? [
Builder(
builder: (context) => IconButton(
icon: SvgPicture.asset(
"assets/funnel.svg",
height: 30.0,
width: 30.0,
allowDrawingOutsideViewBox: true,
), //Icon(Icons.filter),
onPressed: () => Scaffold.of(context).openEndDrawer(),
tooltip:
MaterialLocalizations.of(context).openAppDrawerTooltip,
),
),
]
Builder(
builder: (context) => IconButton(
icon: SvgPicture.asset(
"assets/funnel.svg",
height: 30.0,
width: 30.0,
allowDrawingOutsideViewBox: true,
), //Icon(Icons.filter),
onPressed: () => Scaffold.of(context).openEndDrawer(),
tooltip:
MaterialLocalizations.of(context).openAppDrawerTooltip,
),
),
]
: null,
),
);