Language Pushi Push
This Contains A lot of new Functions. None of them commented. Selected Language will be highlighted
This commit is contained in:
@@ -1,136 +0,0 @@
|
||||
{
|
||||
"de":
|
||||
{
|
||||
"pageAmbiente":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageAnmerkungen":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageEssen":
|
||||
{
|
||||
"question1": "Geschmack",
|
||||
"question2": "Qualität",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageHome":
|
||||
{
|
||||
|
||||
},
|
||||
"pageService":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageSpecial":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"navBar":
|
||||
{
|
||||
"symbol1": "Essen",
|
||||
"symbol2": "Ambiente",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Anmerkungen",
|
||||
"symbol5": "Spezielle Ernährung"
|
||||
},
|
||||
"floating":
|
||||
{
|
||||
"info": "* Pflichtfeld",
|
||||
"return": "Absenden"
|
||||
}
|
||||
},
|
||||
"en":
|
||||
{
|
||||
"pageAmbiente": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageAnmerkungen": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageEssen": {
|
||||
"question1": "Taste",
|
||||
"question2": "Quality",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageHome": {
|
||||
|
||||
},
|
||||
"pageService": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageSpecial": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"navBar": {
|
||||
"symbol1": "Food",
|
||||
"symbol2": "Ambience",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Remarks",
|
||||
"symbol5": "Special Diet"
|
||||
},
|
||||
"floating": {
|
||||
"info": "* Required field",
|
||||
"return": "Submit"
|
||||
}
|
||||
},
|
||||
"fr":
|
||||
{
|
||||
"pageAmbiente": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageAnmerkungen": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageEssen": {
|
||||
"question1": "Goût",
|
||||
"question2": "Qualité",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageHome": {
|
||||
|
||||
},
|
||||
"pageService": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageSpecial": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"navBar": {
|
||||
"symbol1": "Nourriture",
|
||||
"symbol2": "Ambiance",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Remarques",
|
||||
"symbol5": "Régime spécial"
|
||||
},
|
||||
"floating": {
|
||||
"info": "* Champ obligatoire",
|
||||
"return": "Envoyer"
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
-41
@@ -5,6 +5,7 @@ import 'package:google_nav_bar/google_nav_bar.dart';
|
||||
import 'package:mensaapp/providers/ambienteProvider.dart';
|
||||
import 'package:mensaapp/providers/anmerkungProvider.dart';
|
||||
import 'package:mensaapp/providers/essenProvider.dart';
|
||||
import 'package:mensaapp/providers/languageProvider.dart';
|
||||
import 'package:mensaapp/providers/pageProvider.dart';
|
||||
import 'package:mensaapp/providers/serviceProvider.dart';
|
||||
import 'package:mensaapp/providers/spezielleErnaehrungProvider.dart';
|
||||
@@ -19,25 +20,9 @@ void main() {
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
Future<void> loadLanguage() async
|
||||
{
|
||||
try
|
||||
{
|
||||
String language = await rootBundle.loadString("assets/language/language.json");
|
||||
Map<String, dynamic> languageData = json.decode(language);
|
||||
print(languageData);
|
||||
}catch(e)
|
||||
{
|
||||
print("Hello World");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
loadLanguage();
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(
|
||||
@@ -57,6 +42,9 @@ class MyApp extends StatelessWidget {
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => SpezielleErnaehrungProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => LanguageProvider(),
|
||||
)
|
||||
],
|
||||
child: MaterialApp(
|
||||
@@ -91,15 +79,15 @@ class MyHome extends StatelessWidget {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
title: const Text("Bewertungen löschen"),
|
||||
content: const Text("Möchtest du alle Eingaben entfernen?",
|
||||
title: Text(Provider.of<LanguageProvider>(context, listen: false).languageData[Provider.of<LanguageProvider>(context, listen: false).language]["floating"]["delete"]["title"]),
|
||||
content: Text(Provider.of<LanguageProvider>(context, listen: false).languageData[Provider.of<LanguageProvider>(context, listen: false).language]["floating"]["delete"]["info"],
|
||||
style: TextStyle(fontSize: 18),),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("Behalten"),
|
||||
child: Text(Provider.of<LanguageProvider>(context, listen: false).languageData[Provider.of<LanguageProvider>(context, listen: false).language]["floating"]["delete"]["keep"]),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary
|
||||
),
|
||||
@@ -115,7 +103,7 @@ class MyHome extends StatelessWidget {
|
||||
// Hier Aktion für Löschen ausführen
|
||||
Navigator.of(context).pop(); // Dialog schließen
|
||||
},
|
||||
child: Text("Löschen"),
|
||||
child: Text(Provider.of<LanguageProvider>(context, listen: false).languageData[Provider.of<LanguageProvider>(context, listen: false).language]["floating"]["delete"]["del"]),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -161,36 +149,54 @@ class MyHome extends StatelessWidget {
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'assets/flags/de.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
), // Erster Button rechts
|
||||
icon: Opacity(
|
||||
opacity: Provider.of<LanguageProvider>(context).language == "de"
|
||||
? 1.0 // Voll sichtbar
|
||||
: 0.4, // Halb durchsichtig
|
||||
child: Image.asset(
|
||||
'assets/flags/de.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// Aktion für diesen Button
|
||||
Provider.of<LanguageProvider>(context, listen: false)
|
||||
.setLanguage("de");
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'assets/flags/fr.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
), // Zweiter Button rechts
|
||||
icon: Opacity(
|
||||
opacity: Provider.of<LanguageProvider>(context).language == "en"
|
||||
? 1.0 // Voll sichtbar
|
||||
: 0.4, // Halb durchsichtig
|
||||
child: Image.asset(
|
||||
'assets/flags/en.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// Aktion für diesen Button
|
||||
Provider.of<LanguageProvider>(context, listen: false)
|
||||
.setLanguage("en");
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Image.asset(
|
||||
'assets/flags/en.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
), // Dritter Button rechts
|
||||
icon: Opacity(
|
||||
opacity: Provider.of<LanguageProvider>(context).language == "fr"
|
||||
? 1.0 // Voll sichtbar
|
||||
: 0.4, // Halb durchsichtig
|
||||
child: Image.asset(
|
||||
'assets/flags/fr.png',
|
||||
width: 34,
|
||||
height: 24,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// Aktion für diesen Button
|
||||
Provider.of<LanguageProvider>(context, listen: false)
|
||||
.setLanguage("fr");
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class LanguageProvider extends ChangeNotifier {
|
||||
Map<String, dynamic> languageData = {
|
||||
"de":
|
||||
{
|
||||
"pageAmbiente":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageAnmerkungen":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageEssen":
|
||||
{
|
||||
"question1": "Geschmack",
|
||||
"question2": "Qualität",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageHome":
|
||||
{
|
||||
|
||||
},
|
||||
"pageService":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"pageSpecial":
|
||||
{
|
||||
"question1": "Frage1",
|
||||
"question2": "Frage2",
|
||||
"textfield": "Dein Feedback"
|
||||
},
|
||||
"navBar":
|
||||
{
|
||||
"symbol1": "Essen",
|
||||
"symbol2": "Ambiente",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Anmerkungen",
|
||||
"symbol5": "Spezielle Ernährung"
|
||||
},
|
||||
"floating":
|
||||
{
|
||||
"info": "* Pflichtfeld",
|
||||
"return": "Absenden",
|
||||
"delete":
|
||||
{
|
||||
"title": "Bewertungen löschen",
|
||||
"info": "Möchtest du alle Eingaben entfernen?",
|
||||
"keep": "Behalten",
|
||||
"del": "Löschen"
|
||||
}
|
||||
}
|
||||
},
|
||||
"en":
|
||||
{
|
||||
"pageAmbiente": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageAnmerkungen": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageEssen": {
|
||||
"question1": "Taste",
|
||||
"question2": "Quality",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageHome": {
|
||||
|
||||
},
|
||||
"pageService": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"pageSpecial": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Your Feedback"
|
||||
},
|
||||
"navBar": {
|
||||
"symbol1": "Food",
|
||||
"symbol2": "Ambience",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Remarks",
|
||||
"symbol5": "Special Diet"
|
||||
},
|
||||
"floating": {
|
||||
"info": "* Required field",
|
||||
"return": "Submit",
|
||||
"delete":
|
||||
{
|
||||
"title": "Delete Reviews",
|
||||
"info": "Do you want to remove all entries?",
|
||||
"keep": "Keep",
|
||||
"del": "Delete"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fr":
|
||||
{
|
||||
"pageAmbiente": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageAnmerkungen": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageEssen": {
|
||||
"question1": "Goût",
|
||||
"question2": "Qualité",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageHome": {
|
||||
|
||||
},
|
||||
"pageService": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"pageSpecial": {
|
||||
"question1": "Question1",
|
||||
"question2": "Question2",
|
||||
"textfield": "Votre avis"
|
||||
},
|
||||
"navBar": {
|
||||
"symbol1": "Nourriture",
|
||||
"symbol2": "Ambiance",
|
||||
"symbol3": "Service",
|
||||
"symbol4": "Remarques",
|
||||
"symbol5": "Régime spécial"
|
||||
},
|
||||
"floating": {
|
||||
"info": "* Champ obligatoire",
|
||||
"return": "Envoyer",
|
||||
"delete": {
|
||||
"title": "Supprimer les avis",
|
||||
"info": "Voulez-vous supprimer toutes les entrées ?",
|
||||
"keep": "Garder",
|
||||
"del": "Supprimer"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
String language = "de";
|
||||
|
||||
void setLanguage(String newLanguage) {
|
||||
language = newLanguage;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,6 @@ flutter:
|
||||
assets:
|
||||
- assets/flags/
|
||||
- assets/backgrounds/
|
||||
- assets/language/
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
|
||||
Reference in New Issue
Block a user