Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
10 changes: 9 additions & 1 deletion pick_up_recipe/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ app.*.map.json
/android/app/release

# FVM Version Cache
.fvm/
.fvm/

# Auto-generated files by build_runner
*.g.dart
*.freezed.dart
*.chopper.dart
*.injectable.dart
*.mocks.dart
*.gr.dart
4 changes: 4 additions & 0 deletions pick_up_recipe/l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false
75 changes: 75 additions & 0 deletions pick_up_recipe/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"@_LOGIN_FORM": {},
"loginFormTitle": "Sign in to account",
"loginFormEmail": "Email",
"loginFormInvalidEmail": "Enter existing email",
"loginFormPassword": "Password",
"loginFormInvalidPassword": "Password must contain minimum 6 symbols",
"loginFormSignIn": "Sign in",

"@_MAIL_CONFIRMATION_FORM": {},
"mailConfirmationFormTitle": "Confirm your e-mail address",
"mailConfirmationFormCode": "Confirmation code",
"mailConfirmationFormInvalidCode": "Code must contain 6 symbols",
"mailConfirmationFormConfirm": "Confirm email",

"@_REGISTRATION_FORM": {},
"registrationFormTitle": "Create new account",
"registrationFormEmail": "Email",
"registrationFormInvalidEmail": "Enter existing email address",
"registrationFormPassword": "Password",
"registrationFormInvalidPassword": "Password must contain minimum of 6 symbols",
"registrationFormConfirmPassword": "Confirm password",
"registrationFormPasswordsUnmatch": "Passwords do not match",
"registrationFormRegister": "Register",

"@_NEW_PACK_SCREEN": {},
"newPackScreenTitle": "Add a new pack",
"newPackScreenSubtitle": "You can make a photo of your pack to recognise it",
"newPackScreenCamera": "Camera",
"newPackScreenGallery": "Gallery",
"newPackImageError": "Error fetching information from pack image",
"newPackName": "Name",
"newPackCountry": "Country",
"newPackScore": "SCA score",
"newPackDescriptors": "Descriptors",
"newPackDescriptor": "Descriptor",
"newPackVariety": "Variety",
"newPackMethods": "Processing methods",
"newPackMethod": "Method",
"newPackDate": "Roast date",
"newPackSend": "Send",

"@_RECIPES": {},
"recipesCoffee": "Coffee",
"recipesBrewed": "Brewed",
"recipesVolume": "ml",

"@_AUTH_PAGE": {},
"authPageTitle": "PickUpRecipe",
"authPageButtonRegistration": "Have an account? Sign in",
"authPageButtonVerifyEmail": "Have an account? Sign in",
"authPageButtonLogin": "Not registered? Sign up",

"@_BREW_PAGE": {},
"brewPageBrewed": "Brewed on",
"brewPageRecipeFor": "Recipe for pack",
"brewPageStart": "Start brewing!",
"brewPageStop": "Stop brewing",
"brewPageDegrees": "°C",
"brewPageMass": "g",
"brewPageVolume": "ml",
"brewPageGrind": "click",

"@_RECIPE_PAGE": {},
"recipePageChoose": "Choose brewing method",
"recipePageGenerate": "Generate",
"recipePageFor": "recipe for",
"recipePageChooseGenerate": "Choose brewing method to generate",

"@_MAIN_PAGE": {},
"mainPageLatest": "Latest Recipes",
"mainPageActive": "Active packs",
"mainPageHome": "Main",
"mainPageAdd": "Add pack"
}
75 changes: 75 additions & 0 deletions pick_up_recipe/lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"@_LOGIN_FORM": {},
"loginFormTitle": "Вход в аккаунт",
"loginFormEmail": "Email",
"loginFormInvalidEmail": "Введите существующий email",
"loginFormPassword": "Пароль",
"loginFormInvalidPassword": "Пароль должен содержать хотя бы 6 символов",
"loginFormSignIn": "Войти",

"@_MAIL_CONFIRMATION_FORM": {},
"mailConfirmationFormTitle": "Подтверждение e-mail адреса",
"mailConfirmationFormCode": "Код подтверждения",
"mailConfirmationFormInvalidCode": "Код должен состоять из 6 символов",
"mailConfirmationFormConfirm": "Подтвердить email",

"@_REGISTRATION_FORM": {},
"registrationFormTitle": "Создать новый аккаунт",
"registrationFormEmail": "Email",
"registrationFormInvalidEmail": "Введите существующий emai",
"registrationFormPassword": "Пароль",
"registrationFormInvalidPassword": "Пароль должен содержать хотя бы 6 символов",
"registrationFormConfirmPassword": "Повторите пароль",
"registrationFormPasswordsUnmatch": "Пароли не совпадают",
"registrationFormRegister": "Зарегистрироваться",

"@_NEW_PACK_SCREEN": {},
"newPackScreenTitle": "Добавить новую пачку",
"newPackScreenSubtitle": "Вы можете добавить фото, чтобы распознать текст",
"newPackScreenCamera": "Камера",
"newPackScreenGallery": "Галерея",
"newPackImageError": "Не удалось получить информацию с изображения",
"newPackName": "Название",
"newPackCountry": "Страна",
"newPackScore": "Оценка SCA",
"newPackDescriptors": "Дескрипторы",
"newPackDescriptor": "Дескриптор",
"newPackVariety": "Сорт",
"newPackMethods": "Методы обработки",
"newPackMethod": "Метод",
"newPackDate": "Дата обжарки",
"newPackSend": "Отправить",

"@_RECIPES": {},
"recipesCoffee": "Кофе",
"recipesBrewed": "Заварен",
"recipesVolume": "мл",

"@_AUTH_PAGE": {},
"authPageTitle": "PickUpRecipe",
"authPageButtonRegistration": "Уже есть аккаунт? Войти",
"authPageButtonVerifyEmail": "Уже есть аккаунт? Войти",
"authPageButtonLogin": "Нет аккаунта? Зарегестрироваться",

"@_BREW_PAGE": {},
"brewPageBrewed": "Был заварен",
"brewPageRecipeFor": "Рецепт для зерна",
"brewPageStart": "Начать заваривать!",
"brewPageStop": "Закончить заваривать",
"brewPageDegrees": "°C",
"brewPageMass": "г",
"brewPageVolume": "мл",
"brewPageGrind": "помол",

"@_RECIPE_PAGE": {},
"recipePageChoose": "Выберите метод заваривания",
"recipePageGenerate": "Сгенерировать",
"recipePageFor": "рецепт для",
"recipePageChooseGenerate": "Выберите метод заваривания для генерации",

"@_MAIN_PAGE": {},
"mainPageLatest": "Недавние рецепты",
"mainPageActive": "Текущее зерно",
"mainPageHome": "Главная",
"mainPageAdd": "Добавить пачку"
}
19 changes: 19 additions & 0 deletions pick_up_recipe/lib/l10n/s.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter/widgets.dart';

class S {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай все-таки поменяем нейминг

static const locale = Locale('ru');

static const supportedLocales = [Locale('en'), Locale('ru')];

static const localizationDelegates = <LocalizationsDelegate>[
GlobalWidgetsLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
AppLocalizations.delegate,
];

static AppLocalizations of(BuildContext context) =>
AppLocalizations.of(context);
}
14 changes: 9 additions & 5 deletions pick_up_recipe/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:pick_up_recipe/routing/app_router.dart';
import 'package:pick_up_recipe/src/features/authentication/provider/authentication_state_notifier.dart';
import 'package:pick_up_recipe/src/themes/dark_theme.dart';
import 'package:pick_up_recipe/src/themes/light_theme.dart';
import 'package:pick_up_recipe/l10n/s.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -58,6 +59,9 @@ class _MyAppState extends ConsumerState<MyApp> {
routerConfig: AppRouter(ref).config(),
theme: lightTheme,
darkTheme: darkTheme,
localizationsDelegates: S.localizationDelegates,
supportedLocales: S.supportedLocales,
locale: S.locale,
);
}
}
Expand Down Expand Up @@ -95,14 +99,14 @@ class _RootScreenState extends State<RootScreen> {
enableFeedback: false,
selectedItemColor: Theme.of(context).colorScheme.primary,
iconSize: 28,
items: const [
items: [
BottomNavigationBarItem(
label: 'Main',
icon: Icon(Icons.coffee),
label: S.of(context).mainPageHome,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай перейдем на расширение контекста, чтобы использовать context.localizations
https://dart.dev/language/extension-methods

icon: const Icon(Icons.coffee),
),
BottomNavigationBarItem(
label: 'Add pack',
icon: Icon(Icons.add),
label: S.of(context).mainPageAdd,
icon: const Icon(Icons.add),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:pick_up_recipe/routing/app_router.dart';
import 'package:pick_up_recipe/src/features/authentication/provider/authentication_state_notifier.dart';
import 'package:pick_up_recipe/src/general_widgets/buttons/app_button.dart';
import 'package:pick_up_recipe/l10n/s.dart';

class LoginFormWidget extends ConsumerStatefulWidget {
const LoginFormWidget({super.key});
Expand Down Expand Up @@ -57,11 +58,11 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
Widget build(BuildContext context) {
return Column(
children: [
const Align(
Align(
alignment: Alignment.topLeft,
child: Text(
'Sign in to account',
style: TextStyle(fontSize: 18),
S.of(context).loginFormTitle,
style: const TextStyle(fontSize: 18),
),
),
const SizedBox(
Expand All @@ -75,7 +76,7 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
TextFormField(
controller: _emailController,
decoration: InputDecoration(
labelText: 'Email',
labelText: S.of(context).loginFormEmail,
border: const OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -85,7 +86,7 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
),
validator: (value) {
if (value!.isEmpty || !value.contains('@')) {
return 'Enter existing email';
return S.of(context).loginFormInvalidEmail;
}
return null;
},
Expand All @@ -95,7 +96,7 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
controller: _passwordController,
obscureText: true,
decoration: InputDecoration(
labelText: 'Password',
labelText: S.of(context).loginFormPassword,
border: const OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -105,7 +106,7 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
),
validator: (value) {
if (value!.isEmpty || value.length < 6) {
return 'Password must contain minimum 6 symbols';
return S.of(context).loginFormInvalidPassword;
}
return null;
},
Expand All @@ -125,7 +126,7 @@ class _LoginFormWidgetState extends ConsumerState<LoginFormWidget> {
color: Theme.of(context).colorScheme.surface,
)
: Text(
'Sign in',
S.of(context).loginFormSignIn,
style: TextStyle(
fontSize: 20,
color: Theme.of(context).colorScheme.surface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:pick_up_recipe/src/features/authentication/provider/authenticati
import 'package:pick_up_recipe/src/features/authentication/provider/authentication_state_notifier.dart';
import 'package:pick_up_recipe/src/general_widgets/buttons/app_button.dart';
import 'package:pick_up_recipe/src/pages/authentication_page.dart';
import 'package:pick_up_recipe/l10n/s.dart';

class MailConfirmationFormWidget extends ConsumerStatefulWidget {
const MailConfirmationFormWidget({
Expand Down Expand Up @@ -54,11 +55,11 @@ class _MailConfirmationFormWidgetState
Widget build(BuildContext context) {
return Column(
children: [
const Align(
Align(
alignment: Alignment.topLeft,
child: Text(
'Confirm your e-mail address',
style: TextStyle(fontSize: 18),
S.of(context).mailConfirmationFormTitle,
style: const TextStyle(fontSize: 18),
),
),
const SizedBox(
Expand All @@ -72,7 +73,7 @@ class _MailConfirmationFormWidgetState
TextFormField(
controller: _codeController,
decoration: InputDecoration(
labelText: 'Confirmation code',
labelText: S.of(context).mailConfirmationFormCode,
border: const OutlineInputBorder(),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
Expand All @@ -82,7 +83,7 @@ class _MailConfirmationFormWidgetState
),
validator: (value) {
if (value!.isEmpty || value.length != 6) {
return 'Code must contain 6 symbols';
return S.of(context).mailConfirmationFormInvalidCode;
}
return null;
},
Expand All @@ -102,7 +103,7 @@ class _MailConfirmationFormWidgetState
color: Theme.of(context).colorScheme.surface,
)
: Text(
'Confirm email',
S.of(context).mailConfirmationFormConfirm,
style: TextStyle(
fontSize: 20,
color: Theme.of(context).colorScheme.surface,
Expand Down
Loading