Comments (10)
@filippkowalski Strange, this should work from my point of view. However, I can't provide any further info because I don't have the code
from easy_localization.
Hi @KevinTsangSKH, could you explain the issue with more details? What do you observe, what did you expect?
from easy_localization.
Hello, @bw-flagship
As you mentioned in the documentation, when we change the language, the languages of some widgets do not change. For example, the language of the widget I wrap with StreamBuilder does not change, but the language of the fields such as the page title changes. If we save the app with CMD + S or do a HOT reload, it gets fixed. At the user level, I need to open and close the app once for the language change to be detected.
If I print a log like the one below in the build function on the pages that do not change, that error is corrected. (I don't know if this will cause performance loss)
print('setting_view: ${context.locale}');
from easy_localization.
@ismailcaakir The desired behavior is that all the widgets update when changing the language.
If you experience it differently, could you provide a minimal sample to reproduce? Thanks!
from easy_localization.
@KevinTsangSKH did you manage to resolve the issue? I'm facing the same
from easy_localization.
ok, I've managed to fix it by removing const
from home: const HomePage(),
in main.dart
from easy_localization.
@filippkowalski This should not be necessary. I suppose your homePage was located in a place where it does not react on the BuildContext, e.g. because it is the home-attribute of the materialApp.
If that's the case, the proper fix would be to wrap it with a Builder()
from easy_localization.
@bw-flagship this is my main.dart
, it's rather a standard one:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
runApp(
EasyLocalization(
supportedLocales: const [ Locale('pl'), Locale('en')],
path: 'assets/translations',
fallbackLocale: const Locale('en'),
child: const myappApp()
),
);
}
class myappApp extends StatefulWidget {
const myappApp({super.key});
@override
State<myappApp> createState() => _myappAppState();
}
class _myappAppState extends State<myappApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: AppColors.colorBrand),
useMaterial3: true,
),
home: HomePage(), // do not put const as it's going to stop refreshing the language
);
}
}
from easy_localization.
@filippkowalski I sadly cannot run the example because I don't have the HomePage() widget and the required assets.
However, it's exactly as I expected, the HomePage is a direct value for the "home"-Attribute.
This means that it does not react on the Build Context. E.g. if you would change the theme, the update would not work as well.
The fix to not make it const might work, but this is not the correct solution.
IMHO you should wrap the HomePage in a builder, I expect it to work then, and you can leave it const.
from easy_localization.
@bw-flagship I did try it, but to no avail
from easy_localization.
Related Issues (20)
- useOnlyLangCode config is not used anywhere
- [FEATURE REQUEST] Generate 'need_translations' file HOT 1
- Set locale does not work properly HOT 1
- Ability to get translations for specific locale without changing the application locale HOT 1
- after context.setLocale it Restarts/rebuild the whole app HOT 1
- please consider supporting/providing psuedolocalization HOT 3
- Tests failing when JSON file size is > 52 kbs HOT 1
- Generation error
- LocalizationsDelegate make widget rebuild after using route HOT 1
- setLocale(Locale) doesn't refresh the widgets. HOT 4
- Stuck (frezee) on splashscreen HOT 1
- Missings translations cause generation failure on Windows HOT 1
- version 4.0.0
- output-file not respected
- Crash on start on Android HOT 2
- [FR] Disable translation
- there is no example on how's this library works on api call, i want to add my translation files through api calls HOT 1
- How to correctly set Translation keys from a dynamic Map?
- Missing features about easy localization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy_localization.