Prepare the render operation environment settings

@param codeType
@param locale
@param usrCtx
@return the engine instance itself
3772
public final RythmEngine prepare(ICodeType codeType, Locale locale, Map<String, Object> usrCtx) {
        renderSettings.init(codeType).init(locale).init(usrCtx);
        return this;
    }
11802
function getRenderer(eng) {
  if (!eng) {
    throw new Error(
      NAME + ': option "engine" must be a non-zero-length string or a function')
  }

  if (typeof eng === 'function') {
    return {
      engine: null,
      render: customRenderFn.call(this, eng)
    }
  }

  try {
    var engine = require(eng)
  } catch (e) {
    throw new Error(NAME + ': unable to load engine "' + eng + '".'
      + ' Make sure the engine is installed, e.g., "npm install ' + eng + '"')
  }

  if (!renderers[eng]) {
    throw new Error(NAME + ': no renderer found for "' + eng + '".'
      + ' You may need to create a custom engine definition')
  }

  return {
    engine: engine,
    render: renderers[eng]
  }
}
1216470
protected function initEnvironment()
    {
        $this->storedLocale = getenv("LANG");

        $this->log("Setting locale to " . $this->locale, Project::MSG_DEBUG);
        putenv("LANG=" . $this->locale);
        $ret = setlocale(LC_ALL, $this->locale);
        if ($ret === false) {
            $msg = "Could not set locale to " . $this->locale
                . ". You may need to use fully qualified name"
                . " (e.g. en_US instead of en).";
            throw new BuildException($msg);
        }

        $this->log("Binding domain '" . $this->domain . "' to " . $this->dir, Project::MSG_DEBUG);
        bindtextdomain($this->domain, $this->dir->getAbsolutePath());
        textdomain($this->domain);
    }
1154555
@JSFProperty(deferredValueType="java.lang.Object")
    public Locale getLocale()
    {
        if (_locale != null)
        {
            return _locale;
        }
        FacesContext context = FacesContext.getCurrentInstance();
        return context.getViewRoot().getLocale();
    }
732949
function _init () {
    if (_locale) return
    // TODO: Depject this!
    i18nL.configure({
      directory: appRoot + '/locales',
      defaultLocale: 'en'
    })

    watch(api.settings.obs.get('patchwork.lang'), currentLocale => {
      currentLocale = currentLocale || navigator.language
      var locales = i18nL.getLocales()

      // Try BCP47 codes, otherwise load family language if exist
      if (locales.indexOf(currentLocale) !== -1) {
        i18nL.setLocale(currentLocale)
      } else {
        i18nL.setLocale(getSimilar(locales, currentLocale))
      }

      // Only refresh if the language has already been selected once.
      // This will prevent the update loop
      if (_locale) {
        electron.remote.getCurrentWebContents().reloadIgnoringCache()
      }
    })

    _locale = true
  }
585231
private void initLocales(CmsPreviewInfo previewInfo) {

        if (m_localeSelect != null) {
            removeButton(m_localeSelect);
            m_localeSelect = null;
        }
        if (previewInfo.hasAdditionalLocales()) {
            m_localeSelect = new CmsSelectBox(previewInfo.getLocales());
            m_localeSelect.setFormValueAsString(previewInfo.getLocale());
            m_localeSelect.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {

                    loadOtherLocale(event.getValue());
                }
            });
            Style style = m_localeSelect.getElement().getStyle();
            style.setWidth(SELECTBOX_WIDTH, Unit.PX);
            style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT);
            style.setMargin(0, Unit.PX);
            m_localeSelect.truncate(TRUNCATION_PREFIX, SELECTBOX_WIDTH - 20);
            addButton(m_localeSelect);

        }
    }
732459
private static void createLocales(TypeSpec.Builder type, List<LocaleID> defaultContent, Set<LocaleID> available) {
    TypeSpec.Builder localeInterface = TypeSpec.interfaceBuilder("Locale")
        .addModifiers(PUBLIC, STATIC)
        .addMethod(MethodSpec.methodBuilder("language")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("script")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("territory")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("variant")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("compact")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("expanded")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build());
    
    List<LocaleID> localeFields = new ArrayList<>();
    List<String> allLocales = new ArrayList<>();
    List<String> bundles = new ArrayList<>();
    
    for (LocaleID locale : available) {
      localeFields.add(locale);
      allLocales.add(locale.safe);
      bundles.add(locale.safe);
    }
    
    MethodSpec.Builder method = MethodSpec.methodBuilder("registerDefaultContent")
        .addModifiers(PRIVATE, STATIC);
    
    for (LocaleID locale : defaultContent) {
      LocaleID dest = new LocaleID(locale.language, "", "", "");
      if (available.contains(dest)) {
        localeFields.add(locale);
        allLocales.add(locale.safe);
        method.addStatement("DEFAULT_CONTENT.put(Locale.$L, Locale.$L)",
            locale.safe,
            dest.safe);
      }
    }
    type.addMethod(method.build());

    Collections.sort(localeFields);
    for (LocaleID locale : localeFields) {
      addLocaleField(localeInterface, locale.safe, locale);
    }

    StringBuilder buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < allLocales.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");

    Collections.sort(allLocales);
    
    List<Object> arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(allLocales);
    
    FieldSpec.Builder field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_LOCALES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < bundles.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");
    
    Collections.sort(bundles);
    arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(bundles);
    
    field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_BUNDLES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    method = MethodSpec.methodBuilder("availableLocales")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_LOCALES");
    
    type.addMethod(method.build());
    
    method = MethodSpec.methodBuilder("availableBundles")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_BUNDLES");
    
    type.addMethod(method.build());

    type.addType(localeInterface.build());
  }
1311287
private void doGetLocales() throws PageException {
	Struct sct = new StructImpl(StructImpl.TYPE_LINKED);
	// Array arr=new ArrayImpl();
	String strLocale = getString("locale", "english (united kingdom)");
	Locale locale = LocaleFactory.getLocale(strLocale);
	pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
	Map locales = LocaleFactory.getLocales();
	Iterator it = locales.keySet().iterator();

	String key;
	Locale l;
	while (it.hasNext()) {
	    key = (String) it.next();
	    l = (Locale) locales.get(key);
	    sct.setEL(l.toString(), l.getDisplayName(locale));
	    // arr.append(locale.getDisplayName());
	}
	// arr.sort("textnocase","asc");
    }
49588
function (str, options, cb) {
    var ECT = this.engine;
    var tmpl = this.cache(options) || this.cache(options, new ECT({ root: { page: str }}));
    tmpl.render('page', options, cb);
  }
473604
private Locale getLocale(FacesContext context) {

        // PENDING(craigmcc) - JSTL localization context?
        Locale locale = this.locale;
        if (locale == null) {
            locale = context.getViewRoot().getLocale();
        }
        return (locale);

    }
323830
function(ctx, frame, cb) {
                // ... 如果是 .render(function () {})
                if (typeof ctx === 'function') {
                    cb = ctx;
                    ctx = {};
                } 
                // ...? 什么场景使用了frame
                else if (typeof frame === 'function') {
                    cb = frame;
                    frame = null;
                }

                return lib.withPrettyErrors(this.path, this.env.dev, function() {
                    // debugger;
                    this.compile();

                    // ... 当前作用域不是简单的Object对象，是Context类的实例，并且整合了blocks对象
                    // ...todo 整合了blocks对象的情景分析
                    var context = new Context(ctx || {}, this.blocks);
                    var syncResult = null;

                    frame = frame || new Frame()

                    this.rootRenderFunc(this.env, context, frame, runtime, cb || function(err, res) {
                        if (err) {
                            throw err;
                        }
                        syncResult = res;
                    });

                    return syncResult;
                }.bind(this));
            }
1070919
function  {
  var data = {};

  init();

  if (cache.defaultTranslation[defaultLocale]) {
    return cache.defaultTranslation[defaultLocale];
  }

  assertReactElements(reactElements);

  // Load i18n content.
  loadCldr(defaultLocale);

  // Set default locale.
  Globalize.locale(defaultLocale);

  // Have react to render all passed components, therefore the formatters in
  // use will be created in Globalize.cache.
  _reactElements(reactElements).forEach(function(reactElement) {
    React.renderToString(reactElement);
  });

  data[Globalize.cldr.attributes.bundle] = Globalize.cldr.get("globalize-messages/{bundle}");

  return cache.defaultTranslation[defaultLocale] = data;
}
634594
private function ensureRequiredEnvironment()
    {
        if (empty($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'])) {
            throw new Exception('$GLOBALS[\'TYPO3_CONF_VARS\'][\'FE\'][\'pageNotFoundOnCHashError\'] needs to be enabled when using out of bound typoscript rendering!', 1403808246);
        }
        if (empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['typoscript_rendering']['renderClasses']) || !is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['typoscript_rendering']['renderClasses'])) {
            throw new Exception('No renderer found in configuration: $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'typoscript_rendering\'][\'renderClasses\']', 1403808247);
        }
        if (!in_array('tx_typoscriptrendering[context]', $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['requireCacheHashPresenceParameters'], true)) {
            throw new Exception('tx_typoscriptrendering[context] must be set as required cHash parameter', 1403808248);
        }
    }
357569
protected void loadOtherLocale(final String locale) {

        CmsRpcAction<CmsPreviewInfo> previewAction = new CmsRpcAction<CmsPreviewInfo>() {

            @SuppressWarnings("synthetic-access")
            @Override
            public void execute() {

                if (m_previewInfoProvider != null) {
                    m_previewInfoProvider.loadPreviewForLocale(locale, this);
                } else {
                    CmsCoreProvider.getVfsService().getPreviewInfo(getSitePath(), locale, this);
                }
                start(0, true);
            }

            @Override
            protected void onResponse(CmsPreviewInfo result) {

                stop(false);
                updatePreviewContent(result);
            }
        };
        previewAction.execute();
    }
241239
private void doGetRegional() throws PageException {
	Struct sct = new StructImpl();
	pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
	sct.set("locale", Caster.toString(config.getLocale()));
	sct.set("timezone", toStringTimeZone(config.getTimeZone()));
	sct.set("timeserver", config.getTimeServer());
	sct.set("usetimeserver", config.getUseTimeServer());
	// replaced with encoding outputsct.set("defaultencoding", config.get DefaultEncoding());
    }
1280978
protected void initializeLocalTypes(GenerationContext context, JvmFeature feature, XExpression expression) {
		if (expression != null) {
			int localTypeIndex = context.getLocalTypeIndex();
			final TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true);
			final String nameStub = "__" + feature.getDeclaringType().getSimpleName() + "_"; //$NON-NLS-1$ //$NON-NLS-2$
			while (iterator.hasNext()) {
				final EObject next = iterator.next();
				if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) {
					inferLocalClass((AnonymousClass) next, nameStub + localTypeIndex, feature);
					iterator.prune();
					++localTypeIndex;
				}
			}
			context.setLocalTypeIndex(localTypeIndex);
		}
	}
170328
public CLDR.Locale fromJavaLocale(java.util.Locale javaLocale) {
    return MetaLocale.fromJavaLocale(javaLocale);
  }