Translate something.

    Syntax: {command} [--from <language code>] [--to <language code>] <text>
    See https://cloud.google.com/translate/v2/translate-reference#supported_languages for a list of valid language codes
182333
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--lang', '--from', default=None)
    parser.add_argument('--to', default='en')
    parser.add_argument('msg', nargs='+')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    send(gen_translate(' '.join(cmdargs.msg), cmdargs.lang, cmdargs.to))
1348966
function translateDigit(d)
{
	if (d >= CP_0 && d <= CP_9) {
		/* '0' to '9' -> 0 to 9 */
		return (d - PI_CONV_DEC);
	} else if (d >= CP_A && d <= CP_Z) {
		/* 'A' - 'Z' -> 10 to 35 */
		return (d - PI_CONV_UC);
	} else if (d >= CP_a && d <= CP_z) {
		/* 'a' - 'z' -> 10 to 35 */
		return (d - PI_CONV_LC);
	} else {
		/* Invalid character code */
		return (-1);
	}
}
395045
def translated(structure, values, lang_spec):
    """"""
    # LANGUAGE SPECS
    indentation = '\t'
    endline = '\n'


    object_code = ""
    stack = []
    # define shortcuts to behavior
    push = lambda x: stack.append(x)
    pop  = lambda  : stack.pop()
    last = lambda  : stack[-1] if len(stack) > 0 else ' '
    def indented_code(s, level, end):
        return lang_spec[INDENTATION]*level + s + end

    # recreate python structure, and replace type by value
    level = 0
    CONDITIONS = [LEXEM_TYPE_PREDICAT, LEXEM_TYPE_CONDITION]
    ACTION = LEXEM_TYPE_ACTION
    DOWNLEVEL = LEXEM_TYPE_DOWNLEVEL
    for lexem_type in structure:
        if lexem_type is ACTION:
            # place previous conditions if necessary
            if last() in CONDITIONS:
                # construct conditions lines
                value, values = values[0:len(stack)], values[len(stack):]
                object_code += (indented_code(lang_spec[BEG_CONDITION] 
                    + lang_spec[LOGICAL_AND].join(value) 
                    + lang_spec[END_CONDITION], 
                    level, 
                    lang_spec[END_LINE]
                ))
                # if provided, print the begin block token on a new line
                if len(lang_spec[BEG_BLOCK]) > 0:
                    object_code += indented_code( 
                        lang_spec[BEG_BLOCK],
                        level, 
                        lang_spec[END_LINE]
                    )
                stack = []
                level += 1
            # and place the action
            object_code += indented_code(
                lang_spec[BEG_ACTION] + values[0], 
                level, 
                lang_spec[END_ACTION]+lang_spec[END_LINE]
            )
            values = values[1:]
        elif lexem_type in CONDITIONS:
            push(lexem_type)
        elif lexem_type is DOWNLEVEL:
            if last() not in CONDITIONS:
                # down level, and add a END_BLOCK only if needed
                level -= 1
                if level >= 0:
                    object_code += indented_code(
                        lang_spec[END_BLOCK], level,
                        lang_spec[END_LINE]
                    )
                else:
                    level = 0

    # add END_BLOCK while needed for reach level 0
    while level > 0:
        level -= 1
        if level >= 0:
            object_code += indented_code(
                lang_spec[END_BLOCK], level,
                lang_spec[END_LINE]
            )
        else:
            level = 0
    # Finished !
    return object_code
684780
function(){
	var clauses = this.clauses = {
		where: {},
		order: {},
		paginate: {},
		id: {}
	};
	this.translators = {
		where: new Translate("where", {
			fromSet: function(set, setRemainder){
				return setRemainder;
			},
			toSet: function(set, wheres){
				return assign(set, wheres);
			}
		})
	};
	var self = this;
	each(arguments, function(arg) {

		if(arg) {
			if(arg instanceof Translate) {
				self.translators[arg.clause] = arg;
			} else {
				assign(clauses[arg.constructor.type || 'where'], arg);
			}
		}
	});
}
1037496
def translate_basic(usercode):
    
    codenum = get_code_num(codes['fore'][usercode])
    colorcode = codeformat(codenum)
    msg = 'Name: {:>10}, Number: {:>3}, EscapeCode: {!r}'.format(
        usercode,
        codenum,
        colorcode
    )
    if disabled():
        return msg
    return str(C(msg, fore=usercode))
643002
function translate(key, options, hasOwnOptions) {

			var lng = options.lng || 'auto';

			if (!translations[lng]) {
				translations[lng] = {};
			}

			if (!t) {
				translations[lng][key] = key;
			} else if (!translations[lng][key] || hasOwnOptions) {
				translations[lng][key] = t(key, options);
			}

		}
1021939
function FilterCommand(value, engine) {
        var match = value.match(/^\s*([a-z0-9_-]+)\s*(\(([\s\S]*)\))?\s*$/i);
        if (!match) {
            throw new Error('Invalid ' + this.type + ' syntax: ' + value);
        }

        this.name = match[1];
        this.args = match[3];
        Command.call(this, value, engine);
        this.cloneProps = ['name', 'args'];
    }
273514
def cmd(send, msg, _):
    
    demorse_codes = {
        '.----': '1',
        '-.--': 'y',
        '..-': 'u',
        '...': 's',
        '-.-.': 'c',
        '.-.-.': '+',
        '--..--': ',',
        '-.-': 'k',
        '.--.': 'p',
        '----.': '9',
        '-----': '0',
        '  ': ' ',
        '...--': '3',
        '-....-': '-',
        '...-..-': '$',
        '..---': '2',
        '.--.-.': '@',
        '-...-': '=',
        '-....': '6',
        '...-': 'v',
        '.----.': "'",
        '....': 'h',
        '.....': '5',
        '....-': '4',
        '.': 'e',
        '.-.-.-': '.',
        '-': 't',
        '.-..': 'l',
        '..': 'i',
        '.-': 'a',
        '-..-': 'x',
        '-...': 'b',
        '-.': 'n',
        '.-..-.': '"',
        '.--': 'w',
        '-.--.-': ')',
        '--...': '7',
        '.-.': 'r',
        '.---': 'j',
        '---..': '8',
        '--': 'm',
        '-.-.-.': ';',
        '-.-.--': '!',
        '-..': 'd',
        '-.--.': '(',
        '..-.': 'f',
        '---...': ':',
        '-..-.': '/',
        '..--.-': '_',
        '.-...': '&',
        '..--..': '?',
        '--.': 'g',
        '--..': 'z',
        '--.-': 'q',
        '---': 'o'
    }
    demorse = ""
    if not msg:
        send("demorse what?")
        return
    for word in msg.lower().split("   "):
        for c in word.split():
            if c in demorse_codes:
                demorse += demorse_codes[c]
            else:
                demorse += "?"
        demorse += " "
    send(demorse)
1347755
def show_list_translations(context, item):
    
    if not item:
        return

    manager = Manager()
    manager.set_master(item)

    ct_item = ContentType.objects.get_for_model(item)

    item_language_codes = manager.get_languages_from_item(ct_item, item)
    model_language_codes = manager.get_languages_from_model(ct_item.app_label, ct_item.model)

    item_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.filter(code__in=item_language_codes).order_by('name')]

    more_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.exclude(main_language=True).order_by('name')]

    return render_to_string('languages/translation_language_selector.html', {
        'item_languages': item_languages,
        'more_languages': more_languages,
        'api_url': TM_API_URL,
        'app_label': manager.app_label,
        'model': manager.model_label,
        'object_pk': item.pk
    })
1101771
def translate(self, instruction):
        
        try:
            trans_instrs = self.__translate(instruction)
        except NotImplementedError:
            unkn_instr = self._builder.gen_unkn()
            unkn_instr.address = instruction.address << 8 | (0x0 & 0xff)
            trans_instrs = [unkn_instr]

            self._log_not_supported_instruction(instruction)
        except Exception:
            self._log_translation_exception(instruction)

            raise

        return trans_instrs
491449
function translate(val, scope, status) {
        var app = (scope && scope.appName) || context.get('app') || '';
        var lang = (scope && scope.lang) || context.get('lang') || 'en';
        var translated;

        // if just one character or is a number, don't do translation
        if (!val || val.length < 2 || !isNaN(val)) {
            return val;
        }

        // translations could be either nested (on the server) or at the root (on the client)
        translated = (translations[app] && translations[app][lang] && translations[app][lang][val]) ||
            (_.isString(translations[val]) && translations[val]);

        // if no transation AND caller passed in status object AND lang is not default (i.e. not english),
        // set the status object values which the caller can use to record some info
        // note: this is kind of hacky, but we want the caller (i.e. jng.directives.js) to handle
        // it because jng.directives has more info about the translation than we do at this level
        if (!translated && config.i18nDebug && status && lang !== config.lang.default) {
            status.app = app;
            status.lang = lang;
            status.missing = true;
        }

        // attempt to interpolate and return the resulting value (val if no translation found)
        return interpolate(translated || val, scope);
    }
541187
def translations(context: Context, pull=False, push=False):
    
    if not (pull or push):
        raise TaskError('Specify whether to push or pull translations')
    if pull:
        context.shell('tx', 'pull')
        make_messages(context, javascript=False)
        make_messages(context, javascript=True)
    if push:
        context.shell('tx', 'push', '--source', '--no-interactive')
658259
def _translate(self):
        
        table_styles = self.table_styles or []
        caption = self.caption
        ctx = self.ctx
        precision = self.precision
        hidden_index = self.hidden_index
        hidden_columns = self.hidden_columns
        uuid = self.uuid or str(uuid1()).replace("-", "_")
        ROW_HEADING_CLASS = "row_heading"
        COL_HEADING_CLASS = "col_heading"
        INDEX_NAME_CLASS = "index_name"

        DATA_CLASS = "data"
        BLANK_CLASS = "blank"
        BLANK_VALUE = ""

        def format_attr(pair):
            return "{key}={value}".format(**pair)

        # for sparsifying a MultiIndex
        idx_lengths = _get_level_lengths(self.index)
        col_lengths = _get_level_lengths(self.columns, hidden_columns)

        cell_context = dict()

        n_rlvls = self.data.index.nlevels
        n_clvls = self.data.columns.nlevels
        rlabels = self.data.index.tolist()
        clabels = self.data.columns.tolist()

        if n_rlvls == 1:
            rlabels = [[x] for x in rlabels]
        if n_clvls == 1:
            clabels = [[x] for x in clabels]
        clabels = list(zip(*clabels))

        cellstyle = []
        head = []

        for r in range(n_clvls):
            # Blank for Index columns...
            row_es = [{"type": "th",
                       "value": BLANK_VALUE,
                       "display_value": BLANK_VALUE,
                       "is_visible": not hidden_index,
                       "class": " ".join([BLANK_CLASS])}] * (n_rlvls - 1)

            # ... except maybe the last for columns.names
            name = self.data.columns.names[r]
            cs = [BLANK_CLASS if name is None else INDEX_NAME_CLASS,
                  "level{lvl}".format(lvl=r)]
            name = BLANK_VALUE if name is None else name
            row_es.append({"type": "th",
                           "value": name,
                           "display_value": name,
                           "class": " ".join(cs),
                           "is_visible": not hidden_index})

            if clabels:
                for c, value in enumerate(clabels[r]):
                    cs = [COL_HEADING_CLASS, "level{lvl}".format(lvl=r),
                          "col{col}".format(col=c)]
                    cs.extend(cell_context.get(
                        "col_headings", {}).get(r, {}).get(c, []))
                    es = {
                        "type": "th",
                        "value": value,
                        "display_value": value,
                        "class": " ".join(cs),
                        "is_visible": _is_visible(c, r, col_lengths),
                    }
                    colspan = col_lengths.get((r, c), 0)
                    if colspan > 1:
                        es["attributes"] = [
                            format_attr({"key": "colspan", "value": colspan})
                        ]
                    row_es.append(es)
                head.append(row_es)

        if (self.data.index.names and
                com._any_not_none(*self.data.index.names) and
                not hidden_index):
            index_header_row = []

            for c, name in enumerate(self.data.index.names):
                cs = [INDEX_NAME_CLASS,
                      "level{lvl}".format(lvl=c)]
                name = '' if name is None else name
                index_header_row.append({"type": "th", "value": name,
                                         "class": " ".join(cs)})

            index_header_row.extend(
                [{"type": "th",
                  "value": BLANK_VALUE,
                  "class": " ".join([BLANK_CLASS])
                  }] * (len(clabels[0]) - len(hidden_columns)))

            head.append(index_header_row)

        body = []
        for r, idx in enumerate(self.data.index):
            row_es = []
            for c, value in enumerate(rlabels[r]):
                rid = [ROW_HEADING_CLASS, "level{lvl}".format(lvl=c),
                       "row{row}".format(row=r)]
                es = {
                    "type": "th",
                    "is_visible": (_is_visible(r, c, idx_lengths) and
                                   not hidden_index),
                    "value": value,
                    "display_value": value,
                    "id": "_".join(rid[1:]),
                    "class": " ".join(rid)
                }
                rowspan = idx_lengths.get((c, r), 0)
                if rowspan > 1:
                    es["attributes"] = [
                        format_attr({"key": "rowspan", "value": rowspan})
                    ]
                row_es.append(es)

            for c, col in enumerate(self.data.columns):
                cs = [DATA_CLASS, "row{row}".format(row=r),
                      "col{col}".format(col=c)]
                cs.extend(cell_context.get("data", {}).get(r, {}).get(c, []))
                formatter = self._display_funcs[(r, c)]
                value = self.data.iloc[r, c]
                row_dict = {"type": "td",
                            "value": value,
                            "class": " ".join(cs),
                            "display_value": formatter(value),
                            "is_visible": (c not in hidden_columns)}
                # only add an id if the cell has a style
                if (self.cell_ids or
                        not(len(ctx[r, c]) == 1 and ctx[r, c][0] == '')):
                    row_dict["id"] = "_".join(cs[1:])
                row_es.append(row_dict)
                props = []
                for x in ctx[r, c]:
                    # have to handle empty styles like ['']
                    if x.count(":"):
                        props.append(x.split(":"))
                    else:
                        props.append(['', ''])
                cellstyle.append({'props': props,
                                  'selector': "row{row}_col{col}"
                                  .format(row=r, col=c)})
            body.append(row_es)

        table_attr = self.table_attributes
        use_mathjax = get_option("display.html.use_mathjax")
        if not use_mathjax:
            table_attr = table_attr or ''
            if 'class="' in table_attr:
                table_attr = table_attr.replace('class="',
                                                'class="tex2jax_ignore ')
            else:
                table_attr += ' class="tex2jax_ignore"'

        return dict(head=head, cellstyle=cellstyle, body=body, uuid=uuid,
                    precision=precision, table_styles=table_styles,
                    caption=caption, table_attributes=table_attr)
668431
function (text, arg1, arg2, arg3) {
    text = translateWord(text);

    var pos = text.indexOf('%s');
    if (pos !== -1) {
        text = text.replace('%s', arg1);
    } else {
        return text;
    }

    pos = text.indexOf('%s');
    if (pos !== -1)  {
        text = text.replace('%s', arg2);
    } else {
        return text;
    }

    pos = text.indexOf('%s');
    if (pos !== -1)  {
        text = text.replace('%s', arg3);
    }

    return text;
}
1004371
function translate(cldr, locale, opts) {
  if (typeof cldr === 'string') return augment(interpolate(cldr, opts));

  opts = opts || {};

  var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
  if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);

  validate(cldr, pluralize);

  var paramsObj = {};
  var cases = toFunctions(cldr, pluralize, opts, paramsObj);
  var paramsKeys = Object.keys(paramsObj);

  var key = cldr._plural_key ||
            opts.pluralKey ||
            discoverKey(paramsKeys,
                        opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
                        opts.defaultPluralKey || 'smart_count');

  var validatePluralKey = opts.validatePluralKey !== false;
  var silentValidation = !!opts.validatePluralSilent;
  var decimal = number.decimal[locale] || number.decimal.en;
  var toLocaleString = opts.toLocaleString !== false;

  return augment(function(params) {
    if (typeof params === 'number') params = convertSmartCount(params, key);

    var count = parseInt(params[key], 10);
    if (validatePluralKey && isNaN(count)) {
      if (silentValidation) return [];
      throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
    }

    if (toLocaleString) params = formatNumbers(params, decimal);

    return (cases[count] || cases[pluralize(count || 0)])(params);
  }, paramsKeys);
}
910449
def get_by_code(self, code):
        
        if any(x in code for x in ('_', '-')):
            cc = CultureCode.objects.get(code=code.replace('_', '-'))
            return cc.language

        elif len(code) == 2:
            return self.get(iso_639_1=code)

        elif len(code) == 3:
            return self.get(Q(iso_639_2T=code) |
                            Q(iso_639_2B=code) |
                            Q(iso_639_3=code))

        raise ValueError(
            'Code must be either 2, or 3 characters: "%s" is %s' % (code, len(code)))
214413
def translate(self, input_entity, vector):
        
        d = {1: "Line", 2: "Surface", 3: "Volume"}
        self._GMSH_CODE.append(
            "Translate {{{}}} {{ {}{{{}}}; }}".format(
                ", ".join([str(co) for co in vector]),
                d[input_entity.dimension],
                input_entity.id,
            )
        )
        return