Open main menu

Gramps β

Changes

Date Handler/he

743 bytes added, 1 May
m
יצירת מחלקת נתך תאריכים ממוקממת חדשה: typo
כל ההטיות שסופקו וכל הקידומות החד משמעיות שלהן יוכרו אוטומטית כמילים נרדפות חוקיות לקוד המחלקה הבסיסית של מנתח תאריכים.
===Providing a localized date displayer classהמקמת מחלקה למצג תאריכים===The displayer class must derive from the מחלקת מתצג התאריכים צריכה להגזר ממחלקת '''DateDisplay''' classבאופן הבא: <div dir="ltr"> from _DateDisplay import DateDisplay class MyDateParser(DateDisplay): ...</div>בנוסף היא אמורה לספק שיטת <div dir="ltr> <code>display()</code>.</div>אם משתמשם ביישום ברירת המחדל, יורשים ממנו את סגנון iso, כלומר, כל התאריכים יוצגו ללא הבדל גלוי בין תאריכי תקופה וטווח.
The displayer class must provide הרמת ההתאמה האישית הבאה תהיה בחירת חלופה "ארוזה" מראש אחרת, שמסופקת במחלקה הבסיסית, כדלקמן (כפי ש־DateDisplayEN עושה):<codediv dir="ltr"> display()= DateDisplay.display_formatted</codediv> methodהתאמה זו תתאים ליותר ממחצית מהשפות הנתמכות נכון להיום, שפות שלא מטפללות את רשימת המשתנים הזמינים למתצג התאריך.
If you inherit the default implementationליבת display_formatted מציגה תאריכים רגילים ו/או מורכבים, then all the dates will be displayed in iso styleומקשטת אותם, without any visible difference between span and range datesבמידת הצורך, במבחינים (כמו "לפני..."), מאייכי איכות (כמו "מחושב...") ולוחות שנה בעלי מידע תחילת שנה לא תקניים.
The next level of customization is to select another pre-canned alternativeכששפת היעד דורשת הטיית שמות חודשים תלויי מבחינים, provided in the base classאו, as follows (like DateDisplayEN does):למשל, אם התאריך הוא תאריך התחלה או סיום בטווח, נדרש להשתמש ולתרגם מחרוזות מיוחדות כדי לציין את ההטיה המתאימה. תיעוד לתרחיש מתקדם זה ניתן למצוא בהערות קוד המקור של DateDisplay.
display = DateDisplayכששפת היעד עוקפת את Display.formats למשהו אחר, היא צריכה לעקוף גם את _display_calendar (או את _display_gregorian/_display_hebrew/... בנפרד, לכל השיטות שמאצילות ל־_display_calendar כברירת מחדל עם רשימות שמות החודשים המתאימים). עקיפת _display_calendar צריכה לעצב את התאריך בהתאם לתסדיר מותאם אישית שנבחר, תוך שימוש במספר self.format כמפתח לרשימת self.formats.display_formatted
This will be sufficient for over half of the currently supported languages, that don't tweak the list of formats available for date display. The core of display_formatted displays both regular and compound dates, and adorns them, if necessary, with modifiers (as in "before..."), quality indicators (as in "calculated..."), and calendar/non-standard year start information. If your language requires inflections of month names dependent on modifiers, or, for instance, whether the date is a start or a stop date in a range, there are special strings you need to translate to indicate the appropriate inflection. Documentation for this advanced scenario can be found in the source code comments to DateDisplay. If your language overrides Display.formats to something else, it should also override _display_calendar (or, separately, the _display_gregorian/_display_hebrew/... whatever methods that delegate to _display_calendar by default with the appropriate month lists). The override of _display_calendar should format the date according to the currently selected custom format, using self.format number as an index into the self.formats list. ===Providing a localized date parser classיצירת מחלקת נתח תאריכים ממומקמת חדשה===The parser class must derive from the המחלקה החדש חייבת להגזר ממחלקת '''DateParser''' class: <div dir="ltr"><code> from _DateParser import DateParser</code><br> <code> class MyDateParser(DateParser):</code><br> <code> ...</code></div>::The parser class must provide מחלקת הנתח חייבת לספק את השיטה <div dir="ltr"><code>parse()</code> method. In fact</div> למעשה, since the base class already defines such methodמכיוון שהמחלקה הבסיסית כבר מגדירה שיטה זו, it is most likely that you will only need to re-define class constants and, maybe, the סביר להניח שיהיה צורך להגדיר מחדש רק את קבועי המחלקה ואולי את השיטה <div dir="ltr"><code>init_strings()</code> method.</div>
===Localizing the date formats===
3,401
edits