diff --git a/assets/translations/en.json b/assets/translations/en.json new file mode 100644 index 0000000000..709704c474 --- /dev/null +++ b/assets/translations/en.json @@ -0,0 +1,3 @@ +{ + "test": "en-test" +} \ No newline at end of file diff --git a/assets/translations/ru.json b/assets/translations/ru.json new file mode 100644 index 0000000000..05f81893d9 --- /dev/null +++ b/assets/translations/ru.json @@ -0,0 +1,3 @@ +{ + "test": "ру-тест" +} \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 946bddab85..055f60660c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2,12 +2,15 @@ PODS: - Flutter (1.0.0) - path_provider (0.0.1): - Flutter + - shared_preferences (0.0.1): + - Flutter - url_launcher (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - path_provider (from `.symlinks/plugins/path_provider/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) EXTERNAL SOURCES: @@ -15,12 +18,15 @@ EXTERNAL SOURCES: :path: Flutter path_provider: :path: ".symlinks/plugins/path_provider/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" url_launcher: :path: ".symlinks/plugins/url_launcher/ios" SPEC CHECKSUMS: Flutter: 0e3d915762c693b495b44d77113d4970485de6ec path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c + shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 4fa97b4330..9140ef0c91 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ @@ -33,6 +33,8 @@ 02BB87F67990BDBF46B33A99 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 247FA89325766918005A3DE3 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Main.strings; sourceTree = ""; }; + 247FA89425766918005A3DE3 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/LaunchScreen.strings; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 4F50D46E1FAD96D4DE911FF3 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 5DAE4FF490544D49BC2DD9A3 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -121,7 +123,6 @@ F3A7AA4BF6A26F2649361520 /* Pods-Runner.release.xcconfig */, 4F50D46E1FAD96D4DE911FF3 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -172,6 +173,7 @@ knownRegions = ( en, Base, + ru, ); mainGroup = 97C146E51CF9000F007C117D; productRefGroup = 97C146EF1CF9000F007C117D /* Products */; @@ -284,6 +286,7 @@ isa = PBXVariantGroup; children = ( 97C146FB1CF9000F007C117D /* Base */, + 247FA89325766918005A3DE3 /* ru */, ); name = Main.storyboard; sourceTree = ""; @@ -292,6 +295,7 @@ isa = PBXVariantGroup; children = ( 97C147001CF9000F007C117D /* Base */, + 247FA89425766918005A3DE3 /* ru */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -303,6 +307,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -362,7 +367,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -379,6 +387,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -434,6 +443,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -475,7 +485,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -494,7 +505,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -521,7 +535,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -560,4 +577,4 @@ /* End XCConfigurationList section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; -} \ No newline at end of file +} diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 1f80744c6d..eed819f78b 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,11 @@ + CFBundleLocalizations + + ru + en + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/ios/Runner/ru.lproj/LaunchScreen.strings b/ios/Runner/ru.lproj/LaunchScreen.strings new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/ios/Runner/ru.lproj/LaunchScreen.strings @@ -0,0 +1 @@ + diff --git a/ios/Runner/ru.lproj/Main.strings b/ios/Runner/ru.lproj/Main.strings new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/ios/Runner/ru.lproj/Main.strings @@ -0,0 +1 @@ + diff --git a/lib/config/localization.dart b/lib/config/localization.dart new file mode 100644 index 0000000000..b8e33be3d7 --- /dev/null +++ b/lib/config/localization.dart @@ -0,0 +1,22 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; + +class Localization extends StatelessWidget { + const Localization({ + Key key, + this.child, + }) : super(key: key); + + final Widget child; + @override + Widget build(BuildContext context) { + return EasyLocalization( + preloaderColor: Colors.black, + supportedLocales: [Locale('ru'), Locale('en')], + path: 'assets/translations', + fallbackLocale: Locale('en'), + useOnlyLangCode: true, + child: child, + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 039713f70e..3b3a6ab857 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,20 +1,31 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:selfprivacy/ui/pages/onboarding/onboarding.dart'; +import 'package:easy_localization/easy_localization.dart'; import 'config/brand_theme.dart'; +import 'config/localization.dart'; void main() { - runApp(MyApp()); + WidgetsFlutterBinding.ensureInitialized(); + + runApp( + Localization( + child: MyApp(), + ), + ); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return AnnotatedRegion( value: SystemUiOverlayStyle.light, // Manually changnig appbar color + child: MaterialApp( + localizationsDelegates: context.localizationDelegates, + supportedLocales: context.supportedLocales, + locale: context.locale, debugShowCheckedModeBanner: false, title: 'SelfPrivacy', theme: theme, diff --git a/pubspec.lock b/pubspec.lock index 208a4465f8..f3b1f207ba 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -78,6 +78,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + easy_localization: + dependency: "direct main" + description: + name: easy_localization + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.3" fake_async: dependency: transitive description: @@ -111,6 +118,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.8.1" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -247,6 +259,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.13" + shared_preferences: + dependency: transitive + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.12+4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+4" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+11" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2+7" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+3" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 08ae7efc6d..ad190df3e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.0 + easy_localization: ^2.3.3 google_fonts: ^1.1.1 url_launcher: ^5.7.10 @@ -27,6 +28,7 @@ flutter: uses-material-design: true assets: - assets/images/logos/ + - assets/translations/ fonts: - family: BrandIcons fonts: