Skip to content

Commit

Permalink
adding localization mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
User623-crypto committed Feb 21, 2023
1 parent 13a834c commit 08c4ec1
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 2 deletions.
5 changes: 5 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
arb-dir: lib/l10n
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
class-name: S
main-locale: en
71 changes: 71 additions & 0 deletions lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';

import 'messages_de.dart' as messages_de;
import 'messages_en.dart' as messages_en;
import 'messages_nl.dart' as messages_nl;

typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'de': () => new SynchronousFuture(null),
'en': () => new SynchronousFuture(null),
'nl': () => new SynchronousFuture(null),
};

MessageLookupByLibrary? _findExact(String localeName) {
switch (localeName) {
case 'de':
return messages_de.messages;
case 'en':
return messages_en.messages;
case 'nl':
return messages_nl.messages;
default:
return null;
}
}

/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new SynchronousFuture(false);
}
var lib = _deferredLibraries[availableLocale];
lib == null ? new SynchronousFuture(false) : lib();
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new SynchronousFuture(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);
}
37 changes: 37 additions & 0 deletions lib/generated/intl/messages_de.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';

final messages = new MessageLookup();

typedef String MessageIfAbsent(String messageStr, List<dynamic> args);

class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'de';

static String m0(name) => "Welcome in German ${name}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"demoScreen":
MessageLookupByLibrary.simpleMessage("Demo Screen in German"),
"mainTitle":
MessageLookupByLibrary.simpleMessage("Main Title in German"),
"name": MessageLookupByLibrary.simpleMessage("Name in German"),
"next": MessageLookupByLibrary.simpleMessage("Next in German"),
"pageHomeConfirm":
MessageLookupByLibrary.simpleMessage("Confirm in German"),
"pageHomeWelcome": m0
};
}
34 changes: 34 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';

final messages = new MessageLookup();

typedef String MessageIfAbsent(String messageStr, List<dynamic> args);

class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

static String m0(name) => "Welcome ${name}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"demoScreen": MessageLookupByLibrary.simpleMessage("Demo Screen"),
"mainTitle": MessageLookupByLibrary.simpleMessage("Coll Action"),
"name": MessageLookupByLibrary.simpleMessage("Name"),
"next": MessageLookupByLibrary.simpleMessage("Next"),
"pageHomeConfirm": MessageLookupByLibrary.simpleMessage("Confirm"),
"pageHomeWelcome": m0
};
}
37 changes: 37 additions & 0 deletions lib/generated/intl/messages_nl.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that provides messages for a nl 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, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';

final messages = new MessageLookup();

typedef String MessageIfAbsent(String messageStr, List<dynamic> args);

class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'nl';

static String m0(name) => "Welcome ${name}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"demoScreen":
MessageLookupByLibrary.simpleMessage("Demo Screen in Holland"),
"mainTitle":
MessageLookupByLibrary.simpleMessage("Coll Action in Holland"),
"name": MessageLookupByLibrary.simpleMessage("Name in Holland"),
"next": MessageLookupByLibrary.simpleMessage("Next in Holland"),
"pageHomeConfirm":
MessageLookupByLibrary.simpleMessage("Confirm in Holland"),
"pageHomeWelcome": m0
};
}
140 changes: 140 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pageHomeConfirm": "Confirm in German",
"pageHomeWelcome": "Welcome in German {name}",
"name":"Name in German",
"next":"Next in German",
"mainTitle":"Main Title in German",
"demoScreen":"Demo Screen in German"
}
8 changes: 8 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pageHomeConfirm": "Confirm",
"pageHomeWelcome": "Welcome {name}",
"name":"Name",
"next":"Next",
"mainTitle":"Coll Action",
"demoScreen":"Demo Screen"
}
8 changes: 8 additions & 0 deletions lib/l10n/intl_nl.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pageHomeConfirm": "Confirm in Holland",
"pageHomeWelcome": "Welcome {name}",
"name":"Name in Holland",
"next":"Next in Holland",
"mainTitle":"Coll Action in Holland",
"demoScreen":"Demo Screen in Holland"
}
11 changes: 11 additions & 0 deletions lib/presentation/core/app_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import '../../application/auth/auth_bloc.dart';
import '../../application/user/profile/profile_bloc.dart';
import '../../application/user/profile_tab/profile_tab_bloc.dart';
import '../../generated/l10n.dart';
import '../../infrastructure/core/injection.dart';
import '../routes/app_routes.gr.dart';
import '../themes/themes.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class AppWidget extends StatelessWidget {
final _appRouter = AppRouter();
Expand All @@ -32,6 +35,14 @@ class AppWidget extends StatelessWidget {
},
child: MaterialApp.router(
color: Colors.white,
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
locale: Locale("nl", "NL"),
title: 'CollAction',
theme: lightTheme(),
routerDelegate: _appRouter.delegate(),
Expand Down
Loading

0 comments on commit 08c4ec1

Please sign in to comment.