channdara / flutter_localization

BSD 3-Clause "New" or "Revised" License
10 stars 17 forks source link

how to handle localization key is not found in the locale file? #4

Open Kancheraj opened 10 months ago

channdara commented 10 months ago

The localization key is not found due to it not being added in all the locale map data. You need those missing keys to all your locale map data that you use in the app.

If I'm getting your question wrong, please provide more information about your error. Thank you.

vibhashan commented 8 months ago

Same here.

mixin AppLocale { // static const String title = 'title'; static const String sampleText = 'sampleText';

static const Map<String, dynamic> EN = { // title: 'Localization', sampleText: 'Hello', }; static const Map<String, dynamic> SI = { // title: 'සිංහල', sampleText: 'Hello', }; }

The above is my file. But I can't use sampleText. It says "sampleText not found"

channdara commented 8 months ago

Hello @vibhashan Did you provide supportedLocales and localizationsDelegates to the MaterialApp in your app?

vibhashan commented 8 months ago

Yes I did...the key "title" is working fine...only issue is when I try to add a new key value for example "abc"

On Wed, 18 Oct 2023, 7:16 am Eam Channdara, @.***> wrote:

Hello @vibhashan https://github.com/vibhashan Did you provide supportedLocales and localizationsDelegates to the MaterialApp in your app?

— Reply to this email directly, view it on GitHub https://github.com/channdara/flutter_localization/issues/4#issuecomment-1767476568, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAVPAMHWILLD5LS6OTLUSK3X74YGDAVCNFSM6AAAAAA3SH5CW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRXGQ3TMNJWHA . You are receiving this because you were mentioned.Message ID: @.***>

channdara commented 8 months ago

@vibhashan I will check that. But make sure to re-run the app after adding a new key and value to the map data. Hot reload will not work and show the error "key not found"

vibhashan commented 8 months ago

Ohh okay. I did not actually re run the app instead performed hot reload. I'll check this and get back to you

On Wed, 18 Oct 2023, 10:14 am Eam Channdara, @.***> wrote:

@vibhashan https://github.com/vibhashan I will check that. But make sure to re-run the app after adding a new key and value to the map data. Hot reload will not work and show the error "key not found"

— Reply to this email directly, view it on GitHub https://github.com/channdara/flutter_localization/issues/4#issuecomment-1767631517, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAVPAMCNNFFDEEJD6SR653LX75NEBAVCNFSM6AAAAAA3SH5CW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRXGYZTCNJRG4 . You are receiving this because you were mentioned.Message ID: @.***>

vibhashan commented 8 months ago

Hi. Thanks for the tip. Actually after rerunning, all the new key-values and translations are working. Thanks brother, saved my day 😎🙌🔥