diff --git a/tarok/lib/about.dart b/tarok/lib/about.dart index a23d488..3ee2c9c 100644 --- a/tarok/lib/about.dart +++ b/tarok/lib/about.dart @@ -14,22 +14,18 @@ // along with this program. If not, see . import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:tarok/constants.dart'; -class About extends StatefulWidget { +class About extends StatelessWidget { const About({super.key}); - @override - State createState() => _AboutState(); -} - -class _AboutState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Palčka"), + title: Text("palcka".tr), actions: [ IconButton( icon: const Icon(Icons.cancel), @@ -39,14 +35,14 @@ class _AboutState extends State { ), ], ), - body: const Center( + body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("Tarok Palčka", style: TextStyle(fontSize: 40)), - Text("Copyright 2023 Mitja Ševerkar"), - Text("Licencirano pod AGPLv3 licenco."), - Text("Verzija $RELEASE"), + Text("tarock_palcka".tr, style: const TextStyle(fontSize: 40)), + Text("copyright".tr), + Text("licensed_under".tr), + Text("version".trParams({"version": RELEASE})), ], ), ), diff --git a/tarok/lib/admin/users.dart b/tarok/lib/admin/users.dart index e2eef05..e1350dc 100644 --- a/tarok/lib/admin/users.dart +++ b/tarok/lib/admin/users.dart @@ -38,7 +38,7 @@ class Users extends StatelessWidget { onPressed: () async { await controller.getUsers(); }, - child: const Text("Osveži podatke"), + child: Text("refresh_data".tr), ), ), const SizedBox( @@ -49,68 +49,68 @@ class Users extends StatelessWidget { child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( - columns: const [ + columns: [ DataColumn( label: Expanded( child: Text( - 'Uporabniški ID', - style: TextStyle(fontStyle: FontStyle.italic), + "user_id".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Ime', - style: TextStyle(fontStyle: FontStyle.italic), + "name".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Elektronski naslov', - style: TextStyle(fontStyle: FontStyle.italic), + "email".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Odigranih iger', - style: TextStyle(fontStyle: FontStyle.italic), + "played_games".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Rola', - style: TextStyle(fontStyle: FontStyle.italic), + "role".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Onemogočen račun', - style: TextStyle(fontStyle: FontStyle.italic), + "account_disabled".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Preverjen elektronski naslov', - style: TextStyle(fontStyle: FontStyle.italic), + "verified_email".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), DataColumn( label: Expanded( child: Text( - 'Registriran dne', - style: TextStyle(fontStyle: FontStyle.italic), + "registered_on".tr, + style: const TextStyle(fontStyle: FontStyle.italic), ), ), ), @@ -132,13 +132,13 @@ class Users extends StatelessWidget { controller.controller.value.text = m.name; Get.dialog( AlertDialog( - title: const Text( - "Sprememba uporabnikovega imena"), + title: Text("change_user_name".tr), content: IntrinsicHeight( child: Column( children: [ - Text( - "Uporabnikovo trenutno ime je ${m.name}."), + Text("user_current_name" + .trParams( + {"name": m.name})), TextField( controller: controller .controller.value, @@ -151,7 +151,7 @@ class Users extends StatelessWidget { onPressed: () async { Get.back(); }, - child: const Text("Prekliči"), + child: Text("cancel".tr), ), TextButton( onPressed: () async { @@ -159,12 +159,12 @@ class Users extends StatelessWidget { .changeName(m.userId); Get.back(); }, - child: const Text("Spremeni"), + child: Text("change".tr), ), ]), ); }, - child: const Text("Spremeni ime"), + child: Text("change_user_name".tr), ), ], ), @@ -184,10 +184,8 @@ class Users extends StatelessWidget { .promoteDemoteUser(m.userId); }, child: m.role == "admin" - ? const Text( - "Pretvori administratorja v uporabnika") - : const Text( - "Pretvori uporabnika v administratorja"), + ? Text("admin_to_user".tr) + : Text("user_to_admin".tr), ), ], ), diff --git a/tarok/lib/constants.dart b/tarok/lib/constants.dart index 7746d61..2ce18bb 100644 --- a/tarok/lib/constants.dart +++ b/tarok/lib/constants.dart @@ -22,6 +22,7 @@ import 'package:get/get.dart'; import 'package:logger/logger.dart'; import 'package:media_kit/media_kit.dart'; import 'package:stockskis/stockskis.dart'; +import 'package:tarok/lobby/lobby_controller.dart'; part 'constants.g.dart'; @@ -31,7 +32,7 @@ const WS_URL = kReleaseMode ? "wss://palcka.si/api/ws" : "ws://localhost:8080/ws"; const LOBBY_WS_URL = kReleaseMode ? "wss://palcka.si/api/lobby" : "ws://localhost:8080/lobby"; -const RELEASE = "DEBUG"; +const RELEASE = "0.0.5 Beta"; bool OMOGOCI_STOCKSKIS_PREDLOGE = true; bool SLEPI_TAROK = false; bool AVTOPOTRDI_ZALOZITEV = false; @@ -40,6 +41,7 @@ bool PREMOVE = false; bool DEVELOPER_MODE = false; bool SKISFANG = false; String THEME = ""; +Locale LOCALE = Get.deviceLocale ?? const Locale("sl", "SI"); const double ANGLE = 25; const int ANIMATION_TIME = 75; @@ -85,12 +87,12 @@ final List KINGS = [ LocalCard(asset: "/src/kralj", worth: 5, worthOver: 8, alt: "Src kralj"), ]; -const List KONTRE = [ - "Ni kontre", - "Kontra", - "Rekontra", - "Subkontra", - "Mortkontra", +List KONTRE = [ + "no_kontra".tr, + "kontra".tr, + "rekontra".tr, + "subkontra".tr, + "mortkontra".tr, ]; const List BOT_NAMES = [ @@ -116,11 +118,11 @@ const List BOT_NAMES = [ "Žiga", ]; -const BOTS = [ +List BOTS = [ { "type": "normalni", "preferred_names": BOT_NAMES, - "name": "Normalni boti", + "name": "normal_bots".tr, }, { "type": "vrazji", @@ -135,7 +137,7 @@ const BOTS = [ "Žiga", "Mark", ], - "name": "Vražji boti", + "name": "advanced_bots".tr, }, { "type": "berac", @@ -145,7 +147,7 @@ const BOTS = [ "Marko", "Lojze", ], - "name": "Berač boti", + "name": "beggar_bots".tr, }, { "type": "klop", @@ -155,7 +157,7 @@ const BOTS = [ "Marija", "Marko", ], - "name": "Klop boti", + "name": "klop_bots".tr, }, ]; @@ -168,15 +170,30 @@ int hashCode(String str) { } Future logout() async { - await dio.post( - '$BACKEND_URL/logout', - options: Options( - headers: {"X-Login-Token": await storage.read(key: "token")}, - validateStatus: (s) { - return true; - }, - ), - ); + String? token = await storage.read(key: "token"); + if (!(token == "a" || token == "" || token == null)) { + try { + await dio.post( + '$BACKEND_URL/logout', + options: Options( + headers: {"X-Login-Token": token}, + validateStatus: (s) { + return true; + }, + ), + ); + } catch (e) {} + } await storage.deleteAll(); - Get.toNamed("/login"); + await Get.toNamed("/login"); + await Get.delete(); +} + +void parseLocale(String? locale) { + if (locale == null) return; + List locales = locale.split("_"); + LOCALE = Locale( + locales[0].toString().toLowerCase(), + locales[1].toString().toUpperCase(), + ); } diff --git a/tarok/lib/game/game.dart b/tarok/lib/game/game.dart index 4ec18da..9dcc876 100644 --- a/tarok/lib/game/game.dart +++ b/tarok/lib/game/game.dart @@ -13,6 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +import 'dart:convert'; import 'dart:math'; import 'package:draggable_widget/draggable_widget.dart'; @@ -431,26 +432,35 @@ class Game extends StatelessWidget { ]), if (DEVELOPER_MODE) ListView(children: [ - const Center( + Center( child: Text( - "Odpravljanje hroščev", - style: TextStyle( + "debugging".tr, + style: const TextStyle( fontSize: 20, ), ), ), - Text( - "Prva karta: ${controller.firstCard.value == null ? '' : controller.firstCard.value!.asset}", - ), - Text("Štih: ${controller.cardStih}"), - Text( - "Izbran kralj: ${controller.selectedKing.value}"), - Text( - "Uporabnik s kraljem: ${controller.userHasKing.value}"), - Text( - "Karte založene: ${controller.stashAmount.value}"), - Text( - "Talon izbran: ${controller.talonSelected.value}"), + Text("first_card".trParams({ + "card": controller.firstCard.value == null + ? '' + : controller.firstCard.value!.asset + })), + Text("trick".trParams({ + "trick": jsonEncode(controller.cardStih), + })), + Text("selected_king".trParams( + {"king": controller.selectedKing.value})), + Text("player_with_king".trParams({ + "player": controller.userHasKing.value + })), + Text("stashed_cards".trParams({ + "cards": + jsonEncode(controller.stashAmount.value) + })), + Text("talon_picked".trParams({ + "talon": controller.talonSelected.value + .toString() + })), ElevatedButton( style: ElevatedButton.styleFrom( textStyle: const TextStyle( @@ -460,9 +470,7 @@ class Game extends StatelessWidget { onPressed: () { controller.validCards(); }, - child: const Text( - "Ponovno evaluiraj karte", - ), + child: Text("reevaluate_cards".tr), ), ]), if (!controller.bots) @@ -472,8 +480,7 @@ class Game extends StatelessWidget { onPressed: () { Get.dialog( AlertDialog( - title: - const Text("Povabi prijatelja"), + title: Text("invite_friend".tr), content: SizedBox( width: double.maxFinite, child: Friends( @@ -483,7 +490,7 @@ class Game extends StatelessWidget { ), ); }, - child: const Text("Povabi prijatelje"), + child: Text("invite_friends".tr), ), ), const SizedBox(height: 10), @@ -492,7 +499,7 @@ class Game extends StatelessWidget { onPressed: () async { await controller.manuallyStartGame(); }, - child: const Text("Začni igro"), + child: Text("start_game".tr), ), ), ]), @@ -889,8 +896,10 @@ class Game extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ if (controller.zalozeniTaroki.isNotEmpty) - const Text("Založeni taroki:", - style: TextStyle(fontSize: 18)), + Text( + "stashed_tarocks".tr, + style: const TextStyle(fontSize: 18), + ), if (controller.zalozeniTaroki.isNotEmpty) const SizedBox(height: 10), Row( @@ -936,9 +945,10 @@ class Game extends StatelessWidget { columns: [ DataColumn( label: Expanded( - child: Text( - 'Igra (${stockskis.GAMES[controller.currentPredictions.value!.gamemode + 1].name == "Naprej" ? "Klop" : stockskis.GAMES[controller.currentPredictions.value!.gamemode + 1].name})', - ), + child: Text("game".trParams({ + "type": + "(${stockskis.GAMES[controller.currentPredictions.value!.gamemode + 1].name == "Naprej" ? "Klop" : stockskis.GAMES[controller.currentPredictions.value!.gamemode + 1].name})" + })), ), ), DataColumn( @@ -1005,7 +1015,7 @@ class Game extends StatelessWidget { -1)) DataRow( cells: [ - const DataCell(Text('Trula')), + DataCell(Text("trula".tr)), if (controller.myPredictions.value != null && controller @@ -1059,7 +1069,7 @@ class Game extends StatelessWidget { -1)) DataRow( cells: [ - const DataCell(Text('Kralji')), + DataCell(Text("Kralji".tr)), if (controller.myPredictions.value != null && controller @@ -1113,7 +1123,7 @@ class Game extends StatelessWidget { -1)) DataRow( cells: [ - const DataCell(Text('Pagat ultimo')), + DataCell(Text("pagat_ultimo".tr)), if (controller.myPredictions.value != null && controller.myPredictions.value! @@ -1194,7 +1204,7 @@ class Game extends StatelessWidget { -1)) DataRow( cells: [ - const DataCell(Text('Kralj ultimo')), + DataCell(Text("king_ultimo".tr)), if (controller.myPredictions.value != null && controller.myPredictions.value! @@ -1282,7 +1292,7 @@ class Game extends StatelessWidget { 5) DataRow( cells: [ - const DataCell(Text('Mondfang')), + DataCell(Text("mondfang".tr)), if (controller.myPredictions.value != null && controller @@ -1364,7 +1374,7 @@ class Game extends StatelessWidget { !controller.isPlaying.value)) DataRow( cells: [ - const DataCell(Text('Barvni valat')), + DataCell(Text("color_valat".tr)), if (controller.myPredictions.value != null && controller.myPredictions.value! @@ -1400,7 +1410,7 @@ class Game extends StatelessWidget { !controller.isPlaying.value)) DataRow( cells: [ - const DataCell(Text('Valat')), + DataCell(Text("valat".tr)), if (controller.myPredictions.value != null && controller @@ -1438,9 +1448,9 @@ class Game extends StatelessWidget { onPressed: () { controller.showTalon.value = true; }, - child: const Text( - "Pokaži talon", - style: TextStyle( + child: Text( + "show_talon".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -1448,9 +1458,9 @@ class Game extends StatelessWidget { if (controller.startPredicting.value) ElevatedButton( onPressed: controller.predict, - child: const Text( - "Napovej", - style: TextStyle( + child: Text( + "predict".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -1475,17 +1485,29 @@ class Game extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ if (controller.selectedKing.value != "") - Text( - "${controller.users.map((e) { - //debugPrint("igra ${currentPredictions!.igra.id} ${e.id}"); - if (e.id == - controller - .currentPredictions.value!.igra.id) { - return e.name; - } - return ""; - }).join("")} igra v ${controller.selectedKing.value == "/pik/kralj" ? "piku" : controller.selectedKing.value == "/kara/kralj" ? "kari" : controller.selectedKing.value == "/src/kralj" ? "srcu" : "križu"}.", - ), + Text("playing_in".trParams( + { + "player": controller.users.map((e) { + //debugPrint("igra ${currentPredictions!.igra.id} ${e.id}"); + if (e.id == + controller.currentPredictions.value! + .igra.id) { + return e.name; + } + return ""; + }).join(""), + "color": controller.selectedKing.value == + "/pik/kralj" + ? "piku".tr + : controller.selectedKing.value == + "/kara/kralj" + ? "kari".tr + : controller.selectedKing.value == + "/src/kralj" + ? "srcu".tr + : "križu".tr, + }, + )), const SizedBox(height: 10), Row( mainAxisSize: MainAxisSize.min, @@ -1577,16 +1599,14 @@ class Game extends StatelessWidget { const SizedBox( height: 10, ), - if (controller.zaruf.value) - const Text( - "Uf, tole pa bo zaruf. Če izbereš kralja in ga uspešno pripelješ čez, dobiš še preostanek talona in v primeru, da je v talonu mond, ne pišeš -21 dol."), + if (controller.zaruf.value) Text("zaruf".tr), ElevatedButton( onPressed: () { controller.showTalon.value = false; }, - child: const Text( - "Skrij talon", - style: TextStyle( + child: Text( + "hide_talon".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -1611,9 +1631,7 @@ class Game extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - const Text( - "Trenutno si zalagate naslednje karte.", - ), + Text("stashing_cards".tr), Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, @@ -1658,9 +1676,7 @@ class Game extends StatelessWidget { await controller.stashEnd(true); controller.stashedCards.value = []; }, - child: const Text( - "Potrdi", - ), + child: Text("confirm".tr), ), const SizedBox(width: 20), ElevatedButton( @@ -1676,9 +1692,7 @@ class Game extends StatelessWidget { controller.turn.value = true; controller.sortCards(); }, - child: const Text( - "Zamenjaj karte", - ), + child: Text("change_card_selection".tr), ), ], ), @@ -1709,7 +1723,7 @@ class Game extends StatelessWidget { ElevatedButton( onPressed: () async => await controller.gameStartEarly(), - child: const Text("Takoj naprej")), + child: Text("immediately_onward".tr)), if (controller.gamesPlayed.value != controller.gamesRequired.value && !controller.bots) @@ -1759,12 +1773,12 @@ class Game extends StatelessWidget { dataRowMaxHeight: 40, dataRowMinHeight: 40, headingRowHeight: 40, - columns: const [ + columns: [ DataColumn( label: Expanded( child: Text( - 'Napoved', - style: TextStyle( + "prediction".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -1773,8 +1787,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Kontra', - style: TextStyle( + "kontra".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -1783,8 +1797,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Rezultat', - style: TextStyle( + "result".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -1793,8 +1807,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Napovedal', - style: TextStyle( + "predicted_by".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -1803,8 +1817,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Kontro dal', - style: TextStyle( + "kontra_by".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -1815,7 +1829,7 @@ class Game extends StatelessWidget { if (e.showGamemode) DataRow( cells: [ - const DataCell(Text('Igra')), + DataCell(Text("game".tr)), DataCell(Text( '${pow(2, e.kontraIgra)}x')), DataCell(Text( @@ -1843,7 +1857,7 @@ class Game extends StatelessWidget { if (e.showDifference) DataRow( cells: [ - const DataCell(Text('Razlika')), + DataCell(Text("difference".tr)), DataCell(Text( '${pow(2, e.kontraIgra)}x')), DataCell(Text( @@ -1868,7 +1882,7 @@ class Game extends StatelessWidget { if (e.showTrula) DataRow( cells: [ - const DataCell(Text('Trula')), + DataCell(Text("trula".tr)), const DataCell(Text('1x')), DataCell(Text( '${e.trula}', @@ -1890,7 +1904,7 @@ class Game extends StatelessWidget { if (e.showKralji) DataRow( cells: [ - const DataCell(Text('Kralji')), + DataCell(Text("kings".tr)), const DataCell(Text('1x')), DataCell(Text( '${e.kralji}', @@ -1912,8 +1926,8 @@ class Game extends StatelessWidget { if (e.showKralj) DataRow( cells: [ - const DataCell( - Text('Kralj ultimo')), + DataCell( + Text("king_ultimo".tr)), DataCell(Text( '${pow(2, e.kontraKralj)}x')), DataCell(Text( @@ -1941,8 +1955,8 @@ class Game extends StatelessWidget { if (e.showPagat) DataRow( cells: [ - const DataCell( - Text('Pagat ultimo')), + DataCell( + Text("pagat_ultimo".tr)), DataCell(Text( '${pow(2, e.kontraPagat)}x')), DataCell(Text( @@ -1970,8 +1984,7 @@ class Game extends StatelessWidget { if (e.mondfang) DataRow( cells: [ - const DataCell( - Text('Izguba monda')), + DataCell(Text("mondfang".tr)), DataCell(Text( '${pow(2, e.kontraMondfang)}x')), DataCell(Text( @@ -1997,23 +2010,23 @@ class Game extends StatelessWidget { ], ), if (e.skisfang) - const DataRow( + DataRow( cells: [ - DataCell(Text('Škisfang')), - DataCell(Text('/')), - DataCell(Text( + DataCell(Text("skisfang".tr)), + const DataCell(Text('/')), + const DataCell(Text( '-100', style: TextStyle( color: Colors.red, ), )), - DataCell(Text("")), - DataCell(Text("")), + const DataCell(Text("")), + const DataCell(Text("")), ], ), DataRow( cells: [ - const DataCell(Text('Skupaj')), + DataCell(Text("total".tr)), const DataCell(Text('')), DataCell( RichText( @@ -2064,12 +2077,12 @@ class Game extends StatelessWidget { dataRowMaxHeight: 40, dataRowMinHeight: 40, headingRowHeight: 40, - columns: const [ + columns: [ DataColumn( label: Expanded( child: Text( - 'Igralec', - style: TextStyle( + "player".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), ), @@ -2077,8 +2090,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Število dodatnih rund', - style: TextStyle( + "num_additional_rounds".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), ), @@ -2178,18 +2191,14 @@ class Game extends StatelessWidget { !controller.razpriKarte.value; }, child: controller.razpriKarte.value - ? const Text( - "Skrij točkovanje po štihih", - ) - : const Text( - "Prikaži točkovanje po štihih", - ), + ? Text("hide_point_count_by_tricks".tr) + : Text("show_point_count_by_tricks".tr), ), // pobrane karte v štihu if (controller.razpriKarte.value) - const Text("Pobrane karte:", - style: TextStyle(fontSize: 30)), + Text("picked_up_cards".tr, + style: const TextStyle(fontSize: 30)), if (controller.razpriKarte.value) Wrap( children: [ @@ -2205,38 +2214,42 @@ class Game extends StatelessWidget { const SizedBox( height: 10), Text( - controller.currentPredictions.value! - .gamemode >= - 0 && + controller.currentPredictions.value!.gamemode >= 0 && controller .currentPredictions .value! .gamemode <= 5 ? (e.key == 0 - ? "Založeno" + ? "stashed".tr : e.key + 1 == controller .results .value! .stih .length - ? "Talon" - : "${e.key}. štih") + ? "talon" + .tr + : "trick_nr".trParams({ + "number": e + .key + .toString() + })) : (controller .currentPredictions .value! .gamemode == -1 - ? "${e.key + 1}. štih" + ? "trick_nr" + .trParams({ + "number": e + .key + .toString() + }) : (e.key + 1 == - controller - .results - .value! - .stih - .length - ? "Talon" - : "${e.key + 1}. štih")), + controller.results.value!.stih.length + ? "talon".tr + : "trick_nr".trParams({"number": e.key.toString()}))), style: TextStyle( fontWeight: e.value .pickedUpByPlaying @@ -2310,14 +2323,37 @@ class Game extends StatelessWidget { ), const SizedBox( height: 10), - Text( - "Štih je vreden ${e.value.worth.round()} ${e.value.worth == 3 || e.value.worth == 4 ? 'točke' : e.value.worth == 2 ? 'točki' : e.value.worth == 1 ? 'točko' : 'točk'}.", - ), + Text("trick_is_worth" + .trParams({ + "points": e + .value.worth + .round() + .toString(), + "pointstext": e.value + .worth == + 3 || + e.value.worth == + 4 + ? 'točke'.tr + : e.value.worth == + 2 + ? 'točki'.tr + : e.value.worth == + 1 + ? 'točko' + .tr + : 'točk' + .tr + })), if (e.value .pickedUpBy != "") Text( - "Štih je pobral ${e.value.pickedUpBy}.", + "trick_picked_up_by" + .trParams({ + "player": e.value + .pickedUpBy + }), ), const SizedBox( height: 10), @@ -2333,9 +2369,7 @@ class Game extends StatelessWidget { onPressed: () { controller.results.value = null; }, - child: const Text( - "Zapri vpogled v rezultate", - ), + child: Text("close_results".tr), ), ], ), @@ -2356,21 +2390,21 @@ class Game extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - const Text( - "Hvala za igro", - style: TextStyle( + Text( + "thanks_game".tr, + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ), DataTable( dataRowMaxHeight: 40, dataRowMinHeight: 40, headingRowHeight: 40, - columns: const [ + columns: [ DataColumn( label: Expanded( child: Text( - 'Igralec', - style: TextStyle( + "player".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), ), @@ -2378,8 +2412,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Rezultat', - style: TextStyle( + "result".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), ), @@ -2387,8 +2421,8 @@ class Game extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Rating', - style: TextStyle( + "rating".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), ), @@ -2466,9 +2500,10 @@ class Game extends StatelessWidget { try { controller.socket.close(1000, 'CLOSE_NORMAL'); } catch (e) {} - Navigator.pop(context); + Get.back(); + Get.delete(); }, - tooltip: 'Zapusti igro', + tooltip: "leave_game".tr, child: const Icon(Icons.close), ) : const SizedBox(), diff --git a/tarok/lib/game/game_controller.dart b/tarok/lib/game/game_controller.dart index fa258bf..12ad883 100644 --- a/tarok/lib/game/game_controller.dart +++ b/tarok/lib/game/game_controller.dart @@ -1072,6 +1072,7 @@ class GameController extends GetxController { kingSelection.value = false; zaruf.value = false; requestedGameEnd.value = false; + talon.value = []; currentPredictions.value = Messages.Predictions(); copyGames(); @@ -1501,14 +1502,14 @@ class GameController extends GetxController { } stockskisUsers["player"] = stockskis.User( cards: [], - user: stockskis.SimpleUser(id: "player", name: "Igralec"), + user: stockskis.SimpleUser(id: "player", name: "player".tr), playing: false, secretlyPlaying: false, botType: "NAB", // not a bot licitiral: false, ); stockskis.SimpleUser user = - stockskis.SimpleUser(id: "player", name: "Igralec"); + stockskis.SimpleUser(id: "player", name: "player".tr); users.add(user); stockskisContext = stockskis.StockSkis( users: stockskisUsers, @@ -2292,7 +2293,7 @@ class GameController extends GetxController { AnimatedPositioned( duration: const Duration(milliseconds: ANIMATION_TIME), top: leftFromTop, - left: stihBoolValues[0] != true ? 0 : center, + left: stihBoolValues[0] != true ? 0 : center - cardHeight / 4, height: cardHeight, child: AnimatedRotation( duration: const Duration(milliseconds: ANIMATION_TIME), @@ -2326,7 +2327,7 @@ class GameController extends GetxController { top: stihBoolValues[1] != true ? leftFromTop - (cardHeight * 0.5) - 100 : leftFromTop - (cardHeight * 0.5), - left: center + cardHeight / 2, + left: center + cardHeight / 4, height: cardHeight, child: AnimatedRotation( duration: const Duration(milliseconds: ANIMATION_TIME), @@ -2360,7 +2361,7 @@ class GameController extends GetxController { top: leftFromTop, left: stihBoolValues[2] != true ? center + cardHeight + 100 - : center + cardHeight, + : center + cardHeight - cardHeight / 4, height: cardHeight, child: AnimatedRotation( duration: const Duration(milliseconds: ANIMATION_TIME), @@ -2423,7 +2424,7 @@ class GameController extends GetxController { top: stihBoolValues[3] != true ? leftFromTop + (cardHeight * 0.5) + 100 : leftFromTop + (cardHeight * 0.5), - left: center + cardHeight / 2, + left: center + cardHeight / 2 - cardHeight / 4, height: cardHeight, child: AnimatedRotation( duration: const Duration(milliseconds: ANIMATION_TIME), diff --git a/tarok/lib/game/variables.dart b/tarok/lib/game/variables.dart index 00d7886..c08532a 100644 --- a/tarok/lib/game/variables.dart +++ b/tarok/lib/game/variables.dart @@ -13,4 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -String name = "Igralec"; +import 'package:get/get.dart'; + +String name = "player".tr; diff --git a/tarok/lib/internationalization/languages.dart b/tarok/lib/internationalization/languages.dart new file mode 100644 index 0000000..eddaa93 --- /dev/null +++ b/tarok/lib/internationalization/languages.dart @@ -0,0 +1,469 @@ +import 'package:get/get.dart'; + +class Messages extends Translations { + @override + Map> get keys => { + 'en_US': { + "login": "Login", + "email": "Email address", + "password": "Password", + "registration": "Registration", + "guest_access": "Guest access", + "official_discord": "An official Discord server", + "source_code": "Source code", + "palcka": "Palčka", + "profile_name": "Profile name", + "repeat_password": "Repeat the password", + "register": "Register", + "account_login_403": "Trouble logging into your account", + "account_login_403_desc": + "Your account wasn't activated yet or the administrator has locked/disabled it.", + "account_login_unknown_error": "Unknown error while logging in", + "account_login_unknown_error_desc": + "Please recheck your login credentials.", + "password_mismatch": "Passwords don't match", + "ok": "OK", + "registration_success": + "Registration was successful. You should receive an e-mail with a registration code to your specified e-mail account. Until you verify your e-mail, you won't be able to log into your account.", + "refresh_data": "Refresh the data", + "user_id": "User ID", + "name": "Name", + "played_games": "Played online games", + "role": "Role", + "account_disabled": "Disabled account", + "verified_email": "Verified e-mail address", + "registered_on": "Registered on", + "change_user_name": "Change user's name", + "user_current_name": "User's current name is @name.", + "cancel": "Cancel", + "change": "Change", + "admin_to_user": "Demote to user", + "user_to_admin": "Promote to administrator", + "settings": "Settings", + "appearance": "Appearance", + "dark_mode": "Dark mode", + "use_dark_mode": "Use dark mode", + "sound": "Sound", + "sound_effects": "Sound effects", + "sound_effects_desc": "Enable sound effects", + "modifications": "Modifications", + "modifications_desc": + "If you're in a need for a challenge, you may modify below options.", + "stockskis_recommendations": "StockŠkis recommendations", + "stockskis_recommendations_desc": + "StockŠkis recommends you games when licitating. If you turn this option off, you won't receive any recommendations.", + "predicted_mondfang": "Predicted capture of Mond", + "predicted_mondfang_desc": "Capture of Mond can be predicted.", + "blind_tarock": "Blind tarock", + "blind_tarock_desc": + "You won't be able to see any tricks. Applies only to offline (bot) games.", + "skisfang": "Capture of Škis", + "skisfang_desc": + "-100 for a captured Škis. Applies only to offline (bot) games.", + "autoconfirm_stash": "Autoconfirm stashed cards", + "autoconfirm_stash_desc": + "Autoconfirms stashed cards. Enable this only if you know what you're doing and cannot misclick.", + "autogreet": "Automatically send a greeting", + "autogreet_desc": + "Automatically sends a greeting upon game start and every reconnect.", + "premove": "Premove", + "premove_desc": "Premove a card", + "developer_options": "Developer options", + "developer_options_desc": + "These options are mostly meant for use by the developers of Palčka tarock program. Perhaps, some people might take them for fun or as a challenge and that's why they are left here for everyone :). These options only work on local games with bots. Some settings are incompatible between each other.", + "developer_mode": "Developer mode", + "developer_mode_desc": "Enables additional developer/debug menus", + "falsify_game": "Falsify the game", + "falsify_game_desc": + "Your hand might contain a bunch of high tarocks. Sounds great for a valat ;).", + "guaranteed_zaruf": "Guaranteed zaruf", + "guaranteed_zaruf_desc": + "How come that all the kings are in talon? What a strange coincidence.", + "mond_in_talon": "Mond in talon", + "mond_in_talon_desc": "Here comes one minor problem ...", + "skis_in_talon": "Škis in talon", + "skis_in_talon_desc": + "Perhaps a Škis might (always) be in talon ... I don't know anything about that.", + "open_games": "Open games", + "open_games_desc": + "I may or may not have peeked into others' hands, nothing too serious...", + "color_valat": "Color valat", + "color_valat_desc": "Color valat, but just a little bit rigged.", + "beggar": "Beggar", + "beggar_desc": "Just the right cards for beggar", + "autostart_next_game": "Autostart next game", + "autostart_next_game_desc": + "If this option is turned off, we can only play a single game...", + "no_kontra": "No kontra", + "kontra": "Kontra", + "rekontra": "Rekontra", + "subkontra": "Subkontra", + "mortkontra": "Mortkontra", + "normal_bots": "Normal bots", + "advanced_bots": "Advanced bots", + "beggar_bots": "Beggar bots", + "klop_bots": "Klop bots", + "tarock_palcka": "Tarock Palčka", + "copyright": "Copyright 2023 Mitja Ševerkar", + "licensed_under": "Licensed under AGPLv3 license.", + "version": "Version @version", + "name_change": "Change of name", + "change_of_name_desc1": + "Change of name may be made free of charge and is available to everybody.", + "change_of_name_desc2": + "In case of an inappropriate name, administrators shall change the name and user's account might get locked after multiple violations.", + "change_of_name_desc3": "Your current name is: @name", + "change_of_email": "Change of e-mail address", + "change_of_email_desc": + "Due to possible account abuse, we do not offer e-mail address change directly from the application. Please contact the developers at info@palcka.si or on Discord (@mytja).", + "number_of_played_games": "Number of played games: ", + "user_profile_registered": "User profile registered on: ", + "role_in_system": "Role in the system: ", + "change_of_password": "Change of password", + "change_of_password_desc1": + "Pick a strong password. The application will log you out of your account due to security reasons.", + "change_of_password_desc2": + "In case nothing happens on click of the Change button, you might have misspelled your old password or new passwords.", + "old_password": "Old password", + "new_password": "New password", + "confirm_new_password": "Confirm new password", + "home": "Home", + "friends": "Friends", + "replays": "Game replays", + "discord": "Discord server", + "users": "Users", + "profile": "User profile", + "logout": "Logout", + "my_friends": "My friends", + "incoming_friend_requests": "Incoming friend requests", + "outgoing_friend_requests": "Outgoing friend requests", + "invite": "Invite", + "add_friend": "Add a friend", + "player": "Player", + "new_game": "Create a new game", + "welcome_message": "Welcome to Palčka tarock program.", + "using_guest_access": "You're using guest access", + "games_available": "Games available", + "with_players": "With players", + "in_three": "In three", + "in_four": "In four", + "chatroom": "Chatroom", + "with_bots": "With bots", + "replay_desc": "Here you can enter the URL to a game replay", + "replay_link": "Replay link", + "replay": "Game replay", + "modify_bots": "Modify bots", + "modify_bots_desc": + "Here you can edit what kinds of bots you want to play with in your games. The app will randomly pick bots from this list upon entering the game, if there are at least as many players as required for the game.", + "bot": "Bot", + "remove": "Remove", + "bot_name": "Bot name", + "add_bot": "Add the bot to the list", + "finish_list_editing": "Finish editing", + "discord_desc": + "The official Discord server contains the official forum as well as a community of tarock players.", + "game": "Game @type", + "mondfang_radelci": "Radelci on Mond capture", + "join_game": "Join the game", + "watch_replay": "Watch the replay", + "seconds_per_move": "Additional seconds per move", + "start_time": "Starting time (in seconds)", + "number_games": "Number of games", + "private_game": "Private game", + "friend_email": "Friend's e-mail address", + "add": "Add", + "debugging": "Debugging", + "first_card": "First card: @card", + "trick": "Trick: @trick", + "selected_king": "Selected king: @king", + "player_with_king": "Player with the king: @player", + "stashed_cards": "Stashed cards: @stashed", + "picked_talon": "Picked talon: @talon", + "reevaluate_cards": "Reevaluate cards", + "invite_friend": "Invite a friend", + "invite_friends": "Invite friends", + "start_game": "Start the game", + "stashed_tarocks": "Stashed tarocks:", + "trula": "Trula", + "kings": "Kings", + "pagat_ultimo": "Pagat ultimo", + "king_ultimo": "King ultimo", + "mondfang": "Capture of Mond", + "valat": "Valat", + "show_talon": "Show talon", + "hide_talon": "Hide talon", + "predict": "Predict", + "playing_in": "@player is playing in @color.", + "piku": "spades", + "srcu": "hearts", + "križu": "clubs", + "kari": "diamonds", + "zaruf": + "It looks like a zaruf. If you take the king, you get the remainder of talon and in case of Mond being inside, your mond doesn't get captured.", + "stashing_cards": "You're currently stashing the following cards.", + "confirm": "Confirm", + "change_card_selection": "Change card selection", + "immediately_onward": "Immediately onwards", + "prediction": "Prediction", + "result": "Result", + "predicted_by": "Predicted by", + "kontra_by": "Kontra given by", + "game_simple": "Game", + "difference": "Difference", + "total": "Total", + "num_additional_rounds": "Number of additional rounds", + "hide_point_count_by_tricks": "Hide point count by tricks", + "show_point_count_by_tricks": "Show point count by tricks", + "picked_up_cards": "Picked up cards:", + "stashed": "Stashed", + "talon": "Talon", + "trick_nr": "Trick number @number", + "točk": "points", + "točko": "point", + "točki": "points", + "točke": "points", + "trick_is_worth": "Trick is worth @points @pointstext.", + "trick_picked_up_by": "Trick was picked up by @player", + "close_results": "Close results overview", + "thanks_game": "Thanks for the game", + "rating": "Rating", + "leave_game": "Leave the game", + "account_confirmed": "User profile has been successfully confirmed.", + "account_not_confirmed": + "User profile hasn't been confirmed or is already confirmed.", + "customize_bots": "Customize bots", + "language": "Language", + }, + 'sl_SI': { + "login": "Prijava", + "account_login_403": "Težava s prijavo v vaš uporabniški profil", + "account_login_403_desc": + "Vaš uporabniški profil ni še bil aktiviran ali pa ga je administrator zaklenil.", + "account_login_unknown_error": "Neznana napaka pri prijavi", + "account_login_unknown_error_desc": + "Prosimo, ponovno preverite prijavne podatke.", + "registration_success": + "Registracija je bila uspešna. Na vaš elektronski naslov bi moralo priti sporočilo z registracijsko kodo. Dokler ne aktivirate računa, se ne boste mogli prijaviti", + "user_id": "Uporabniški ID", + "developer_options_desc": + "Te opcije so namenjene predvsem razvijalcem programa Palčka.si. Mogoče so komu v izziv ali pa malo tako za zabavo, tako da jih puščam tukaj na voljo vsem :). Te opcije delujejo samo na lokalnih igrah z boti. Nekatere nastavitve so nekompatibilne med sabo.", + "falsify_game_desc": + "V roke dobite kar dosti visokih tarokov. Odlična stvar za valata ;).", + "guaranteed_zaruf_desc": + "Le kako so se vsi kralji pojavili v talonu. Čudno naključje.", + "mond_in_talon_desc": + "Potem pa pridemo do enega manjšega problemčka ...", + "skis_in_talon_desc": + "Mogoče je škis v talonu (vedno) ... Nič ne vem o tem.", + "open_games_desc": + "Mogoče sem čisto malo pokukal v karte drugih, nič takega ...", + "color_valat_desc": "Barvič, samo da drobceno prirejen.", + "autostart_next_game": "Avtomatično začni naslednjo igro", + "autostart_next_game_desc": + "Če je opcija ugasnjena, se bomo lahko šli samo eno igro ...", + "name_change": "Sprememba imena", + "change_of_name_desc1": + "Zamenjava imena je brezplačna in prosto dostopna vsem.", + "change_of_name_desc2": + "V primeru neprimernega imena, bodo administratorji spremenili ime, uporabniku pa se lahko po večkratnih kršitvah zakleni uporabniški račun.", + "change_of_name_desc3": "Vaše trenutno uporabniško ime je: @name", + "change_of_email": "Zamenjava elektronskega naslova", + "change_of_email_desc": + "Zaradi možne zlorabe ne ponujamo menjave elektronskega naslova direktno prek uporabniškega vmesnika. Kontaktirajte razvijalca na info@palcka.si ali na Discordu (@mytja).", + "number_of_played_games": "Število odigranih iger: ", + "user_profile_registered": "Uporabniški profil registriran: ", + "role_in_system": "Vloga v sistemu: ", + "change_of_password": "Sprememba gesla", + "change_of_password_desc1": + "Izberite si dobro geslo. Program vas bo zaradi varnosti izpisal/odjavil po uspešni spremembi gesla.", + "change_of_password_desc2": + "V primeru, da se ne zgodi nič po kliku na Spremeni, ste se mogoče zatipkali pri novem ali starem geslu.", + "my_friends": "Moji prijatelji", + "incoming_friend_requests": "Prihodne prošnje za prijateljstvo", + "outgoing_friend_requests": "Odhodne prošnje za prijateljstvo", + "player": "Igralec", + "welcome_message": "Dobrodošli v Palčka tarok programu.", + "replay_desc": "Tukaj lahko vpišete URL do posnetka igre", + "modify_bots_desc": + "Tukaj lahko urejate, kakšne bote želite videti v svojih igrah. Program bo ob vstopu v igro avtomatično izbral naključne igralce iz tega seznama, če jih je vsaj toliko, kot zahteva ta igra.", + "discord_desc": + "Uradni Discord strežnik vsebuje forum in skupnost igralcev taroka.", + "seconds_per_move": "Sekund na potezo (pribitek)", + "start_time": "Začetni čas (sekund)", + "number_games": "Število iger", + "private_game": "Zasebna partija", + "zaruf": + "Uf, tole pa bo zaruf. Če izbereš kralja in ga uspešno pripelješ čez, dobiš še preostanek talona in v primeru, da je v talonu mond, ne pišeš -21 dol.", + "stashing_cards": "Trenutno si zalagate naslednje karte.", + "account_confirmed": "Uporabniški profil je bil uspešno potrjen.", + "account_not_confirmed": "Uporabniški profil ni bil potrjen", + // + "email": "Elektronski naslov", + "password": "Geslo", + "registration": "Registracija", + "guest_access": "Gostujoči dostop", + "official_discord": "Uradni Discord strežnik", + "source_code": "Izvorna koda", + "palcka": "Palčka", + "profile_name": "Ime profila", + "repeat_password": "Ponovite geslo", + "register": "Registracija", + "password_mismatch": "Gesli se ne ujemata", + "ok": "OK", + "refresh_data": "Osveži podatke", + "name": "Ime", + "played_games": "Igrane igre", + "role": "Vloga", + "account_disabled": "Onemogočen račun", + "verified_email": "Preverjen elektronski naslov", + "registered_on": "Čas registracije", + "change_user_name": "Zamenjaj uporabnikovo ime", + "user_current_name": "Uporabnikovo trenutno ime je @name.", + "cancel": "Prekliči", + "change": "Spremeni", + "admin_to_user": "Spremeni administratorja v uporabnika", + "user_to_admin": "Spremeni uporabnika v administratorja", + "settings": "Nastavitve", + "appearance": "Izgled", + "dark_mode": "Temni način", + "use_dark_mode": "Uporabi temni način", + "sound": "Zvok", + "sound_effects": "Zvočni efekti", + "sound_effects_desc": "Vključi zvočne efekte", + "modifications": "Modifikacije", + "modifications_desc": + "Če potrebujete izziv, si lahko prilagodite spodnje opcije.", + "stockskis_recommendations": "StockŠkis priporočila", + "stockskis_recommendations_desc": + "StockŠkis priporoča igre. Če izključite to opcijo, ne boste več prejemali priporočil.", + "predicted_mondfang": "Napovedan mondfang", + "predicted_mondfang_desc": "Mondfang se lahko napove.", + "blind_tarock": "Slepi tarok", + "blind_tarock_desc": + "Ne boste videli štihov. Velja samo za igre z boti.", + "skisfang": "Škisfang", + "skisfang_desc": "-100 za ujetega škisa. Velja samo za igre z boti.", + "autoconfirm_stash": "Avtopotrdi založitev", + "autoconfirm_stash_desc": + "Avtopotrdi založitev. Vključite to le če veste kaj delate in se ne morete zaklikati.", + "autogreet": "Avtomatični lp", + "autogreet_desc": + "Pošlje lp na začetku vsake igre in na vsako ponovno priključitev igri.", + "premove": "Premove", + "premove_desc": "Premovaj karto", + "developer_options": "Razvijalske opcije", + "developer_mode": "Razvijalski način", + "developer_mode_desc": " Vključi dodatne razvijalske menije", + "falsify_game": "Priredi igro", + "guaranteed_zaruf": "Garantiran zaruf", + "mond_in_talon": "Mond v talonu", + "skis_in_talon": "Škis v talonu", + "open_games": "Odprte igre", + "color_valat": "Barvni valat", + "beggar": "Berač", + "beggar_desc": "Ravno prave karte za berača", + "no_kontra": "Brez kontre", + "kontra": "Kontra", + "rekontra": "Rekontra", + "subkontra": "Subkontra", + "mortkontra": "Mortkontra", + "normal_bots": "Normalni boti", + "advanced_bots": "Napredni boti", + "beggar_bots": "Berač boti", + "klop_bots": "Klop boti", + "tarock_palcka": "Tarok Palčka", + "copyright": "Copyright 2023 Mitja Ševerkar, vse pravice pridržane", + "licensed_under": "Licencirano z AGPLv3 licenco.", + "version": "Različica @version", + "old_password": "Staro geslo", + "new_password": "Novo geslo", + "confirm_new_password": "Potrdi novo geslo", + "home": "Domov", + "friends": "Prijatelji", + "replays": "Posnetki iger", + "discord": "Discord strežnik", + "users": "Uporabniki", + "profile": "Uporabniški profil", + "logout": "Odjava", + "invite": "Povabi", + "add_friend": "Dodaj prijatelja", + "new_game": "Ustvari novo igro", + "using_guest_access": "Uporabljate gostujoči dostop", + "games_available": "Igre na voljo", + "with_players": "Z igralci", + "in_three": "V tri", + "in_four": "V štiri", + "chatroom": "Klepetalnica", + "with_bots": "Z računalniškimi igralci", + "replay_link": "Povezava do posnetka igre", + "replay": "Posnetek igre", + "modify_bots": "Prilagodi računalniške igralce", + "bot": "Bot", + "remove": "Odstrani", + "bot_name": "Ime bota", + "add_bot": "Dodaj bota na seznam", + "finish_list_editing": "Končaj z urejanjem", + "game": "Igra @type", + "mondfang_radelci": "Radelci na mondfang", + "join_game": "Pridruži se igri", + "watch_replay": "Oglej si posnetek igre", + "friend_email": "Elektronski naslov prijatelja", + "add": "Dodaj", + "debugging": "Razhroščevanje", + "first_card": "Prva karta: @card", + "trick": "Štih: @trick", + "selected_king": "Izbrani kralj: @king", + "player_with_king": "Igralec s kraljem: @player", + "stashed_cards": "Založene karte: @stashed", + "picked_talon": "Izbran talon: @talon", + "reevaluate_cards": "Ponovno evaluiraj karte", + "invite_friend": "Povabi prijatelja", + "invite_friends": "Povabi prijatelje", + "start_game": "Začni igro", + "stashed_tarocks": "Založeni taroki:", + "trula": "Trula", + "kings": "Kralji", + "pagat_ultimo": "Pagat ultimo", + "king_ultimo": "Kralj ultimo", + "mondfang": "Mondfang", + "valat": "Valat", + "show_talon": "Pokaži talon", + "hide_talon": "Skrij talon", + "predict": "Napovej", + "playing_in": "@player igra v @color.", + "piku": "piku", + "srcu": "srcu", + "križu": "križu", + "kari": "kari", + "confirm": "Potrdi", + "change_card_selection": "Spremeni izbiro", + "immediately_onward": "Takoj naprej", + "prediction": "Napoved", + "result": "Rezultat", + "predicted_by": "Napovedal", + "kontra_by": "Kontriral", + "game_simple": "Igra", + "difference": "Razlika", + "total": "Skupaj", + "num_additional_rounds": "Število dodatnih rund", + "hide_point_count_by_tricks": "Skrij evaluacijo po štihih", + "show_point_count_by_tricks": "Pokaži evaluacijo po štihih", + "picked_up_cards": "Pobrane karte:", + "stashed": "Založeno", + "talon": "Talon", + "trick_nr": "@number. štih", + "točk": "točk", + "točko": "točko", + "točki": "točki", + "točke": "točke", + "trick_is_worth": "Štih je (zaokroženo) vreden @points @pointstext.", + "trick_picked_up_by": "Štih je pobral @player", + "close_results": "Zapri vpogled v rezultate", + "thanks_game": "Hvala za igro", + "rating": "Rating", + "leave_game": "Zapusti igro", + "customize_bots": "Prilagodi računalniške igralce", + "language": "Jezik", + } + }; +} diff --git a/tarok/lib/lobby/friends.dart b/tarok/lib/lobby/friends.dart index 8b5888b..d5c0dbe 100644 --- a/tarok/lib/lobby/friends.dart +++ b/tarok/lib/lobby/friends.dart @@ -36,16 +36,16 @@ class Friends extends StatelessWidget { () => ListView( shrinkWrap: true, children: [ - const Center( + Center( child: Text( - 'Moji prijatelji', - style: TextStyle(fontSize: 40), + "my_friends".tr, + style: const TextStyle(fontSize: 40), ), ), - const Center( + Center( child: Text( - 'Prihodne prošnje za prijateljstvo', - style: TextStyle(fontSize: 20), + "incoming_friend_requests".tr, + style: const TextStyle(fontSize: 20), ), ), ...controller.prihodne.map( @@ -101,10 +101,10 @@ class Friends extends StatelessWidget { ), ), ), - const Center( + Center( child: Text( - 'Odhodne prošnje za prijateljstvo', - style: TextStyle(fontSize: 20), + "outgoing_friend_requests".tr, + style: const TextStyle(fontSize: 20), ), ), ...controller.odhodne.map( @@ -153,10 +153,10 @@ class Friends extends StatelessWidget { ), ), ), - const Center( + Center( child: Text( - 'Prijatelji', - style: TextStyle(fontSize: 20), + "friends".tr, + style: const TextStyle(fontSize: 20), ), ), ...controller.prijatelji.map( @@ -233,7 +233,7 @@ class Friends extends StatelessWidget { ), if (gameId != "" && !invited.contains(e.id)) ElevatedButton( - child: const Text("Povabi"), + child: Text("invite".tr), onPressed: () async { GameController c = Get.put(GameController()); await c.invitePlayer(e.id); @@ -259,7 +259,7 @@ class Friends extends StatelessWidget { return PalckaHome( floatingActionButton: FloatingActionButton( onPressed: controller.friendAddDialog, - tooltip: 'Dodaj prijatelja', + tooltip: "add_friend".tr, child: const Icon(Icons.add), ), child: mainContent, diff --git a/tarok/lib/lobby/lobby.dart b/tarok/lib/lobby/lobby.dart index d3fec16..66204db 100644 --- a/tarok/lib/lobby/lobby.dart +++ b/tarok/lib/lobby/lobby.dart @@ -13,7 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart' hide FormData; @@ -44,43 +43,43 @@ class Lobby extends StatelessWidget { return PalckaHome( floatingActionButton: FloatingActionButton( onPressed: controller.dialog, - tooltip: 'Ustvari novo igro', + tooltip: "new_game".tr, child: const Icon(Icons.add), ), child: Obx( () => ListView( shrinkWrap: true, children: [ - const Center( + Center( child: Text( - 'Dobrodošli v Palčka tarok programu.', - style: TextStyle(fontSize: 40), + "welcome_message".tr, + style: const TextStyle(fontSize: 40), ), ), if (controller.guest.value) - const Center( + Center( child: Text( - "Uporabljate gostujoči dostop", - style: TextStyle(fontSize: 20), + "using_guest_access".tr, + style: const TextStyle(fontSize: 20), ), ), - const Center( + Center( child: Text( - "Igre na voljo", - style: TextStyle(fontSize: 30), + "games_available".tr, + style: const TextStyle(fontSize: 30), ), ), if (!controller.guest.value) Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text("S pravimi igralci"), + Text("with_players".tr), const SizedBox( width: 10, ), ElevatedButton.icon( onPressed: () => controller.quickGameFind(3, "normal"), - label: const Text( - "V tri", - style: TextStyle( + label: Text( + "in_three".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -88,9 +87,9 @@ class Lobby extends StatelessWidget { ), ElevatedButton.icon( onPressed: () => controller.quickGameFind(4, "normal"), - label: const Text( - "V štiri", - style: TextStyle( + label: Text( + "in_four".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -99,15 +98,15 @@ class Lobby extends StatelessWidget { ]), if (!controller.guest.value) Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text("Klepetalnica"), + Text("chatroom".tr), const SizedBox( width: 10, ), ElevatedButton.icon( onPressed: () => controller.quickGameFind(3, "klepetalnica"), - label: const Text( - "V tri", - style: TextStyle( + label: Text( + "in_three".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -115,9 +114,9 @@ class Lobby extends StatelessWidget { ), ElevatedButton.icon( onPressed: () => controller.quickGameFind(4, "klepetalnica"), - label: const Text( - "V štiri", - style: TextStyle( + label: Text( + "in_four".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -125,15 +124,15 @@ class Lobby extends StatelessWidget { ), ]), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text("Z računalniškimi igralci"), + Text("with_bots".tr), const SizedBox( width: 10, ), ElevatedButton.icon( onPressed: () => controller.botGame(3), - label: const Text( - "V tri", - style: TextStyle( + label: Text( + "in_three".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -141,186 +140,63 @@ class Lobby extends StatelessWidget { ), ElevatedButton.icon( onPressed: () => controller.botGame(4), - label: const Text( - "V štiri", - style: TextStyle( + label: Text( + "in_four".tr, + style: const TextStyle( fontSize: 20, ), ), icon: const Icon(Icons.smart_toy), ), ]), - const SizedBox( - height: 10, - ), - if (controller.isAdmin.value) + if (!controller.guest.value) + const SizedBox( + height: 10, + ), + if (!controller.guest.value) Center( child: ElevatedButton( onPressed: () => Get.defaultDialog( - title: 'Administratorska plošča', + title: "replay".tr, content: SingleChildScrollView( - child: Column(children: [ - const Text( - 'Na tej plošči lahko kot administrator urejate razne nastavitve tarok programa Palčka', - ), - const SizedBox( - height: 10, - ), - FutureBuilder( - future: controller.getRegistrationCodes(), - builder: - (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { - return DataTable( - columns: const [ - DataColumn( - label: Expanded( - child: Text( - 'Registracijska koda', - style: TextStyle( - fontStyle: FontStyle.italic), - ), - ), - ), - DataColumn( - label: Expanded( - child: Text( - 'Izbriši', - style: TextStyle( - fontStyle: FontStyle.italic), - ), - ), - ), - ], - rows: [ - ...controller.codes.map( - (code) => DataRow( - cells: [ - DataCell(Text(code["Code"])), - DataCell( - IconButton( - icon: const Icon(Icons.delete), - onPressed: () async { - await dio.delete( - "$BACKEND_URL/admin/reg_code", - data: FormData.fromMap( - { - "code": code["Code"], - }, - ), - options: Options( - headers: { - "X-Login-Token": - await storage.read( - key: "token") - }, - ), - ); - controller.getRegistrationCodes(); - }, - ), - ), - ], - ), - ), - ], - ); - } - return const SizedBox(); - }, - ), - Row(children: [ - Expanded( - child: TextField( - controller: controller.controller.value, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - labelText: 'Nova registracijska koda', - ), - ), + child: Obx( + () => Column(children: [ + Text("replay_desc".tr), + const SizedBox( + height: 10, ), - IconButton( - icon: const Icon(Icons.save), - onPressed: () async { - await dio.post( - "$BACKEND_URL/admin/reg_code", - data: FormData.fromMap( - { - "code": controller.controller.value.text, - }, - ), - options: Options( - headers: { - "X-Login-Token": - await storage.read(key: "token") - }, + Row(children: [ + Expanded( + child: TextField( + controller: controller.replayController.value, + decoration: InputDecoration( + border: const UnderlineInputBorder(), + labelText: "replay_link".tr, ), - ); - controller.getRegistrationCodes(); - }, - ), + ), + ), + ]), ]), - ]), + ), ), actions: [ TextButton( - onPressed: () => Get.back(), - child: const Text('OK'), + onPressed: () { + Get.back(); + }, + child: Text("cancel".tr), + ), + TextButton( + onPressed: () { + joinReplay(controller.replayController.value.text); + }, + child: Text("ok".tr), ), ], ), - child: const Text("Administratorska plošča"), - ), - ), - const SizedBox( - height: 10, - ), - Center( - child: ElevatedButton( - onPressed: () => Get.defaultDialog( - title: 'Posnetek igre', - content: SingleChildScrollView( - child: Obx( - () => Column(children: [ - const Text( - 'Tukaj lahko vpišete URL do posnetka igre', - ), - const SizedBox( - height: 10, - ), - Row(children: [ - Expanded( - child: TextField( - controller: controller.replayController.value, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - labelText: 'Povezava do posnetka igre', - ), - ), - ), - ]), - ]), - ), - ), - actions: [ - TextButton( - onPressed: () { - Get.back(); - }, - child: const Text('Prekliči'), - ), - TextButton( - onPressed: () { - joinReplay(controller.replayController.value.text); - }, - child: const Text('OK'), - ), - ], + child: Text("replay".tr), ), - child: const Text("Posnetek igre"), ), - ), - const SizedBox( height: 10, ), @@ -331,13 +207,11 @@ class Lobby extends StatelessWidget { builder: (context) { return StatefulBuilder(builder: (context, setState) { return AlertDialog( - title: const Text('Prilagodi računalniške igralce'), + title: Text("modify_bots".tr), content: SingleChildScrollView( child: Obx( () => Column(children: [ - const Text( - 'Tukaj lahko urejate, kakšne bote želite videti v svojih igrah. Program bo ob vstopu v igro avtomatično izbral naključne igralce iz tega seznama, če jih je vsaj toliko, kot zahteva ta igra.', - ), + Text("modify_bots_desc".tr), const SizedBox( height: 10, ), @@ -347,12 +221,12 @@ class Lobby extends StatelessWidget { AsyncSnapshot snapshot) { if (controller.botNames.isNotEmpty) { return DataTable( - columns: const [ + columns: [ DataColumn( label: Expanded( child: Text( - 'Bot', - style: TextStyle( + "bot".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -361,8 +235,8 @@ class Lobby extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Ime', - style: TextStyle( + "name".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -371,8 +245,8 @@ class Lobby extends StatelessWidget { DataColumn( label: Expanded( child: Text( - 'Izbriši', - style: TextStyle( + "remove".tr, + style: const TextStyle( fontStyle: FontStyle.italic), ), @@ -415,9 +289,9 @@ class Lobby extends StatelessWidget { child: TextField( controller: controller.playerNameController.value, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - labelText: 'Ime igralca', + decoration: InputDecoration( + border: const UnderlineInputBorder(), + labelText: "bot_name".tr, ), ), ), @@ -467,9 +341,9 @@ class Lobby extends StatelessWidget { ); setState(() {}); }, - label: const Text( - "Dodaj bota na seznam", - style: TextStyle( + label: Text( + "add_bot".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -481,13 +355,13 @@ class Lobby extends StatelessWidget { actions: [ TextButton( onPressed: () => Navigator.pop(context), - child: const Text('Končaj z urejanjem'), + child: Text("finish_list_editing".tr), ), ], ); }); }), - child: const Text("Prilagodi računalniške igralce"), + child: Text("customize_bots".tr), ), ), @@ -500,10 +374,8 @@ class Lobby extends StatelessWidget { child: Card( child: ListTile( leading: const FaIcon(FontAwesomeIcons.discord), - title: const Text('Discord strežnik'), - subtitle: const Text( - "Uradni Discord strežnik vsebuje forum in skupnost igralcev taroka", - ), + title: Text("discord".tr), + subtitle: Text("discord_desc".tr), onTap: () async { await launchUrl( Uri.parse("https://discord.gg/fzeN4Cnbr3")); @@ -527,9 +399,9 @@ class Lobby extends StatelessWidget { children: [ ...controller.priorityQueue.map( (e) => GestureDetector( - onTap: () { + onTap: () async { debugPrint("Priority"); - Get.toNamed("/game", parameters: { + await Get.toNamed("/game", parameters: { "playing": e.requiredPlayers.toString(), "gameId": e.id, "bots": "false", @@ -541,19 +413,24 @@ class Lobby extends StatelessWidget { children: [ Center( child: Text( - 'Igra ${e.totalTime}+${e.additionalTime} ${e.mondfangRadelci || e.skisfang || e.napovedanMondfang ? "+ modifikacije" : ""} ${e.type == "klepetalnica" ? "(klepetalnica)" : ""}'), + "game".trParams({ + "type": e.type == "klepetalnica" + ? "(klepetalnica)" + : "" + }), + ), ), if (e.mondfangRadelci) - const Center( - child: Text('Mondfang radelci'), + Center( + child: Text("mondfang_radelci".tr), ), if (e.skisfang) - const Center( - child: Text('Škisfang'), + Center( + child: Text("skisfang".tr), ), if (e.napovedanMondfang) - const Center( - child: Text('Napovedan mondfang'), + Center( + child: Text("predicted_mondfang".tr), ), const SizedBox( height: 10, @@ -573,12 +450,12 @@ class Lobby extends StatelessWidget { shrinkWrap: true, itemCount: e.requiredPlayers - e.user.length, itemBuilder: (BuildContext context, int index) { - return const Center( + return Center( child: SizedBox( height: 40, child: Text( - "Pridružite se igri", - style: TextStyle( + "join_game".tr, + style: const TextStyle( fontSize: 25, ), ), @@ -603,8 +480,8 @@ class Lobby extends StatelessWidget { children: [ ...controller.queue.map( (e) => GestureDetector( - onTap: () { - Get.toNamed("/game", parameters: { + onTap: () async { + await Get.toNamed("/game", parameters: { "playing": e.requiredPlayers.toString(), "gameId": e.id, "bots": "false", @@ -615,19 +492,24 @@ class Lobby extends StatelessWidget { children: [ Center( child: Text( - 'Igra ${e.totalTime}+${e.additionalTime} ${e.mondfangRadelci || e.skisfang || e.napovedanMondfang ? "+ modifikacije" : ""} ${e.type == "klepetalnica" ? "(klepetalnica)" : ""}'), + "game".trParams({ + "type": e.type == "klepetalnica" + ? "(klepetalnica)" + : "" + }), + ), ), if (e.mondfangRadelci) - const Center( - child: Text('Mondfang radelci'), + Center( + child: Text("mondfang_radelci".tr), ), if (e.skisfang) - const Center( - child: Text('Škisfang'), + Center( + child: Text("skisfang".tr), ), if (e.napovedanMondfang) - const Center( - child: Text('Napovedan mondfang'), + Center( + child: Text("predicted_mondfang".tr), ), const SizedBox( height: 10, @@ -643,17 +525,22 @@ class Lobby extends StatelessWidget { ), ), ), - ...List.generate( - e.requiredPlayers - e.user.length, - (index) => const SizedBox( - height: 40, - child: Text( - "Pridružite se igri", - style: TextStyle( - fontSize: 25, + ListView.builder( + shrinkWrap: true, + itemCount: e.requiredPlayers - e.user.length, + itemBuilder: (BuildContext context, int index) { + return Center( + child: SizedBox( + height: 40, + child: Text( + "join_game".tr, + style: const TextStyle( + fontSize: 25, + ), + ), ), - ), - ), + ); + }, ), ], ), diff --git a/tarok/lib/lobby/lobby_controller.dart b/tarok/lib/lobby/lobby_controller.dart index b8b7ca4..a8cbed9 100644 --- a/tarok/lib/lobby/lobby_controller.dart +++ b/tarok/lib/lobby/lobby_controller.dart @@ -144,7 +144,7 @@ class LobbyController extends GetxController { children: guest.value ? [] : [ - const Text('Sekund na potezo (pribitek)'), + Text("seconds_per_move".tr), Slider( value: pribitek.value, max: 5, @@ -154,7 +154,7 @@ class LobbyController extends GetxController { pribitek.value = value; }, ), - const Text('Začetni čas (sekund)'), + Text("start_time".tr), Slider( value: zacetniCas.value, min: 15, @@ -165,7 +165,7 @@ class LobbyController extends GetxController { zacetniCas.value = value; }, ), - const Text('Število iger'), + Text("number_games".tr), Slider( value: iger.value, min: 1, @@ -176,28 +176,28 @@ class LobbyController extends GetxController { iger.value = value; }, ), - const Text('Zasebna partija'), + Text("private_game".tr), Switch( value: party.value, onChanged: (bool value) { party.value = value; }, ), - const Text('Vsi igralci dobijo radelce na mondfang'), + Text("mondfang_radelci".tr), Switch( value: mondfang.value, onChanged: (bool value) { mondfang.value = value; }, ), - const Text('-100 dol za igralca, ki izgubi škisa'), + Text("skisfang".tr), Switch( value: skisfang.value, onChanged: (bool value) { skisfang.value = value; }, ), - const Text('Napovedan mondfang'), + Text("predicted_mondfang".tr), Switch( value: napovedanMondfang.value, onChanged: (bool value) { @@ -217,7 +217,7 @@ class LobbyController extends GetxController { } await newGame(3); }, - child: const Text('V tri'), + child: Text("in_three".tr), ), TextButton( onPressed: () async { @@ -227,7 +227,7 @@ class LobbyController extends GetxController { } await newGame(4); }, - child: const Text('V štiri'), + child: Text("in_four".tr), ), ], ), @@ -258,7 +258,7 @@ class LobbyController extends GetxController { // ignore: use_build_context_synchronously //Navigator.pop(context); // ignore: use_build_context_synchronously - Get.toNamed("/game", parameters: { + await Get.toNamed("/game", parameters: { "playing": players.toString(), "gameId": gameId, "bots": "false", @@ -276,15 +276,15 @@ class LobbyController extends GetxController { ), ); String gameId = response.data.toString(); - Get.toNamed("/game", parameters: { + await Get.toNamed("/game", parameters: { "playing": players.toString(), "gameId": gameId, "bots": "false", }); } - void botGame(int players) { - Get.toNamed("/game", parameters: { + Future botGame(int players) async { + await Get.toNamed("/game", parameters: { "playing": players.toString(), "gameId": "", "bots": "true", @@ -352,10 +352,10 @@ class LobbyController extends GetxController { Get.dialog( AlertDialog( scrollable: true, - title: const Text('Dodaj prijatelja'), + title: Text("add_friend".tr), content: Column( children: [ - const Text('Elektronski naslov prijatelja'), + Text("friend_email".tr), TextField( controller: emailController.value, ), @@ -367,7 +367,7 @@ class LobbyController extends GetxController { await addFriend(); Get.back(); }, - child: const Text('Dodaj'), + child: Text("add".tr), ), ], ), @@ -405,11 +405,21 @@ class LobbyController extends GetxController { */ @override void onInit() async { - storage.read(key: "role").then((value) { - debugPrint(value); - isAdmin.value = value == "admin"; - if (!isAdmin.value) return; - }); + String? token = await storage.read(key: "token"); + if (token == "" || token == "a" || token == null) { + guest.value = true; + } else { + storage.read(key: "role").then((value) { + debugPrint(value); + isAdmin.value = value == "admin"; + if (!isAdmin.value) return; + }); + } + + if (guest.value) { + super.onInit(); + return; + } // ONLINE try { diff --git a/tarok/lib/lobby/replays.dart b/tarok/lib/lobby/replays.dart index 2d9afaf..2737aa8 100644 --- a/tarok/lib/lobby/replays.dart +++ b/tarok/lib/lobby/replays.dart @@ -32,10 +32,10 @@ class Replays extends StatelessWidget { padding: const EdgeInsets.only(left: 50, right: 50, top: 10, bottom: 10), children: [ - const Center( + Center( child: Text( - 'Posnetki iger', - style: TextStyle(fontSize: 40), + "replays".tr, + style: const TextStyle(fontSize: 40), ), ), ...controller.replays.map( @@ -49,7 +49,7 @@ class Replays extends StatelessWidget { onPressed: () async { await joinReplay(e.url); }, - child: const Text("Oglej si posnetek"), + child: Text("watch_replay".tr), ), ], ), diff --git a/tarok/lib/login/login.dart b/tarok/lib/login/login.dart index 513d34a..e02880b 100644 --- a/tarok/lib/login/login.dart +++ b/tarok/lib/login/login.dart @@ -13,9 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import 'dart:io'; - -import 'package:draggable_widget/draggable_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -32,20 +29,27 @@ class Login extends StatelessWidget { LoginController controller = Get.put(LoginController()); return Scaffold( - appBar: !(Platform.isAndroid || Platform.isIOS || isWebMobile) - ? AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Palčka"), - ) - : null, + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Text("palcka".tr), + automaticallyImplyLeading: false, + actions: [ + IconButton( + icon: const Icon(Icons.settings), + onPressed: () async { + await Get.toNamed("/settings"); + }, + ), + ], + ), body: Center( child: ListView( shrinkWrap: true, padding: const EdgeInsets.all(20.0), children: [ - const Text( - "Prijava", - style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), + Text( + "login".tr, + style: const TextStyle(fontSize: 45, fontWeight: FontWeight.bold), ), const SizedBox( height: 20, @@ -54,9 +58,9 @@ class Login extends StatelessWidget { width: 350, child: TextField( controller: controller.email.value, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Elektronski naslov', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "email".tr, ), ), ), @@ -68,9 +72,9 @@ class Login extends StatelessWidget { child: TextField( controller: controller.password1.value, obscureText: true, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Geslo', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "password".tr, ), ), ), @@ -79,16 +83,17 @@ class Login extends StatelessWidget { ), ElevatedButton( onPressed: controller.login, - child: const Text("Prijava", style: TextStyle(fontSize: 20)), + child: Text("login".tr, style: const TextStyle(fontSize: 20)), ), const SizedBox( height: 20, ), ElevatedButton( - onPressed: () { - Get.toNamed("/registration"); + onPressed: () async { + await Get.toNamed("/registration"); }, - child: const Text("Registracija", style: TextStyle(fontSize: 20)), + child: + Text("registration".tr, style: const TextStyle(fontSize: 20)), ), const SizedBox( height: 20, @@ -108,19 +113,19 @@ class Login extends StatelessWidget { ElevatedButton( onPressed: () async { await storage.write(key: "token", value: "a"); - Get.toNamed("/"); + await Get.toNamed("/"); }, - child: const Text("Gostujoči dostop", - style: TextStyle(fontSize: 20)), + child: Text("guest_access".tr, + style: const TextStyle(fontSize: 20)), ), ElevatedButton.icon( onPressed: () async { await launchUrl(Uri.parse("https://discord.gg/fzeN4Cnbr3")); }, icon: const FaIcon(FontAwesomeIcons.discord), - label: const Text( - "Uradni Discord strežnik", - style: TextStyle( + label: Text( + "official_discord".tr, + style: const TextStyle( fontSize: 20, ), ), @@ -165,20 +170,7 @@ class Login extends StatelessWidget { icon: const FaIcon(FontAwesomeIcons.android), ), ElevatedButton.icon( - onPressed: () => showDialog( - context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('F-Droid'), - content: const Text( - 'F-Droid je alternativna trgovina za Android naprave. Ta trgovina omogoča vsem odprtokodnim aplikacijam, da preko tega vira uporabnikom dostavljajo aplikacije in posodobitve zanje. Ker ta aplikacija še ni odprtokodna, še ni na voljo za prenos v tej trgovini. Seveda pa bo aplikacija popolnoma brezplačna za prenesti, kot tudi za igrati :).'), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: const Text('OK'), - ), - ], - ), - ), + onPressed: () {}, label: const Text( "Android (F-Droid)", style: TextStyle( @@ -208,9 +200,9 @@ class Login extends StatelessWidget { await launchUrl( Uri.parse("https://github.com/mytja/Tarok")); }, - label: const Text( - "Koda", - style: TextStyle( + label: Text( + "source_code".tr, + style: const TextStyle( fontSize: 20, ), ), diff --git a/tarok/lib/login/login_controller.dart b/tarok/lib/login/login_controller.dart index 111dbc6..48604cd 100644 --- a/tarok/lib/login/login_controller.dart +++ b/tarok/lib/login/login_controller.dart @@ -40,33 +40,33 @@ class LoginController extends GetxController { if (response.statusCode != 200) { if (response.statusCode == 403) { Get.snackbar( - "Težava s prijavo v vaš uporabniški profil", - "Vaš uporabniški profil ni še bil aktiviran ali pa ga je administrator zaklenil.", + "account_login_403".tr, + "account_login_403_desc".tr, ); return; } Get.snackbar( - "Neznana napaka pri prijavi", - "Prosimo, ponovno preverite prijavne podatke.", + "account_login_unknown_error".tr, + "account_login_unknown_error_desc".tr, ); return; } final data = jsonDecode(response.data); await storage.write(key: "token", value: data["token"]); await storage.write(key: "role", value: data["role"]); - Get.toNamed("/"); + await Get.toNamed("/"); } Future register() async { if (password1.value.text != password2.value.text) { Get.dialog( AlertDialog( - title: const Text('Gesli se ne ujemata'), + title: Text("password_mismatch".tr), content: const SizedBox(), actions: [ TextButton( onPressed: () => Get.back(), - child: const Text('OK'), + child: Text("ok".tr), ), ], ), @@ -88,10 +88,10 @@ class LoginController extends GetxController { }), ); if (response.statusCode != 201) return; - Get.toNamed("/login"); + await Get.toNamed("/login"); Get.snackbar( - "Registracija", - "Registracija je bila uspešna. Na vaš elektronski naslov bi moralo priti sporočilo z registracijsko kodo. Dokler ne aktivirate računa, se ne boste mogli prijaviti", + "registration".tr, + "registration_success".tr, ); } diff --git a/tarok/lib/login/register.dart b/tarok/lib/login/register.dart index 4348c32..86d2381 100644 --- a/tarok/lib/login/register.dart +++ b/tarok/lib/login/register.dart @@ -13,9 +13,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import 'dart:io'; - -import 'package:draggable_widget/draggable_widget.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tarok/login/login_controller.dart'; @@ -28,20 +25,27 @@ class Register extends StatelessWidget { LoginController controller = Get.put(LoginController()); return Scaffold( - appBar: !(Platform.isAndroid || Platform.isIOS || isWebMobile) - ? AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Palčka"), - ) - : null, + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Text("palcka".tr), + automaticallyImplyLeading: false, + actions: [ + IconButton( + icon: const Icon(Icons.settings), + onPressed: () async { + await Get.toNamed("/settings"); + }, + ), + ], + ), body: Center( child: ListView( shrinkWrap: true, padding: const EdgeInsets.all(20.0), children: [ - const Text( - "Registracija", - style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), + Text( + "registration".tr, + style: const TextStyle(fontSize: 45, fontWeight: FontWeight.bold), ), const SizedBox( height: 20, @@ -50,9 +54,9 @@ class Register extends StatelessWidget { width: 350, child: TextField( controller: controller.email.value, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Elektronski naslov', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "email".tr, ), ), ), @@ -63,9 +67,9 @@ class Register extends StatelessWidget { width: 350, child: TextField( controller: controller.name.value, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Ime profila', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "profile_name".tr, ), ), ), @@ -77,9 +81,9 @@ class Register extends StatelessWidget { child: TextField( controller: controller.password1.value, obscureText: true, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Geslo', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "password".tr, ), ), ), @@ -91,9 +95,9 @@ class Register extends StatelessWidget { child: TextField( controller: controller.password2.value, obscureText: true, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Ponovite geslo', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: "repeat_password".tr, ), ), ), @@ -115,16 +119,16 @@ class Register extends StatelessWidget { ), ElevatedButton( onPressed: controller.register, - child: const Text("Registracija", style: TextStyle(fontSize: 20)), + child: Text("register".tr, style: const TextStyle(fontSize: 20)), ), const SizedBox( height: 20, ), ElevatedButton( - onPressed: () { - Get.toNamed("/login"); + onPressed: () async { + await Get.toNamed("/login"); }, - child: const Text("Prijava", style: TextStyle(fontSize: 20)), + child: Text("login".tr, style: const TextStyle(fontSize: 20)), ), ], ), diff --git a/tarok/lib/main.dart b/tarok/lib/main.dart index 6071758..45b891c 100644 --- a/tarok/lib/main.dart +++ b/tarok/lib/main.dart @@ -24,6 +24,7 @@ import 'package:tarok/about.dart'; import 'package:tarok/admin/users.dart'; import 'package:tarok/constants.dart'; import 'package:tarok/game/game.dart'; +import 'package:tarok/internationalization/languages.dart'; import 'package:tarok/lobby/friends.dart'; import 'package:tarok/lobby/lobby.dart'; import 'package:tarok/lobby/replays.dart'; @@ -46,6 +47,7 @@ void main() async { // } //}); MediaKit.ensureInitialized(); + final SharedPreferences prefs = await SharedPreferences.getInstance(); PRIREDI_IGRO = prefs.getBool("priredi_igro") ?? false; GARANTIRAN_ZARUF = prefs.getBool("garantiran_zaruf") ?? false; @@ -66,6 +68,9 @@ void main() async { SOUNDS_ENABLED = prefs.getBool("sounds") ?? true; DEVELOPER_MODE = prefs.getBool("developer_mode") ?? false; + String? locale = prefs.getString("locale"); + parseLocale(locale); + SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, @@ -86,12 +91,15 @@ void main() async { runApp( GetMaterialApp( - title: 'Palčka', + title: "palcka".tr, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, brightness: Brightness.light, ), + translations: Messages(), + locale: LOCALE, + fallbackLocale: const Locale('sl', 'SI'), initialRoute: initialRoute, getPages: [ GetPage(name: '/', page: () => const Lobby()), @@ -126,36 +134,36 @@ void main() async { return const Center(child: CircularProgressIndicator()); } if (snapshot.data == true) { - return const Center( + return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon( + const Icon( Icons.check, color: Colors.green, size: 100, ), Text( - "Uporabniški profil je bil uspešno potrjen.", - style: TextStyle(fontSize: 35), + "account_confirmed".tr, + style: const TextStyle(fontSize: 35), ), ], )); } - return const Center( + return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon( + const Icon( Icons.cancel, color: Colors.red, size: 100, ), Text( - "Uporabniški profil ni bil potrjen.", - style: TextStyle(fontSize: 30), + "account_not_confirmed".tr, + style: const TextStyle(fontSize: 30), ), ], )); diff --git a/tarok/lib/replay.dart b/tarok/lib/replay.dart index dc4a5c9..180e641 100644 --- a/tarok/lib/replay.dart +++ b/tarok/lib/replay.dart @@ -58,7 +58,7 @@ Future joinReplay(String url) async { Map s = jsonDecode(r); String gameId = s["replayId"].toString(); String players = s["playerCount"].toString(); - Get.toNamed("/game", parameters: { + await Get.toNamed("/game", parameters: { "playing": players, "gameId": gameId, "bots": "false", diff --git a/tarok/lib/settings.dart b/tarok/lib/settings.dart index 2c94a64..66b512e 100644 --- a/tarok/lib/settings.dart +++ b/tarok/lib/settings.dart @@ -34,7 +34,7 @@ class _SettingsState extends State { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Nastavitve"), + title: Text("settings".tr), leading: IconButton( icon: const Icon(Icons.close), onPressed: () async { @@ -45,7 +45,7 @@ class _SettingsState extends State { body: SettingsList( sections: [ SettingsSection( - title: const Text('Izgled'), + title: Text("appearance".tr), tiles: [ SettingsTile.switchTile( onToggle: (value) async { @@ -61,15 +61,52 @@ class _SettingsState extends State { }, initialValue: THEME == "dark", leading: const Icon(Icons.dark_mode), - title: const Text('Temni način'), - description: const Text( - "Uporabi temni način", + title: Text("dark_mode".tr), + description: Text("use_dark_mode".tr), + ), + ], + ), + SettingsSection( + title: Text("language".tr), + tiles: [ + SettingsTile( + leading: Radio( + value: const Locale("en", "US"), + groupValue: LOCALE, + onChanged: (Locale? value) async { + if (value == null) return; + LOCALE = value; + final SharedPreferences prefs = + await SharedPreferences.getInstance(); + await prefs.setString( + "locale", "${value.languageCode}_${value.countryCode}"); + Get.updateLocale(LOCALE); + setState(() {}); + }, ), + title: const Text("English (United States)"), + ), + SettingsTile( + leading: Radio( + value: const Locale("sl", "SI"), + groupValue: LOCALE, + onChanged: (Locale? value) async { + if (value == null) return; + LOCALE = value; + final SharedPreferences prefs = + await SharedPreferences.getInstance(); + await prefs.setString( + "locale", "${value.languageCode}_${value.countryCode}"); + Get.updateLocale(LOCALE); + setState(() {}); + }, + ), + title: const Text("slovenščina (Slovenija)"), ), ], ), SettingsSection( - title: const Text('Zvok'), + title: Text("sound".tr), tiles: [ SettingsTile.switchTile( onToggle: (value) async { @@ -81,21 +118,15 @@ class _SettingsState extends State { }, initialValue: SOUNDS_ENABLED, leading: const Icon(Icons.music_note), - title: const Text('Zvočni efekti'), - description: const Text( - "Vklopi zvočne efekte", - ), + title: Text("sound_effects".tr), + description: Text("sound_effects_desc".tr), ), ], ), SettingsSection( - title: const Text('Modifikacije'), + title: Text("modifications".tr), tiles: [ - const CustomSettingsTile( - child: Text( - "Če želite izzive lahko prilagodite naslednje opcije.", - ), - ), + CustomSettingsTile(child: Text("modifications_desc".tr)), SettingsTile.switchTile( onToggle: (value) async { final SharedPreferences prefs = @@ -107,10 +138,8 @@ class _SettingsState extends State { }, initialValue: OMOGOCI_STOCKSKIS_PREDLOGE, leading: const Icon(Icons.smart_toy), - title: const Text('StockŠkis predlogi'), - description: const Text( - "StockŠkis vam predlaga igre pri licitiranju. Če to izklopite, ne boste več dobivali predlogov.", - ), + title: Text("stockskis_recommendations".tr), + description: Text("stockskis_recommendations_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -123,10 +152,8 @@ class _SettingsState extends State { }, initialValue: NAPOVEDAN_MONDFANG, leading: const Icon(Icons.timeline), - title: const Text('Napovedan mondfang'), - description: const Text( - "Mondfang se da napovedati.", - ), + title: Text("predicted_mondfang".tr), + description: Text("predicted_mondfang_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -138,10 +165,8 @@ class _SettingsState extends State { }, initialValue: SLEPI_TAROK, leading: const Icon(Icons.blind), - title: const Text('Slepi tarok'), - description: const Text( - "Odigrajte igro ne da bi videli kaj je bilo v štihu. Deluje samo v igrah z boti.", - ), + title: Text("blind_tarock".tr), + description: Text("blind_tarock_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -153,10 +178,8 @@ class _SettingsState extends State { }, initialValue: SKISFANG, leading: const Icon(Icons.timeline), - title: const Text('Škisfang'), - description: const Text( - "-100 za izgubljenega škisa. Deluje samo v igrah z boti.", - ), + title: Text("skisfang".tr), + description: Text("skisfang_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -169,10 +192,8 @@ class _SettingsState extends State { }, initialValue: AVTOPOTRDI_ZALOZITEV, leading: const Icon(Icons.precision_manufacturing), - title: const Text('Avtopotrdi založitev'), - description: const Text( - "Avtopotrdite založitev. To vklopite samo če res veste kaj delate in se ne morete zaklikati.", - ), + title: Text("autoconfirm_stash".tr), + description: Text("autoconfirm_stash_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -184,10 +205,8 @@ class _SettingsState extends State { }, initialValue: AVTOLP, leading: const Icon(Icons.waving_hand), - title: const Text('Avtomatični lep pozdrav'), - description: const Text( - "lp", - ), + title: Text("autogreet".tr), + description: Text("autogreet_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -199,23 +218,15 @@ class _SettingsState extends State { }, initialValue: PREMOVE, leading: const Icon(Icons.history), - title: const Text('Premove'), - description: const Text( - "Premovaj karto", - ), + title: Text("premove".tr), + description: Text("premove_desc".tr), ), ], ), SettingsSection( - title: const Text('Razvijalske opcije'), + title: Text("developer_options".tr), tiles: [ - const CustomSettingsTile( - child: Text( - "Te opcije so namenjene predvsem razvijalcem programa Palčka.si. Mogoče so komu v izziv ali pa malo tako za zabavo, " - "tako da jih puščam tukaj na voljo vsem :)." - "Te opcije delujejo samo na lokalnih igrah z boti. Nekatere nastavitve so nekompatibilne med sabo.", - ), - ), + CustomSettingsTile(child: Text("developer_options_desc".tr)), SettingsTile.switchTile( onToggle: (value) async { final SharedPreferences prefs = @@ -226,10 +237,8 @@ class _SettingsState extends State { }, initialValue: DEVELOPER_MODE, leading: const Icon(Icons.code), - title: const Text('Način za razvijalce'), - description: const Text( - "Vklopi še dodatna razvijalska orodja", - ), + title: Text("developer_mode".tr), + description: Text("developer_mode_desc".tr), ), if (!BARVIC && !BERAC) SettingsTile.switchTile( @@ -243,12 +252,10 @@ class _SettingsState extends State { initialValue: PRIREDI_IGRO, leading: const Text( "🤫", - style: TextStyle(fontSize: 30), - ), - title: const Text('Priredi igro'), - description: const Text( - "V roke dobite kar dosti visokih tarokov. Odlična stvar za valata ;).", + style: TextStyle(fontSize: 28), ), + title: Text("falsify_game".tr), + description: Text("falsify_game_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -260,10 +267,8 @@ class _SettingsState extends State { }, initialValue: GARANTIRAN_ZARUF, leading: const Icon(Icons.casino), - title: const Text('Garantiran zaruf'), - description: const Text( - "Le kako so se vsi kralji pojavili v talonu. Čudno naključje.", - ), + title: Text("guaranteed_zaruf".tr), + description: Text("guaranteed_zaruf_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -275,10 +280,8 @@ class _SettingsState extends State { }, initialValue: MOND_V_TALONU, leading: const Icon(Icons.casino), - title: const Text('Mond v talonu'), - description: const Text( - "Potem pa pridemo do enega manjšega problemčka ...", - ), + title: Text("mond_in_talon".tr), + description: Text("mond_in_talon_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -290,10 +293,8 @@ class _SettingsState extends State { }, initialValue: SKIS_V_TALONU, leading: const Icon(Icons.trending_down), - title: const Text('Škis v talonu'), - description: const Text( - "Mogoče je škis v talonu (vedno) ... Nič ne vem o tem.", - ), + title: Text("skis_in_talon".tr), + description: Text("skis_in_talon_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -305,10 +306,8 @@ class _SettingsState extends State { }, initialValue: ODPRTE_IGRE, leading: const Icon(Icons.visibility), - title: const Text('Odprte igre'), - description: const Text( - "Mogoče sem čisto malo pokukal v karte drugih, nič takega ...", - ), + title: Text("open_games".tr), + description: Text("open_games_desc".tr), ), if (!PRIREDI_IGRO && !BERAC) SettingsTile.switchTile( @@ -321,10 +320,8 @@ class _SettingsState extends State { }, initialValue: BARVIC, leading: const Icon(Icons.palette), - title: const Text('Barvni valat'), - description: const Text( - "Barvič, samo da drobceno prirejen.", - ), + title: Text("color_valat".tr), + description: Text("color_valat_desc".tr), ), if (!PRIREDI_IGRO && !BARVIC) SettingsTile.switchTile( @@ -337,10 +334,8 @@ class _SettingsState extends State { }, initialValue: BERAC, leading: const Icon(Icons.money_off), - title: const Text('Berač'), - description: const Text( - "Karte za berača.", - ), + title: Text("beggar".tr), + description: Text("beggar_desc".tr), ), SettingsTile.switchTile( onToggle: (value) async { @@ -352,10 +347,8 @@ class _SettingsState extends State { }, initialValue: AUTOSTART_GAME, leading: const Icon(Icons.pan_tool), - title: const Text('Avtomatično začni naslednjo igro'), - description: const Text( - "Če je opcija ugasnjena, se bomo lahko šli samo eno igro ...", - ), + title: Text("autostart_next_game".tr), + description: Text("autostart_next_game_desc".tr), ), ], ), diff --git a/tarok/lib/sounds.dart b/tarok/lib/sounds.dart index 9dec17b..0f44105 100644 --- a/tarok/lib/sounds.dart +++ b/tarok/lib/sounds.dart @@ -15,7 +15,6 @@ import 'dart:math'; -import 'package:flutter/foundation.dart'; import 'package:media_kit/media_kit.dart'; import 'package:tarok/constants.dart'; @@ -29,9 +28,9 @@ class Sounds { int r = Random().nextInt(2); final Media playable; if (r == 0) { - playable = Media('${kIsWeb ? "assets/" : ""}assets/zvoki/karta.ogg'); + playable = Media('asset:///assets/zvoki/karta.ogg'); } else { - playable = Media('${kIsWeb ? "assets/" : ""}assets/zvoki/karta2.mp3'); + playable = Media('asset:///assets/zvoki/karta2.mp3'); } await player.open(playable); } @@ -40,7 +39,7 @@ class Sounds { if (!SOUNDS_ENABLED) { return; } - final playable = Media('${kIsWeb ? "assets/" : ""}assets/zvoki/click1.wav'); + final playable = Media('asset:///assets/zvoki/click1.wav'); await player.open(playable); } @@ -48,8 +47,7 @@ class Sounds { if (!SOUNDS_ENABLED) { return; } - final playable = - Media('${kIsWeb ? "assets/" : ""}assets/zvoki/notification1.mp3'); + final playable = Media('asset:///assets/zvoki/notification1.mp3'); await player.open(playable); } } diff --git a/tarok/lib/ui/main_page.dart b/tarok/lib/ui/main_page.dart index c6db712..106e442 100644 --- a/tarok/lib/ui/main_page.dart +++ b/tarok/lib/ui/main_page.dart @@ -33,6 +33,7 @@ class PalckaHome extends StatelessWidget { @override Widget build(BuildContext context) { LobbyController controller = Get.put(LobbyController()); + return Scaffold( drawer: Drawer( child: Obx( @@ -43,9 +44,9 @@ class PalckaHome extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context).primaryColor, ), - child: const Text( - 'Palčka.si tarok program', - style: TextStyle( + child: Text( + "palcka".tr, + style: const TextStyle( color: Colors.white, fontSize: 24, ), @@ -53,28 +54,30 @@ class PalckaHome extends StatelessWidget { ), ListTile( leading: const Icon(Icons.home), - title: const Text('Domov'), - onTap: () { - Get.toNamed("/"); - }, - ), - ListTile( - leading: const Icon(Icons.people), - title: const Text('Prijatelji'), - onTap: () { - Get.toNamed("/friends"); - }, - ), - ListTile( - leading: const Icon(Icons.replay), - title: const Text('Posnetki iger'), - onTap: () { - Get.toNamed("/replays"); + title: Text("home".tr), + onTap: () async { + await Get.toNamed("/"); }, ), + if (!controller.guest.value) + ListTile( + leading: const Icon(Icons.people), + title: Text("friends".tr), + onTap: () async { + await Get.toNamed("/friends"); + }, + ), + if (!controller.guest.value) + ListTile( + leading: const Icon(Icons.replay), + title: Text("replays".tr), + onTap: () async { + await Get.toNamed("/replays"); + }, + ), ListTile( leading: const FaIcon(FontAwesomeIcons.discord), - title: const Text('Discord strežnik'), + title: Text("discord".tr), onTap: () async { await launchUrl(Uri.parse("https://discord.gg/fzeN4Cnbr3")); }, @@ -83,30 +86,31 @@ class PalckaHome extends StatelessWidget { if (controller.isAdmin.value) ListTile( leading: const Icon(Icons.account_box), - title: const Text('Uporabniki'), - onTap: () { - Get.toNamed("/users"); + title: Text("users".tr), + onTap: () async { + await Get.toNamed("/users"); }, ), /*if (controller.isAdmin.value) ListTile( leading: const Icon(Icons.admin_panel_settings), title: const Text('Administratorske nastavitve'), - onTap: () { - Get.toNamed("/admin"); + onTap: () async { + await Get.toNamed("/admin"); }, ),*/ const Divider(), - ListTile( - leading: const Icon(Icons.account_circle), - title: const Text('Uporabniški profil'), - onTap: () async { - Get.toNamed("/profile"); - }, - ), + if (!controller.guest.value) + ListTile( + leading: const Icon(Icons.account_circle), + title: Text("profile".tr), + onTap: () async { + await Get.toNamed("/profile"); + }, + ), ListTile( leading: const Icon(Icons.logout), - title: const Text('Odjava'), + title: Text("logout".tr), onTap: () async { await logout(); }, @@ -117,18 +121,18 @@ class PalckaHome extends StatelessWidget { ), appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Palčka"), + title: Text("palcka".tr), actions: [ IconButton( icon: const Icon(Icons.settings), onPressed: () async { - Get.toNamed("/settings"); + await Get.toNamed("/settings"); }, ), IconButton( icon: const Icon(Icons.info), onPressed: () async { - Get.toNamed("/about"); + await Get.toNamed("/about"); }, ), IconButton( diff --git a/tarok/lib/user/user.dart b/tarok/lib/user/user.dart index f2385f9..791e909 100644 --- a/tarok/lib/user/user.dart +++ b/tarok/lib/user/user.dart @@ -70,47 +70,40 @@ class Profile extends StatelessWidget { controller.user.value.name; Get.dialog( AlertDialog( - title: const Text("Zamenjava imena"), - content: IntrinsicHeight( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - const Text( - "Zamenjava imena je brezplačna in prosto dostopna vsem.", - ), - const Text( - "V primeru neprimernega imena, bodo administratorji spremenili ime, uporabniku pa se lahko po večkratnih kršitvah zakleni uporabniški račun.", - ), - Text( - "Vaše trenutno uporabniško ime je: ${controller.user.value.name}", - ), - TextField( - controller: - controller.nameController.value, - ) - ], - ), + scrollable: true, + title: Text("name_change".tr), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("change_of_name_desc1".tr), + Text("change_of_name_desc2".tr), + Text("change_of_name_desc3".trParams( + {"name": controller.user.value.name})), + TextField( + controller: + controller.nameController.value, + ), + ], ), actions: [ TextButton( onPressed: () { Get.back(); }, - child: const Text("Prekliči"), + child: Text("cancel".tr), ), TextButton( onPressed: () async { await controller.changeName(); Get.back(); }, - child: const Text("Spremeni"), + child: Text("change".tr), ), ], ), ); }, - child: const Text("Sprememba imena"), + child: Text("name_change".tr), ), ], ), @@ -123,13 +116,11 @@ class Profile extends StatelessWidget { ElevatedButton( onPressed: () { Get.defaultDialog( - title: "Zamenjava elektronskega naslova", - content: const Text( - "Zaradi možne zlorabe ne ponujamo menjave elektronskega naslova direktno prek uporabniškega vmesnika. Kontaktirajte razvijalca na info@palcka.si ali na Discordu (@mytja).", - ), + title: "change_of_email".tr, + content: Text("change_of_email_desc".tr), ); }, - child: const Text("Sprememba elektronskega naslova"), + child: Text("change_of_email".tr), ), ], ), @@ -142,8 +133,10 @@ class Profile extends StatelessWidget { ), Row( children: [ - const Text("Število odigranih iger: ", - style: TextStyle(fontSize: 20)), + Text( + "number_of_played_games".tr, + style: const TextStyle(fontSize: 20), + ), Text( controller.user.value.playedGames.toString(), style: const TextStyle( @@ -155,8 +148,10 @@ class Profile extends StatelessWidget { ), Row( children: [ - const Text("Uporabniški profil registriran: ", - style: TextStyle(fontSize: 20)), + Text( + "user_profile_registered".tr, + style: const TextStyle(fontSize: 20), + ), Text( controller.user.value.registeredOn, style: const TextStyle( @@ -168,7 +163,7 @@ class Profile extends StatelessWidget { ), Row( children: [ - const Text("Vloga v sistemu: ", style: TextStyle(fontSize: 20)), + Text("role_in_system".tr, style: const TextStyle(fontSize: 20)), Text( controller.user.value.role, style: const TextStyle( @@ -190,31 +185,27 @@ class Profile extends StatelessWidget { Get.dialog( AlertDialog( scrollable: true, - title: const Text("Sprememba gesla"), + title: Text("change_of_password".tr), content: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - "Izberite si dobro geslo. Program vas bo zaradi varnosti izpisal/odjavil po uspešni spremembi gesla.", - ), - const Text( - "V primeru, da se ne zgodi nič po kliku na Spremeni, ste se mogoče zatipkali pri novem ali starem geslu..", - ), + Text("change_of_password_desc1".tr), + Text("change_of_password_desc2".tr), TextField( decoration: - const InputDecoration(hintText: 'Staro geslo'), + InputDecoration(hintText: 'old_password'.tr), obscureText: true, controller: controller.oldPasswordController.value, ), TextField( decoration: - const InputDecoration(hintText: 'Novo geslo'), + InputDecoration(hintText: 'new_password'.tr), obscureText: true, controller: controller.newPasswordController.value, ), TextField( - decoration: const InputDecoration( - hintText: 'Ponovite novo geslo'), + decoration: InputDecoration( + hintText: 'confirm_new_password'.tr), obscureText: true, controller: controller.newPasswordControllerValidate.value, @@ -226,19 +217,19 @@ class Profile extends StatelessWidget { onPressed: () { Get.back(); }, - child: const Text("Prekliči"), + child: Text("cancel".tr), ), TextButton( onPressed: () async { await controller.changePassword(); }, - child: const Text("Spremeni"), + child: Text("change".tr), ), ], ), ); }, - child: const Text("Sprememba gesla"), + child: Text("change_of_password".tr), ), ), ],