-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working on iOS in release #47
Comments
Have you added your supported locales to your Info.plist? |
Yes, I followed the whole guide and added
to my |
Another information: I'm trying to get this working and I noticed that if I run from command palette |
Something error with me. I show you my code and the problem ↓↓↓↓↓↓ Development environment: ➜ flutter_template flutter doctor -v
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15.1 19B88, locale en-CN)
• Flutter version 1.9.1+hotfix.6 at /Users/cy/development/flutter
• Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/cy/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.2.1, Build version 11B500
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 38.2.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.40.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.7.0
[✓] Connected device (1 available)
• iPhone 7 Plus • e38bb612c85e3dca0e22f1e6b9cc3899b68b5a46 • ios • iOS 13.2.3
• No issues found!
➜ flutter_template This is my test code: import 'package:flutter/material.dart';
import 'package:flutter_template/generated/i18n.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() => runApp(App());
class App extends StatefulWidget {
App({Key key}) : super(key: key);
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
final i18n = I18n.delegate;
@override
void initState() {
super.initState();
I18n.onLocaleChanged = onLocaleChange;
}
void onLocaleChange(Locale locale) {
setState(() {
I18n.locale = locale;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Flutter Template",
localizationsDelegates: [
i18n,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate // <-- needed for iOS
],
supportedLocales: i18n.supportedLocales,
localeResolutionCallback: i18n.resolution(fallback: new Locale("zh", "CN")),
// flutter run --debug: throw error
// flutter run --release: throw error
//
// when I use I18n.of(context).homePageTitle with this way, It will throw error with message:
//
// NoSuchMethodError: The getter 'HomePageTitle' was called on null.
// Receiver: null
// tried calling: homePageTitle
//
// I'm sure I had made the homePageTitle's value and it's not null.
//home: MyHomePage(title: I18n.of(context).homePageTitle),
home: MyHomePage(title: "I18n Test"),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
leading: IconButton(icon: Icon(Icons.settings),onPressed: () {
I18n.onLocaleChanged(Locale('zh'));
},),
actions: <Widget>[
FlatButton(child: Text('en-US'),textColor: Colors.white,onPressed: (){
I18n.onLocaleChanged(Locale('en'));
}),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
// flutter run --debug: work well
// flutter run --release: work well
I18n.of(context).greetTo("name") + " " + I18n.of(context).homePageTitle
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
} I am a new flutter developer. |
I also have exactly the same problem. I figure it out and the reason is because Flutter calls However, the generated |
Hi @idearibosome , the patch is working in iOS but not in android. |
@NuclearGear I have this issue only on iOS. On Android, it works well without that patch. |
Hi! I think that is a bug. Two lines after I'm able to do pull request quickly but I don't know if I'm right with my thoughts. |
Hello, I used this plugin to generate my json files for the translations.
It was super simple and fast, worked immediately on both Android and iOS.
Now I want to test it in release using
flutter run --release
, on Android the localization works perfectly, but on iOS only works in debug, in release mode the locale is always en_US (my fallback language).Am I missing something? Someone has the same problem?
I followed all the the steps in the github page/vs code plugin page.
This is my flutter doctor
The text was updated successfully, but these errors were encountered: