From d8fe89ba56642fdc80f2017bedea49e11992dee4 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 10 Mar 2021 23:32:23 +0100 Subject: [PATCH] Move translations to new i18n approach --- lib/helpers/ui.dart | 2 +- lib/l10n.README | 1 + lib/l10n.yaml | 3 + lib/l10n/{intl_de.arb => app_de.arb} | 0 lib/l10n/app_en.arb | 135 +++++ lib/l10n/intl_en.arb | 15 - lib/l10n/intl_messages.arb | 75 --- lib/l10n/messages_all.dart | 71 --- lib/l10n/messages_de.dart | 27 - lib/l10n/messages_en.dart | 27 - lib/l10n/messages_messages.dart | 30 -- lib/locale/README.txt | 7 - lib/locale/locales.dart | 466 ------------------ lib/main.dart | 16 +- lib/screens/dashboard.dart | 2 +- lib/screens/nutritional_plan_screen.dart | 2 +- lib/screens/nutritional_plans_screen.dart | 2 +- lib/screens/weight_screen.dart | 2 +- lib/screens/workout_plan_screen.dart | 2 +- lib/screens/workout_plans_screen.dart | 2 +- lib/widgets/app_drawer.dart | 2 +- lib/widgets/dashboard/calendar.dart | 2 +- lib/widgets/dashboard/widgets.dart | 2 +- lib/widgets/nutrition/charts.dart | 2 +- lib/widgets/nutrition/forms.dart | 2 +- lib/widgets/nutrition/meal.dart | 2 +- .../nutrition/nutritional_plan_detail.dart | 2 +- lib/widgets/weight/entries_list.dart | 2 +- lib/widgets/weight/forms.dart | 2 +- lib/widgets/workouts/day.dart | 2 +- lib/widgets/workouts/forms.dart | 2 +- lib/widgets/workouts/gym_mode.dart | 2 +- lib/widgets/workouts/workout_plan_detail.dart | 2 +- pubspec.yaml | 2 + 34 files changed, 164 insertions(+), 751 deletions(-) create mode 100644 lib/l10n.README create mode 100644 lib/l10n.yaml rename lib/l10n/{intl_de.arb => app_de.arb} (100%) create mode 100644 lib/l10n/app_en.arb delete mode 100644 lib/l10n/intl_en.arb delete mode 100644 lib/l10n/intl_messages.arb delete mode 100644 lib/l10n/messages_all.dart delete mode 100644 lib/l10n/messages_de.dart delete mode 100644 lib/l10n/messages_en.dart delete mode 100644 lib/l10n/messages_messages.dart delete mode 100644 lib/locale/README.txt delete mode 100644 lib/locale/locales.dart diff --git a/lib/helpers/ui.dart b/lib/helpers/ui.dart index a7eeb719..a8b006dd 100644 --- a/lib/helpers/ui.dart +++ b/lib/helpers/ui.dart @@ -19,7 +19,7 @@ import 'dart:developer'; import 'package:flutter/material.dart'; -import 'package:wger/locale/locales.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:wger/models/http_exception.dart'; void showErrorDialog(dynamic exception, BuildContext context) { diff --git a/lib/l10n.README b/lib/l10n.README new file mode 100644 index 00000000..e56a60bb --- /dev/null +++ b/lib/l10n.README @@ -0,0 +1 @@ +flutter gen-l10n \ No newline at end of file diff --git a/lib/l10n.yaml b/lib/l10n.yaml new file mode 100644 index 00000000..4e6692e5 --- /dev/null +++ b/lib/l10n.yaml @@ -0,0 +1,3 @@ +arb-dir: lib/l10n +template-arb-file: app_en.arb +output-localization-file: app_localizations.dart \ No newline at end of file diff --git a/lib/l10n/intl_de.arb b/lib/l10n/app_de.arb similarity index 100% rename from lib/l10n/intl_de.arb rename to lib/l10n/app_de.arb diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb new file mode 100644 index 00000000..f243df8d --- /dev/null +++ b/lib/l10n/app_en.arb @@ -0,0 +1,135 @@ +{ + "@@last_modified": "2020-11-11T15:04:05.523531", + "labelWorkoutPlans": "Workout plans", + "@labelWorkoutPlans": { + "description": "Title for screen workout plans" + }, + "labelWorkoutPlan": "Workout plan", + "@labelWorkoutPlan": { + "description": "Title for screen workout plan" + }, + "labelDashboard": "Dashboard", + "@labelDashboard": { + "description": "Title for screen dashboard" + }, + "successfullyDeleted": "Successfully deleted", + "@successfullyDeleted": { + "description": "Message when an item was successfully deleted" + }, + "exercise": "Exercise", + "@exercise": { + "description": "An exercise for a workout" + }, + "newWorkout": "New Workout", + "@newWorkout": { + "description": "Header when adding a new workout" + }, + "repetitions": "Repetitions", + "@repetitions": { + "description": "Repetitions for an exercise set" + }, + "rir": "RiR", + "@rir": { + "description": "Shorthand for Repetitions In Reserve" + }, + "comment": "Comment", + "@comment": { + "description": "Comment, additional information" + }, + "impression": "Impression", + "@impression": { + "description": "General impression (e.g. for a workout session) such as good, bad, etc." + }, + "notes": "Notes", + "@notes": { + "description": "Personal notes, e.g. for a workout session" + }, + "workoutSession": "Workout session", + "@workoutSession": { + "description": "A (logged) workout session" + }, + "newDay": "New day", + "newSet": "New set", + "@newSet": { + "description": "Header when adding a new set to a workout day" + }, + "description": "Description", + "save": "Description", + "cancel": "Cancel", + "add": "Add", + "addMeal": "Add meal", + "mealLogged": "Meal was successfully logged to diary", + "addIngredient": "Add ingredient", + "nutritionalPlan": "Nutritional plan", + "nutritionalDiary": "Nutritional diary", + "nutritionalPlans": "Nutritional plans", + "anErrorOccurred": "An Error Occurred!", + "dismiss": "Dismiss", + "weight": "Weight", + "@weight": { + "description": "The weight of a workout log or body weight entry" + }, + "date": "Date", + "@date": { + "description": "The date of a workout log or body weight entry" + }, + "time": "Time", + "@time": { + "description": "The time of a meal or workout" + }, + "timeStart": "Start time", + "@timeStart": { + "description": "The starting time of a workout" + }, + "timeEnd": "End time", + "@timeEnd": { + "description": "The end time of a workout" + }, + "ingredient": "Ingredient", + "energy": "Energy", + "@energy": { + "description": "Energy in a meal, ingredient etc. e.g. in kJ" + }, + "kcal": "kcal", + "@kcal": { + "description": "Energy in a meal in kilocalories, kcal" + }, + "kJ": "kJ", + "@kJ": { + "description": "Energy in a meal in kilo joules, kJ" + }, + "g": "g", + "@g": { + "description": "Abbreviation for gram" + }, + "protein": "Protein", + "carbohydrates": "Carbohydrates", + "sugars": "Sugars", + "fat": "Fat", + "saturatedFat": "Saturated fat", + "fibres": "Fibres", + "sodium": "Sodium", + "amount": "Amount", + "@amount": { + "description": "The amount (e.g. in grams) of an ingredient in a meal" + }, + "newEntry": "New entry", + "@newEntry": { + "description": "Title when adding a new entry such as a weight or log entry" + }, + "edit": "Edit", + "loadingText": "Loading...", + "@loadingText": { + "description": "Text to show when entries are being loaded in the background: Loading..." + }, + "delete": "Delete", + "newNutritionalPlan": "New nutritional plan", + "toggleDetails": "Toggle details", + "@toggleDetails": { + "description": "Switch to toggle detail / overview" + }, + "aboutText": "wger Workout Manager is free, open source (FLOSS) software released under the GNU General Public version 3 or later. The code is freely available on github:", + "@aboutText": { + "description": "Text in the about dialog" + } +} \ No newline at end of file diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb deleted file mode 100644 index e0abcd23..00000000 --- a/lib/l10n/intl_en.arb +++ /dev/null @@ -1,15 +0,0 @@ -{ - "@@last_modified": "2020-11-11T15:04:05.523531", - "labelWorkoutPlans": "Workout plans", - "@labelWorkoutPlans": { - "description": "Title for screen workout plans", - "type": "text", - "placeholders": {} - }, - "labelWorkoutPlan": "Workout plan", - "@labelWorkoutPlan": { - "description": "Title for screen workout plan", - "type": "text", - "placeholders": {} - } -} \ No newline at end of file diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb deleted file mode 100644 index 129bc28e..00000000 --- a/lib/l10n/intl_messages.arb +++ /dev/null @@ -1,75 +0,0 @@ -{ - "@@last_modified": "2020-12-05T11:28:38.887425", - "labelWorkoutPlans": "Workout plans", - "@labelWorkoutPlans": { - "description": "Title for screen workout plans", - "type": "text", - "placeholders": {} - }, - "newWorkout": "New Workout", - "@newWorkout": { - "description": "Header when adding a new workout", - "type": "text", - "placeholders": {} - }, - "newDay": "New day", - "@newDay": { - "description": "Header when adding a new day to a workout", - "type": "text", - "placeholders": {} - }, - "newSet": "New set", - "@newSet": { - "description": "Header when adding a new set to a workout day", - "type": "text", - "placeholders": {} - }, - "description": "Description", - "@description": { - "description": "Description of a workout, nutritional plan, etc.", - "type": "text", - "placeholders": {} - }, - "save": "Save", - "@save": { - "description": "Saving a new entry in the DB", - "type": "text", - "placeholders": {} - }, - "cancel": "Cancel", - "@cancel": { - "description": "Cancelling an action", - "type": "text", - "placeholders": {} - }, - "add": "Add", - "@add": { - "description": "Label for a button etc.", - "type": "text", - "placeholders": {} - }, - "labelWorkoutPlan": "Workout plan", - "@labelWorkoutPlan": { - "description": "Title for screen workout plan", - "type": "text", - "placeholders": {} - }, - "labelDashboard": "Dashboard", - "@labelDashboard": { - "description": "Title for screen dashboard", - "type": "text", - "placeholders": {} - }, - "anErrorOccurred": "An Error Occurred!", - "@anErrorOccurred": { - "description": "Title for error popups", - "type": "text", - "placeholders": {} - }, - "dismiss": "Dismiss", - "@dismiss": { - "description": "Button to close a dialog", - "type": "text", - "placeholders": {} - } -} \ No newline at end of file diff --git a/lib/l10n/messages_all.dart b/lib/l10n/messages_all.dart deleted file mode 100644 index ee060686..00000000 --- a/lib/l10n/messages_all.dart +++ /dev/null @@ -1,71 +0,0 @@ -// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart -// This is a library that looks up messages for specific locales by -// delegating to the appropriate library. - -// Ignore issues from commonly used lints in this file. -// ignore_for_file:implementation_imports, file_names, unnecessary_new -// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering -// ignore_for_file:argument_type_not_assignable, invalid_assignment -// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases -// ignore_for_file:comment_references - -import 'dart:async'; - -import 'package:intl/intl.dart'; -import 'package:intl/message_lookup_by_library.dart'; -import 'package:intl/src/intl_helpers.dart'; - -import 'messages_en.dart' as messages_en; -import 'messages_de.dart' as messages_de; -import 'messages_messages.dart' as messages_messages; - -typedef Future LibraryLoader(); -Map _deferredLibraries = { - 'en': () => new Future.value(null), - 'de': () => new Future.value(null), - 'messages': () => new Future.value(null), -}; - -MessageLookupByLibrary _findExact(String localeName) { - switch (localeName) { - case 'en': - return messages_en.messages; - case 'de': - return messages_de.messages; - case 'messages': - return messages_messages.messages; - default: - return null; - } -} - -/// User programs should call this before using [localeName] for messages. -Future initializeMessages(String localeName) async { - var availableLocale = Intl.verifiedLocale( - localeName, - (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null); - if (availableLocale == null) { - return new Future.value(false); - } - var lib = _deferredLibraries[availableLocale]; - await (lib == null ? new Future.value(false) : lib()); - initializeInternalMessageLookup(() => new CompositeMessageLookup()); - messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); - return new Future.value(true); -} - -bool _messagesExistFor(String locale) { - try { - return _findExact(locale) != null; - } catch (e) { - return false; - } -} - -MessageLookupByLibrary _findGeneratedMessagesFor(String locale) { - var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, - onFailure: (_) => null); - if (actualLocale == null) return null; - return _findExact(actualLocale); -} diff --git a/lib/l10n/messages_de.dart b/lib/l10n/messages_de.dart deleted file mode 100644 index 29fae417..00000000 --- a/lib/l10n/messages_de.dart +++ /dev/null @@ -1,27 +0,0 @@ -// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart -// This is a library that provides messages for a de locale. All the -// messages from the main program should be duplicated here with the same -// function name. - -// Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new -// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering -// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names - -import 'package:intl/intl.dart'; -import 'package:intl/message_lookup_by_library.dart'; - -final messages = new MessageLookup(); - -typedef String MessageIfAbsent(String messageStr, List args); - -class MessageLookup extends MessageLookupByLibrary { - String get localeName => 'de'; - - final messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { - "labelWorkoutPlan" : MessageLookupByLibrary.simpleMessage("Trainingsplan"), - "labelWorkoutPlans" : MessageLookupByLibrary.simpleMessage("Trainingspläne") - }; -} diff --git a/lib/l10n/messages_en.dart b/lib/l10n/messages_en.dart deleted file mode 100644 index a49a1934..00000000 --- a/lib/l10n/messages_en.dart +++ /dev/null @@ -1,27 +0,0 @@ -// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart -// This is a library that provides messages for a en locale. All the -// messages from the main program should be duplicated here with the same -// function name. - -// Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new -// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering -// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names - -import 'package:intl/intl.dart'; -import 'package:intl/message_lookup_by_library.dart'; - -final messages = new MessageLookup(); - -typedef String MessageIfAbsent(String messageStr, List args); - -class MessageLookup extends MessageLookupByLibrary { - String get localeName => 'en'; - - final messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { - "labelWorkoutPlan" : MessageLookupByLibrary.simpleMessage("Workout plan"), - "labelWorkoutPlans" : MessageLookupByLibrary.simpleMessage("Workout plans") - }; -} diff --git a/lib/l10n/messages_messages.dart b/lib/l10n/messages_messages.dart deleted file mode 100644 index bc41aaff..00000000 --- a/lib/l10n/messages_messages.dart +++ /dev/null @@ -1,30 +0,0 @@ -// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart -// This is a library that provides messages for a messages locale. All the -// messages from the main program should be duplicated here with the same -// function name. - -// Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new -// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering -// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names - -import 'package:intl/intl.dart'; -import 'package:intl/message_lookup_by_library.dart'; - -final messages = new MessageLookup(); - -typedef String MessageIfAbsent(String messageStr, List args); - -class MessageLookup extends MessageLookupByLibrary { - String get localeName => 'messages'; - - final messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { - "description" : MessageLookupByLibrary.simpleMessage("description"), - "labelDashboard" : MessageLookupByLibrary.simpleMessage("Dashboard"), - "labelWorkoutPlan" : MessageLookupByLibrary.simpleMessage("Workout plan"), - "labelWorkoutPlans" : MessageLookupByLibrary.simpleMessage("Workout plans"), - "newWorkout" : MessageLookupByLibrary.simpleMessage("new Workout") - }; -} diff --git a/lib/locale/README.txt b/lib/locale/README.txt deleted file mode 100644 index fbb83c6a..00000000 --- a/lib/locale/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -1. Add strings to locales.dart - -2. Extract strings to arb files - flutter pub pub run intl_translation:extract_to_arb --output-dir=lib\l10n lib\locale\locales.dart - -3. Generate dart files (in linux you can do lib/l10n/intl_*.arb) - flutter pub pub run intl_translation:generate_from_arb --output-dir=lib\l10n --no-use-deferred-loading lib/l10n/intl_en.arb lib/l10n/intl_de.arb lib/l10n/intl_messages.arb lib/locale/locales.dart \ No newline at end of file diff --git a/lib/locale/locales.dart b/lib/locale/locales.dart deleted file mode 100644 index 6b919874..00000000 --- a/lib/locale/locales.dart +++ /dev/null @@ -1,466 +0,0 @@ -/* - * This file is part of wger Workout Manager . - * Copyright (C) 2020 wger Team - * - * wger Workout Manager is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wger Workout Manager is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:wger/l10n/messages_all.dart'; - -class AppLocalizations { - static Future load(Locale locale) { - final String name = locale.countryCode.isEmpty ? locale.languageCode : locale.toString(); - final localeName = Intl.canonicalizedLocale(name); - - return initializeMessages(localeName).then((bool _) { - Intl.defaultLocale = localeName; - return AppLocalizations(); - }); - } - - static AppLocalizations of(BuildContext context) { - return Localizations.of(context, AppLocalizations); - } - - String get successfullyDeleted { - return Intl.message( - 'Successfully deleted', - name: 'successfullyDeleted', - desc: 'Message when an item was successfully deleted', - ); - } - - String get labelWorkoutPlans { - return Intl.message( - 'Workout plans', - name: 'labelWorkoutPlans', - desc: 'Title for screen workout plans', - ); - } - - String get exercise { - return Intl.message( - 'Exercise', - name: 'exercise', - desc: 'An exercise for a workout', - ); - } - - String get newWorkout { - return Intl.message( - 'New Workout', - name: 'newWorkout', - desc: 'Header when adding a new workout', - ); - } - - String get repetitions { - return Intl.message( - 'Repetitions', - name: 'repetitions', - desc: 'Repetitions for an exercise set', - ); - } - - String get rir { - return Intl.message( - 'rir', - name: 'RiR', - desc: 'Shorthand for Repetitions In Reserve', - ); - } - - String get comment { - return Intl.message( - 'Comment', - name: 'comment', - desc: 'Comment, additional information', - ); - } - - String get impression { - return Intl.message( - 'Impression', - name: 'impression', - desc: 'General Impression for a workout session (good, bad, etc.)', - ); - } - - String get notes { - return Intl.message( - 'Notes', - name: 'notes', - desc: 'Personal notes for a workout session', - ); - } - - String get workoutSession { - return Intl.message( - 'Workout session', - name: 'workoutSession', - desc: 'A logged workout session', - ); - } - - String get newDay { - return Intl.message( - 'New day', - name: 'newDay', - desc: 'Header when adding a new day to a workout', - ); - } - - String get newSet { - return Intl.message( - 'New set', - name: 'newSet', - desc: 'Header when adding a new set to a workout day', - ); - } - - String get description { - return Intl.message( - 'Description', - name: 'description', - desc: 'Description of a workout, nutritional plan, etc.', - ); - } - - String get save { - return Intl.message( - 'Save', - name: 'save', - desc: 'Saving a new entry in the DB', - ); - } - - String get cancel { - return Intl.message( - 'Cancel', - name: 'cancel', - desc: 'Cancelling an action', - ); - } - - String get add { - return Intl.message( - 'Add', - name: 'add', - desc: 'Label for a button etc.', - ); - } - - String get addMeal { - return Intl.message( - 'Add meal', - name: 'addMeal', - desc: 'Header for form or label for button', - ); - } - - String get mealLogged { - return Intl.message( - 'Meal was successfully logged to diary', - name: 'mealLogged', - desc: 'Info message after logging a meal', - ); - } - - String get addIngredient { - return Intl.message( - 'Add ingredient', - name: 'addIngredient', - desc: 'Label for button to add a new ingredient to a meal', - ); - } - - String get labelWorkoutPlan { - return Intl.message( - 'Workout plan', - name: 'labelWorkoutPlan', - desc: 'Title for screen workout plan', - ); - } - - String get nutritionalPlan { - return Intl.message( - 'Nutritional plan', - name: 'nutritionalPlan', - desc: 'Title for screen nutritional plan', - ); - } - - String get nutritionalDiary { - return Intl.message( - 'Nutritional diary', - name: 'nutritionalDiary', - desc: 'The nutritional diary for a plan', - ); - } - - String get nutritionalPlans { - return Intl.message( - 'Nutritional plans', - name: 'nutritionalPlans', - desc: 'Title for screen nutritional plans overview', - ); - } - - String get labelDashboard { - return Intl.message( - 'Dashboard', - name: 'labelDashboard', - desc: 'Title for screen dashboard', - ); - } - - String get anErrorOccurred { - return Intl.message( - 'An Error Occurred!', - name: 'anErrorOccurred', - desc: 'Title for error popups', - ); - } - - String get dismiss { - return Intl.message( - 'Dismiss', - name: 'dismiss', - desc: 'Button to close a dialog', - ); - } - - String get weight { - return Intl.message( - 'Weight', - name: 'weight', - desc: 'The weight of a workout log or body weight entry', - ); - } - - String get date { - return Intl.message( - 'Date', - name: 'date', - desc: 'The date of a workout log or body weight entry', - ); - } - - String get time { - return Intl.message( - 'Time', - name: 'time', - desc: 'The time of a meal or workout', - ); - } - - String get timeStart { - return Intl.message( - 'Start time', - name: 'timeStart', - desc: 'The starting time of a workout', - ); - } - - String get timeEnd { - return Intl.message( - 'End time', - name: 'timeEnd', - desc: 'The end time of a workout', - ); - } - - String get ingredient { - return Intl.message( - 'Ingredient', - name: 'ingredient', - desc: 'An ingredient', - ); - } - - String get energy { - return Intl.message( - 'Energy', - name: 'energy', - desc: 'Energy in a meal, e.g. in kJ', - ); - } - - String get kcal { - return Intl.message( - 'kcal', - name: 'kcal', - desc: 'Energy in a meal in kilocalories, kcal', - ); - } - - String get kj { - return Intl.message( - 'kJ', - name: 'kj', - desc: 'Energy in a meal in kilo joules, kJ', - ); - } - - String get g { - return Intl.message( - 'g', - name: 'g', - desc: 'Abbreviation for gram', - ); - } - - String get protein { - return Intl.message( - 'Protein', - name: 'protein', - desc: 'Protein content', - ); - } - - String get carbohydrates { - return Intl.message( - 'Carbohydrates', - name: 'carbohydrates', - desc: 'Carbohydrates content', - ); - } - - String get sugars { - return Intl.message( - 'Sugars', - name: 'sugars', - desc: 'sugar content (out of the carbohydrates)', - ); - } - - String get fat { - return Intl.message( - 'Fat', - name: 'fat', - desc: 'Fat content', - ); - } - - String get saturatedFat { - return Intl.message( - 'Saturated fat', - name: 'saturatedFat', - desc: 'Saturated fat content (out of the fat)', - ); - } - - String get fibres { - return Intl.message( - 'Fibres', - name: 'fibres', - desc: 'Fibres content', - ); - } - - String get sodium { - return Intl.message( - 'Sodium', - name: 'sodium', - desc: 'Sodium content', - ); - } - - String get amount { - return Intl.message( - 'Amount', - name: 'amount', - desc: 'The amount (e.g. in grams) of an ingredient in a meal', - ); - } - - String get newEntry { - return Intl.message( - 'New entry', - name: 'newEntry', - desc: 'Header when adding a new entry such as a weight or log entry', - ); - } - - String get edit { - return Intl.message( - 'Edit', - name: 'edit', - desc: 'Header when adding an existing entry', - ); - } - - String get loadingText { - return Intl.message( - 'Loading...', - name: 'loadingText', - desc: 'Text to show when entries are being loaded in the background', - ); - } - - String get delete { - return Intl.message( - 'Delete', - name: 'delete', - desc: 'Header when deleting an existing entry', - ); - } - - String get newNutritionalPlan { - return Intl.message( - 'New nutritional plan', - name: 'newNutritionalPlan', - desc: 'Header when adding a new nutritional plan', - ); - } - - String get toggleDetails { - return Intl.message( - 'Toggle details', - name: 'toggleDetails', - desc: 'Switch to toggle detail / overview', - ); - } - - String get aboutText { - return Intl.message( - 'wger Workout Manager is free, open source (FLOSS) software released ' - 'under the GNU General Public version 3 or later. ' - 'The code is freely available on github: ', - name: 'aboutText', - desc: 'Text in the about dialog', - ); - } -} - -class AppLocalizationsDelegate extends LocalizationsDelegate { - const AppLocalizationsDelegate(); - - @override - bool isSupported(Locale locale) { - return ['en', 'de'].contains(locale.languageCode); - } - - @override - Future load(Locale locale) { - return AppLocalizations.load(locale); - } - - @override - bool shouldReload(AppLocalizationsDelegate old) { - return false; - } -} diff --git a/lib/main.dart b/lib/main.dart index 030f6236..d4649810 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,9 +17,8 @@ */ import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/providers/exercises.dart'; import 'package:wger/providers/nutrition.dart'; @@ -103,17 +102,8 @@ class MyApp extends StatelessWidget { NutritionScreen.routeName: (ctx) => NutritionScreen(), NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(), }, - localizationsDelegates: [ - // ... app-specific localization delegate[s] here - AppLocalizationsDelegate(), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [ - const Locale('en', ''), // English - const Locale('de', ''), // German - ], + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, ), ), ); diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 3ed203d1..b60832b0 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -18,8 +18,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/providers/auth.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/providers/exercises.dart'; diff --git a/lib/screens/nutritional_plan_screen.dart b/lib/screens/nutritional_plan_screen.dart index efc6648a..d4153a68 100644 --- a/lib/screens/nutritional_plan_screen.dart +++ b/lib/screens/nutritional_plan_screen.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/nutrition/nutritional_plan.dart'; import 'package:wger/providers/nutrition.dart'; import 'package:wger/widgets/core/bottom_sheet.dart'; diff --git a/lib/screens/nutritional_plans_screen.dart b/lib/screens/nutritional_plans_screen.dart index b386dd87..8f3ff46d 100644 --- a/lib/screens/nutritional_plans_screen.dart +++ b/lib/screens/nutritional_plans_screen.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/nutrition/nutritional_plan.dart'; import 'package:wger/providers/nutrition.dart'; import 'package:wger/widgets/app_drawer.dart'; diff --git a/lib/screens/weight_screen.dart b/lib/screens/weight_screen.dart index c40c5501..c4d985c7 100644 --- a/lib/screens/weight_screen.dart +++ b/lib/screens/weight_screen.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/body_weight/weight_entry.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/widgets/app_drawer.dart'; diff --git a/lib/screens/workout_plan_screen.dart b/lib/screens/workout_plan_screen.dart index be0d74ba..d087ec98 100644 --- a/lib/screens/workout_plan_screen.dart +++ b/lib/screens/workout_plan_screen.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/workouts/workout_plan.dart'; import 'package:wger/providers/workout_plans.dart'; import 'package:wger/screens/workout_plans_screen.dart'; diff --git a/lib/screens/workout_plans_screen.dart b/lib/screens/workout_plans_screen.dart index 5bf91ee7..df7fac8e 100644 --- a/lib/screens/workout_plans_screen.dart +++ b/lib/screens/workout_plans_screen.dart @@ -18,8 +18,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/workouts/workout_plan.dart'; import 'package:wger/providers/workout_plans.dart'; import 'package:wger/widgets/app_drawer.dart'; diff --git a/lib/widgets/app_drawer.dart b/lib/widgets/app_drawer.dart index c260fa32..7f84ab00 100644 --- a/lib/widgets/app_drawer.dart +++ b/lib/widgets/app_drawer.dart @@ -18,9 +18,9 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/providers/auth.dart'; class AppDrawer extends StatelessWidget { diff --git a/lib/widgets/dashboard/calendar.dart b/lib/widgets/dashboard/calendar.dart index 5b7d7a09..1a305455 100644 --- a/lib/widgets/dashboard/calendar.dart +++ b/lib/widgets/dashboard/calendar.dart @@ -19,10 +19,10 @@ import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:table_calendar/table_calendar.dart'; import 'package:wger/helpers/json.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/workouts/session.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/providers/nutrition.dart'; diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index 1e634088..930df26e 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -18,9 +18,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/nutrition/nutritional_plan.dart'; import 'package:wger/models/workouts/workout_plan.dart'; import 'package:wger/providers/body_weight.dart'; diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart index 8f8d768e..3e44fe5c 100644 --- a/lib/widgets/nutrition/charts.dart +++ b/lib/widgets/nutrition/charts.dart @@ -18,7 +18,7 @@ import 'package:charts_flutter/flutter.dart' as charts; import 'package:flutter/widgets.dart'; -import 'package:wger/locale/locales.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:wger/models/nutrition/nutritional_plan.dart'; import 'package:wger/models/nutrition/nutritrional_values.dart'; import 'package:wger/theme/theme.dart'; diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index 7f5a4ea3..fca1d0d5 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -17,11 +17,11 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:provider/provider.dart'; import 'package:wger/helpers/json.dart'; import 'package:wger/helpers/ui.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/http_exception.dart'; import 'package:wger/models/nutrition/meal.dart'; import 'package:wger/models/nutrition/meal_item.dart'; diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index c1081409..3d7641bc 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/nutrition/meal.dart'; import 'package:wger/models/nutrition/meal_item.dart'; import 'package:wger/providers/nutrition.dart'; diff --git a/lib/widgets/nutrition/nutritional_plan_detail.dart b/lib/widgets/nutrition/nutritional_plan_detail.dart index 0e689e0b..3110f5ea 100644 --- a/lib/widgets/nutrition/nutritional_plan_detail.dart +++ b/lib/widgets/nutrition/nutritional_plan_detail.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:intl/intl.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/nutrition/nutritional_plan.dart'; import 'package:wger/models/nutrition/nutritrional_values.dart'; import 'package:wger/widgets/core/bottom_sheet.dart'; diff --git a/lib/widgets/weight/entries_list.dart b/lib/widgets/weight/entries_list.dart index c726591c..b97e2572 100644 --- a/lib/widgets/weight/entries_list.dart +++ b/lib/widgets/weight/entries_list.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:intl/intl.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/providers/body_weight.dart'; import 'package:wger/widgets/core/bottom_sheet.dart'; import 'package:wger/widgets/weight/charts.dart'; diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart index f894402e..80f1416f 100644 --- a/lib/widgets/weight/forms.dart +++ b/lib/widgets/weight/forms.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:wger/helpers/json.dart'; import 'package:wger/helpers/ui.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/body_weight/weight_entry.dart'; import 'package:wger/models/http_exception.dart'; import 'package:wger/providers/body_weight.dart'; diff --git a/lib/widgets/workouts/day.dart b/lib/widgets/workouts/day.dart index 94b2c017..a447dd62 100644 --- a/lib/widgets/workouts/day.dart +++ b/lib/widgets/workouts/day.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/workouts/day.dart'; import 'package:wger/models/workouts/set.dart'; import 'package:wger/models/workouts/setting.dart'; diff --git a/lib/widgets/workouts/forms.dart b/lib/widgets/workouts/forms.dart index 86a748b5..936d580d 100644 --- a/lib/widgets/workouts/forms.dart +++ b/lib/widgets/workouts/forms.dart @@ -17,9 +17,9 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:provider/provider.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/exercises/exercise.dart'; import 'package:wger/models/workouts/day.dart'; import 'package:wger/models/workouts/repetition_unit.dart'; diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index 5823e629..50ad228d 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -19,10 +19,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:wger/helpers/ui.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/exercises/exercise.dart'; import 'package:wger/models/http_exception.dart'; import 'package:wger/models/workouts/day.dart'; diff --git a/lib/widgets/workouts/workout_plan_detail.dart b/lib/widgets/workouts/workout_plan_detail.dart index 284c7e70..bc4e0230 100644 --- a/lib/widgets/workouts/workout_plan_detail.dart +++ b/lib/widgets/workouts/workout_plan_detail.dart @@ -17,8 +17,8 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:intl/intl.dart'; -import 'package:wger/locale/locales.dart'; import 'package:wger/models/workouts/workout_plan.dart'; import 'package:wger/screens/workout_plan_screen.dart'; import 'package:wger/widgets/core/bottom_sheet.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index d05ff500..4e7378c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -102,3 +102,5 @@ flutter: # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages + + generate: true \ No newline at end of file