반응형
m.logPrint() is working!
<eq> and <eqq> tags are rendered to MathJax format, being enclosed by \ ( \ ) and \ [ \ ].
docuK-1 scripts started!
If this log is not closed automatically, there must be an error somewhere in your document or scripts.
Table of Contents is filled out.
Auto numberings of sections (div.sec>h2, div.subsec>h3, div.subsubsec>h4), <eqq> tags, and <figure> tags are done.
<cite> and <refer> tags are rendered to show bubble reference.
<codeprint> tags are printed to corresponding <pre> tags, only when the tags exist in the document.
Current styles (dark/bright mode, font-family, font-size, line-height) are shown.
disqus.js with id="disqus-js" is loaded.
kakao.js with id="kakao-jssdk" is loaded.
New ShortKeys (T: Table of Contents, F: Forward Section, D: Previous Section, L: To 전체목록/[Lists]) are set.
m.delayPad=0;
m.wait=1024;
wait 1520ms.
<eq> and <eqq> tags are rendered to MathJax format, being enclosed by \ ( \ ) and \ [ \ ].
docuK-1 scripts started!
If this log is not closed automatically, there must be an error somewhere in your document or scripts.
Table of Contents is filled out.
Auto numberings of sections (div.sec>h2, div.subsec>h3, div.subsubsec>h4), <eqq> tags, and <figure> tags are done.
<cite> and <refer> tags are rendered to show bubble reference.
<codeprint> tags are printed to corresponding <pre> tags, only when the tags exist in the document.
Current styles (dark/bright mode, font-family, font-size, line-height) are shown.
disqus.js with id="disqus-js" is loaded.
kakao.js with id="kakao-jssdk" is loaded.
New ShortKeys (T: Table of Contents, F: Forward Section, D: Previous Section, L: To 전체목록/[Lists]) are set.
m.delayPad=0;
m.wait=1024;
wait 1520ms.







Mode: Bright; Font: Noto Sans KR; font-size: 18.0px (10.0); line-height: 1.6;
width: 1280, height: 720, version: 2.12.18
dg:plink (Document Global Permanent Link): https://kipid.tistory.com/188
document.referrer: Empty
width: 1280, height: 720, version: 2.12.18
dg:plink (Document Global Permanent Link): https://kipid.tistory.com/188
document.referrer: Empty







Web site - 다국어 지원 (multi-language support)
다국어를 지원하는 여러 방법들이 있는거 같긴한데... 내가 다루기 편한 형태로서 다국어 지원하려고 다음과 같은 JAVA class 들을 만듬.
Table of Contents
T1.class FileMap
▼ Show/Hide
On the left side of codes is there a hiden button to toggle/switch scrollability ({max-height:some} or {max-height:none}).
package recoeve.db; import java.lang.StringBuilder; import java.util.Set; import java.util.HashSet; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.regex.Pattern; import java.util.regex.Matcher; import java.io.File; import java.io.FileReader; import java.io.IOException; public class FileMap { private static final String[] referersAllowed={ "localhost" , "recoeve.net" // , "kipid.tistory.com" }; private static final String imgPath="C:/Recoeve/img"; private static final String[] imgNames={ "/favicon.ico" , "/icon-Twitter.png", "/icon-Facebook.png" }; private static final String filePath="C:/Recoeve/sources/recoeve/db/html/"; private static final String[] fileNames={ "jquery.min.js" , "log-in.html", "to-log-in.html" //, "log-in.css", "log-in.js" , "log-out.html" , "user-page.html", "to-user-page.html" , "redirect.html", "remember-me.html" , "AJAX post test (Cross orgin policy) and Reco test.html", "Reco-musics-test.html" }; private static final int fileMapSize=50; private static final int fileLangMapSize=10; public static Set<String> refererSet; public static Map<String, String> imgMap; // imgMap.get("imgName") public static Map<String, Map<String, String>> fileMap; // fileMap.get("fileName").get("lang") public static final Pattern ptnReplacer=Pattern.compile("\\[--[\\s\\S]+?--\\]"); static { refererSet=new HashSet<String>(); for (String referer: referersAllowed) { refererSet.add(referer); } imgMap=new HashMap<String, String>(); for (String imgName: imgNames) { imgMap.put(imgName, imgPath+imgName); } fileMap=new HashMap<String, Map<String, String>>(fileMapSize); File file=null; String fileStr=null; file=new File(filePath+"lang.txt"); if (file.exists()) { try { StringBuilder sb=new StringBuilder(); int ch; FileReader reader=new FileReader(file); while((ch=reader.read())!=-1) { sb.append((char)ch); } reader.close(); fileStr=sb.toString(); } catch (IOException e) { System.out.println(e); } finally { file=null; } } StrArray langMap=new StrArray(fileStr, true, true); // System.out.println(langMap); fileStr=null; for (String fileName: fileNames) { file=new File(filePath+fileName); if (file.exists()) { try { StringBuilder sb=new StringBuilder(); int ch; FileReader reader=new FileReader(file); while((ch=reader.read())!=-1) { sb.append((char)ch); } reader.close(); fileStr=sb.toString(); } catch (IOException e) { System.out.println(e); } finally { file=null; } } if (fileStr!=null) { // System.out.println("\nfileName : "+fileName); fileMap.put(fileName, new HashMap<String, String>(fileLangMapSize)); Map<String, String> fileLangMap=fileMap.get(fileName); fileLangMap.put("df", fileStr); // default. int start=0; Matcher matchReplacer=ptnReplacer.matcher(fileStr); ArrayList<String> strList=new ArrayList<String>(); while (start<fileStr.length()) { if (matchReplacer.find(start)) { strList.add(fileStr.substring(start, matchReplacer.start())); strList.add(matchReplacer.group()); start=matchReplacer.end(); } else { strList.add(fileStr.substring(start)); start=fileStr.length(); } } if (strList.size()>1) { int colSize=langMap.getColSizeAtRow(0); for (int k=2;k<colSize;k++) { String lang=langMap.get(0,k); if (!lang.equals("desc")) { String strReplaced=""; String replaced=null; for (int i=0;i<strList.size();i++) { if (i%2==0) { strReplaced+=strList.get(i); } else { replaced=langMap.get(strList.get(i), lang); if (replaced==null||replaced.isEmpty()||replaced.equals("-")) { replaced=langMap.get(strList.get(i), "en"); // "en" is default lang. } if (replaced==null) { replaced=strList.get(i); } strReplaced+=replaced; } } fileLangMap.put(lang, strReplaced); // after replacing langMap. } } } fileStr=null; } } } public FileMap() {} public static boolean refererAllowed(String host) { return refererSet.contains(host); } public static String getImg(String imgName) { return imgMap.get(imgName); } public static String get(String fileName, String lang) { Map<String, String> fileLangMap=fileMap.get(fileName); if (fileLangMap==null) {return null;} String res=fileLangMap.get(lang); if (res==null) { res=fileLangMap.get("df"); } return res; } public static void main(String... args) { // System.out.println(FileMap.refererAllowed("localhost")); // System.out.println(FileMap.get("AJAX post test (Cross orgin policy) and Reco test.html", "en")); // System.out.println(Pattern.quote("[a-d]")); } }
▲ Hide
T2.class FileMapWithVar
▼ Show/Hide
On the left side of codes is there a hiden button to toggle/switch scrollability ({max-height:some} or {max-height:none}).
package recoeve.db; import java.lang.StringBuilder; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.regex.Pattern; import java.util.regex.Matcher; import java.io.File; import java.io.FileReader; import java.io.IOException; public class FileMapWithVar { private static String filePath="C:/Recoeve/sources/recoeve/db/html/"; private static final String[] fileNames={ "user-page.html" , "signed-up.html" // , "redirect.html", "remember-me.html" }; private static final int fileMapSize=50; private static final int fileLangMapSize=10; public static Map<String, Map<String, ArrayList<String>>> fileMap; // fileMap.get("fileName").get("lang") public static final Pattern ptnReplacer=Pattern.compile("\\[--[\\s\\S]+?--\\]"); public static final Pattern ptnVariable=Pattern.compile("\\{--[\\s\\S]+?--\\}"); static { fileMap=new HashMap<String, Map<String, ArrayList<String>>>(fileMapSize); File file=null; String fileStr=null; file=new File(filePath+"lang.txt"); if (file.exists()) { try { StringBuilder sb=new StringBuilder(); int ch; FileReader reader=new FileReader(file); while((ch=reader.read())!=-1) { sb.append((char)ch); } reader.close(); fileStr=sb.toString(); } catch (IOException e) { System.out.println(e); } finally { file=null; } } StrArray langMap=new StrArray(fileStr, true, true); // System.out.println(langMap); fileStr=null; for (String fileName: fileNames) { file=new File(filePath+fileName); if (file.exists()) { try { StringBuilder sb=new StringBuilder(); int ch; FileReader reader=new FileReader(file); while((ch=reader.read())!=-1) { sb.append((char)ch); } reader.close(); fileStr=sb.toString(); } catch (IOException e) { System.out.println(e); } finally { file=null; } } if (fileStr!=null) { // System.out.println("\nfileName : "+fileName); fileMap.put(fileName, new HashMap<String, ArrayList<String>>(fileLangMapSize)); Map<String, ArrayList<String>> fileLangMap=fileMap.get(fileName); ArrayList<String> strListVars=new ArrayList<String>(); Matcher matchVariable=ptnVariable.matcher(fileStr); // default int start=0; while (start<fileStr.length()) { if (matchVariable.find(start)) { strListVars.add(fileStr.substring(start, matchVariable.start())); strListVars.add(matchVariable.group()); start=matchVariable.end(); } else { strListVars.add(fileStr.substring(start)); start=fileStr.length(); } } fileLangMap.put("df", strListVars); // default. ArrayList<String> strList=new ArrayList<String>(); Matcher matchReplacer=ptnReplacer.matcher(fileStr); start=0; while (start<fileStr.length()) { if (matchReplacer.find(start)) { strList.add(fileStr.substring(start, matchReplacer.start())); strList.add(matchReplacer.group()); start=matchReplacer.end(); } else { strList.add(fileStr.substring(start)); start=fileStr.length(); } } if (strList.size()>1) { int colSize=langMap.getColSizeAtRow(0); for (int k=2;k<colSize;k++) { String lang=langMap.get(0,k); if (!lang.equals("desc")) { String strReplaced=""; String replaced=null; for (int i=0;i<strList.size();i++) { if (i%2==0) { strReplaced+=strList.get(i); } else { replaced=langMap.get(strList.get(i), lang); if (replaced==null||replaced.isEmpty()||replaced.equals("-")) { replaced=langMap.get(strList.get(i), "en"); // "en" is default lang. } if (replaced==null) { replaced=strList.get(i); } strReplaced+=replaced; } } strListVars=new ArrayList<String>(); matchVariable=ptnVariable.matcher(strReplaced); // [--lang--] replaced start=0; while (start<strReplaced.length()) { if (matchVariable.find(start)) { strListVars.add(strReplaced.substring(start, matchVariable.start())); strListVars.add(matchVariable.group()); start=matchVariable.end(); } else { strListVars.add(strReplaced.substring(start)); start=strReplaced.length(); } } fileLangMap.put(lang, strListVars); // after replacing langMap. } } } fileStr=null; } } } public FileMapWithVar() {} public static String get(String fileName, String lang, Map<String,String> varMap) { Map<String, ArrayList<String>> fileLangMap=fileMap.get(fileName); if (fileLangMap==null) {return null;} ArrayList<String> strList=fileLangMap.get(lang); if (strList==null) { strList=fileLangMap.get("df"); } String res=""; String replaced=null; for (int i=0;i<strList.size();i++) { if (i%2==0) { res+=strList.get(i); } else { replaced=varMap.get(strList.get(i)); if (replaced==null) { replaced=strList.get(i); } res+=replaced; } } return res; } public static void main(String... args) { Map<String,String> varMap=new HashMap<String,String>(); varMap.put("{--userIndex--}", "10000"); varMap.put("{--userId--}", "id"); varMap.put("{--user email--}", "id@email.com"); // System.out.println(FileMapWithVar.get("signed-up.html", "en", varMap)); } }
▲ Hide







반응형
'[IT/Programming]' 카테고리의 다른 글
카카오톡 채널 광고 차단하는 법 (0) | 2023.10.27 |
---|---|
정렬법 (Sorting Algorithm) (0) | 2023.06.01 |
Open AI chatbot ChatGPT 가 신 (GOD) 이 될 수 있을까? (0) | 2023.05.30 |
Compiling and Running JAVA (Build System) through batch (.bat) and shell script (.sh) (0) | 2022.12.19 |
움직이는 사진 gif 만들기 (GifCam.exe) (1) | 2019.03.06 |
한국 IT의 미래 (0) | 2019.03.04 |
JAVA SE 8 - API - index with Fuzzy Search (0) | 2019.02.19 |