Search in sources :

Example 26 with MessageFormat

use of java.text.MessageFormat in project translationstudio8 by heartsome.

the class XLIFFEditorImplWithNatTable method updateStatusLine.

/**
	 * 在状态栏上显示被编辑文件的信息。
	 */
public void updateStatusLine() {
    if (table == null || table.isDisposed()) {
        return;
    }
    SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
    ViewportLayer viewportLayer = bodyLayer.getViewportLayer();
    PositionCoordinate cellPosition = selectionLayer.getLastSelectedCellPosition();
    if (cellPosition == null) {
        return;
    }
    // int order = LayerUtil.convertRowPosition(selectionLayer, cellPosition.rowPosition, viewportLayer);
    // Bug #2317:选中文本段后排序,不会刷新状态栏中的序号
    int[] selectedRowPostions = selectionLayer.getFullySelectedRowPositions();
    if (selectedRowPostions.length <= 0) {
        return;
    }
    // 刷新选中行的术语,使其排序后保持高亮显示
    // if (!isHorizontalLayout()) {
    // int rowPosition = selectedRowPostions[0];
    // rowPosition *= VerticalNatTableConfig.ROW_SPAN;
    // cellPosition.set(rowPosition, cellPosition.getColumnPosition());
    // } else {
    // cellPosition.set(selectedRowPostions[0], cellPosition.getColumnPosition());
    // }
    // if (!FindReplaceDialog.isOpen) {
    // CellRegion cellRegion = new CellRegion(cellPosition, new Region(0, selectionLayer.getWidth()));
    // ActiveCellRegion.setActiveCellRegion(cellRegion);
    // }
    int order = LayerUtil.convertRowPosition(selectionLayer, selectedRowPostions[0], viewportLayer);
    order += viewportLayer.getOriginRowPosition() + 1;
    // 垂直布局时order需要进行两行递增的处理
    if (!isHorizontalLayout) {
        order = (int) Math.ceil(order / 2.0);
    }
    MessageFormat messageFormat = null;
    if (order > 0) {
        /* 一个Xliff文件,可能有多个File节点,这里使用File结点的original属性 */
        /* 当前文件:{0} | 顺序号:{1} | 可见文本段数:{2} | 文本段总数:{3} | 当前用户名" */
        messageFormat = new MessageFormat(Messages.getString("editor.XLIFFEditorImplWithNatTable.messageFormat1"));
    } else {
        messageFormat = new MessageFormat(Messages.getString("editor.XLIFFEditorImplWithNatTable.messageFormat2"));
    }
    String fileName = "";
    // 添加 Project Name
    IEditorInput editorInput = getEditorInput();
    String filePath = "";
    if (isMultiFile()) {
        if (getSelectedRowIds().size() > 0) {
            filePath = RowIdUtil.getFileNameByRowId(getSelectedRowIds().get(0));
            fileName = ResourceUtils.toWorkspacePath(filePath);
        }
    } else {
        fileName = getEditorInput().getName();
        if (editorInput instanceof FileEditorInput) {
            FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
            filePath = fileEditorInput.getFile().getLocation().toOSString();
            fileName = fileEditorInput.getFile().getFullPath().toOSString();
        }
    }
    String systemUser = Activator.getDefault().getPreferenceStore().getString(IPreferenceConstants.SYSTEM_USER);
    int editableTuSum = handler.countEditableTransUnit();
    int tuSum = handler.countTransUnit();
    // int translatedSum1 = handler
    // .getNodeCount(filePath,
    // "/xliff/file/body/trans-unit[@approved = 'yes' and target/@state != 'translated' and target/@state != 'signed-off']");
    // int translatedSum2 = handler.getNodeCount(filePath,
    // "/xliff/file/body/trans-unit/target[@state = 'translated' or @state = 'signed-off']");
    // int approveSum1 = handler.getNodeCount(filePath,
    // "/xliff/file/body/trans-unit[not(@approved='yes') and target/@state='signed-off']");
    // int approveSum2 = handler.getNodeCount(filePath, "/xliff/file/body/trans-unit[@approved = 'yes']");
    int translatedSum = handler.getTranslatedCount();
    int approveedSum = handler.getApprovedCount();
    int approveP = (int) Math.floor(approveedSum / (double) tuSum * 100.00);
    int translatedP = (int) Math.floor(translatedSum / (double) tuSum * 100.00);
    translationItem.setProgressValue(translatedP);
    approveItem.setProgressValue(approveP);
    // 将信息显示在状态栏
    String message = messageFormat.format(new String[] { fileName, String.valueOf(order), String.valueOf(editableTuSum), String.valueOf(tuSum), systemUser });
    statusLineManager.setMessage(statusLineImage, message);
}
Also used : MessageFormat(java.text.MessageFormat) SelectionLayer(net.sourceforge.nattable.selection.SelectionLayer) FileEditorInput(org.eclipse.ui.part.FileEditorInput) PositionCoordinate(net.sourceforge.nattable.coordinate.PositionCoordinate) HorizontalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer) ViewportLayer(net.sourceforge.nattable.viewport.ViewportLayer) VerticalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer) Point(org.eclipse.swt.graphics.Point) IEditorInput(org.eclipse.ui.IEditorInput) IURIEditorInput(org.eclipse.ui.IURIEditorInput)

Example 27 with MessageFormat

use of java.text.MessageFormat in project translationstudio8 by heartsome.

the class SaxonSearcher method getPropagateTranslationsRowIds.

/**
	 * 得到所有需要繁殖翻译的文本段的rowId,用于繁殖翻译 robert 2012-04-03	//UNDO 这里还没有完善,因为text()后还有多个空格的情况,见Bug #2279。
	 * @param xliffXmlnsMap
	 * @param langFilterCondition
	 * @return ;
	 * @throws XQException 
	 */
public static Map<String, List<String>> getPropagateTranslationsRowIds(Map<String, String> xliffXmlnsMap, String langFilterCondition) throws XQException {
    if (xliffXmlnsMap == null || xliffXmlnsMap.isEmpty()) {
        return null;
    }
    StringBuffer querySB = new StringBuffer();
    // 声明部分
    String declare = "";
    // 所有命名空间和别名的映射
    HashMap<String, String> nsAliasMap = new HashMap<String, String>();
    if (xliffXmlnsMap != null && !xliffXmlnsMap.isEmpty()) {
        HashSet<String> set = new HashSet<String>(xliffXmlnsMap.values());
        int i = 0;
        for (String ns : set) {
            if (ns == null || "".equals(ns)) {
                continue;
            }
            declare += "declare namespace ns" + i + "='" + ns + "'; ";
            nsAliasMap.put(ns, "ns" + i);
            i++;
        }
    }
    HashMap<String, String> fileURIs = new HashMap<String, String>();
    for (String fileName : xliffXmlnsMap.keySet()) {
        fileURIs.put(fileName, new File(fileName).toURI().getPath().replace("'", "''"));
    }
    if (langFilterCondition == null || "".equals(langFilterCondition)) {
        langFilterCondition = "";
    } else {
        langFilterCondition = "[" + langFilterCondition + "]";
    }
    String queryString1 = "";
    String queryString2 = "";
    List<String> args;
    MessageFormat messageFormat1;
    MessageFormat messageFormat2;
    int i = 0;
    for (String fileName : fileURIs.keySet()) {
        //{1}
        String varFile = "$file" + i;
        //{2}
        String varTU = "$tu" + i;
        String namespace = xliffXmlnsMap.get(fileName);
        // 命名空间别名	{4}
        String nsAlias = nsAliasMap.get(namespace);
        if (nsAlias == null) {
            nsAlias = "";
        }
        if (!"".equals(nsAlias)) {
            nsAlias += ":";
        }
        //查询出源文与译文不为空,并且未加锁状态的所有节点的rowid
        String message1 = "for {1} in doc(\''{0}'')/{4}xliff/{4}file{3}, {2} in {1}/{4}body//{4}trans-unit[({4}source/text()!='''' or {4}source/*) and ({4}target/text()!='''') and not(@translate=''no'')] \n" + "return <tu fileName=''{0}'' original='''{'{1}/@original'}''' tuid='''{'{2}/@id'}''' source='''{'{2}/{4}source/text()'}''' /> " + (i == fileURIs.size() - 1 ? "\n" : ", \n");
        String message2 = "for {1} in doc(\''{0}'')/{4}xliff/{4}file{3}, {2} in {1}/{4}body//{4}trans-unit[({4}source/text()!='''' or {4}source/*) and not({4}target/text()!='''') and not(@translate=''no'')] \n" + "return <tu fileName=''{0}'' original='''{'{1}/@original'}''' tuid='''{'{2}/@id'}''' source='''{'{2}/{4}source/text()'}''' /> " + (i == fileURIs.size() - 1 ? "\n" : ", \n");
        messageFormat1 = new MessageFormat(message1);
        messageFormat2 = new MessageFormat(message2);
        args = new ArrayList<String>(Arrays.asList(fileURIs.get(fileName), varFile, varTU, langFilterCondition, nsAlias));
        queryString1 += messageFormat1.format(args.toArray(new String[] {}));
        queryString2 += messageFormat2.format(args.toArray(new String[] {}));
        i++;
    }
    querySB.append(declare + "\n");
    querySB.append("let $matchTU := (");
    querySB.append(queryString1 + ")\n");
    querySB.append("let $matchedTU := (");
    querySB.append(queryString2 + ")\n");
    //下面是测试部份了
    //		querySB.append("for $rootTU in $matchedTU return <root fileName='{$rootTU/@fileName}' original='{$rootTU/@original}' tuid='{$rootTU/@tuid}' />");
    querySB.append("for $rootTU in $matchTU return <root fileName='{$rootTU/@fileName}' original='{$rootTU/@original}' tuid='{$rootTU/@tuid}'>{ \n");
    querySB.append("for $tu in $matchedTU \n");
    querySB.append("return if($rootTU/@source=$tu/@source) then <tu fileName='{$tu/@fileName}' original='{$tu/@original}' tuid='{$tu/@tuid}' />  else '' \n");
    querySB.append("}</root>");
    System.out.println("querySB.toString() = " + querySB.toString());
    return PropagateQurey(querySB.toString());
}
Also used : MessageFormat(java.text.MessageFormat) HashMap(java.util.HashMap) File(java.io.File) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 28 with MessageFormat

use of java.text.MessageFormat in project spring-framework by spring-projects.

the class StaticMessageSource method resolveCode.

@Override
protected MessageFormat resolveCode(String code, Locale locale) {
    String key = code + '_' + locale.toString();
    String msg = this.messages.get(key);
    if (msg == null) {
        return null;
    }
    synchronized (this.cachedMessageFormats) {
        MessageFormat messageFormat = this.cachedMessageFormats.get(key);
        if (messageFormat == null) {
            messageFormat = createMessageFormat(msg, locale);
            this.cachedMessageFormats.put(key, messageFormat);
        }
        return messageFormat;
    }
}
Also used : MessageFormat(java.text.MessageFormat)

Example 29 with MessageFormat

use of java.text.MessageFormat in project spring-framework by spring-projects.

the class ReloadableResourceBundleMessageSource method resolveCode.

/**
	 * Resolves the given message code as key in the retrieved bundle files,
	 * using a cached MessageFormat instance per message code.
	 */
@Override
protected MessageFormat resolveCode(String code, Locale locale) {
    if (getCacheMillis() < 0) {
        PropertiesHolder propHolder = getMergedProperties(locale);
        MessageFormat result = propHolder.getMessageFormat(code, locale);
        if (result != null) {
            return result;
        }
    } else {
        for (String basename : getBasenameSet()) {
            List<String> filenames = calculateAllFilenames(basename, locale);
            for (String filename : filenames) {
                PropertiesHolder propHolder = getProperties(filename);
                MessageFormat result = propHolder.getMessageFormat(code, locale);
                if (result != null) {
                    return result;
                }
            }
        }
    }
    return null;
}
Also used : MessageFormat(java.text.MessageFormat)

Example 30 with MessageFormat

use of java.text.MessageFormat in project antlrworks by antlr.

the class XJLocalizable method getStringFormat.

public static String getStringFormat(String s, Object[] args) {
    MessageFormat formatter = new MessageFormat("");
    formatter.setLocale(Locale.getDefault());
    formatter.applyPattern(getXJString(s));
    return formatter.format(args);
}
Also used : MessageFormat(java.text.MessageFormat)

Aggregations

MessageFormat (java.text.MessageFormat)260 CertificateException (java.security.cert.CertificateException)27 KeyStoreException (java.security.KeyStoreException)23 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)22 UnrecoverableKeyException (java.security.UnrecoverableKeyException)22 Date (java.util.Date)22 UnrecoverableEntryException (java.security.UnrecoverableEntryException)21 CertStoreException (java.security.cert.CertStoreException)21 X509Certificate (java.security.cert.X509Certificate)17 IOException (java.io.IOException)15 ArrayList (java.util.ArrayList)15 File (java.io.File)14 Format (java.text.Format)12 Support_MessageFormat (tests.support.Support_MessageFormat)12 Certificate (java.security.cert.Certificate)10 ChoiceFormat (java.text.ChoiceFormat)10 DateFormat (java.text.DateFormat)10 MissingResourceException (java.util.MissingResourceException)10 SimpleDateFormat (java.text.SimpleDateFormat)9 ResourceBundle (java.util.ResourceBundle)9