easy_localization icon indicating copy to clipboard operation
easy_localization copied to clipboard

Unable to load asset

Open duck-dev-go opened this issue 3 years ago • 2 comments

On IOS when I change the device language of the device multiple time I get the following error

image

The whole app doesn't work and I even need to uninstall to get it working again. It doesn't matter which language I switch to. Usually it happens after 3 to 6 times switching language.

I wrap my app widget with the EasyLocalization

runApp(
  EasyLocalization(
    supportedLocales: [
      Locale('af'),
      Locale('da'),
      Locale('de'),
      Locale('el'),
      Locale('en'),
      Locale('es'),
      Locale('fi'),
      Locale('fr'),
      Locale('hu'),
      Locale('id'),
      Locale('it'),
      Locale('ms'),
      Locale('nb'),
      Locale('nl'),
      Locale('pl'),
      Locale('pt'),
      Locale('ru'),
      Locale('sv'),
      Locale('tr'),
    ],
    path: 'assets/translations',
    useOnlyLangCode: true,
    fallbackLocale: Locale('en'),
    child: _App( ),
  ),
);

And I have all my json files in assets/translations. I import the translations like this

flutter:
  uses-material-design: true
  assets:
    - assets/images/
    - assets/translations/
    - assets/translations/notifications/

duck-dev-go avatar Aug 28 '21 03:08 duck-dev-go

I've the same problem, any solution please

MrAbdelrahman10 avatar Oct 21 '21 10:10 MrAbdelrahman10

Did you add

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>nb</string>
</array>

to the Info.plist file?

Edit: You need to add the codes of the languages you support here.

HakkiAlkan avatar Nov 29 '21 07:11 HakkiAlkan

I don't know if it'll help in your case but I was having the same problem when I was deploying on the web and it was that file name and the locale declaration is case sensitive. Eg. Locale('pt', 'br') the file name should also be pt-br.json and not pt-BR.json, so your translation file names should follow how you declared them in "Locale".

rsegecin avatar Feb 02 '23 03:02 rsegecin

Closing since there was no feedback on a potential solution

bw-flagship avatar May 14 '23 11:05 bw-flagship