How to use the tv4.language function in tv4

To help you get started, we’ve selected a few tv4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Talend / ui / packages / forms / src / UIForm / hooks / useLanguageEffect.js View on Github external
useEffect(() => {
		// control the tv4 language here.
		const mergedLanguage = getLanguage(t);
		if (language != null) {
			Object.assign(mergedLanguage, language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(t), userCustomFormats);
		tv4.addFormat(allFormats);
	}, [t]);
}
github Talend / ui / packages / forms / src / UIForm / hooks / useLanguageEffect.js View on Github external
useEffect(() => {
		// control the tv4 language here.
		const mergedLanguage = getLanguage(t);
		if (language != null) {
			Object.assign(mergedLanguage, language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(t), userCustomFormats);
		tv4.addFormat(allFormats);
	}, [t]);
}
github Talend / ui / packages / forms / src / UIForm / UIFormFn.js View on Github external
useEffect(() => {
		// control the tv4 language here.
		const mergedLanguage = getLanguage(t);
		if (language != null) {
			Object.assign(mergedLanguage, language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(t), userCustomFormat);
		tv4.addFormat(allFormats);
	}, [t]);
github dcos / dcos-ui / src / js / utils / SchemaFormUtil.js View on Github external
ARRAY_UNIQUE: "Array items are not unique (indices {match1} and {match2})",
  ARRAY_ADDITIONAL_ITEMS: "Additional items not allowed",

  // Format errors
  FORMAT_CUSTOM: "{message}",
  KEYWORD_CUSTOM: "{message}",

  // Schema structure
  CIRCULAR_REFERENCE: "Circular $refs: {urls}",

  // Non-standard validation options
  UNKNOWN_PROPERTY: "Unknown property (not in schema)"
});

// Set the new language we just defined
tv4.language("en-us");

const SchemaFormUtil = {
  /**
   * Finds a specific field definition when a path is passed in.
   *
   * @param {Object} definition Definition to traverse to find the field definition.
   * @param {Array} paths Array of the properties needed to lookup to get to
   * definition.
   *
   * @return {Object} definition The definition that was found, or the
   * definition before the dead end.
   */
  getDefinitionFromPath(definition, paths) {
    if (definition[paths[0]]) {
      definition = definition[paths[0]];
      paths = paths.slice(1);
github Talend / ui / packages / forms / src / UIForm / UIForm.component.js View on Github external
this.onSubmit = this.onSubmit.bind(this);
		this.onTrigger = this.onTrigger.bind(this);
		this.onActionClick = this.onActionClick.bind(this);
		this.focusFirstError = this.focusFirstError.bind(this);
		this.setFormRef = this.setFormRef.bind(this);
		// control the tv4 language here.
		const language = getLanguage(props.t);
		if (props.language != null) {
			Object.assign(language, props.language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', language);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', language);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(props.t), props.customFormats);
		tv4.addFormat(allFormats);
	}
github Talend / ui / packages / forms / src / UIForm / UIForm.component.js View on Github external
this.onChange = this.onChange.bind(this);
		this.onFinish = this.onFinish.bind(this);
		this.onSubmit = this.onSubmit.bind(this);
		this.onTrigger = this.onTrigger.bind(this);
		this.onActionClick = this.onActionClick.bind(this);
		this.focusFirstError = this.focusFirstError.bind(this);
		this.setFormRef = this.setFormRef.bind(this);
		// control the tv4 language here.
		const language = getLanguage(props.t);
		if (props.language != null) {
			Object.assign(language, props.language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', language);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', language);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(props.t), props.customFormats);
		tv4.addFormat(allFormats);
	}
github Talend / ui / packages / forms / src / UIForm / UIFormFn.js View on Github external
useEffect(() => {
		// control the tv4 language here.
		const mergedLanguage = getLanguage(t);
		if (language != null) {
			Object.assign(mergedLanguage, language);
			// Force update of language @talend even if already set
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend');
		}
		if (!tv4.language('@talend')) {
			tv4.addLanguage('@talend', mergedLanguage);
			tv4.language('@talend'); // set it
		}
		const allFormats = Object.assign(customFormats(t), userCustomFormat);
		tv4.addFormat(allFormats);
	}, [t]);
github dogenzaka / react-manager / src / js / i18n / index.js View on Github external
resolve.setLanguage = function(lang) {
  currentLang = lang;
  tv4.language(lang);
};
github backstage / loopback-jsonschema / lib / domain / json-schema-validator.js View on Github external
validate: function(schema, data) {

            var translation = config.jsonSchemaValidatorTranslation.draft4 || {};
            if (!_.isEmpty(translation)) {
                tv4.addLanguage(translation.language, translation.mapping);
                tv4.language(translation.language);
            }

            var result = tv4.validateMultiple(data, schema);
            return formatError(schema, result);
        }
    };
github dogenzaka / react-manager / src / js / i18n / index.js View on Github external
/**
 * Set language
 */
resolve.setLanguage = function(lang) {
  currentLang = lang;
  tv4.language(lang);
};

['en','ja'].forEach(lang => {
  let res = require('./'+lang);
  resolve.merge(res, lang);
  if (res.tv4) {
    tv4.addLanguage(lang, res.tv4);
  }
});
tv4.language(currentLang);

export default resolve;