By GokiSoft.com| 20:19 03/08/2022|
Java Advanced

[Source Code] Tìm hiểu đa ngôn ngữ trong Java - C2108L

#global.properties


# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

option_1 = 1. Add
option_2 = 2. Edit
option_3 = 3. Delete
option_choose = Choose: 


#global_vi_VN.properties


# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

option_1 = 1. Them
option_2 = 2. Sua
option_3 = 3. Xoa
option_choose = Chon: 


#Test.java


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package lesson08;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 *
 * @author QTA
 */
public class Test {
    public static void main(String[] args) {
        showMenu();
    }
    
    static void showMenu() {
//        Locale locale = new Locale("vi", "VN");
        Locale locale = Locale.getDefault();
        ResourceBundle bundle = ResourceBundle.getBundle("res.global", locale);
        
        System.out.println(bundle.getString("option_1"));
        System.out.println(bundle.getString("option_2"));
        System.out.println(bundle.getString("option_3"));
        System.out.println(bundle.getString("option_choose"));
    }
}


Tags:

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)