准备你的应用程序以进行日本纪元更改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 日 (Heisei, 平成) 之前和 (Reiwa, 令和) 之后正确无误。Make sure that the era is correct before May 1, 2019 (Heisei, 平成) and after (Reiwa, 令和).

Gannen (元年)Gannen (元年)

日本历的格式通常为 <纪元名称> <纪元年份>The format for the Japanese calendar is generally <Era name> <Year of era>. 例如,2018 年是 Heisei 30 (平成 30 年)。For example, the year 2018 is Heisei 30 (平成30年). 但是,纪元的第一年很特殊;不是 <纪元名称> 1,而是 <纪元名称> 元年 (gannen)。However, the first year of an era is special; instead of being <Era name> 1, it is <Era name> 元年 (gannen). 因此,平成纪元的第一年将为平成元年 (Heisei 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 月日本纪元更改的更新中的操作系统和 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