Package com.google.template.soy.msgs

Examples of com.google.template.soy.msgs.SoyMsgBundle


      return;
    }

    SoyFileSet sfs = sfsBuilder.build();

    SoyMsgBundle msgBundle = sfs.extractMsgs();

    SoyMsgBundleHandler msgBundleHandler = injector.getInstance(SoyMsgBundleHandler.class);
    OutputFileOptions options = new OutputFileOptions();
    options.setSourceLocaleString(sourceLocaleString);
    if (targetLocaleString.length() > 0) {
View Full Code Here


        SoyFileSetNode soyTreeClone = soyTree.clone();

        String msgFilePath =
            JsSrcUtils.buildFilePath(messageFilePathFormat, locale, null, inputFilePathPrefix);

        SoyMsgBundle msgBundle =
            msgBundleHandlerProvider.get().createFromFile(new File(msgFilePath));
        if (msgBundle.getLocaleString() == null) {
          // TODO: Remove this check (but make sure no projects depend on this behavior).
          // There was an error reading the message file. We continue processing only if the locale
          // begins with "en", because falling back to the Soy source will proably be fine.
          if (!locale.startsWith("en")) {
            throw new IOException("Error opening or reading message file " + msgFilePath);
View Full Code Here

    SoyJavaSrcOptions javaSrcOptions = new SoyJavaSrcOptions();
    javaSrcOptions.setCodeStyle(codeStyle);
    javaSrcOptions.setBidiGlobalDir(bidiGlobalDir);

    // Create SoyMsgBundle.
    SoyMsgBundle msgBundle = null;
    if (messageFilePath.length() > 0) {
      SoyMsgBundleHandler msgBundleHandler = injector.getInstance(SoyMsgBundleHandler.class);
      msgBundle = msgBundleHandler.createFromFile(new File(messageFilePath));
    }
View Full Code Here

    URL testSoyFile = Resources.getResource(XliffMsgPluginTest.class, "test_data/test-v2.soy");
    SoyFileSetNode soyTree =
        (new SoyFileSetParser(SoyFileSupplier.Factory.create(testSoyFile, SoyFileKind.SRC)))
            .parse();
    SoyMsgBundle msgBundle = (new ExtractMsgsVisitor()).exec(soyTree);

    XliffMsgPlugin msgPlugin = new XliffMsgPlugin();

    // Test without target language.
    OutputFileOptions outputFileOptions = new OutputFileOptions();
View Full Code Here

  public void testParseTranslatedMsgsFile() throws Exception {

    URL translatedMsgsFile = Resources.getResource(
        XliffMsgPluginTest.class, "test_data/test-v2_translated_x-zz.xlf");
    XliffMsgPlugin msgPlugin = new XliffMsgPlugin();
    SoyMsgBundle msgBundle = msgPlugin.parseTranslatedMsgsFile(
        Resources.toString(translatedMsgsFile, Charsets.UTF_8));

    assertEquals(5, msgBundle.getNumMsgs());

    List<SoyMsg> msgs = Lists.newArrayList();
    for (SoyMsg msg : msgBundle) {
      msgs.add(msg);
    }
View Full Code Here

        .add(Resources.getResource("features.soy"))
        .setCompileTimeGlobals(Resources.getResource("FeaturesUsage_globals.txt"))
        .build();
    SoyTofu tofu = sfs.compileToTofu().forNamespace("soy.examples.features");

    SoyMsgBundle msgBundle;
    if (locale.length() > 0) {
      // Use translations from an XLIFF file.
      SoyMsgBundleHandler msgBundleHandler = injector.getInstance(SoyMsgBundleHandler.class);
      URL xliffResource = Resources.getResource(XLIFF_RESOURCE_PREFIX + locale + ".xlf");
      msgBundle = msgBundleHandler.createFromResource(xliffResource);
      if (msgBundle.getLocaleString() == null) {
        throw new IOException(
            "Error reading message resource \"" + XLIFF_RESOURCE_PREFIX + locale + ".xlf\".");
      }
    } else {
      // Use the messages from the Soy source files.
View Full Code Here

                compile();
            }
            renderer = tofu.newRenderer(templateName);
        }

        final SoyMsgBundle msgBundle = locale != null ? msgBundleCache.getUnchecked(locale) : null;
        return renderer.setData(model)
            .setMsgBundle(msgBundle)
            .setIjData(ijData)
            .render();
    }
View Full Code Here

TOP

Related Classes of com.google.template.soy.msgs.SoyMsgBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.