次の記事では、Java における国際化の概要を説明します。国際化とは、アプリケーションに変更を加えることなく、複数の国、言語、通貨を自動的にサポートするような Web アプリケーションを作成するプロセスです。文字 I と N の間に 18 文字があるため、I18N とも呼ばれます。今日、ソフトウェアや Web サイトを設計する場合、世界的な市場は重要な要素です。世界市場向けのソフトウェア アプリケーションの拡大が続く中、企業は現地の地域や言語のユーザーを魅了する製品を作成する必要があります。
無料ソフトウェア開発コースを始めましょう
Web 開発、プログラミング言語、ソフトウェア テスト、その他
国際市場向けのソフトウェアに取り組んでいる開発者は、それぞれの文化の習慣と違いを認識する必要があります。言語、句読点、通貨、日付、時刻、数字、タイムゾーンはすべて違いの例です。最初の文字「L」と最後の文字「N」の間に 10 文字があるため、ローカリゼーションは I10N とも短縮されます。ローカリゼーションとは、アプリケーションを特定の言語と場所に合わせて調整できるように、ロケール固有のテキストとコンポーネントをアプリケーションに追加するプロセスです。
Java における国際化の構文
次のクラスを使用して国際化を実装できます:
- ロケール
- 数値形式
- 日付形式
1.ロケール
Locale オブジェクトは、地理的位置または言語を表すために使用できます。 java.util パッケージには Locale クラスが含まれています。
Locale クラスのコンストラクター:
Locale l = new Locale(String language);
Locale l = new Locale(String language, String country);
ロケールクラスの定数:
一部の Locale 定数は Locale クラスですでに宣言されています。
これらの定数は直接使用できます。いくつかの定数を以下に示します。
- ロケール。イギリス
- ロケール.ITALY
- ロケール.US
ロケールクラスの関数:
- pubic static Locale getDefault(): このメソッドは、現在のロケールのインスタンスを取得するために使用されます。
- public static Locale[] getAvailableLocales(): このメソッドは、現在のロケールの配列を取得するために使用されます。
- public String getDisplayLanguage(Locale l): このメソッドは、渡されたロケール オブジェクトの言語名を取得するために使用されます。
- public String getDisplayVariant(Locale l): このメソッドは、渡されたロケール オブジェクトのバリアント コードを取得するために使用されます。
- public String getDisplay Country(Locale l): このメソッドは、渡されたロケール オブジェクトの国名を取得するために使用されます。
- public static getISO3Language(): このメソッドは、ロケールの現在の言語コードの 3 文字の省略形を取得するために使用されます。
- public static getISO3 Country(): このメソッドは、ロケールの現在の国の 3 文字の略称を取得するために使用されます。
2.数値形式
NumberFormat クラスを使用すると、特定のロケールに従って数値を書式設定できます。 NumberFormat クラスは java.Text パッケージに存在し、抽象クラスであるため、そのコンストラクターを使用してオブジェクトを作成できません。
ロケールクラスの関数:
- public static NumberFormat getInstance(): このメソッドは、デフォルトの Locale のオブジェクトを取得するために使用されます。
- public static NumberFormat getInstance(Locale l): このメソッドは、渡された Locale オブジェクトのオブジェクトを取得するために使用されます。
- public static NumberFormat getCurrencyInstance(): このメソッドは、特定の通貨で表示するデフォルト ロケールのオブジェクトを取得するために使用されます。
- public static format(long l):このメソッドは、渡された数値をロケール オブジェクトに変換するために使用されます。
3.日付形式
日付の形式は場所によって異なるため、日付形式を国際化しています。 DateFromat クラスを使用すると、指定されたロケールに従って日付をフォーマットできます。 DateFormat は java.text パッケージの抽象クラスです。
ロケールクラスの定数:
一部の DateFormat 定数は、DateFormat クラスですでに宣言されています。
これらの定数は直接使用できます。いくつかの定数を以下に示します。
- DateFormat.LONG
- DateFormat.MINUTE_FIELD
- DateFormat.MINUTE_FIELD
DateFormat クラスの関数:
- final String format(Date date): This method converts and returns the specified Date object into a string.
- static final DateFormat getInstance(): This method is used to gets a date-time formatter with a short formatting style for date and time.
- static Locale[] getAvailableLocales(): This method is used to gets an array of present locales.
- static final DateFormat getTimeInstance(): This method is used to gets time formatter with default formatting style for the default locale.
- static final DateFormat getTimeInstance(int style): This method is used to gets time formatter with the specified formatting style for the default locale.
- static final DateFormat getTimeInstance(int style, Locale locale): This method is used to gets time formatter with the specified formatting style for the given locale.
- TimeZone getTimeZone(): This method is used to gets an object of TimeZone for this DateFormat instance.
- static final DateFormat getDateInstance(): This method is used to gets date formatter with default formatting style for the default locale.
- static final DateFormat getDateInstance(int style): This method is used to gets date formatter with the specified formatting style for the default locale.
- static final DateFormat getDateInstance(int style, Locale locale): This method is used to gets date formatter with the specified formatting style for the given locale.
- static final DateFormat getDateTimeInstance(): This method is used to gets date or time formatter with default formatting style for the default locale.
- NumberFormat getNumberFormat(): This method is used to gets an object of NumberFormat for this DateFormat instance.
- Calendar getCalendar(): This method is used to gets an object of the Calendar for this DateFormat instance.
Examples of Internationalization in Java
Given below are the examples mentioned:
Example #1
Example for the internationalization in Java to create different country locale.
Code:
// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.util.Locale; public class ex { public static void main(String[] args) { Locale[] locales = { new Locale("en", "US"), new Locale("it", "IT"), new Locale("es", "ES") }; for (int l=0; l <p><strong>Output:</strong></p> <p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/172500369926024.jpg?x-oss-process=image/resize,p_40" class="lazy" alt="Java の国際化" ></p> <p>As in the above program, the Locale class objects are created and store in the array. Next, used the for loop to iterate each locale object and display its name and its language, as we can see in the above output.</p> <h4 id="Example">Example #2</h4> <p>Example for the internationalization in Java to show the number in different formats for the different countries.</p> <p><strong>Code:</strong></p> <pre class="brush:php;toolbar:false">// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.util.*; import java.text.*; public class ex { public static void main (String[]args) { double n = 45273.8956; NumberFormat f1 = NumberFormat.getInstance (Locale.US); NumberFormat f2 = NumberFormat.getInstance (Locale.ITALY); NumberFormat f3 = NumberFormat.getInstance (Locale.CHINA); System.out.println ("The number format in US is :" + f1.format (n)); System.out.println ("The number format in ITALY is:" + f2.format (n)); System.out.println ("The number format in CHINA is :" + f3.format (n)); } }
Output:
As in the above program, three different NumberFormat class objects are created using the Locale class. Next, using the format() method of the NumberFormat class, the given number is printing in the specific format of the country, as we can see in the above output.
Example #3
Example for the internationalization in Java to show the date in different formats for the different countries.
Code:
// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.text.DateFormat; import java.util.Date; import java.util.Locale; public class ex { public static void main (String[]args) { DateFormat d1 = DateFormat.getDateInstance (0, Locale.US); DateFormat d2 = DateFormat.getDateInstance (0, Locale.ITALY); DateFormat d3 = DateFormat.getDateInstance (0, Locale.CHINA); System.out.println ("The date format in US is :" + d1.format (new Date ())); System.out.println ("The date format in ITALY is : " + d2.format (new Date ())); System.out.println ("The date format in CHINA is : " + d3.format (new Date ())); } }
Output:
As in the above program, three different DateFormat class objects are created using the Locale class. Next, using the format() method of the DateFormat class, the return date of the Date() method is printing in the specific format of the country, as we can see in the above output.
Conclusion
Internationalization is also called I18N because there are 18 characters between the letters I and N. It is the process of creating web applications in such a way that they automatically support several countries, languages, and currencies without requiring any changes to the application.
以上がJava の国際化の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

Javaは、プラットフォームの独立性により、エンタープライズレベルのアプリケーションで広く使用されています。 1)プラットフォームの独立性は、Java Virtual Machine(JVM)を介して実装されているため、Javaをサポートする任意のプラットフォームでコードを実行できます。 2)クロスプラットフォームの展開と開発プロセスを簡素化し、柔軟性とスケーラビリティを高めます。 3)ただし、パフォーマンスの違いとサードパーティライブラリの互換性に注意を払い、純粋なJavaコードやクロスプラットフォームテストの使用などのベストプラクティスを採用する必要があります。

javaplaysasificanificantduetduetoitsplatformindepence.1)itallowscodetobewrittendunonvariousdevices.2)java'secosystemprovidesutionforiot.3)そのセキュリティフィートルセンハンス系

TheSolution to HandlefilepathsaCrosswindossandlinuxinjavaistousepaths.get()fromthejava.nio.filepackage.1)usesystem.getProperty( "user.dir")およびhearterativepathtoconstructurctthefilepath.2)

java'splatformentepenceissificAntiveSifcuseDeverowsDevelowSowRitecodeOdeonceantoniTONAnyPlatformwsajvm.これは「writeonce、runanywhere」(wora)adportoffers:1)クロスプラットフォームの複雑性、deploymentacrossdiferentososwithusisues; 2)re

Javaは、クロスサーバーWebアプリケーションの開発に適しています。 1)Javaの「Write and、Run Averywhere」哲学は、JVMをサポートするあらゆるプラットフォームでコードを実行します。 2)Javaには、開発プロセスを簡素化するために、SpringやHibernateなどのツールを含む豊富なエコシステムがあります。 3)Javaは、パフォーマンスとセキュリティにおいて優れたパフォーマンスを発揮し、効率的なメモリ管理と強力なセキュリティ保証を提供します。

JVMは、バイトコード解釈、プラットフォームに依存しないAPI、動的クラスの負荷を介してJavaのWORA機能を実装します。 2。標準API抽象オペレーティングシステムの違い。 3.クラスは、実行時に動的にロードされ、一貫性を確保します。

Javaの最新バージョンは、JVMの最適化、標準的なライブラリの改善、サードパーティライブラリサポートを通じて、プラットフォーム固有の問題を効果的に解決します。 1)Java11のZGCなどのJVM最適化により、ガベージコレクションのパフォーマンスが向上します。 2)Java9のモジュールシステムなどの標準的なライブラリの改善は、プラットフォーム関連の問題を削減します。 3)サードパーティライブラリは、OpenCVなどのプラットフォーム最適化バージョンを提供します。

JVMのバイトコード検証プロセスには、4つの重要な手順が含まれます。1)クラスファイル形式が仕様に準拠しているかどうかを確認し、2)バイトコード命令の有効性と正確性を確認し、3)データフロー分析を実行してタイプの安全性を確保し、検証の完全性とパフォーマンスのバランスをとる。これらの手順を通じて、JVMは、安全で正しいバイトコードのみが実行されることを保証し、それによりプログラムの完全性とセキュリティを保護します。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

SublimeText3 中国語版
中国語版、とても使いやすい

メモ帳++7.3.1
使いやすく無料のコードエディター

Dreamweaver Mac版
ビジュアル Web 開発ツール
