msarhan / ummalqura-calendar

Implementation of java.util.Calendar for the Umm Al-Qura calendar system.
MIT License
154 stars 51 forks source link

Crashes on any locale other than English and Arabic #11

Closed guidedways closed 6 years ago

guidedways commented 7 years ago

This line:

ResourceBundle resource = ResourceBundle.getBundle("com.github.msarhan.ummalqura.calendar.text.UmmalquraFormatData", locale);

crashes the app if run on French / German / Russian etc as the bundle only includes _ar and _en. This should be done in a try / catch and if a locale isn't found, English should be used.

msarhan commented 6 years ago

Added check for supported locale. I think it is not good to fallback to English locale if the provided locale is not supported. Thanks!

AmineMessabhia commented 5 years ago

@guidedways , i know this is way too late

but for anyone else coming here, you can always download the library, and use it in ur project, and simply add classes for any other language, then manually translate the months' names to that language, and don't forget to add the condition for your language, otherwise it'd keep throwing the Exception.

msarhan commented 3 years ago

@guidedways I was wrong about refusing fallback solution if the current locale is not supported as this library could be used on mobile devices with no control of the used locale.

Thanks to @AmineMessabhia for the suggestion. I've added the possibility to add new locale using properties files which is much easier than creating Java class for localization. And in case of missing locale, it will fallback to ENGLISH locale.

Please check v1.2.0