| 17 | import org.apache.commons.io.IOUtils; |
| 18 | |
| 19 | public class Lang |
| 20 | { |
| 21 | private static final Splitter splitter = Splitter.on('=').limit(2); |
| 22 | private static final Pattern pattern = Pattern.compile("%(\\d+\\$)?[\\d\\.]*[df]"); |
| 23 | |
| 24 | public static void resourcesReloaded() |
| 25 | { |
| 26 | Map map = I18n.getLocaleProperties(); |
| 27 | List<String> list = new ArrayList(); |
| 28 | String s = "optifine/lang/"; |
| 29 | String s1 = "en_US"; |
| 30 | String s2 = ".lang"; |
| 31 | list.add(s + s1 + s2); |
| 32 | |
| 33 | if (!Config.getGameSettings().language.equals(s1)) |
| 34 | { |
| 35 | list.add(s + Config.getGameSettings().forceUnicodeFont + s2); |
| 36 | } |
| 37 | |
| 38 | String[] astring = (String[])((String[])list.toArray(new String[list.size()])); |
| 39 | loadResources(Config.getDefaultResourcePack(), astring, map); |
| 40 | IResourcePack[] airesourcepack = Config.getResourcePacks(); |
| 41 | |
| 42 | for (int i = 0; i < airesourcepack.length; ++i) |
| 43 | { |
| 44 | IResourcePack iresourcepack = airesourcepack[i]; |
| 45 | loadResources(iresourcepack, astring, map); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | private static void loadResources(IResourcePack rp, String[] files, Map localeProperties) |
| 50 | { |
| 51 | try |
| 52 | { |
| 53 | for (int i = 0; i < files.length; ++i) |
| 54 | { |
| 55 | String s = files[i]; |
| 56 | ResourceLocation resourcelocation = new ResourceLocation(s); |
| 57 | |
| 58 | if (rp.resourceExists(resourcelocation)) |
| 59 | { |
| 60 | InputStream inputstream = rp.getInputStream(resourcelocation); |
| 61 | |
| 62 | if (inputstream != null) |
| 63 | { |
| 64 | loadLocaleData(inputstream, localeProperties); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | catch (IOException ioexception) |
| 70 | { |
| 71 | ioexception.printStackTrace(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | public static void loadLocaleData(InputStream is, Map localeProperties) throws IOException |
| 76 | { |