針對日本紀元變更準備您的應用程式Prepare your application for the Japanese era change

注意

新的紀元年號已在 2019 年 4 月 1 日宣布:Reiwa (令和)。On April 1, 2019, the new era name was announced: Reiwa (令和). 在 4 月 25 日,Microsoft 針對不同的 Windows 作業系統發行了套件,其中包含以新的紀元年號更新的登錄機碼。On April 25, Microsoft released packages for different Windows operating systems containing the updated registry key with the new era name. 更新您的裝置和檢查您的登錄,以查看是否有新的金鑰,然後測試您的應用程式。Update your device and check your registry to see if it has the new key, and then test your application. 請檢查這篇支援文章,確定您的作業系統應已收到更新的登錄機碼。Check this support article to make sure your operating system should have received the updated registry key.

日本曆劃分為紀元,而我們經歷的現代電腦運算時期,大部分落在平成紀元;不過,2019 年 5 月 1 日將會開啟新的紀元。The Japanese calendar is divided into eras, and for most of the modern age of computing, we've been in the Heisei era; however, on May 1, 2019, a new era will begin. 因為這是數十年來第一次要改換年號重新紀元,支援日本曆的軟體需要進行測試,以確保該軟體可在新紀元開始時正常運作。Because this is the first time in decades for an era to change, software that supports the Japanese calendar will need to be tested to ensure it will function properly when the new era begins.

在下列各節中,您將了解如何因應即將來臨的新紀元,準備並測試您的應用程式。In the following sections, you will learn what you can do to prepare and test your application for the upcoming new era.

注意

由於您所做的變更將會影響整部電腦的行為,我們建議使用測試電腦來進行這項工作。We recommend that you use a test machine for this, because the changes you make will impact the behavior of the entire machine.

新增新紀元的登錄機碼Add a registry key for the new era

注意

下列指示適用於尚未以新的登錄機碼更新的裝置。The following instructions are meant for devices that have not yet been updated with the new registry key. 先檢查您的裝置是否包含新的登錄機碼,而如果沒有,請使用下列指示進行測試。First check if your device contains the new registry key, and if not, test using the following instructions.

請務必在紀元變更之前測試相容性問題,而您目前可以先使用新的紀元年號來進行。It is important to test for compatibility problems before the era has changed, and you can do so now using the new era name. 若要這樣做,請使用 [登錄編輯程式] 新增新紀元的登錄機碼:To do this, add a registry key for the new era using Registry Editor:

  1. 瀏覽至 Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Calendars\Japanese\ErasNavigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Calendars\Japanese\Eras.
  2. 選取 [編輯] > [新增] > [字串值] ,並指定其名稱 2019 05 01Select Edit > New > String Value, and give it the name 2019 05 01.
  3. 以滑鼠右鍵按一下機碼,然後按一下 [修改] 。Right-click the key and select Modify.
  4. 在 [值資料] 欄位中,輸入令和_令_Reiwa_R (您從這裡複製後再貼上,會變得容易些)。In the Value data field, enter 令和_令_Reiwa_R (you can copy and paste from here to make it easier).

如需深入了解這些登錄機碼的格式,請參閱日本曆的紀元處理方式See Era Handling for the Japanese Calendar to read more about the format for these registry keys.

新的紀元年號已在 2019 年 4 月 1 日宣布。On April 1, 2019, the new era name was announced. 在 4 月 25 日,針對包含此年號的支援 Windows 版本發行了具有新登錄機碼的更新,讓您驗證您的應用程式是否能適當地處理它。On April 25, an update with a new registry key for supported Windows versions containing the name was released, allowing you to validate that your application handles it properly. 這項更新正傳播至支援的舊版 Windows 10,以及 Windows 8 和 7。This update is being propagated to supported earlier releases of Windows 10, as well as Windows 8 and 7.

完成應用程式的測試後,就可以刪除您的預留位置登錄機碼。You can delete your placeholder registry key once you're finished testing your application. 這可確保不會干擾更新 Windows 時新增的新登錄機碼。This will ensure it doesn't interfere with the new registry key that will be added when Windows is updated.

變更您裝置的日曆格式Change your device's calendar format

新增新紀元的登錄機碼後,您必須將裝置設定為使用日本曆。Once you've added the registry key for the new era, you need to configure your device to use the Japanese calendar. 您的裝置沒有日文語言,也能這樣做。You don't need to have a Japanese-language device to do this. 進行完整測試時,您可能還需要安裝日文語言套件,但是基本測試就不需要如此。For thorough testing, you may want to install the Japanese language pack as well, but it isn't required for basic testing.

若要將您的裝置設定為使用日本曆:To configure your device to use the Japanese calendar:

  1. 開啟 intl.cpl (可從 Windows 搜尋列搜尋找出)。Open intl.cpl (search for it from the Windows search bar).
  2. 從 [格式] 下拉式清單選取 [日文 (日本)] 。From the Format dropdown, select Japanese (Japan).
  3. 選取 [其他設定] 。Select Additional settings.
  4. 選取 [日期] 索引標籤。Select the Date tab.
  5. 從 [月曆類型] 下拉式清單選取 [和暦] (wareki 日本曆)。From the Calendar type dropdown, select 和暦 (wareki, the Japanese calendar). 這應該會是第二個選項。It should be the second option.
  6. 按一下 [確定] 。Click OK.
  7. 按一下 [地區] 視窗中的 [確定] 。Click OK in the Region window.

您的裝置現在應該已設定為使用日本曆,無論哪個紀元在登錄中,都會反映出來。Your device should now be configured to use the Japanese calendar, and it will reflect whichever eras are in the registry. 以下是您可能會在畫面右下角看到現的範例:Below is an example of what you might see now in the lower-right corner of the screen:

使用日本曆格式的日期及時間

調整您裝置的時鐘Adjust your device's clock

若要測試您的應用程式是否可搭配新紀元使用,您必須將電腦的時鐘往前調到 2019 年 5 月 1 日或更晚的日期。To test that your application works with the new era, you must advance your computer's clock to May 1, 2019 or later. 下列指示適用於 Windows 10,但 Windows 8 和 7 也應該同樣有效:The following instructions are for Windows 10, but Windows 8 and 7 should work similarly:

  1. 以滑鼠右鍵按一下畫面右下角的日期和時間區域。Right-click the date and time area in the lower-right corner of the screen.
  2. 選取 [調整日期/時間] ,Select Adjust date/time.
  3. 在 [設定] 應用程式的 [變更日期和時間] 下方,選取 [變更] 。In the Settings app, under Change date and time, select Change.
  4. 將日期變更為 2019 年 5 月 1 日或之後的日期。Change the date to on or after May 1, 2019.

注意

您可能無法根據組織設定變更日期;如果發生這種情況,請洽詢您的管理員。或者,您可以編輯預留位置登錄機碼,以使用過去的日期。You may not be able to change the date based on organization settings; if this is the case, talk to your admin. Alternatively, you can edit your placeholder registry key to have a date that has already passed.

測試您的應用程式Test your application

現在來測試應用程式處理新紀元的情況。Now, test out how your application handles the new era. 檢查會顯示日期的位置,例如時間戳記和日期選擇器。Check places where the date is displayed, such as timestamps and date pickers. 確定紀元在 2019 年 5 月1 日之前 (平成) 和之後 (令和) 的年號是正確的。Make sure that the era is correct before May 1, 2019 (Heisei, 平成) and after (Reiwa, 令和).

元年Gannen (元年)

日本曆的格式通常是 <紀元年號> <紀元年份>The format for the Japanese calendar is generally <Era name> <Year of era>. 例如,2018 年是平成 30 年For example, the year 2018 is Heisei 30 (平成30年). 不過,紀元的第一年有特殊格式;使用的不是 <紀元年號> 1 年,而是 <紀元年號> 元年However, the first year of an era is special; instead of being <Era name> 1, it is <Era name> 元年 (gannen). 因此,平成紀元的第一年會是「平成元年」 。So, the first year of the Heisei era would be 平成元年 (Heisei gannen). 請確定您的應用程式會適當處理新紀元的第一年,並正確輸出「令和元年」。Make sure that your application properly handles the first year of the new era, and correctly outputs 令和元年.

有幾個 WinRT、.NET 和 Win32 API 會更新來處理紀元變更,因此用到這些 API 的話,您應該不需要太過擔心。There are several WinRT, .NET, and Win32 APIs that will be updated to handle the era change, so if you use them, you shouldn't have to worry too much. 不過,即使您可以完全依賴這些 API,最好還是要測試您的應用程式,確定看到您想要得到的行為,尤其是在您要用它們來執行任何特殊作業 (例如剖析) 的時候。However, even if you do rely entirely on these APIs, it's still a good idea to test your application and make sure you get the desired behavior, especially if you are doing anything special with them like parsing.

您可以透過因應日本紀元於 2019 年 5 月變更的更新深入了解 OS 與 SDK 的更新。You can follow along with updates to the OS and SDKs at Updates for May 2019 Japan Era Change.

下列 API 將受影響:The following APIs will be impacted:

WinRTWinRT

.NET.NET

Win32Win32

請參閱See also