Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Language Not Changing

brightinfotech3 opened this issue · comments

Hello Team
Greetings of the Day!!

i have integrate the localisation in application, Its integrated successfully, but when i try to change the language then it's not translated

Can you please tell me how i can resolve it

I am change the language from other screen, like from profile screen..

Here is my main.dart code

import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_translate/flutter_translate.dart';
import 'Home.dart';

final GlobalKey navigatorKey = GlobalKey(debugLabel: "Main Navigator");

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
var delegate = await LocalizationDelegate.create(fallbackLocale: 'en_US', supportedLocales: ['en_US', 'ar']);
runApp(LocalizedApp(delegate,
new MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: navigatorKey,
home: new MyApp()
),
),
);
}

class MyApp extends StatelessWidget {

@OverRide
Widget build(BuildContext context) {

var localizationDelegate = LocalizedApp.of(context).delegate;

new Future.delayed(const Duration(seconds: 10), () {
  Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => Home()));
});


return LocalizationProvider(
  state: LocalizationProvider.of(context).state,

  child: MaterialApp(
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      localizationDelegate
    ],
    supportedLocales: localizationDelegate.supportedLocales,
    locale: localizationDelegate.currentLocale,


    debugShowCheckedModeBanner: false,
    theme: ThemeData(
      backgroundColor: Color.fromARGB(1, 138, 51, 147),
    ),
    home: Scaffold(
      backgroundColor: Colors.white,
      body: Container(
        child: new Center(
            child: new Image(image: new AssetImage('assets/images/logo.png'), fit: BoxFit.fill)
        ),
      ),
    ),
  ),
);

}
}

The issue is probably related to how you perform the navigation.

@bratan what's the solution for that? I have the same issue and I do a normal transition. The example in the repo has a single page. That's working for me but not when I go back