code: public static BidiGlobalDir decodeBidiGlobalDirFromJsOptions(
        int bidiGlobalDir, boolean useGoogIsRtlForBidiGlobalDir) {
      if (bidiGlobalDir == 0) {
        if (!useGoogIsRtlForBidiGlobalDir) {
          return null;
        }
        return BidiGlobalDir.forIsRtlCodeSnippet(
            GOOG_IS_RTL_CODE_SNIPPET, GOOG_IS_RTL_CODE_SNIPPET_NAMESPACE, SoyBackendKind.JS_SRC);
      }
      Preconditions.checkState(
          !useGoogIsRtlForBidiGlobalDir,
          "Must not specify both bidiGlobalDir and bidiGlobalDirIsRtlCodeSnippet.");
      Preconditions.checkArgument(
          bidiGlobalDir == 1 || bidiGlobalDir == -1,
          "If specified, bidiGlobalDir must be 1 for LTR or -1 for RTL.");
      return BidiGlobalDir.forStaticIsRtl(bidiGlobalDir < 0);
    }
docs: Decodes the bidi global directionality from the usual command line options used to specify it.
  Checks that at most one of the options was specified.
  
  @param bidiGlobalDir 1: ltr, -1: rtl, 0: unspecified.
  @param useGoogIsRtlForBidiGlobalDir Whether to determine the bidi global direction at template
  runtime by evaluating goog.i18n.bidi.IS_RTL.
  @return BidiGlobalDir object - or null if neither option was specified.