Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
MIT License
401 stars 118 forks source link

Language Not Changing #69

Closed brightinfotech3 closed 3 years ago

brightinfotech3 commented 3 years ago

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)
        ),
      ),
    ),
  ),
);

} }

bratan commented 3 years ago

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

erperejildo commented 10 months ago

@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