Here you can find the source of getFilename(Locale locale, String fileName, String fileType)
Parameter | Description |
---|---|
locale | Locale to get the file for |
fileName | String fileName, to get the localized file for |
fileType | String file extension |
private static String getFilename(Locale locale, String fileName, String fileType)
//package com.java2s; /**/* www . ja v a 2 s . c o m*/ * The contents of this file are subject to the license and copyright * detailed in the LICENSE and NOTICE files at the root of the source * tree and available online at * * http://www.dspace.org/license/ */ import java.io.File; import java.util.Locale; public class Main { /** * Get the appropriate localized version of a file according to language settings * e. g. help files in jsp/help/ * * @param locale * Locale to get the file for * @param fileName * String fileName, to get the localized file for * @param fileType * String file extension * @return localizedFileName * String - localized filename */ private static String getFilename(Locale locale, String fileName, String fileType) { String localizedFileName = null; boolean fileFound = false; // with Language, Country, Variant String fileNameLCV = null; // with Language, Country String fileNameLC = null; // with Language String fileNameL = null; fileNameL = fileName + "_" + locale.getLanguage(); if (fileType == null) { fileType = ""; } if (!("".equals(locale.getCountry()))) { fileNameLC = fileName + "_" + locale.getLanguage() + "_" + locale.getCountry(); if (!("".equals(locale.getVariant()))) { fileNameLCV = fileName + "_" + locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant(); } } if (fileNameLCV != null && !fileFound) { File fileTmp = new File(fileNameLCV + fileType); if (fileTmp.exists()) { fileFound = true; localizedFileName = fileNameLCV + fileType; } } if (fileNameLC != null && !fileFound) { File fileTmp = new File(fileNameLC + fileType); if (fileTmp.exists()) { fileFound = true; localizedFileName = fileNameLC + fileType; } } if (fileNameL != null && !fileFound) { File fileTmp = new File(fileNameL + fileType); if (fileTmp.exists()) { fileFound = true; localizedFileName = fileNameL + fileType; } } if (!fileFound) { localizedFileName = fileName + fileType; } return localizedFileName; } }