use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class ConversionConfigBean method generateXlfFilePath.
/**
* 根据新需求,将xlf文件存放在以目标语言为名称目录中的,用于生成路径
* @return ;
*/
public List<String> generateXlfFilePath() {
String tgtFilePath = ConverterUtil.toLocalPath(getTarget());
// 注释部分为加了语言代码后缀的情况
// String sourceFileName = source.substring(source.lastIndexOf(spearator));
List<String> xlfFilePaths = new ArrayList<String>();
for (Language lang : hasSelTgtLangList) {
// 修复 bug 2949 ,当文件名中出现 XLIFF 时,文件名获取失败,下面注释代码为之前的代码。 --robert 2013-04-01
// String[] pathArray = tgtFilePath.split(Constant.FOLDER_XLIFF);
// StringBuffer xlffPath = new StringBuffer(pathArray[0]);
// xlffPath.append(Constant.FOLDER_XLIFF).append(spearator).append(lang.getCode()).append(pathArray[1]);
String dirName = tgtFilePath.substring(0, tgtFilePath.lastIndexOf(File.separator) + 1);
String fileName = tgtFilePath.substring(tgtFilePath.lastIndexOf(File.separator) + 1, tgtFilePath.length());
StringBuffer xlfPahtSB = new StringBuffer();
xlfPahtSB.append(dirName);
xlfPahtSB.append(lang.getCode());
xlfPahtSB.append(File.separator);
xlfPahtSB.append(fileName);
// File targetTempFile = new File(xlffPath.toString());
// xlffPath = new StringBuffer(targetTempFile.getParentFile().getPath());
// xlffPath.append(spearator);
// int tempInt = sourceFileName.lastIndexOf(".");
// String fileEx = sourceFileName.substring(sourceFileName.lastIndexOf("."));
// String fileName = sourceFileName.substring(1, tempInt);
// xlffPath.append(fileName).append("_").append(lang.getCode()).append(fileEx).append(CommonFunction.R8XliffExtension_1);
// xlffPath.append(sourceFileName).append(CommonFunction.R8XliffExtension_1);
xlfFilePaths.add(xlfPahtSB.toString());
}
return xlfFilePaths;
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class ProjectConfiger method getTargetlanguages.
/**
* 获取项目的所有目标语言
* @return 如果返回空的list表示没有获取到项目的目标语言;
* @throws XPathParseException
* @throws NavException
* @throws XPathEvalException
*/
public List<Language> getTargetlanguages() throws XPathParseException, NavException, XPathEvalException {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/projectDescription/hs/language/target");
List<Language> targetLangs = new ArrayList<Language>();
while (ap.evalXPath() != -1) {
String code = vu.getCurrentElementAttribut("code", "");
String name = vu.getElementContent();
String image = vu.getCurrentElementAttribut("image", "");
String isBidi = vu.getCurrentElementAttribut("isbidi", "false");
targetLangs.add(new Language(code, name, image, isBidi.equals("false") ? false : true));
}
return targetLangs;
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class ProjectConfiger method createLanguageNode.
private String createLanguageNode(Language srcLang, List<Language> targetLang) {
StringBuffer content = new StringBuffer();
content.append("\n\t\t<language>");
if (srcLang != null) {
content.append("<source code='" + srcLang.getCode() + "' image='" + srcLang.getImagePath() + "' isbidi='" + srcLang.isBidi() + "'>");
content.append(srcLang.getName());
content.append("</source>");
}
for (int i = 0; i < targetLang.size(); i++) {
Language tLang = targetLang.get(i);
content.append("<target code='" + tLang.getCode() + "' image='" + tLang.getImagePath() + "' isbidi='" + tLang.isBidi() + "'>");
content.append(tLang.getName());
content.append("</target>");
}
content.append("</language>");
return content.toString();
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class CSVSettingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(5, 5, 5, 5).applyTo(tparent);
int height = 160;
if (isTBXConverter) {
height = 230;
}
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(320, height).grab(true, true).applyTo(tparent);
Composite cmpSelFile = new Composite(tparent, SWT.None);
GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).extendedMargins(0, 0, 0, 0).applyTo(cmpSelFile);
GridDataFactory.fillDefaults().applyTo(cmpSelFile);
new Label(cmpSelFile, SWT.None).setText(Messages.getString("dialog.CSVSettingDialog.lblFile"));
txtCSV = new Text(cmpSelFile, SWT.BORDER);
txtCSV.setEditable(false);
txtCSV.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnBrowse = new Button(cmpSelFile, SWT.None);
btnBrowse.setText(Messages.getString("dialog.CSVSettingDialog.btnBrowse"));
btnBrowse.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(Messages.getString("dialog.CSVSettingDialog.dialogTitle"));
String[] extensions = { "*.csv", "*.txt", "*" };
String[] filters = { Messages.getString("dialog.CSVSettingDialog.filters1"), Messages.getString("dialog.CSVSettingDialog.filters2"), Messages.getString("dialog.CSVSettingDialog.filters3") };
dialog.setFilterExtensions(extensions);
dialog.setFilterNames(filters);
String fileSep = System.getProperty("file.separator");
if (txtCSV.getText() != null && !txtCSV.getText().trim().equals("")) {
dialog.setFilterPath(txtCSV.getText().substring(0, txtCSV.getText().lastIndexOf(fileSep)));
dialog.setFileName(txtCSV.getText().substring(txtCSV.getText().lastIndexOf(fileSep) + 1));
} else {
dialog.setFilterPath(System.getProperty("user.home"));
}
String name = dialog.open();
if (name != null) {
txtCSV.setText(name);
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Composite cmpContent = new Composite(tparent, SWT.NONE);
cmpContent.setLayout(new GridLayout(2, false));
cmpContent.setLayoutData(new GridData(GridData.FILL_BOTH));
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbColSeparator"));
cmbColSeparator = new Combo(cmpContent, SWT.NONE);
cmbColSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbColSeparator.setItems(arrColSeparator);
cmbColSeparator.select(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbTextDelimiter"));
cmbTextDelimiter = new Combo(cmpContent, SWT.NONE);
cmbTextDelimiter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbTextDelimiter.setItems(arrTextDelimiter);
cmbTextDelimiter.setText("\"");
cmbTextDelimiter.setTextLimit(1);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbEncoding"));
cmbEncoding = new Combo(cmpContent, SWT.READ_ONLY);
cmbEncoding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
String[] arrEncoding = LocaleService.getPageCodes();
cmbEncoding.setItems(arrEncoding);
cmbEncoding.select(indexOf(arrEncoding, "UTF-8"));
if (isTBXConverter) {
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbLang"));
cmbLang = new TableComboViewer(cmpContent, SWT.READ_ONLY | SWT.BORDER);
TableCombo tableCombo = cmbLang.getTableCombo();
tableCombo.setShowTableLines(false);
tableCombo.setShowTableHeader(false);
tableCombo.setDisplayColumnIndex(-1);
tableCombo.setShowImageWithinSelection(true);
tableCombo.setShowColorWithinSelection(false);
tableCombo.setShowFontWithinSelection(false);
tableCombo.setVisibleItemCount(20);
cmbLang.getTableCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
ArrayList<Language> languages = new ArrayList<Language>(LocaleService.getDefaultLanguage().values());
Collections.sort(languages, new Comparator<Language>() {
public int compare(Language o1, Language o2) {
return o1.toString().compareTo(o2.toString());
}
});
cmbLang.setContentProvider(new ArrayContentProvider());
cmbLang.setLabelProvider(new LanguageLabelProvider());
cmbLang.setInput(languages);
cmbLang.getTableCombo().select(0);
createLabel(cmpContent, Messages.getString("dialog.CSVSettingDialog.cmbXCSTemplate"));
cmbXCSTemplate = new Combo(cmpContent, SWT.READ_ONLY);
cmbXCSTemplate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (xcsTemplates.length > 0) {
cmbXCSTemplate.setItems(xcsTemplates);
cmbXCSTemplate.select(0);
}
}
return tparent;
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class TerminologyViewPart method selectionChanged.
/**
* 监听来自IHSEditor的选中改变事件。
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// UNDO 每次启动程序后,术语匹配面板无法识别出术语。 2012-06-21
if (part == null || selection == null) {
return;
}
if (part instanceof IXliffEditor) {
if (!part.equals(tempEditor)) {
IXliffEditor editor = (IXliffEditor) part;
tempEditor = editor;
tempEditor = (IXliffEditor) part;
FileEditorInput input = (FileEditorInput) getSite().getPage().getActiveEditor().getEditorInput();
IProject currProject = input.getFile().getProject();
matcher.setCurrentProject(currProject);
}
} else {
firstAction.setEnabled(false);
return;
}
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
firstAction.setEnabled(false);
return;
}
IStructuredSelection structuredSelecion = (IStructuredSelection) selection;
Object object = structuredSelecion.getFirstElement();
if (object instanceof Integer) {
rowIndex = (Integer) object;
IXliffEditor editor = (IXliffEditor) part;
// handler.getTransUnit(rowId);
TransUnitBean bean = editor.getRowTransUnitBean(rowIndex);
String pureText = bean.getSrcText();
srcLang = bean.getSrcLang();
tgtLang = bean.getTgtLang();
tgtLang = tgtLang == null || tgtLang.equals("") ? editor.getTgtColumnName() : tgtLang;
srcLang = srcLang == null || "".equals(srcLang) ? editor.getSrcColumnName() : srcLang;
if (srcLang == null || "".equals(srcLang) || tgtLang == null || "".equals(tgtLang)) {
return;
}
Language srcLangL = LocaleService.getLanguageConfiger().getLanguageByCode(srcLang);
Language tgtLangL = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLang);
if (srcLangL.isBidi() || tgtLangL.isBidi()) {
gridTable.setOrientation(SWT.RIGHT_TO_LEFT);
} else {
gridTable.setOrientation(SWT.LEFT_TO_RIGHT);
}
srcTableColumn.setText(srcLang);
tgtTableColumn.setText(tgtLang);
loadData(pureText, srcLang, tgtLang, true);
}
}
Aggregations