Open hamzakhanfcb10 opened 6 years ago
had the same issue. that's how I ended up fixing it :
if isCurrentLanguageRTL() {
calendar.locale = Locale(identifier: "ar")
calendar.calendarHeaderView.calendar.locale = Locale(identifier: "ar")
}else {
calendar.locale = Locale(identifier: "en_EN")
calendar.calendarHeaderView.calendar.locale = Locale(identifier: "en_EN")
}
you need to change headerView locale too.
Same issue here. I have tried above solution but still facing same issue in year. Header year display wrong.
The main calendar display correct date while select the date but problem with only above header date(Horizontal scroll view).
any one got a solution?
@tarikhs You can use my forked version full support RTL languages https://github.com/Husseinhj/FSCalendar It’s all really support persian, if you want to support arabic i will give you 1 hour
@Husseinhj Hi, Is your calendar support both English and arabic languages? I'm working on multilingual app and need both languages.
@rehannali yeah dude, it’s support RTL (Persian, Arabic ,...) and LTR (English ,...)
@Husseinhj Shukran Brother!
@Husseinhj , The app is crashed when i select any calendar from your app. The reason is : -[__NSCFConstantString isRTLCalendar]: unrecognized selector sent to instance. I have downloaded it from your v2.8.0
I did fix this at commit
@VidyaRajan7 Use the last version of FSCalendar+Persianv2.8.1
Ok Thank You @Husseinhj
@Husseinhj
If i want to display calendar in Arabic, how can i do it?
@VidyaRajan7 It's really simple, Look at the example and use your locale and calendar except for Persian. Like this :
- (void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
view.backgroundColor = [UIColor whiteColor];
self.view = view;
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), view.frame.size.width, view.frame.size.height - CGRectGetMaxY(self.navigationController.navigationBar.frame))];
calendar.locale = [NSLocale localeWithLocaleIdentifier:@"ar_SA"];
calendar.identifier = NSCalendarIdentifierIslamic; //or NSCalendarIdentifierIslamicCivil
calendar.firstWeekday = 7;
. . . . . . . .
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierIslamic];
self.dateFormatter = [[NSDateFormatter alloc] init];
self.dateFormatter.dateFormat = @"yyyy-MM-dd";
// Uncomment this to perform an 'initial-week-scope'
// self.calendar.scope = FSCalendarScopeWeek;
// For UITest
self.calendar.accessibilityIdentifier = @"calendar";
}
@Husseinhj find error in year when use pod 'FSCalendar+Persian'
my code if L102Language.currentAppleLanguage()=="ar"{ ClanderDate.locale=Locale(identifier: "ar_DZ") //ClanderDate.calendarHeaderView.calendar.locale = Locale(identifier: "ar_DZ") ClanderDate.identifier = NSCalendar.Identifier.islamic.rawValue
}
else{
ClanderDate.locale=Locale(identifier: "en_US_POSIX")
// ClanderDate.calendarHeaderView.calendar.locale = Locale(identifier: "en_US_POSIX")
}
@omarhassansadek Did you use implement FSCalendar delegate method?
#pragma mark - FSCalendarDataSource
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
{
return [self.dateFormatter dateFromString:@"2016-07-08"];
}
self.calendar.scope = FSCalendarScopeWeek
@VidyaRajan7 It's really simple, Look at the example and use your locale and calendar except for Persian. Like this :
- (void)loadView { UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; view.backgroundColor = [UIColor whiteColor]; self.view = view; FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), view.frame.size.width, view.frame.size.height - CGRectGetMaxY(self.navigationController.navigationBar.frame))]; calendar.locale = [NSLocale localeWithLocaleIdentifier:@"ar_SA"]; calendar.identifier = NSCalendarIdentifierIslamic; //or NSCalendarIdentifierIslamicCivil calendar.firstWeekday = 7; . . . . . . . . } - (void)viewDidLoad { [super viewDidLoad]; self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierIslamic]; self.dateFormatter = [[NSDateFormatter alloc] init]; self.dateFormatter.dateFormat = @"yyyy-MM-dd"; // Uncomment this to perform an 'initial-week-scope' // self.calendar.scope = FSCalendarScopeWeek; // For UITest self.calendar.accessibilityIdentifier = @"calendar"; }
Hi I m using v2.9.2. I want calendar in arabic . When i used this code, I'm not getting current year with current month calender. I checked in your example LoadViewExampleViewController by changing it to this code:
calendar.locale = Locale(identifier: "ar_SA")
calendar.calendarIdentifier = NSCalendar.Identifier.islamic.rawValue
calendar.calendarHeaderView.calendar.calendarIdentifier = NSCalendar.Identifier.islamic.rawValue
calendar.firstWeekday = 7
It's not showing the current date month. Please help me.
@anjusr Fixed in v2.9.3
wrong year in arabic language it is not fixed note : i add FSCalendar in UIView not in code
I have the same issue, I am using the FSCalendar+Persian pod, and the date header shows wron g dates after changing the application language.
@OmarHassan25 Could send me a snippet code or screenshot to see the problem?
I fixed it and I don’t remember how and I don’t have a code
On Mon, 24 Jan 2022 at 09:49, Hussein Habibi Juybari < @.***> wrote:
@OmarHassan25 https://github.com/OmarHassan25 Could send me a snippet code or screenshot to see the problem?
— Reply to this email directly, view it on GitHub https://github.com/WenchaoD/FSCalendar/issues/843#issuecomment-1019854284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFRK53I7J3PVTPTMDJLKEKTUXUHBRANCNFSM4EHRYYSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
--
Mustafa Wanni
Information Engineering in Artificial Intelligence
+963993162549 | Skype :Mustafa.wanni.94
https://www.facebook.com/https://www.facebook.com/mostafa.wane https://in.linkedin.com/in/mustafa-wani-a142ab72 https://api.whatsapp.com/send?phone=+963993162549 https://www.instagram.com/mustafawanni/
Information Engineering is my passion - There is nothing like dynamism and creativity with a large dose of technologies and coding.
@OmarHassan25 Could send me a snippet code or screenshot to see the problem?
@Husseinhj check this, please
self.localString = MOLHLanguage.currentAppleLanguage()
// meetingCalendar.collectionView.scroll
meetingCalendar.delegate = self
meetingCalendar.dataSource = self
meetingCalendar.locale = Locale(identifier: localString)
//meetingCalendar.appearance.headerDateFormat
meetingCalendar.appearance.titleFont = FontFamily.FSAlbertArabicWeb.regular.font(size: 14)
meetingCalendar.appearance.weekdayFont = FontFamily.FSAlbertArabicWeb.regular.font(size: 16)
meetingCalendar.appearance.headerTitleFont = FontFamily.FSAlbertArabicWeb.regular.font(size: 16)
meetingCalendar.firstWeekday = 7
meetingCalendar.appearance.weekdayTextColor = ColorName.mtDarkGreen.color
meetingCalendar.appearance.headerTitleColor = ColorName.mtDarkGreen.color
meetingCalendar.appearance.titlePlaceholderColor = ColorName.colorD4D8DB.color
meetingCalendar.appearance.selectionColor = ColorName.mtGreen.color
meetingCalendar.appearance.borderRadius = 1
meetingCalendar.appearance.eventOffset = CGPoint(x: 0, y: -7)
meetingCalendar.bottomBorder.isHidden = true
meetingCalendar.clipsToBounds = true
meetingCalendar.appearance.caseOptions = FSCalendarCaseOptions.weekdayUsesSingleUpperCase
I'll fix this during this week. @OmarHassan25
Thanks 😊
On Mon, 24 Jan 2022 at 10:18, Hussein Habibi Juybari < @.***> wrote:
I'll fix this during this week. @OmarHassan25 https://github.com/OmarHassan25
— Reply to this email directly, view it on GitHub https://github.com/WenchaoD/FSCalendar/issues/843#issuecomment-1019881062, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFRK53OI34EFVKQBX7CY2ZLUXUKNLANCNFSM4EHRYYSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
--
Mustafa Wanni
Information Engineering in Artificial Intelligence
+963993162549 | Skype :Mustafa.wanni.94
https://www.facebook.com/https://www.facebook.com/mostafa.wane https://in.linkedin.com/in/mustafa-wani-a142ab72 https://api.whatsapp.com/send?phone=+963993162549 https://www.instagram.com/mustafawanni/
Information Engineering is my passion - There is nothing like dynamism and creativity with a large dose of technologies and coding.
@Husseinhj Appreciate your fast response, waiting for the fix as promised,
Thanks in advance
@Husseinhj any updates please?
@OmarHassan25 I'll fix it on Saturday when I get back from vacation
@Husseinhj I hope that there are good news about the fix,
@OmarHassan25
You should add locale and calendar identifier to fixed that:
meetingCalendar.locale = NSLocale(localeIdentifier: "ar-ae") as Locale
meetingCalendar.calendarIdentifier = NSCalendar.Identifier.islamic.rawValue
@OmarHassan25
You should add locale and calendar identifier to fixed that:
meetingCalendar.locale = NSLocale(localeIdentifier: "ar-ae") as Locale
meetingCalendar.calendarIdentifier = NSCalendar.Identifier.islamic.rawValue
@Husseinhj This will not solve the issue, I need to use gregorian calendar with the Arabic language, I don't need to use Islamic calendar,
@OmarHassan25 Like this?
@OmarHassan25 Like this?
@Husseinhj Yes, This is my target,
@OmarHassan25
You can use this code snippet to achieve your goal:
override func loadView() {
let view = UIView(frame: UIScreen.main.bounds)
view.backgroundColor = UIColor.white
self.view = view
let calendar = FSCalendar(frame: CGRect(x: 0, y: (navigationController?.navigationBar.frame.maxY)!, width: view.frame.size.width, height: view.frame.size.height - (navigationController?.navigationBar.frame.maxY)!))
view.addSubview(calendar)
self.calendar = calendar
calendar.delegate = self
calendar.dataSource = self
calendar.locale = NSLocale(localeIdentifier: "ar-ae") as Locale
calendar.calendarIdentifier = NSCalendar.Identifier.gregorian.rawValue
calendar.firstWeekday = 7
calendar.appearance.borderRadius = 1
calendar.appearance.eventOffset = CGPoint(x: 0, y: -7)
calendar.clipsToBounds = true
calendar.appearance.caseOptions = FSCalendarCaseOptions.weekdayUsesSingleUpperCase
calendar.register(RangePickerCell.self, forCellReuseIdentifier: "cell")
}
@Husseinhj The issue comes when I change the application language while the app is running, if I killed the app and opened it again everything works fine,
If I opened the app with EN lang then changed to Arabic then the issue arises, If I removed the app from the recent apps menu and opened it again everything works as expected.
I hope that the issue is now more clear to you,
@OmarHassan25
After changing your application language, did you update or regenerate your calendar view?
@Husseinhj I recreate the full app navigation stack after changing the app language, so the calendar view is recreated again, So all my app is regenerated after the app language change, I use MOLHLanguage to manage my application locale.
@OmarHassan25
Is it possible for you to create a sample with the MOLHLanguage
library and an exact scenario so we can work together to figure out the issue?
@Husseinhj Here is the demo, https://drive.google.com/file/d/1UgEdfVXY_F24fmatL5wyjlGN8Y-c-FzN/view?usp=sharing
Steps to reproduce the issue, 1 - Open the app 2- Click go to calendar 3- Click change language from top right 4- repeat step3 2 and 3 again until the problem appears.
@OmarHassan25 I ran your sample project and found the issue. The library is unable to update states, so it displays the wrong year. It is better to use the calendar view in run-time rather than design mode.
Like this:
@IBOutlet weak var containerView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let calender = FSCalendar.init()
let current = MOLHLanguage.currentAppleLanguage()
// calender.locale = Locale(identifier: current)
calender.locale = NSLocale(localeIdentifier: "ar-ae") as Locale
calender.calendarIdentifier = NSCalendar.Identifier.gregorian.rawValue
containerView.addSubview(calender)
calender.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
calender.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
calender.topAnchor.constraint(equalTo: containerView.safeAreaLayoutGuide.topAnchor),
calender.bottomAnchor.constraint(equalTo: containerView.bottomAnchor),
calender.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
])
}
@IBAction func gotoChangeBtn(_ sender: Any) {
MOLH.setLanguageTo(MOLHLanguage.currentAppleLanguage() == "en" ? "ar-ae" : "en")
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.startNavigation()
}
@OmarHassan25 I ran your sample project and found the issue. The library is unable to update states, so it displays the wrong year. It is better to use the calendar view in run-time rather than design mode.
Like this:
@IBOutlet weak var containerView: UIView! override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) let calender = FSCalendar.init() let current = MOLHLanguage.currentAppleLanguage() // calender.locale = Locale(identifier: current) calender.locale = NSLocale(localeIdentifier: "ar-ae") as Locale calender.calendarIdentifier = NSCalendar.Identifier.gregorian.rawValue containerView.addSubview(calender) calender.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ calender.leadingAnchor.constraint(equalTo: containerView.leadingAnchor), calender.topAnchor.constraint(equalTo: containerView.safeAreaLayoutGuide.topAnchor), calender.bottomAnchor.constraint(equalTo: containerView.bottomAnchor), calender.trailingAnchor.constraint(equalTo: containerView.trailingAnchor) ]) } @IBAction func gotoChangeBtn(_ sender: Any) { MOLH.setLanguageTo(MOLHLanguage.currentAppleLanguage() == "en" ? "ar-ae" : "en") let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.startNavigation() }
@Husseinhj Thanks a lot for this solution, this solves my problem.
Hi @WenchaoD ,
I am using your awesome library again but this time in Arabic in xcode 9 ios 11. I am facing this issue in RLT. When i change the system language the header title is displaying irrelevant date.
This is the code for initial calendar setup.
As you can see the date in header is not correct. When i select a date from the calendar it is displaying wrong date value.
Need help urgently please. Thanks