印度尼西亚的正确语言环境("id_ID"与"in_ID")? [英] Correct locale for Indonesia( "id_ID" Vs "in_ID" )?

查看:1186
本文介绍了印度尼西亚的正确语言环境("id_ID"与"in_ID")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用杂种6.0 version.我们的项目完全基于Backoffice.早些时候,我们为印度尼西亚语言环境配置了in_ID(languageISOcode_countryISOcode),并且工作正常,但是现在客户已要求将印度尼西亚语言环境设置为id_ID.

I am currently using 6.0 version of hybris. Our project is entirely based on Backoffice. Earlier We configured in_ID (languageISOcode_countryISOcode) for indonesia locale and was working fine but now Client has requested to do the locale setup as id_ID for Indonesia locale.

请注意,在languageISOcode中已弃用,而id是印度尼西亚的更新后的languageISOcode.

Please note, in languageISOcode is deprecated and id is the updated languageISOcode of Indonesia.

下面是我们的hybris中的代码片段:

Below is the snippet of code in our hybris:

final Locale locale = cockpitLocaleService.getCurrentLocale();

LOG.info("locale : " + locale); //Here I'm getting in_ID value of locale in all scenario

它正在调用Java的Locale.class文件,如果我通过了id_ID,那么convertOldISOCodes方法(在Locale.class内部)也会将id_ID转换为in_ID.

It is calling Locale.class file of java and If I pass id_ID then also convertOldISOCodes method(inside Locale.class) is converting id_ID to in_ID.

请参见下面的代码:

import java.util.Locale;

Locale localeIndonesia = new Locale("id", "ID");

System.out.println(localeIndonesia); //printed in_ID

您能帮我获得id_ID印度尼西亚的语言环境吗?

Could you please help me to get id_ID as locale for Indonesia.

OR

如果这是Java中的错误,那么是否有任何方法可以在hybri中获得 id_ID ?

If it's a bug in Java then Is there any way to get id_ID in hybris ?

推荐答案

您可以使用以下代码:

Locale locale = new Locale("id", "ID");
System.out.print(locale.toLanguageTag().replace('-', '_')) // printed id_ID

顺便说一句.它不是Java中的错误,而是向后兼容的问题". Java使用ISO 639的第一个版本.后来该标准已更新,并且一些代码已更新. Java被设计为完全向后兼容,因此作者决定不更新该代码.这就是为什么将"id_ID"更改为"in_ID"的原因.印度尼西亚语不是唯一以旧格式使用的代码.至少希伯来语和意第绪语也以旧形式使用.

Btw. it is not a bug in Java, but "the problem" with backward compatibility. Java uses the first version of ISO 639. Later the standard has been updated, and some codes have been updated. Java was designed as fully backward compatible, so the authors decided to not update that codes. It is the cause why "id_ID" is changed to "in_ID". Indonesian is not the only code which is used in an old form. At least Hebrew and Yiddish are also used in the old form.

+---------------------------------+
|  Language  | ISO 639 | ISO 3166 |
|------------|---------|----------|
| Indonesian |   IN    |    ID    |
|   Hebrew   |   HE    |    IW    |
|   Yiddish  |   YI    |    JI    |
+---------------------------------+

这篇关于印度尼西亚的正确语言环境("id_ID"与"in_ID")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆