⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 translator.java

📁 piweurrrrq i o fhsadhfka fd dskajc zxkjcnkjsahc
💻 JAVA
字号:
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.util.i18n;import java.util.Properties;public class Translator {    private static Properties _messages;    public Translator() {        this(new Properties());    }    public Translator(Properties p) {        if (_messages == null) {            _messages = p;        }    }    public String getMessage(String key) {        String s = _messages.getProperty(key);        if (s == null) {            throw new RuntimeException("No such key: " + key);        }        return s;    }    public String getMessage(String key, String arg1) {        String[] args = { arg1 };        return getMessage(key, args);    }    public String getMessage(String key, String arg1, String arg2) {        String[] args = { arg1, arg2 };        return getMessage(key, args);    }    public String getMessage(String key, String arg1, String arg2, String arg3) {        String[] args = { arg1, arg2, arg3 };        return getMessage(key, args);    }    public String getMessage(String key, String[] args) {        String s = getMessage(key);        StringBuffer sb = new StringBuffer();        char[] raw = s.toCharArray();        for (int i=0; i < raw.length; i++) {            char c = raw[i];//            System.err.println(i + ": " + c);            if (c == '{') {                int j=i;                for (; j < raw.length; j++) {                    if (raw[j] == '}') {                        break;                    }                }                int idx = extractInt(raw, i, j);                sb.append(args[idx]);                i = j;            } else {                sb.append(c);            }        }        return sb.toString();    }    int extractInt(char[] buf, int start, int end) {        start++;//        System.err.println("extractInt: " + start + ", " + end);        return Integer.parseInt(new String(buf, start, end-start));    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -