Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale 'ru_RU' doesn't work and throw an error. InitializeDateFormatting has beed used. #433

Closed
KrillioSokolov opened this issue Mar 14, 2021 · 13 comments

Comments

@KrillioSokolov
Copy link

KrillioSokolov commented Mar 14, 2021

@aleksanderwozniak, Russian locale haven't work. I've done all by instruction. I found samples of code for Portuguese and implemented it and It works. But when I try to use Russian or Ukrainian or Belorussia it wont. I've even try Iraq and its work) but not with 'ru_RU'
Screenshot 2021-03-14 at 17 35 38
Screenshot 2021-03-14 at 17 36 22
Screenshot 2021-03-14 at 17 36 46

Originally posted by @KrillioSokolov in #417 (comment)

@aleksanderwozniak
Copy link
Owner

Can you check if locale: 'ru_RU' works for you in example project? It doesn't seem to have any issues on my end:

@KrillioSokolov
Copy link
Author

It seems like it won't work with intl localisation... initializeDateFormatting conflicting with

[
const AppLocalizationDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
];

@aleksanderwozniak
Copy link
Owner

I just tried it on the example project - looks like you can safely remove the conflicting initializeDateFormatting() if you are using localizationsDelegates. Doing so still allowed me to use locale: 'ru_RU' without any hiccups.

@Artem-Sobolev
Copy link

Artem-Sobolev commented Mar 16, 2021

I just tried it on the example project - looks like you can safely remove the conflicting initializeDateFormatting() if you are using localizationsDelegates. Doing so still allowed me to use locale: 'ru_RU' without any hiccups.

The problem is not solved with deleting initializeDateFormatting() in main function. The problem remains if there is a need to use some functions from intl package with table_calendar widget. I've also tried polish and spanish locale and they work fine but russian locale doesn't work.

изображение_2021-03-16_175814

@aleksanderwozniak
Copy link
Owner

@Artem-Sobolev
Please try running the example project with 'ru_RU' locale and see if the problem is still present.

@KrillioSokolov
Copy link
Author

KrillioSokolov commented Mar 16, 2021

For header locale works perfectly in Russian, but not for weekdays. It's strange...

Screenshot 2021-03-16 at 18 13 57

@Artem-Sobolev
Copy link

Artem-Sobolev commented Mar 17, 2021

For header locale works perfectly in Russian, but not for weekdays. It's strange...

Screenshot 2021-03-16 at 18 13 57

@KrillioSokolov So, it seems I have found the root of the problem for myself. The problem was in calling

dowTextBuilder: (date, locale) {
          return DateFormat.E(locale)
              .format(date)
              //.substring(0, 3)
              .toLowerCase();
        }

so the issue isn't actually in this package or something but in my code. Here as you can see I'm trying to cut the string and only take first three letters. And here is the trick: in english you have for example "mon, tue, wed and etc", but in russian you get "пн, вт, ср, чт..." thus you can't take the third letter when taking a substring. It was a bit confusing to find since debug console messages didn't point on this line but after few shenanigans I've finally found it. After I've found this line I went through all similar lines of code and fixed them where it is needed and now everything works fine.

@Tamerlanchiques
Copy link

Have same issue in my project. Tried to use ru_RU in example code. It doesn't work.

@KrillioSokolov
Copy link
Author

For header locale works perfectly in Russian, but not for weekdays. It's strange...
Screenshot 2021-03-16 at 18 13 57

@KrillioSokolov So, it seems I have found the root of the problem for myself. The problem was in calling

dowTextBuilder: (date, locale) {
          return DateFormat.E(locale)
              .format(date)
              //.substring(0, 3)
              .toLowerCase();
        }

so the issue isn't actually in this package or something but in my code. Here as you can see I'm trying to cut the string and only take first three letters. And here is the trick: in english you have for example "mon, tue, wed and etc", but in russian you get "пн, вт, ср, чт..." thus you can't take the third letter when taking a substring. It was a bit confusing to find since debug console messages didn't point on this line but after few shenanigans I've finally found it. After I've found this line I went through all similar lines of code and fixed them where it is needed and now everything works fine.

Looks like we copy code from the medium, where table calendars was compared)) because I've the same lines of code))

@aleksanderwozniak
Copy link
Owner

@Tamerlanchiques
What does the debug console log say? Also, what's your Flutter and package version?

@Tamerlanchiques
Copy link

@aleksanderwozniak Just ran table_calendar/example and ru_RU locale works fine for me so never mind.

@Tamerlanchiques
Copy link

But, 2 weeks / week / month selector didn't translated.

@aleksanderwozniak
Copy link
Owner

Looks like this can be closed now.

@Tamerlanchiques
You need to provide your own translations for the format button: https://github.com/aleksanderwozniak/table_calendar#specifying-a-language. Use availableCalendarFormats for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants