Skip to content

Commit

Permalink
chore: merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner committed Jun 29, 2023
2 parents c7eb8db + 2c81ff2 commit 2cf1f0e
Show file tree
Hide file tree
Showing 24 changed files with 454 additions and 186 deletions.
50 changes: 23 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ on:
branches: ['*']
tags: ['v*','V*']

workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'dev' # or: 'dev' or 'beta'
channel: 'stable' # or: 'dev' or 'beta'

- name: Install packages dependencies
run: flutter pub get
Expand All @@ -34,11 +36,6 @@ jobs:
- name: Run tests coverage
run: flutter test --coverage

- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

publish:
if: "(contains(github.event.head_commit.message, '[pub]') &&
contains('
Expand All @@ -53,28 +50,27 @@ jobs:
github.ref)"

name: Publish
permissions:
id-token: write # This is required for authentication using OIDC
needs: [test]
runs-on: ubuntu-latest

container:
image: google/dart:latest
timeout-minutes: 5

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Dry run pub publish
run: dart pub publish --dry-run || true

- name: Setup credentials
run: |
pwd
mkdir -p ~/.pub-cache
cat <<EOF> ~/.pub-cache/credentials.json
{"accessToken":"${{ secrets.OAUTH_ACCESS_TOKEN }}","refreshToken":"${{ secrets.OAUTH_REFRESH_TOKEN }}","idToken":"${{ secrets.OAUTH_ID_TOKEN }}","tokenEndpoint":"https://accounts.google.com/o/oauth2/token","scopes":["openid","https://www.googleapis.com/auth/userinfo.email"],"expiration":1609800070574}
EOF
- uses: actions/checkout@v3
- name: Run a one-line script
id: vars
run: echo "pkg_tag=$(cat pubspec.yaml | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')" >> $GITHUB_OUTPUT
- uses: dart-lang/setup-dart@v1
- uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: code format
run: dart format lib/*/*.dart lib/*.dart
- name: Publish pkg
run: dart pub publish --force
- name: Add pub token
run: echo ${{secrets.OAUTH_ACCESS_TOKEN}} | dart pub token add https://pub.dev
- name: Install dependencies
run: dart pub get
- name: code format
run: dart format lib/*/*.dart lib/*.dart
- name: Publish pkg
run: dart pub publish --server=https://pub.dartlang.org -f
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

### [3.0.2]

- support intl 18
- support dart 3
- added trExists extension
- fix: handle invalid saved local
- handle null returned by assetLoader
- improve parsing scriptCode from local string
- add tr-extension on build context

### [3.0.1]

- added option allowing skip keys of nested object
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ Text('title').tr() //Text widget
print('title'.tr()); //String
var title = tr('title') //Static function
Text(context.tr('title')) //Extension on BuildContext
```

#### Arguments:
Expand Down Expand Up @@ -293,6 +295,9 @@ print('day'.plural(21)); // output: 21 день
//Static function
var money = plural('money', 10.23) // output: You have 10.23 dollars
//Text widget with plural BuildContext extension
Text(context.plural('money', 10.23))
//Static function with arguments
var money = plural('money_args', 10.23, args: ['John', '10.23']) // output: John has 10.23 dollars
Expand Down
2 changes: 1 addition & 1 deletion bin/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class CodegenLoader extends AssetLoader{
const CodegenLoader();
@override
Future<Map<String, dynamic>> load(String fullPath, Locale locale ) {
Future<Map<String, dynamic>?> load(String path, Locale locale) {
return Future.value(mapLocales[locale.toString()]);
}
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>11.0</string>
</dict>
</plist>
78 changes: 16 additions & 62 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand All @@ -10,78 +10,32 @@ project 'Runner', {
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
generated_key_values
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

# Flutter Pod

copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end

# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'

# Plugin Pods

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
flutter_additional_ios_build_settings(target)
end
end
12 changes: 7 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -168,7 +168,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -214,6 +214,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -245,6 +246,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -359,7 +361,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -442,7 +444,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -492,7 +494,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
7 changes: 4 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ publish_to: none
version: 1.0.0+1

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-0 <4.0.0"

dependencies:
flutter:
Expand All @@ -28,8 +28,9 @@ dependencies:
font_awesome_flutter: 9.0.0-nullsafety

#custom loaders
easy_localization_loader:
git: https://github.com/aissat/easy_localization_loader.git
#fixme(DartAndrik): Commented due to [easy_localization_loader] package dependencies issue, uncomment after resolving.
# easy_localization_loader:
# git: https://github.com/aissat/easy_localization_loader.git

dev_dependencies:
flutter_test:
Expand Down
22 changes: 16 additions & 6 deletions lib/src/easy_localization_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class EasyLocalizationController extends ChangeNotifier {
// If saved locale then get
else if (saveLocale && _savedLocale != null) {
EasyLocalization.logger('Saved locale loaded ${_savedLocale.toString()}');
_locale = _savedLocale!;
_locale = selectLocaleFrom(
supportedLocales,
_savedLocale!,
fallbackLocale: fallbackLocale,
);
} else {
// From Device Locale
_locale = selectLocaleFrom(
Expand Down Expand Up @@ -84,15 +88,15 @@ class EasyLocalizationController extends ChangeNotifier {
Future loadTranslations() async {
Map<String, dynamic> data;
try {
data = await loadTranslationData(_locale);
data = Map.from(await loadTranslationData(_locale));
_translations = Translations(data);
if (useFallbackTranslations && _fallbackLocale != null) {
Map<String, dynamic>? baseLangData;
if (_locale.countryCode != null && _locale.countryCode!.isNotEmpty) {
baseLangData =
await loadBaseLangTranslationData(Locale(locale.languageCode));
}
data = await loadTranslationData(_fallbackLocale!);
data = Map.from(await loadTranslationData(_fallbackLocale!));
if (baseLangData != null) {
try {
data.addAll(baseLangData);
Expand Down Expand Up @@ -120,12 +124,18 @@ class EasyLocalizationController extends ChangeNotifier {
return null;
}

Future loadTranslationData(Locale locale) async {
Future<Map<String, dynamic>> loadTranslationData(Locale locale) async {
late Map<String, dynamic>? data;

if (useOnlyLangCode) {
return assetLoader.load(path, Locale(locale.languageCode));
data = await assetLoader.load(path, Locale(locale.languageCode));
} else {
return assetLoader.load(path, locale);
data = await assetLoader.load(path, locale);
}

if (data == null) return {};

return data;
}

Locale get locale => _locale;
Expand Down
Loading

0 comments on commit 2cf1f0e

Please sign in to comment.