當前位置: 首頁>>代碼示例>>Java>>正文


Java Catalog類代碼示例

本文整理匯總了Java中org.fedorahosted.tennera.jgettext.Catalog的典型用法代碼示例。如果您正苦於以下問題:Java Catalog類的具體用法?Java Catalog怎麽用?Java Catalog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Catalog類屬於org.fedorahosted.tennera.jgettext包,在下文中一共展示了Catalog類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toJson

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
/**
 * Transform po file into json file.
 * Using hash map ease the transformation into JSON.
 *
 * @return a JSON representation of the catalog conform to angular-gettext expectations.
 * @throws IOException
 */
public byte[] toJson() throws IOException {
    HashMap<String, HashMap<String, Object>> language = new HashMap<>();
    final HashMap<String, Object> translations = new HashMap<>();

    Catalog catalog = poParser.parseCatalog(poFile);
    language.put(extractLanguageFrom(catalog.locateHeader()), translations);

    catalog.processMessages(new MessageProcessor() {

        @Override
        public void processMessage(Message message) {
            if (isHeader(message)) { // ignore header
                return;
            }
            translations.put(message.getMsgid(),
                    isPlural(message) ?
                            message.getMsgstrPlural() :
                            message.getMsgstr());
        }
    });
    return objectMapper.toJson(language);
}
 
開發者ID:bonitasoft,項目名稱:bonita-ui-designer,代碼行數:30,代碼來源:LanguagePack.java

示例2: loadTranslations

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
public TranslationContainer loadTranslations(TranslationContainer container, Locale locale) throws TranslationLoadingException
{
    Map<String, String> singularMessages = new HashMap<String, String>();
    Map<String, String[]> pluralMessages = new HashMap<String, String[]>();
    Set<URL> loadFrom = new LinkedHashSet<URL>();
    for (URL poFile : poFiles)
    {
        String fileName = poFile.toString();
        if (fileName.endsWith(locale.getLanguage().toLowerCase() + "_" + locale.getCountry().toUpperCase() + ".po")
                || fileName.endsWith(locale.getLanguage().toLowerCase() + ".po"))
        {
            loadFrom.add(poFile);
        }
    }
    for (URL url : loadFrom)
    {
        Catalog catalog = this.parseCatalog(url);
        if (catalog != null)
        {
            for (Message message : catalog)
            {
                singularMessages.put(message.getMsgid(), message.getMsgstr());
                pluralMessages.put(message.getMsgidPlural(), message.getMsgstrPlural().toArray(new String[message.getMsgstrPlural().size()]));
            }
        }
        container.merge(singularMessages, pluralMessages);
    }
    return container;
}
 
開發者ID:CubeEngine,項目名稱:I18n,代碼行數:30,代碼來源:GettextLoader.java

示例3: parseCatalog

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
private Catalog parseCatalog(URL url) throws TranslationLoadingException
{
    try
    {
        return this.parser.parseCatalog(url.openStream(), charset, true);
    }
    catch (IOException e)
    {
        throw new TranslationLoadingException(e);
    }
}
 
開發者ID:CubeEngine,項目名稱:I18n,代碼行數:12,代碼來源:GettextLoader.java

示例4: testBadToken

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
@Test
public void testBadToken() throws Throwable {
    File poFile =
            new File(getClass()
                    .getResource("/invalid/badtoken.po").toURI());
    ExtendedCatalogParser parser =
            new ExtendedCatalogParser(new Catalog(), poFile);
    try {
        parser.catalog();
        fail("was expecting exception");
    } catch (UnexpectedTokenException expected) {
        // ignore
    }
}
 
開發者ID:zanata,項目名稱:jgettext,代碼行數:15,代碼來源:TestExtendedCatalogParser.java

示例5: testPartialObsoleteEntries

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
@Test
public void testPartialObsoleteEntries() throws Throwable {
    File poFile =
            new File(getClass()
                    .getResource("/invalid/mixed_up_obsolete.po").toURI());
    ExtendedCatalogParser parser =
            new ExtendedCatalogParser(new Catalog(), poFile);
    try {
        parser.catalog();
        fail("was expecting exception");
    } catch (ParseException expected) {
    }
}
 
開發者ID:zanata,項目名稱:jgettext,代碼行數:14,代碼來源:TestExtendedCatalogParser.java

示例6: ExtendedCatalogParser

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
public ExtendedCatalogParser(Catalog catalog, Reader reader, boolean isPot) {
    super(new CatalogLexer(reader));
    catalog.setTemplate(isPot);
    this.catalog = catalog;
}
 
開發者ID:zanata,項目名稱:jgettext,代碼行數:6,代碼來源:ExtendedCatalogParser.java

示例7: getCatalog

import org.fedorahosted.tennera.jgettext.Catalog; //導入依賴的package包/類
public Catalog getCatalog() {
    return catalog;
}
 
開發者ID:zanata,項目名稱:jgettext,代碼行數:4,代碼來源:ExtendedCatalogParser.java


注:本文中的org.fedorahosted.tennera.jgettext.Catalog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。