示例#1
0
 private static string[] GetJapaneseEnglishEraNames()
 {
     if (GlobalizationMode.Invariant)
     {
         throw new PlatformNotSupportedException();
     }
     return(JapaneseCalendar.EnglishEraNames());
 }
示例#2
0
        //
        // Get a bunch of data for a calendar
        //
        internal CalendarData(string localeName, CalendarId calendarId, bool bUseUserOverrides)
        {
            this.bUseUserOverrides = bUseUserOverrides;

            Debug.Assert(!GlobalizationMode.Invariant);

            if (!LoadCalendarDataFromSystem(localeName, calendarId))
            {
                Debug.Fail("[CalendarData] LoadCalendarDataFromSystem call isn't expected to fail for calendar " + calendarId + " locale " + localeName);

                // Something failed, try invariant for missing parts
                // This is really not good, but we don't want the callers to crash.
                if (this.sNativeName == null)
                {
                    this.sNativeName = string.Empty;                                     // Calendar Name for the locale.
                }
                // Formats
                if (this.saShortDates == null)
                {
                    this.saShortDates = Invariant.saShortDates;                            // Short Data format, default first
                }
                if (this.saYearMonths == null)
                {
                    this.saYearMonths = Invariant.saYearMonths;                            // Year/Month Data format, default first
                }
                if (this.saLongDates == null)
                {
                    this.saLongDates = Invariant.saLongDates;                            // Long Data format, default first
                }
                if (this.sMonthDay == null)
                {
                    this.sMonthDay = Invariant.sMonthDay;                            // Month/Day format
                }
                // Calendar Parts Names
                if (this.saEraNames == null)
                {
                    this.saEraNames = Invariant.saEraNames;                                       // Names of Eras
                }
                if (this.saAbbrevEraNames == null)
                {
                    this.saAbbrevEraNames = Invariant.saAbbrevEraNames;                                       // Abbreviated Era Names
                }
                if (this.saAbbrevEnglishEraNames == null)
                {
                    this.saAbbrevEnglishEraNames = Invariant.saAbbrevEnglishEraNames;                                       // Abbreviated Era Names in English
                }
                if (this.saDayNames == null)
                {
                    this.saDayNames = Invariant.saDayNames;                                       // Day Names, null to use locale data, starts on Sunday
                }
                if (this.saAbbrevDayNames == null)
                {
                    this.saAbbrevDayNames = Invariant.saAbbrevDayNames;                                       // Abbrev Day Names, null to use locale data, starts on Sunday
                }
                if (this.saSuperShortDayNames == null)
                {
                    this.saSuperShortDayNames = Invariant.saSuperShortDayNames;                                       // Super short Day of week names
                }
                if (this.saMonthNames == null)
                {
                    this.saMonthNames = Invariant.saMonthNames;                                       // Month Names (13)
                }
                if (this.saAbbrevMonthNames == null)
                {
                    this.saAbbrevMonthNames = Invariant.saAbbrevMonthNames;                                       // Abbrev Month Names (13)
                }
                // Genitive and Leap names can follow the fallback below
            }

            if (calendarId == CalendarId.TAIWAN)
            {
                if (SystemSupportsTaiwaneseCalendar())
                {
                    // We got the month/day names from the OS (same as gregorian), but the native name is wrong
                    this.sNativeName = "\x4e2d\x83ef\x6c11\x570b\x66c6";
                }
                else
                {
                    this.sNativeName = string.Empty;
                }
            }

            // Check for null genitive names (in case unmanaged side skips it for non-gregorian calendars, etc)
            if (this.saMonthGenitiveNames == null || this.saMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saMonthGenitiveNames[0]))
            {
                this.saMonthGenitiveNames = this.saMonthNames;              // Genitive month names (same as month names for invariant)
            }
            if (this.saAbbrevMonthGenitiveNames == null || this.saAbbrevMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0]))
            {
                this.saAbbrevMonthGenitiveNames = this.saAbbrevMonthNames;    // Abbreviated genitive month names (same as abbrev month names for invariant)
            }
            if (this.saLeapYearMonthNames == null || this.saLeapYearMonthNames.Length == 0 || string.IsNullOrEmpty(this.saLeapYearMonthNames[0]))
            {
                this.saLeapYearMonthNames = this.saMonthNames;
            }

            InitializeEraNames(localeName, calendarId);

            InitializeAbbreviatedEraNames(localeName, calendarId);

            // Abbreviated English Era Names are only used for the Japanese calendar.
            if (calendarId == CalendarId.JAPAN)
            {
                this.saAbbrevEnglishEraNames = JapaneseCalendar.EnglishEraNames();
            }
            else
            {
                // For all others just use the an empty string (doesn't matter we'll never ask for it for other calendars)
                this.saAbbrevEnglishEraNames = new string[] { "" };
            }

            // Japanese is the only thing with > 1 era.  Its current era # is how many ever
            // eras are in the array.  (And the others all have 1 string in the array)
            this.iCurrentEra = this.saEraNames.Length;
        }
示例#3
0
        //
        // Get a bunch of data for a calendar
        //
        internal CalendarData(string localeName, CalendarId calendarId, bool bUseUserOverrides)
        {
            this.bUseUserOverrides = bUseUserOverrides;

            Debug.Assert(!GlobalizationMode.Invariant);

            bool loadedCalendarData = GlobalizationMode.UseNls ?
                                      NlsLoadCalendarDataFromSystem(localeName, calendarId) :
                                      IcuLoadCalendarDataFromSystem(localeName, calendarId);

            if (!loadedCalendarData)
            {
                // LoadCalendarDataFromSystem sometimes can fail on Linux if the installed ICU package is missing some resources.
                // The ICU package can miss some resources in some cases like if someone compile and build the ICU package manually or ICU has a regression.

                // Something failed, try invariant for missing parts
                // This is really not good, but we don't want the callers to crash.
                this.sNativeName ??= string.Empty;           // Calendar Name for the locale.

                // Formats
                this.saShortDates ??= Invariant.saShortDates; // Short Data format, default first
                this.saYearMonths ??= Invariant.saYearMonths; // Year/Month Data format, default first
                this.saLongDates ??= Invariant.saLongDates;   // Long Data format, default first
                this.sMonthDay ??= Invariant.sMonthDay;       // Month/Day format

                // Calendar Parts Names
                this.saEraNames ??= Invariant.saEraNames;                           // Names of Eras
                this.saAbbrevEraNames ??= Invariant.saAbbrevEraNames;               // Abbreviated Era Names
                this.saAbbrevEnglishEraNames ??= Invariant.saAbbrevEnglishEraNames; // Abbreviated Era Names in English
                this.saDayNames ??= Invariant.saDayNames;                           // Day Names, null to use locale data, starts on Sunday
                this.saAbbrevDayNames ??= Invariant.saAbbrevDayNames;               // Abbrev Day Names, null to use locale data, starts on Sunday
                this.saSuperShortDayNames ??= Invariant.saSuperShortDayNames;       // Super short Day of week names
                this.saMonthNames ??= Invariant.saMonthNames;                       // Month Names (13)
                this.saAbbrevMonthNames ??= Invariant.saAbbrevMonthNames;           // Abbrev Month Names (13)
                // Genitive and Leap names can follow the fallback below
            }

            if (calendarId == CalendarId.TAIWAN)
            {
                if (SystemSupportsTaiwaneseCalendar())
                {
                    // We got the month/day names from the OS (same as gregorian), but the native name is wrong
                    this.sNativeName = "\x4e2d\x83ef\x6c11\x570b\x66c6";
                }
                else
                {
                    this.sNativeName = string.Empty;
                }
            }

            // Check for null genitive names (in case unmanaged side skips it for non-gregorian calendars, etc)
            if (this.saMonthGenitiveNames == null || this.saMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saMonthGenitiveNames[0]))
            {
                this.saMonthGenitiveNames = this.saMonthNames;              // Genitive month names (same as month names for invariant)
            }
            if (this.saAbbrevMonthGenitiveNames == null || this.saAbbrevMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0]))
            {
                this.saAbbrevMonthGenitiveNames = this.saAbbrevMonthNames;    // Abbreviated genitive month names (same as abbrev month names for invariant)
            }
            if (this.saLeapYearMonthNames == null || this.saLeapYearMonthNames.Length == 0 || string.IsNullOrEmpty(this.saLeapYearMonthNames[0]))
            {
                this.saLeapYearMonthNames = this.saMonthNames;
            }

            InitializeEraNames(localeName, calendarId);

            InitializeAbbreviatedEraNames(localeName, calendarId);

            // Abbreviated English Era Names are only used for the Japanese calendar.
            if (calendarId == CalendarId.JAPAN)
            {
                this.saAbbrevEnglishEraNames = JapaneseCalendar.EnglishEraNames();
            }
            else
            {
                // For all others just use the an empty string (doesn't matter we'll never ask for it for other calendars)
                this.saAbbrevEnglishEraNames = new string[] { "" };
            }

            // Japanese is the only thing with > 1 era.  Its current era # is how many ever
            // eras are in the array.  (And the others all have 1 string in the array)
            this.iCurrentEra = this.saEraNames.Length;
        }
示例#4
0
        //
        // Get a bunch of data for a calendar
        //
        internal CalendarData(String localeName, int calendarId, bool bUseUserOverrides)
        {
            // Call nativeGetCalendarData to populate the data
            this.bUseUserOverrides = bUseUserOverrides;
            if (!nativeGetCalendarData(this, localeName, calendarId))
            {
                Contract.Assert(false, "[CalendarData] nativeGetCalendarData call isn't expected to fail for calendar " + calendarId + " locale " + localeName);

                // Something failed, try invariant for missing parts
                // This is really not good, but we don't want the callers to crash.
                if (this.sNativeName == null)
                {
                    this.sNativeName = String.Empty;                                        // Calendar Name for the locale.
                }
                // Formats
                if (this.saShortDates == null)
                {
                    this.saShortDates = Invariant.saShortDates;                             // Short Data format, default first
                }
                if (this.saYearMonths == null)
                {
                    this.saYearMonths = Invariant.saYearMonths;                             // Year/Month Data format, default first
                }
                if (this.saLongDates == null)
                {
                    this.saLongDates = Invariant.saLongDates;                               // Long Data format, default first
                }
                if (this.sMonthDay == null)
                {
                    this.sMonthDay = Invariant.sMonthDay;                                   // Month/Day format
                }
                // Calendar Parts Names
                if (this.saEraNames == null)
                {
                    this.saEraNames = Invariant.saEraNames;                                                                 // Names of Eras
                }
                if (this.saAbbrevEraNames == null)
                {
                    this.saAbbrevEraNames = Invariant.saAbbrevEraNames;                                                     // Abbreviated Era Names
                }
                if (this.saAbbrevEnglishEraNames == null)
                {
                    this.saAbbrevEnglishEraNames = Invariant.saAbbrevEnglishEraNames;                                       // Abbreviated Era Names in English
                }
                if (this.saDayNames == null)
                {
                    this.saDayNames = Invariant.saDayNames;                                                                 // Day Names, null to use locale data, starts on Sunday
                }
                if (this.saAbbrevDayNames == null)
                {
                    this.saAbbrevDayNames = Invariant.saAbbrevDayNames;                                                     // Abbrev Day Names, null to use locale data, starts on Sunday
                }
                if (this.saSuperShortDayNames == null)
                {
                    this.saSuperShortDayNames = Invariant.saSuperShortDayNames;                                             // Super short Day of week names
                }
                if (this.saMonthNames == null)
                {
                    this.saMonthNames = Invariant.saMonthNames;                                                             // Month Names (13)
                }
                if (this.saAbbrevMonthNames == null)
                {
                    this.saAbbrevMonthNames = Invariant.saAbbrevMonthNames;                                                 // Abbrev Month Names (13)
                }
                // Genitive and Leap names can follow the fallback below
            }

            // Clean up the escaping of the formats
            this.saShortDates = CultureData.ReescapeWin32Strings(this.saShortDates);
            this.saLongDates  = CultureData.ReescapeWin32Strings(this.saLongDates);
            this.saYearMonths = CultureData.ReescapeWin32Strings(this.saYearMonths);
            this.sMonthDay    = CultureData.ReescapeWin32String(this.sMonthDay);

            if ((CalendarId)calendarId == CalendarId.TAIWAN)
            {
                // for Geo----al reasons, the ----ese native name should only be returned when
                // for ----ese SKU
                if (CultureInfo.IsTaiwanSku)
                {
                    // We got the month/day names from the OS (same as gregorian), but the native name is wrong
                    this.sNativeName = "\x4e2d\x83ef\x6c11\x570b\x66c6";
                }
                else
                {
                    this.sNativeName = String.Empty;
                }
            }

            // Check for null genitive names (in case unmanaged side skips it for non-gregorian calendars, etc)
            if (this.saMonthGenitiveNames == null || String.IsNullOrEmpty(this.saMonthGenitiveNames[0]))
            {
                this.saMonthGenitiveNames = this.saMonthNames;              // Genitive month names (same as month names for invariant)
            }
            if (this.saAbbrevMonthGenitiveNames == null || String.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0]))
            {
                this.saAbbrevMonthGenitiveNames = this.saAbbrevMonthNames;    // Abbreviated genitive month names (same as abbrev month names for invariant)
            }
            if (this.saLeapYearMonthNames == null || String.IsNullOrEmpty(this.saLeapYearMonthNames[0]))
            {
                this.saLeapYearMonthNames = this.saMonthNames;
            }

            InitializeEraNames(localeName, calendarId);

            InitializeAbbreviatedEraNames(localeName, calendarId);

            // Abbreviated English Era Names are only used for the Japanese calendar.
            if (!GlobalizationMode.Invariant && calendarId == (int)CalendarId.JAPAN)
            {
                this.saAbbrevEnglishEraNames = JapaneseCalendar.EnglishEraNames();
            }
            else
            {
                // For all others just use the an empty string (doesn't matter we'll never ask for it for other calendars)
                this.saAbbrevEnglishEraNames = new String[] { "" };
            }

            // Japanese is the only thing with > 1 era.  Its current era # is how many ever
            // eras are in the array.  (And the others all have 1 string in the array)
            this.iCurrentEra = this.saEraNames.Length;
        }
示例#5
0
 internal CalendarData(string localeName, int calendarId, bool bUseUserOverrides)
 {
     this.bUseUserOverrides = bUseUserOverrides;
     if (!CalendarData.nativeGetCalendarData(this, localeName, calendarId))
     {
         if (this.sNativeName == null)
         {
             this.sNativeName = string.Empty;
         }
         if (this.saShortDates == null)
         {
             this.saShortDates = CalendarData.Invariant.saShortDates;
         }
         if (this.saYearMonths == null)
         {
             this.saYearMonths = CalendarData.Invariant.saYearMonths;
         }
         if (this.saLongDates == null)
         {
             this.saLongDates = CalendarData.Invariant.saLongDates;
         }
         if (this.sMonthDay == null)
         {
             this.sMonthDay = CalendarData.Invariant.sMonthDay;
         }
         if (this.saEraNames == null)
         {
             this.saEraNames = CalendarData.Invariant.saEraNames;
         }
         if (this.saAbbrevEraNames == null)
         {
             this.saAbbrevEraNames = CalendarData.Invariant.saAbbrevEraNames;
         }
         if (this.saAbbrevEnglishEraNames == null)
         {
             this.saAbbrevEnglishEraNames = CalendarData.Invariant.saAbbrevEnglishEraNames;
         }
         if (this.saDayNames == null)
         {
             this.saDayNames = CalendarData.Invariant.saDayNames;
         }
         if (this.saAbbrevDayNames == null)
         {
             this.saAbbrevDayNames = CalendarData.Invariant.saAbbrevDayNames;
         }
         if (this.saSuperShortDayNames == null)
         {
             this.saSuperShortDayNames = CalendarData.Invariant.saSuperShortDayNames;
         }
         if (this.saMonthNames == null)
         {
             this.saMonthNames = CalendarData.Invariant.saMonthNames;
         }
         if (this.saAbbrevMonthNames == null)
         {
             this.saAbbrevMonthNames = CalendarData.Invariant.saAbbrevMonthNames;
         }
     }
     this.saShortDates = CultureData.ReescapeWin32Strings(this.saShortDates);
     this.saLongDates  = CultureData.ReescapeWin32Strings(this.saLongDates);
     this.saYearMonths = CultureData.ReescapeWin32Strings(this.saYearMonths);
     this.sMonthDay    = CultureData.ReescapeWin32String(this.sMonthDay);
     if ((int)(ushort)calendarId == 4)
     {
         this.sNativeName = !CultureInfo.IsTaiwanSku ? string.Empty : "中華民國曆";
     }
     if (this.saMonthGenitiveNames == null || string.IsNullOrEmpty(this.saMonthGenitiveNames[0]))
     {
         this.saMonthGenitiveNames = this.saMonthNames;
     }
     if (this.saAbbrevMonthGenitiveNames == null || string.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0]))
     {
         this.saAbbrevMonthGenitiveNames = this.saAbbrevMonthNames;
     }
     if (this.saLeapYearMonthNames == null || string.IsNullOrEmpty(this.saLeapYearMonthNames[0]))
     {
         this.saLeapYearMonthNames = this.saMonthNames;
     }
     this.InitializeEraNames(localeName, calendarId);
     this.InitializeAbbreviatedEraNames(localeName, calendarId);
     if (calendarId == 3)
     {
         this.saAbbrevEnglishEraNames = JapaneseCalendar.EnglishEraNames();
     }
     else
     {
         this.saAbbrevEnglishEraNames = new string[1] {
             ""
         }
     };
     this.iCurrentEra = this.saEraNames.Length;
 }