Easy_localization: ScriptCode localization support

Created on 11 Apr 2020  路  5Comments  路  Source: aissat/easy_localization

I need to support Locale for Serbian language that has both Cyrilic and Latin scriptCode, and therefore locales look like this:

Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: 'RS')
Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: 'RS')

And due to this requirement I have 2 JSON files for Serbian:

  1. sr_Cyrl-RS.json
  2. sr_Latn-RS.json

But unfortunately plugin just gives me error "Unable to load asset "lang/sr-RS.json"
How can I include support for scriptCode into my locale using this plugin?

App Store just released support for several contries including Serbia, so I assume a lot of iOS developers will now start supporting this language and will need this plugin to do so.

enhancement

All 5 comments

@LugonjaAleksandar easy_localization doesn鈥檛 support scriptCode yet, today I鈥檒l do PR. Can you translate in the example locales?

@Overman775 I've managed to do a workaround for now, just to continue with the development by adding this code:

EasyLocalization(
      child: MyApp(),
      useOnlyLangCode: false,
      fallbackLocale: Locale('sr_Cyrl', 'RS'),
      supportedLocales: [
        Locale('sr_Cyrl', 'RS'),
        Locale('sr_Latn', 'RS'),
        Locale('en', 'US'),
      ],
      path: 'lang',
    )

Problem with this approach is that it doesn't work and throws errors below in main class when I provide locale and supportedLocales from this library for MaterialApp to consume.

I/flutter (19222): 鈺愨晲鈺愨晲鈺愨晲鈺愨晲
I/flutter (19222): Warning: This application's locale, sr_Cyrl_RS, is not supported by all of its
I/flutter (19222): localization delegates.
I/flutter (19222): > A MaterialLocalizations delegate that supports the sr_Cyrl_RS locale was not found.
I/flutter (19222): See https://flutter.dev/tutorials/internationalization/ for more
I/flutter (19222): information about configuring an app's locale, supportedLocales,
I/flutter (19222): and localizationsDelegates parameters.
I/flutter (19222): 鈺愨晲鈺愨晲鈺愨晲鈺愨晲

@LugonjaAleksandar @aissat fixed #136

@LugonjaAleksandar

dependencies:
  easy_localization: ^2.2.0-dev

This works perfectly now, and all localisation delegates are recognising the format specified. Just for the reference if someone has the same issue, file names should be sr-Cyrl-RS.json and sr-Latn-RS.json.

When can we expect official release of this fix?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KarlChow92 picture KarlChow92  路  3Comments

deimantasa picture deimantasa  路  4Comments

AdelMahmoudHussein picture AdelMahmoudHussein  路  7Comments

necipk picture necipk  路  5Comments

KirillArtemenko picture KirillArtemenko  路  6Comments