Skip to content

Commit 6ed28e0

Browse files
committed
Apliación de idiomas correctamente implementada para Español e Inglés
1 parent 6d5b578 commit 6ed28e0

File tree

10 files changed

+243
-85
lines changed

10 files changed

+243
-85
lines changed

lib/Chess.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_svg/flutter_svg.dart';
33
import 'package:eight_queens_game/Theme.dart';
4+
import 'generated/l10n.dart';
45

56
import 'Panel.dart';
67
import 'Dialogs.dart';
@@ -196,7 +197,7 @@ class ChessTableState extends State <ChessTable>
196197
padding: EdgeInsets.symmetric(vertical: 6.88),
197198
content: Text
198199
(
199-
"¡Felicidades! Ganaste el juego...",
200+
S.current.winMessage,
200201
textAlign: TextAlign.center,
201202
style: TextStyle(fontSize: 16)
202203
),

lib/Dialogs.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_svg/flutter_svg.dart';
3+
34
import 'package:eight_queens_game/Theme.dart';
5+
import 'generated/l10n.dart';
6+
47
import 'dart:js' as js;
58

69
AlertDialog buildHowDialog(BuildContext context)
@@ -21,20 +24,20 @@ AlertDialog buildHowDialog(BuildContext context)
2124
)
2225
),
2326
SizedBox(width: 20.0),
24-
Text("¿Cómo jugar?")
27+
Text(S.current.howToPlay_title)
2528
]
2629
),
2730

28-
content: Text("Coloca OCHO reinas en el siguiente tablero de ajedrez.\n\n• Las reinas no pueden atacarse mutuamente.\n• Las reinas atacan en cruz y en diagonal.\n• Haz clic sobre una casilla para colocar una reina."),
31+
content: Text(S.current.howToPlay_description),
2932
actions:
3033
[
3134
Padding
3235
(
3336
padding: EdgeInsets.all(12.0),
3437
child: ElevatedButton
3538
(
36-
onPressed: (){Navigator.of(context).pop();},
37-
child: Padding(padding: EdgeInsets.all(8.0), child: Text("Entendido")),
39+
onPressed: (){ Navigator.of(context).pop(); },
40+
child: Padding(padding: EdgeInsets.all(8.0), child: Text(S.current.howToPlay_button)),
3841
style: ButtonStyle
3942
(
4043
backgroundColor: MaterialStateProperty.all(AppColors.appTheme),
@@ -46,6 +49,7 @@ AlertDialog buildHowDialog(BuildContext context)
4649
]
4750
);
4851
}
52+
4953
AlertDialog buildInfoDialog(BuildContext context)
5054
{
5155
return AlertDialog
@@ -64,11 +68,11 @@ AlertDialog buildInfoDialog(BuildContext context)
6468
)
6569
),
6670
SizedBox(width: 20.0),
67-
Text("Acerca de...")
71+
Text(S.current.about_title)
6872
]
6973
),
7074

71-
content: Text("Desarrollado por Alejandro Ramos | @arhcoder.\n\n• Agradecimiento especial a Sriram Thiagarajan.\n• Iconos sacados de Flaticon.com.\n• Desarrollado con Flutter."),
75+
content: Text(S.current.about_description),
7276

7377
actions:
7478
[
@@ -77,8 +81,8 @@ AlertDialog buildInfoDialog(BuildContext context)
7781
padding: EdgeInsets.all(12.0),
7882
child: ElevatedButton
7983
(
80-
onPressed: (){Navigator.of(context).pop();},
81-
child: Padding(padding: EdgeInsets.all(8.0), child: Text("Entendido")),
84+
onPressed: (){ Navigator.of(context).pop(); },
85+
child: Padding(padding: EdgeInsets.all(8.0), child: Text(S.current.about_button)),
8286
style: ButtonStyle
8387
(
8488
backgroundColor: MaterialStateProperty.all(AppColors.appTheme),
@@ -90,6 +94,7 @@ AlertDialog buildInfoDialog(BuildContext context)
9094
]
9195
);
9296
}
97+
9398
AlertDialog buildGithubDialog(BuildContext context)
9499
{
95100
return AlertDialog
@@ -108,20 +113,20 @@ AlertDialog buildGithubDialog(BuildContext context)
108113
)
109114
),
110115
SizedBox(width: 20.0),
111-
Text("Código fuente")
116+
Text(S.current.github_title)
112117
]
113118
),
114119

115-
content: Text("¿Quieres revisar el código fuente en Dart/Flutter de este proyecto?\n"),
120+
content: Text(S.current.github_description),
116121
actions:
117122
[
118123
Padding
119124
(
120125
padding: const EdgeInsets.only(bottom: 12.0),
121126
child: TextButton
122127
(
123-
onPressed: (){Navigator.of(context).pop();},
124-
child: Text("No")
128+
onPressed: (){ Navigator.of(context).pop(); },
129+
child: Text(S.current.github_noButton)
125130
)
126131
),
127132
Padding
@@ -136,7 +141,7 @@ AlertDialog buildGithubDialog(BuildContext context)
136141
Navigator.of(context).pop();
137142
},
138143

139-
child: Padding(padding: EdgeInsets.all(8.0), child: Text("Ver código")),
144+
child: Padding(padding: EdgeInsets.all(8.0), child: Text(S.current.github_yesButton)),
140145
style: ButtonStyle
141146
(
142147
backgroundColor: MaterialStateProperty.all(AppColors.appTheme),

lib/Header.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import 'package:flutter/material.dart';
22
import 'package:eight_queens_game/Theme.dart';
33
import 'package:google_fonts/google_fonts.dart';
4+
45
import 'dart:js' as js;
56

6-
AppBar buildAppBar() => AppBar
7+
AppBar buildAppBar(String title) => AppBar
78
(
89

910
title: MouseRegion
@@ -21,8 +22,7 @@ AppBar buildAppBar() => AppBar
2122
String link = "https://github.com/arhcoder/eight-queens-game/";
2223
js.context.callMethod('open', [link]);
2324
},
24-
25-
child: Text("Juego de las Ocho Reinas", style: GoogleFonts.staatliches(fontSize: 26.0))
25+
child: Text(title, style: GoogleFonts.staatliches(fontSize: 26.0))
2626
)
2727
),
2828
centerTitle: true,

lib/Panel.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_svg/flutter_svg.dart';
33
import 'package:eight_queens_game/Theme.dart';
44

5+
import 'generated/l10n.dart';
6+
57
List buildPanel(
68
VoidCallback resetMethod,
79
VoidCallback solveMethod,
@@ -20,7 +22,7 @@ List buildPanel(
2022
child: FloatingActionButton
2123
(
2224
backgroundColor: AppColors.takenBox,
23-
tooltip: "Reiniciar",
25+
tooltip: S.current.button_reset,
2426
hoverElevation: 10,
2527
onPressed: resetMethod,
2628
child: Icon
@@ -41,7 +43,7 @@ List buildPanel(
4143
child: FloatingActionButton
4244
(
4345
backgroundColor: AppColors.takenBox,
44-
tooltip: "Solucionar",
46+
tooltip: S.current.button_solve,
4547
hoverElevation: 10,
4648
onPressed: solveMethod,
4749
child: Icon
@@ -62,7 +64,7 @@ List buildPanel(
6264
child: FloatingActionButton
6365
(
6466
backgroundColor: AppColors.appTheme,
65-
tooltip: "¿Cómo jugar?",
67+
tooltip: S.current.button_howToPlay,
6668
hoverElevation: 10,
6769
onPressed: howMethod,
6870
child: Center
@@ -87,7 +89,7 @@ List buildPanel(
8789
child: FloatingActionButton
8890
(
8991
backgroundColor: AppColors.appTheme,
90-
tooltip: "Acerca de...",
92+
tooltip: S.current.button_about,
9193
hoverElevation: 10,
9294
onPressed: infoMethod,
9395
child: Center
@@ -112,7 +114,7 @@ List buildPanel(
112114
child: FloatingActionButton
113115
(
114116
backgroundColor: AppColors.appTheme,
115-
tooltip: "Código fuente",
117+
tooltip: S.current.button_github,
116118
hoverElevation: 10,
117119
onPressed: githubMethod,
118120
child: Center

lib/generated/intl/messages_en.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ class MessageLookup extends MessageLookupByLibrary {
2121

2222
final messages = _notInlinedMessages(_notInlinedMessages);
2323
static _notInlinedMessages(_) => <String, Function> {
24-
"title" : MessageLookupByLibrary.simpleMessage("EIGHT QUEENS GAME"),
24+
"about_button" : MessageLookupByLibrary.simpleMessage("Got it!"),
25+
"about_description" : MessageLookupByLibrary.simpleMessage("Developed by Alejandro Ramos | @arhcoder.\n\n• Special thanks to Sriram Thiagarajan.\n• Icons taken from Flaticon.com.\n• Made with Flutter 💙"),
26+
"about_title" : MessageLookupByLibrary.simpleMessage("About..."),
27+
"app_title" : MessageLookupByLibrary.simpleMessage("EIGHT QUEENS GAME"),
28+
"button_about" : MessageLookupByLibrary.simpleMessage("About..."),
29+
"button_github" : MessageLookupByLibrary.simpleMessage("Source code"),
30+
"button_howToPlay" : MessageLookupByLibrary.simpleMessage("How to play"),
31+
"button_reset" : MessageLookupByLibrary.simpleMessage("Reset"),
32+
"button_solve" : MessageLookupByLibrary.simpleMessage("Solve"),
33+
"github_description" : MessageLookupByLibrary.simpleMessage("Want to check out the Dart/Flutter source code for this project?\n"),
34+
"github_noButton" : MessageLookupByLibrary.simpleMessage("No"),
35+
"github_title" : MessageLookupByLibrary.simpleMessage("Source code"),
36+
"github_yesButton" : MessageLookupByLibrary.simpleMessage("View code."),
37+
"howToPlay_button" : MessageLookupByLibrary.simpleMessage("Got it!"),
38+
"howToPlay_description" : MessageLookupByLibrary.simpleMessage("Put EIGHT queens in the chessboard.\n\n• Queens must not attack each other.\n• Queens attack cross and diagonal.\n• Click on a square to place a queen."),
39+
"howToPlay_title" : MessageLookupByLibrary.simpleMessage("How to play"),
2540
"winMessage" : MessageLookupByLibrary.simpleMessage("Congratulations! You won the game...")
2641
};
2742
}

lib/generated/intl/messages_es.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ class MessageLookup extends MessageLookupByLibrary {
2121

2222
final messages = _notInlinedMessages(_notInlinedMessages);
2323
static _notInlinedMessages(_) => <String, Function> {
24-
"title" : MessageLookupByLibrary.simpleMessage("JUEGO DE LAS OCHO REINAS"),
24+
"about_button" : MessageLookupByLibrary.simpleMessage("Entendido"),
25+
"about_description" : MessageLookupByLibrary.simpleMessage("Desarrollado por Alejandro Ramos | @arhcoder.\n\n• Agradecimiento especial a Sriram Thiagarajan.\n• Iconos sacados de Flaticon.com.\n• Desarrollado con Flutter 💙"),
26+
"about_title" : MessageLookupByLibrary.simpleMessage("Acerca de..."),
27+
"app_title" : MessageLookupByLibrary.simpleMessage("JUEGO DE LAS OCHO REINAS"),
28+
"button_about" : MessageLookupByLibrary.simpleMessage("Acerca de..."),
29+
"button_github" : MessageLookupByLibrary.simpleMessage("Código fuente"),
30+
"button_howToPlay" : MessageLookupByLibrary.simpleMessage("¿Cómo jugar?"),
31+
"button_reset" : MessageLookupByLibrary.simpleMessage("Reiniciar"),
32+
"button_solve" : MessageLookupByLibrary.simpleMessage("Solucionar"),
33+
"github_description" : MessageLookupByLibrary.simpleMessage("¿Quieres revisar el código fuente en Dart/Flutter de este proyecto?\n"),
34+
"github_noButton" : MessageLookupByLibrary.simpleMessage("No"),
35+
"github_title" : MessageLookupByLibrary.simpleMessage("Código fuente"),
36+
"github_yesButton" : MessageLookupByLibrary.simpleMessage("Ver código"),
37+
"howToPlay_button" : MessageLookupByLibrary.simpleMessage("Entendido"),
38+
"howToPlay_description" : MessageLookupByLibrary.simpleMessage("Coloca OCHO reinas en el siguiente tablero de ajedrez.\n\n• Las reinas no pueden atacarse mutuamente.\n• Las reinas atacan en cruz y en diagonal.\n• Haz clic sobre una casilla para colocar una reina."),
39+
"howToPlay_title" : MessageLookupByLibrary.simpleMessage("¿Cómo jugar?"),
2540
"winMessage" : MessageLookupByLibrary.simpleMessage("¡Felicidades! Ganaste el juego...")
2641
};
2742
}

0 commit comments

Comments
 (0)