首页 技术 正文
技术 2022年11月14日
0 收藏 442 点赞 2,702 浏览 2289 个字

这两天在搞joomla插件,在看peter的视频,在此谢过他了。看到它汉化插件那个视频。反正闲着无聊,就写了一个Java小程序,方便使用joomla的人汉化插件。这个程序的方法很简单,你只要先运行outputToFile方法,将原来的英文配置拷贝到控制台,在输入ok,程序就会将英文配置输出到两个文件,你将zhi.txt中的英文利用百度翻译或者google翻译翻译好,覆盖zhi.txt中的内容,然后再运行getTranslationResult方法,将翻译好的重组一下重新输出至控制台。没花多少时间,所以代码写的也很差,各位不要骂人丢砖啊。

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;/**
* 将joomla插件汉化
* @author Agrin
*
*/
public class JoomlaPlugIn {public static final String LINE_SEPARATOR = System.getProperty("line.separator");
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {/*
* 方法
*
* 在控制台输入英文配置字段=“值”
*
* 从文件1当中逐行读取,拆分成字段 和 值,分别输出到两个文件中,ziduan.txt 和 zhi.txt中
*
* 将值当中的内容翻译好
*
* 然后再从两个文件中读数据,然后拼凑在一块,输出到控制台中
*
*/
File fieldFile = new File("ziduan.txt");
File valueFile = new File("zhi.txt");
if(!fieldFile.exists() || !valueFile.exists()){
return;
}//outputToFile(fieldFile, valueFile);getTranslationResult(fieldFile, valueFile);
}
/**
* 从文件中读取出翻译好的中文,拼凑好打印到控制台
* @param fieldFile
* @param valueFile
* @throws FileNotFoundException
* @throws IOException
*/
public static void getTranslationResult(File fieldFile, File valueFile)
throws FileNotFoundException, IOException {
BufferedReader fieldBr = new BufferedReader(new FileReader(fieldFile));
BufferedReader valueBr = new BufferedReader(new FileReader(valueFile));StringBuilder sb = new StringBuilder();
String field = fieldBr.readLine();
String value = valueBr.readLine();while (field != null && value != null) {
value = value.replaceAll("“", "");
value = value.replaceAll("”", "");
sb.append(field+" = "+"\""+value+"\""+LINE_SEPARATOR);
field = fieldBr.readLine();
value = valueBr.readLine();
}
System.out.println();
System.out.println(sb.toString());
}/**
* 将英文配置输出到文件
* @param fieldFile
* @param valueFile
* @throws IOException
*/
public static void outputToFile(File fieldFile, File valueFile)
throws IOException {
BufferedReader confBr = new BufferedReader(new InputStreamReader(System.in));
PrintWriter fieldPt = new PrintWriter(new FileWriter(fieldFile),true);
PrintWriter valuePt = new PrintWriter(new FileWriter(valueFile),true);String input = null;
while(!"ok".equals(input = confBr.readLine())){
String records[] = input.split("=");
fieldPt.println(records[0]);
valuePt.println(records[1]);
}fieldPt.close();
valuePt.close();
}}

这是原来的英文

这是翻译好的中文

希望对汉化joomla的插件的人员有点帮助吧

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,111
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922