query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Adds a block to the BlockArgs object
|
def add(&block)
@block_args << block
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_block block\n block.at self.length\n @blocks << block\n end",
"def add_block(article_block)\n self.blocks << article_block\n end",
"def add(name, &block)\n blocks[name.to_sym] = block\n end",
"def add(*args, &block)\n end",
"def add_block(block)\n return if ilp.has_variable?(block)\n ilp.add_variable(block)\n lhs = block_frequency(block) + [[block, -1]]\n ilp.add_constraint(lhs,\"equal\",0,\"block_#{block.qname}\", :structural)\n end",
"def addSetupBlock( &block ); self.class.addSetupBlock( &block ); end",
"def add_block_container_to_list(*args, &block)\n block_container = self.build_block_container(*args, &block)\n if blocks[block_container.name].nil?\n blocks[block_container.name] = [block_container]\n else\n blocks[block_container.name] << block_container\n end\n end",
"def <<(block)\n blocks << block\n end",
"def define_block_container(*args, &block)\n block_container = self.build_block_container(*args, &block)\n blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given?\n block_container\n end",
"def add(*args, &block)\n\n end",
"def add_block(new_block, blockchain)\n blockchain.push(new_block) if valid_new_block?(new_block, latest_block(blockchain))\n end",
"def add_block name, hash\n\t\t\t@blocks ||= {}\n\t\t\t@blocks[name] = hash\n\t\tend",
"def append_to_block(line)\n @block_buffer = (@block_buffer || '') + line\n end",
"def add_multi_block(block)\n\t\t\t@encoded << block\n\tend",
"def add(config_or_block)\n self.class.new @config_list + Array.wrap(config_or_block)\n end",
"def add_block\n @user = User.current\n @user.pref.add_block params[:block]\n @user.pref.save\n redirect_to my_page_layout_path\n end",
"def put_block(x, y, block)\n _layer.set(x, y, block)\n end",
"def add_callback(&block)\n @blocks << block\n end",
"def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end",
"def create_block(arg_type , frame_type)\n @callable.create_block(arg_type ,frame_type)\n end",
"def set_block &b\n @block = b\n end",
"def on_block(blk)\n log.debug { \">> block: #{blk.hash} (#{blk.payload.size} bytes)\" }\n @node.queue.push([:block, blk])\n end",
"def new_block_el(*args); end",
"def begin_block(name, opts)\n @block_name_stack << name\n @block_opts_stack << opts\n @block_break_type_stack << \"entry-break\"\n end",
"def push(block)\n @names[block.name.to_s] ||= []\n @names[block.name.to_s] << block\n end",
"def add_block_callback(hook_name, handle, block)\n case block.arity\n when -1, 0\n hooks[hook_name].add_internal_callback(handle, &block)\n else\n add_external_callback(hook_name, handle, block)\n end\n end",
"def append(name, content = nil, &block)\n content = capture(&block) if block_given?\n add_instruction_to_area name, :push, content\n end",
"def add_single_block(block)\n\n\t\tif @decoded[block.blocks[0]].nil? \n\t\t \t@decoded[block.blocks[0]] = block.data \n\t\t\t@num_valid += 1\n\t\tend\n\tend",
"def parse_block(*_arg0); end",
"def initialize\n @block_args = []\n end",
"def maybe_append_block! args, blk\n return false unless @has_proc_contract && !blk &&\n (@args_contract_index || args.size < args_contracts.size)\n\n args << nil\n true\n end",
"def add_block_callback(hook_name, handle, block)\n case block.arity\n when -1, 0\n fetch_or_create_hooks[hook_name].add_internal_callback(handle, &block)\n else\n add_external_callback(hook_name, handle, block)\n end\n end",
"def <<(block)\n # parent assignment pending refactor\n #block.parent = self\n @blocks << block\n end",
"def add_block\n block = params[:block].to_s.underscore\n if block.present? && BLOCKS.key?(block)\n @user = User.current\n layout = @user.pref[:my_page_layout] || {}\n # remove if already present in a group\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n # add it on top\n layout['top'].unshift block\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n end\n redirect_to my_page_layout_path\n end",
"def add_block\n block = params[:block].to_s.underscore\n if block.present? && BLOCKS.key?(block)\n @user = User.current\n layout = @user.pref[:my_page_layout] || {}\n # remove if already present in a group\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n # add it on top\n layout['top'].unshift block\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n end\n redirect_to my_page_layout_path\n end",
"def add(name, &block)\n define_method(name.to_sym) { yield block }\n end",
"def passed_blockarg\n <<-CODE\n next_int;\n if((unsigned long int)_int == c->blockargs) {\n stack_push(Qtrue);\n } else {\n stack_push(Qfalse);\n }\n CODE\n end",
"def push(block, line_count = -1)\n\t\t@stack[-1].lines << block\n\t\t@stack << block\n\tend",
"def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end",
"def add(block)\n if valid?(block)\n connect(block)\n consolidate_successors(block)\n else\n queue_unconsolidated(block)\n end\n end",
"def start_new_block_element(attrs)\n @current_block = {\n formatting_spans: [],\n paragraph_classes: [],\n }.merge(attrs)\n @block_elements << @current_block\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n @single_block += words\n end",
"def add_argument(*args, &block)\n ArgParse.add_option(*args, &block)\n end",
"def pass_block(*ags, &b)\n @expectation.pass_block(*ags, &b)\n self\n end",
"def set_block_params(item)\n if block_params.blank?\n commands.object = item\n elsif item.is_a?(Array) && item.size > 1\n # split item into block variables\n # the # of @block_params may be < the # of subitems, so put it first\n block_params.zip(item).each {|param, subitem| commands.set(param, subitem) }\n else\n # now this item is available thru the block variable\n commands.set(block_params.first, item)\n end\n end",
"def queue(*args, &block)\n self.queued_blocks << self.define_block_container(*args, &block)\n nil\n end",
"def update_block(hash, attrs)\n raise \"Not implemented\"\n end",
"def on_block(node)\n builder = DefinitionBuilder::RubyBlock.new(node, current_scope)\n definition = builder.build\n\n associate_node(node, definition)\n\n push_scope(definition)\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n single_block.concat(words)\n end",
"def add(child, left, right, top, bottom, &block)\n super(child, false, &block)\n\n gtk_instance.attach(child.gtk_instance, left, right, top, bottom)\n end",
"def require_block(block_given)\n raise ArgumentError, \"Must provide a block\" unless block_given\n end",
"def block=(_arg0); end",
"def block=(_arg0); end",
"def post_init_block(&block)\n raise ArgumentError, \"does not accept a block\"\n end",
"def queue(*args, &block)\n @queue << [block, args]\n end",
"def with_block(&block)\n end",
"def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end",
"def func_block (arg1, arg2, block_args = {})\n p arg1.inspect\n p arg2.inspect\n p block_args.inspect\nend",
"def set_blocks(x0,y0,z0,x1,y1,z1,block)\n @api.send(\"world.setBlocks(#{x0},#{y0},#{z0},#{x1},#{y1},#{z1},#{block.as_parameter_list})\")\n end",
"def on_add(&block)\n @add_proc = block\n end",
"def append(name = \"\")\n BasicBlock.create(@fun, name)\n end",
"def register_block_for(type, &blk); end",
"def set_block_params(name, params)\n\t\t\tparams = {} if !params.is_a?(Hash)\n\t\t\t@vars[:block_params][name] = params\n\t\tend",
"def add_message_builder(name, &block)\n give_name(name, block)\n @message_builders << block\n end",
"def append_block(block)\n valid = block.transactions.all? do |tx|\n tx.coinbase? || verify_transaction?(tx)\n end\n\n unless valid\n puts \"Verify block failed!\"\n return\n end\n\n pow = ProofOfWork.new(block)\n catch :not_found do\n result = pow.run!\n nonce, hash = result.values_at(:nonce, :hash)\n puts \"Mining done - #{hash}\"\n block.hash = hash\n block.nonce = nonce\n save_block(block)\n\n self.hash = hash\n end\n end",
"def block request_pb, options:, &block\n request_json = JSON.parse ::Google::Showcase::V1beta1::BlockRequest.encode_json(request_pb)\n\n uri = \"/v1beta1/echo:block\"\n body = request_pb.to_json\n\n result_json = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n &block\n )\n\n ::Google::Showcase::V1beta1::BlockResponse.decode_json result_json[:body]\n end",
"def on_method_add_block(begin_line, end_line)\n if begin_line && end_line\n @begins_to_ends[begin_line] = end_line\n end\n end",
"def insert_block\n BasicBlock.from_ptr(C.get_insert_block(self))\n end",
"def extend_block(name, value = nil, &block)\n value = self._template.context.capture(&block) if value.nil? && block\n self._template.blocks[name] += value\n return self._template.blocks[name]\n end",
"def cp_block_params\n params.require(:block).permit(:name, :text, :title, :description, :keywords)\n end",
"def append_verified_block(block)\n @chain << block\n @ledger.write(block)\n\n if block.index % BLOCK_REBALANCE_OFFSET == 0\n rebalance_difficulty\n end\n end",
"def add(*add_args, &add_block_arg)\n add_options = if add_args.last.is_a?(Hash) then add_args.pop else {} end\n\n (add_options[:features] ||= []) << :default if add_options.delete(:default)\n\n unless add_options.empty? || ADD_OPTION_NAMES.any? {|o| add_options.include?(o)}\n add_options = {:dependencies => add_options}\n end\n\n if add_args.first.is_a?(Symbol)\n extra_named_feature = add_args.shift\n add_options[:method_name] ||= extra_named_feature\n (add_options[:features] ||= []) << extra_named_feature\n end\n\n main_arg = add_args.shift\n case main_arg\n when Factory::Interface\n add_options[:args] = add_args unless add_args.empty?\n add_factory(main_arg, add_options, &add_block_arg)\n when ::Module\n add_options[:class] = main_arg\n add_options[:args] = add_args unless add_args.empty?\n add_new_factory(add_options, &add_block_arg)\n when NilClass\n add_new_factory(add_options, &add_block_arg)\n else\n add_instance(main_arg, add_options)\n end\n end",
"def add(*add_args, &add_block_arg)\n add_options = if add_args.last.is_a?(Hash) then add_args.pop else {} end\n\n (add_options[:features] ||= []) << :default if add_options.delete(:default)\n\n unless add_options.empty? || ADD_OPTION_NAMES.any? {|o| add_options.include?(o)}\n add_options = {:dependencies => add_options}\n end\n\n if add_args.first.is_a?(Symbol)\n extra_named_feature = add_args.shift\n add_options[:method_name] ||= extra_named_feature\n (add_options[:features] ||= []) << extra_named_feature\n end\n\n main_arg = add_args.shift\n case main_arg\n when Factory::Interface\n add_options[:args] = add_args unless add_args.empty?\n add_factory(main_arg, add_options, &add_block_arg)\n when ::Module\n add_options[:class] = main_arg\n add_options[:args] = add_args unless add_args.empty?\n add_new_factory(add_options, &add_block_arg)\n when NilClass\n add_new_factory(add_options, &add_block_arg)\n else\n add_instance(main_arg, add_options)\n end\n end",
"def set_block(x,y,z,block)\n @api.send(\"world.setBlock(#{x},#{y},#{z},#{block.as_parameter_list})\")\n end",
"def define(*args, &block)\n options = args.extract_options!\n\n name = if args.first\n args.shift\n else\n anonymous = true\n self.anonymous_block_number += 1\n \"anonymous_block_#{anonymous_block_number}\"\n end\n\n block_definitions[name].tap do |block_definition|\n block_definition.reverse_merge! options, &block\n block_definition.anonymous = !!anonymous\n end\n end",
"def add_room_block_to_list(room_block)\n raise ArgumentError.new('Not a valid reservation.') if room_block.class != Hotel::RoomBlock\n @room_blocks << room_block\n end",
"def prepend(arg, &block)\n begin # rails edge after 2.1.0 eliminated need for block.binding\n concat(arg) + block.call\n rescue\n concat(arg, block.binding) + block.call\n end\n end",
"def validate_items\n # Either a block may be passed, or a literal block may be created, but not both\n if block_pass && block\n error \"cannot pass a block in the arguments and give a literal block at the same time\"\n end\n \n # Block pass only valid at end of args. Note this also implies that multiple block passes\n # are invalid.\n if block_pass && block_pass != items.last\n error \"a block pass must only occur at the end of the argument list\"\n end\n end",
"def add_arg_processor(ver,&block)\n raise InvalidArity.new(\"Argument processor must accept one parameter\") if block.arity !=1\n @arg_processors[ver]=block\n @default=ver\n end",
"def add_filter(name, &block)\n raise ArgumentError, \"Expected block to be given\" if block.nil?\n\n @filters[name] = block\n end",
"def add(**options, &block)\n r = ole.Add\n options.each do |k, v|\n r.send(\"#{k}=\", v) unless v.nil?\n end\n yield r if block_given?\n r\n end",
"def initialize(block_arg = nil, &block)\n @block = block || block_arg\n @run = false\n @ivars = {}\n if !@block\n raise ArgumentError, \"needs a block.\"\n end\n end",
"def initialize args\n hash_make args, BlockState::ARG_SPECS\n end",
"def set_block\n @request = JSON.parse(request.body.read, {:symbolize_names => true})\n @block = Block.find_by(prev_block: @request[:prev_block])\n end",
"def initialize(*args)\n if self.class == BlockCommand\n raise TypeError, 'BlockCommand.new should not be called directly'\n end\n super\n end",
"def set_block_argument_names\n @block_argument_names = if has_block? && element[2].is_a?(Sexp) # HACK: for lambdas\n element[2].drop(1).map { |argument| argument }\n end || []\n end",
"def with_a_block\n method_signature_expectation.block_argument = true\n\n self\n end",
"def parfait_block(compiler)\n return @parfait_block if @parfait_block\n @parfait_block = compiler.create_block( make_arg_type , make_frame(compiler))\n end",
"def add_attribute(name, &block); end",
"def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n block_container.options = options\n block_container.block = block\n \n blocks[name.to_sym] = block_container \n end\n \n nil\n end",
"def create_block_object(&block)\n block\nend",
"def with(*args, &block)\n @args = args\n @block = block if block_given?\n self\n end",
"def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end",
"def after(&block)\n @blocks << block\n end",
"def add(short, long, arg, description, block)\n pad = @align ? \" \" : \"\"\n s = short ? short.dup : pad\n s << (short ? \", \" : pad) if long\n doc \" #{s}#{long} #{arg}\".ljust(@width-1) + \" #{description}\"\n @options << Option.new(short, long, arg, description, block)\n end",
"def optional_args_block_call(block, args)\n if RUBY_VERSION >= \"1.9.0\"\n if block.arity == 0\n block.call\n else\n block.call(*args)\n end\n else\n block.call(*args)\n end\n end",
"def pass(*args, &block)\n end",
"def on(instruction, arguments, &bloc)\n @instructions[instruction] = [arguments, bloc]\n end",
"def raise_if_block(obj, name, has_block, type)\n return unless has_block\n\n puts \"Type passed in: #{type}\"\n puts \"#{obj.class}##{name} does not accept blocks\"\n\n raise Appom::UnsupportedBlockError\n end",
"def action &block\n if block.nil?\n raise RuntimeError, 'expected a block but none given'\n end\n @actions << block\n end"
] |
[
"0.7374964",
"0.68489355",
"0.66917056",
"0.65283126",
"0.65031314",
"0.6482519",
"0.64730287",
"0.64226466",
"0.63106906",
"0.6299988",
"0.6241403",
"0.6238178",
"0.6185426",
"0.6149992",
"0.614374",
"0.60489124",
"0.60339093",
"0.6033659",
"0.60122275",
"0.599923",
"0.59992296",
"0.5976864",
"0.5959873",
"0.5942637",
"0.59237576",
"0.5903799",
"0.58896047",
"0.58824515",
"0.5863882",
"0.5857989",
"0.5834697",
"0.58198965",
"0.5801236",
"0.5800155",
"0.5800155",
"0.57771313",
"0.5762536",
"0.57436174",
"0.57338595",
"0.57229257",
"0.5662714",
"0.5657985",
"0.56532186",
"0.56367236",
"0.56287193",
"0.5612871",
"0.56077784",
"0.5603019",
"0.56028384",
"0.5594926",
"0.55946314",
"0.5581025",
"0.5581025",
"0.55763006",
"0.556575",
"0.5562536",
"0.55545807",
"0.5550316",
"0.5535725",
"0.550677",
"0.5470235",
"0.5466764",
"0.54645884",
"0.5452894",
"0.54308903",
"0.5428856",
"0.5408024",
"0.54009366",
"0.54008174",
"0.5400696",
"0.5399681",
"0.5399176",
"0.53984404",
"0.5397563",
"0.5395472",
"0.53828734",
"0.5376653",
"0.5375884",
"0.53731215",
"0.53726715",
"0.5369027",
"0.5354062",
"0.53535944",
"0.5353396",
"0.5351743",
"0.53470844",
"0.5344493",
"0.53408265",
"0.5334478",
"0.5332534",
"0.5331414",
"0.532796",
"0.5312246",
"0.53006685",
"0.5291441",
"0.5290125",
"0.52822566",
"0.52761173",
"0.52711433",
"0.52701426"
] |
0.8359032
|
0
|
Deletes a block to the BlockArgs object
|
def delete(&block)
@block_args.delete(block)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy_block(user)\n delete \"blocks/destroy/#{user}\"\n end",
"def delete_block\n Block.destroy(params[:id])\n render :text => \"Block with ID #{params[:id]} was successfully destroyed.\"\n end",
"def destroy\n @block.destroy\n\n head :no_content\n end",
"def destroy\n @block = Block.find(params[:id])\n @block.destroy\n redirect_to :back\n end",
"def delete(*args, &block)\n map_method(:delete, args, &block)\n end",
"def destroy\n @block = Block.find(params[:id])\n @block.destroy\n\n respond_to do |format|\n format.html { redirect_to blocks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @block = Block.find(params[:id])\n @block.destroy\n\n respond_to do |format|\n format.html { redirect_to blocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block = Block.find(params[:id])\n @block.destroy\n\n respond_to do |format|\n format.html { redirect_to(blocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @block = Block.find(params[:id])\n @block.destroy\n\n respond_to do |format|\n format.html { redirect_to(blocks_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @block = @site.blocks.find(params[:id])\n @block.destroy\n\n respond_to do |format|\n format.html { redirect_to(blocks_url) }\n format.xml { head :ok }\n end\n end",
"def remove_block\n @user = User.current\n @user.pref.remove_block params[:block]\n @user.pref.save\n redirect_to my_page_layout_path\n end",
"def deleteEntityAffiliate_adblock( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/affiliate_adblock\",params)\n end",
"def destroy\n @visit_block = VisitBlock.find(params[:id])\n @visit_block.destroy\n\n respond_to do |format|\n format.html { redirect_to visit_blocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block.destroy\n respond_to do |format|\n format.html { redirect_to blocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block.destroy\n respond_to do |format|\n format.html { redirect_to blocks_url }\n format.json { head :no_content }\n end\n end",
"def delete(key, &block); end",
"def destroy\n\n # delete associate block\n Block.where(parent_id: params[:id]).each do |block|\n Block.where(parent_id: block.id).destroy_all\n block.destroy\n end\n\n # delete the main block\n @block.destroy\n\n redirect_to :back\n end",
"def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end",
"def destroy\n\t\t@block.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to blocks_url, notice: 'Block was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def delete(parameters = {}, headers = {}, &block)\n build_delete(parameters, headers, &block).invoke\n end",
"def delete(path, *data, &block)\n map(path, R3::DELETE, *data, &block)\n end",
"def delete(name,&block)\n build_resource(name, :delete, &block)\n end",
"def delete_mark(block)\n if @marks[block]\n @marks[block].each { |line| line.remove }\n @marks.delete(block)\n end\n end",
"def destroy\n @userblock = Userblock.find(params[:id])\n @userblock.destroy\n\n respond_to do |format|\n format.html { redirect_to(userblocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @block.destroy\n respond_to do |format|\n format.html { redirect_to blocks_url, notice: 'Block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy(&block)\n use_callback = block_given?\n api_client.delete(sync_url(:delete)) do\n block.call() if use_callback\n end\n delete\n end",
"def destroy(&block)\n delete(member_url) do |response, json|\n if block\n block.call response, json\n end\n end\n end",
"def destroy\n @cp_block.destroy\n respond_to do |format|\n format.html { redirect_to cp_blocks_url, notice: 'Block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(key, &block)\n convert_value_to_parameters(@parameters.delete(key, &block))\n end",
"def delete_if(&block); end",
"def destroy\n @block.destroy\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end",
"def delete(node=nil, root=nil, &block)\n return super(node, root) do | dn | \n block.call(dn) if block\n dn.update_left_size(:deleted, -1) if dn\n end\n end",
"def delete(*arguments, &block)\n objects = q(*arguments, &block).map { |o| o.removed_from_bibliography(self) }\n @data = @data - objects\n objects.length == 1 ? objects[0] : objects\n end",
"def destroy\n @users_block.destroy\n respond_to do |format|\n format.html { redirect_to block_path, notice: 'Block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unstore(*args, &block)\n delete(*args, &block)\n end",
"def destroy\n @twitter_block = TwitterBlock.find(params[:id])\n @twitter_block.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_twitter_blocks_path, :notice => t('twitter_blocks.successfully_deleted') }\n format.json { head :ok }\n end\n end",
"def destroy\n post = @post_block.post\n @post_block.destroy\n respond_to do |format|\n format.html { redirect_to url_for(controller: 'cm/post_blocks', action: :index, post_id: post.id) }\n format.json { head :no_content }\n end\n end",
"def block!(block)\n\t\t@grid[block.position.y][block.position.x] = 0\n\t\t@blocks.delete_if { |b| block == b }\n\tend",
"def destroy\r\n\t \t@codeblock = @step.codeblocks.find_by(id: params[:id])\r\n\t @codeblock.destroy\r\n\t respond_to do |format|\r\n\t format.html { redirect_to tutorial_step_url(@tutorial, @step), notice: 'CodeBlock was successfully destroyed.' }\r\n\t format.json { head :no_content }\r\n\t end\r\n\t end",
"def delete_content_block(name, div_wrapper_id, existing)\n data = { confirm: 'Are you sure?', content_block: \"#content-block-#{div_wrapper_id}-wrapper\" }\n data[:destroy_field] = \"#destroy-#{div_wrapper_id}\" if existing\n link_to(name, '#', data: data, class: 'small-button delete delete-content-block')\n end",
"def destroy\n @building_block.destroy\n respond_to do |format|\n format.html { redirect_to building_blocks_path, notice: 'Building block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_block\n block = params[:block].to_s.underscore\n @user = User.current\n # remove block in all groups\n layout = @user.pref[:my_page_layout] || {}\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n redirect_to my_page_layout_path\n end",
"def remove_block\n block = params[:block].to_s.underscore\n @user = User.current\n # remove block in all groups\n layout = @user.pref[:my_page_layout] || {}\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n redirect_to my_page_layout_path\n end",
"def destroy\n @production_block.destroy\n respond_to do |format|\n format.html { redirect_to production_blocks_url, notice: 'Production block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def call(&block)\n return unless (deleted_job = delete_job_by_digest)\n\n log_info(\"Deleted job: #{deleted_job}\")\n if (del_count = delete_lock)\n log_info(\"Deleted `#{del_count}` keys for #{lock_digest}\")\n end\n\n block&.call\n end",
"def destroy\n @content_block.destroy\n respond_to do |format|\n format.html { redirect_to content_blocks_url, notice: 'Content block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!(*rest) end",
"def discard\n @args = nil\n @block = nil\n end",
"def destroy\n @document_block = DocumentBlock.find(params[:id])\n @document_block.destroy\n\n respond_to do |format|\n flash[:notice] = \"Document block <em>#{@document_block.title}</em> has been deleted.\".html_safe\n format.html {redirect_to edit_portfolio_project_path(@document_block.project_id)+\"?new_document_block=1\"}\n format.json { head :ok }\n end\n end",
"def del(*args); end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def delete(&block)\n # TODO: Better error raising\n raise 'No Receipt Handle' unless @receipt_handle\n @queue.sqs.delete_message(@queue.url, @receipt_handle, &block)\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def destroy\n begin\n \t@block = User.find(params[:blocked][:blocked_id])\n\t\n\t\t@user.blocked.delete(@block)\n\t\trender json: @user, status: :accepted, location: @user\n\trescue => error\n\t\trender :json => error.message, status: :unprocessable_entity\n\tend\n end",
"def delete_blocked\n end",
"def destroy\n @block_class.destroy\n respond_to do |format|\n format.html { redirect_to block_classes_url, notice: 'Block class was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_log = BlockLog.find(params[:id])\n @block_log.destroy\n\n respond_to do |format|\n format.html { redirect_to block_logs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @text_block = TextBlock.find(params[:id])\n @text_block.destroy\n \n respond_to do |format|\n format.html { redirect_to text_blocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @campaign_text_block = CampaignTextBlock.find(params[:id])\n @campaign_text_block.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_campaign_text_blocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroys(object,*args,&block)\n opts = args.last.is_a?(Hash) ? args.pop.symbolize_keys : {}\n deletes_to(path_for(object,args),opts,&block)\n end",
"def delete(params = {})\n params ||= {}\n params[:path] = @attributes[:path]\n raise MissingParameterError.new(\"Current object doesn't have a path\") unless @attributes[:path]\n raise InvalidParameterError.new(\"Bad parameter: path must be an String\") if params[:path] and !params[:path].is_a?(String)\n raise InvalidParameterError.new(\"Bad parameter: token must be an String\") if params[:token] and !params[:token].is_a?(String)\n raise MissingParameterError.new(\"Parameter missing: path\") unless params[:path]\n raise MissingParameterError.new(\"Parameter missing: token\") unless params[:token]\n\n Api.send_request(\"/locks/#{@attributes[:path]}\", :delete, params, @options)\n end",
"def destroy\n @blocker = Blocker.find(params[:id])\n @blocker.destroy\n\n respond_to do |format|\n format.html { redirect_to blockers_url }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def delete(url, options = {}, &block)\n run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)\n end",
"def clear_block(add = true)\n if add\n @block_num += 1\n \n @block_stats << { :name => block_name, :types => @block_types,\n :tokens => @block_tokens }\n @blocks << @block.dup\n end\n \n @block_counter = 0\n @block_types = 0\n @block_tokens = 0\n \n # Set up an empty block\n @block = {}\n @word_list.each do |w|\n @block[w] = 0\n end\n end",
"def delete request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/regions/#{request_pb.region}/routers/#{request_pb.router}\"\n\n query_string_params = {}\n query_string_params[\"requestId\"] = request_pb.request_id.to_s if request_pb.request_id && request_pb.request_id != \"\"\n\n response = @client_stub.make_delete_request(\n uri: uri,\n params: query_string_params,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def block delete = nil\n unless delete.nil? # this is from RubyParser\n return find_node :block, delete\n end\n\n expect :iter, :scope, :resbody\n\n case self.node_type\n when :iter\n self[3]\n when :scope\n self[1]\n when :resbody\n # This is for Ruby2Ruby ONLY\n find_node :block\n end\n end",
"def destroy\n @time_block.destroy\n respond_to do |format|\n format.html { redirect_to time_blocks_url, notice: 'Time block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @voting_block.destroy\n respond_to do |format|\n format.html { redirect_to voting_blocks_url, notice: 'Voting block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n execute(:delete, *args)\n end",
"def delete(path, options = {}, &block)\n map(path, options, :delete, &block)\n end",
"def destroy\n if not signed_in?\n redirect_back_or signin_path\n end\n @home_page_block.destroy\n respond_to do |format|\n format.html { redirect_to home_page_blocks_url, notice: 'Блок успешно удален!' }\n format.json { head :no_content }\n end\n end",
"def lbDelete _obj, _args\n \"_obj lbDelete _args;\" \n end",
"def remove_for_block(block)\n tx_hashes = []\n\n block.tx.each{|tx|\n tx_hashes << tx.hash\n # remove any now conflicted txs from the memory pool --\n # these are txs which spend outputs spent by txs in this new block. why would this happen?\n # maybe a tx in the block wasn't relayed to us but an associated double-spend was.\n self.remove_conflicts(tx)\n }\n\n # TODO: should probably transfer timestamps and other information\n Toshi::Models::UnconfirmedTransaction.remove_for_block(tx_hashes)\n Toshi::Models::UnconfirmedRawTransaction.where(hsh: tx_hashes).delete\n\n # make sure the transactions are on the tip pool (if they previously existed.)\n Toshi::Models::Transaction.where(hsh: tx_hashes)\n .update(pool: Toshi::Models::Transaction::TIP_POOL)\n end",
"def delete request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/zones/#{request_pb.zone}/disks/#{request_pb.disk}\"\n\n query_string_params = {}\n query_string_params[\"requestId\"] = request_pb.request_id.to_s if request_pb.request_id && request_pb.request_id != \"\"\n\n response = @client_stub.make_delete_request(\n uri: uri,\n params: query_string_params,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def delete_ip_address_block_0(ip_block_id, opts = {})\n delete_ip_address_block_0_with_http_info(ip_block_id, opts)\n nil\n end",
"def delete_ip_address_block_0_with_http_info(ip_block_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPBlocksApi.delete_ip_address_block_0 ...'\n end\n # verify the required parameter 'ip_block_id' is set\n if @api_client.config.client_side_validation && ip_block_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_block_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPBlocksApi.delete_ip_address_block_0\"\n end\n # resource path\n local_var_path = '/infra/ip-blocks/{ip-block-id}'.sub('{' + 'ip-block-id' + '}', ip_block_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPBlocksApi#delete_ip_address_block_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def delete_data(path, &block)\n url = \"#{host}/api/v#{version}/#{path}\"\n params = Jbuilder.encode(&block) if block_given?\n params ||= {}\n resource = RestClient::Resource.new(\n url, \n headers: {\n \"uid\" => @uid,\n \"client\" => @client,\n \"access-token\" => @access_token\n }\n )\n resource.delete(params) do |response, request, result, &blk|\n case response.code\n when 200\n if response.blank?\n true\n else\n auth_data = {\n uid: response.headers[:uid],\n client: response.headers[:client],\n access_token: response.headers[:access_token]\n }\n JSON.parse(response).merge(auth_data)\n end\n when 404\n nil\n else\n JSON.parse(response)\n end\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def unblock!\n self.blocked = nil\n self.save\n end",
"def destroy\n @textblock = Textblock.find(params[:id])\n @textblock.destroy\n\n respond_to do |format|\n format.html { redirect_to(textblocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @roadblock.destroy\n respond_to do |format|\n format.html { redirect_to \"/roadblocks-dash\" }\n format.json { head :no_content }\n end\n end",
"def delete_ip_address_block(ip_block_id, opts = {})\n delete_ip_address_block_with_http_info(ip_block_id, opts)\n nil\n end",
"def rest_delete(path, options={}, &blk)\n delete path do |*args|\n @object = yield(*args) or pass\n @object.destroy\n rest_respond :result => :success\n end\n end",
"def rest_delete(path, options={}, &blk)\n delete path do |*args|\n @object = yield(*args) or pass\n @object.destroy\n rest_respond :result => :success\n end\n end",
"def delete(arg_)\n @config.lock\n\n @mutex.synchronize do\n if (objdata_ = _get_objdata(arg_))\n @objects.delete(objdata_[0].object_id)\n objdata_[2].each_key{ |tup_| _remove_tuple(objdata_, tup_) }\n end\n end\n self\n end",
"def destroy(&block)\n super do |tx|\n tx.delete(RDF::Statement(nil, nil, nil, graph_name: subject_uri))\n end\n end",
"def delete(path, opts = {}, &block)\n request(:delete, path, opts, &block)\n end",
"def delete!\n delete( nil, true ) \n end",
"def destroy()\n return unless @ptr\n self_p = __ptr_give_ref\n result = ::Sprk::FFI.sprk_block_manager_destroy(self_p)\n result\n end",
"def delete(opts = {}, &block)\n @channel.once_open do\n self.once_name_is_available do\n queue_delete(opts.fetch(:if_unused, false), opts.fetch(:if_empty, false), opts.fetch(:nowait, false), &block)\n end\n end\n\n # backwards compatibility\n nil\n end",
"def destroy(&block)\n destroy!(&block)\n rescue ZendeskAPI::Error::ClientError\n false\n end",
"def unblock(blocker_blog, blockee_blog=nil, **options)\n validate_options([:blocked_tumblelog, :anonymous_only], options)\n options[:blocked_tumblelog] ||= blockee_blog\n delete(blog_path(blocker_blog, 'blocks'), options)\n end",
"def destroy\n @admin_block_material.destroy\n respond_to do |format|\n format.html { redirect_to admin_block_materials_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def deleteLocation _args\n \"deleteLocation _args;\" \n end",
"def delete!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n type = DELETE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 166:10: 'delete'\n match( \"delete\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n end",
"def deleteEditorObject _obj, _args\n \"_obj deleteEditorObject _args;\" \n end",
"def destroy\n @action_runner.run(:box_remove, { :box_name => @name, :box_directory => @directory })\n end"
] |
[
"0.71437997",
"0.697673",
"0.6745141",
"0.6623005",
"0.6562336",
"0.6495251",
"0.64677906",
"0.6440162",
"0.6423591",
"0.6410092",
"0.6407131",
"0.6356241",
"0.6337435",
"0.631876",
"0.631876",
"0.6305668",
"0.6300602",
"0.62919676",
"0.6269776",
"0.62613267",
"0.622092",
"0.6186765",
"0.6160822",
"0.6157072",
"0.61568534",
"0.6105351",
"0.6100611",
"0.6097886",
"0.6097359",
"0.6064214",
"0.60368246",
"0.60144585",
"0.60135955",
"0.59603363",
"0.59340036",
"0.5925981",
"0.5922007",
"0.5920989",
"0.59198636",
"0.59124285",
"0.5871027",
"0.5862119",
"0.5862119",
"0.58539903",
"0.58079493",
"0.58016974",
"0.57935876",
"0.57903093",
"0.5780227",
"0.57716185",
"0.57493466",
"0.5736666",
"0.5735961",
"0.5735961",
"0.5722356",
"0.5716357",
"0.57136023",
"0.57093894",
"0.56957304",
"0.56938565",
"0.5636154",
"0.5600662",
"0.55774605",
"0.55566955",
"0.5554971",
"0.55508876",
"0.5542753",
"0.55303323",
"0.5511134",
"0.550311",
"0.54985505",
"0.5486778",
"0.54797864",
"0.545315",
"0.5448886",
"0.54423106",
"0.54415345",
"0.5423815",
"0.5416552",
"0.5393617",
"0.5393464",
"0.53869796",
"0.53766406",
"0.53697056",
"0.53639334",
"0.5363424",
"0.53630024",
"0.5362714",
"0.5360373",
"0.5351332",
"0.5351312",
"0.53338",
"0.53305805",
"0.5326882",
"0.5325148",
"0.5325029",
"0.5314215",
"0.5311151",
"0.5306768",
"0.53042626"
] |
0.8450111
|
0
|
required to enumerate objects for Enumerable iterator returns each block at a time
|
def each
@block_args.each do |arg|
yield arg
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def enumerator ; end",
"def enumerator ; end",
"def enumerator; end",
"def each\n if @length > 0\n item = @head\n begin\n yield item.object\n item = item.next\n end until item.nil?\n end\n end",
"def each_with_iterator\n\n iterator = get_iterator_fast\n while (iterator.has_next?)\n yield iterator.get_next, iterator if block_given?\n end\n \n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each_raw\n iterator.each { |i| yield i }\n end",
"def each_identity; end",
"def each()\n yield izq\n yield der\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < length\n yield(self[i], i)\n i += 1\n end\n end",
"def each(&block)\n raise NotImplementedError\n end",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def each(&block)\n raise NotImplementedError\n end",
"def my_each_with_index\n a = (is_a? Hash) ? to_a : self\n i = 0\n while i < a.count\n yield a[i], i\n i += 1\n end\n end",
"def iterator()\n raise NotImplementedError\n end",
"def each\n if @java_object.getClass.getMethods.any? {|m| m.getName == \"iterator\"}\n i = @java_object.iterator\n while i.hasNext\n yield wrap_java_object(i.next)\n end\n end\n end",
"def each\n with_separate_read_io do | iterable |\n reading_lens = Obuf::Lens.new(iterable)\n @size.times { yield(reading_lens.recover_object) }\n end\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield self[i], i\n i += 1\n end\n end",
"def each\n\t\titerator = @head\n\t\twhile iterator != nil do\n\t\t\tyield iterator.value\n\t\t\titerator = iterator.next\n\t\tend\n\tend",
"def each # And define each on top of next\n loop {yield self.next }\n end",
"def each(&block)\n @size.times { |position| yield self.get(position) }\n end",
"def each # And define each on top of next\n loop { yield self.next }\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each(&block)\n @current = self.head\n position = @current\n if block_given?\n while position do\n block.call( position.value.dup )\n position = position.next\n break if position.equal?(@current)\n end\n else\n Enumerator.new do |yielder|\n while position do\n yielder << position.value.dup\n position = position.next\n break if position.equal?(@current)\n end\n end\n end\n end",
"def each()\n i = 0\n while i < @total\n yield at(i)\n i += 1\n end\n self\n end",
"def each &block\n end",
"def each\n return to_enum(:each) unless block_given?\n\n seek(:head)\n yield current_entry while move_next\n end",
"def iterate(iterator)\n\tloop do\n\t\tyield iterator.next\n\tend\nend",
"def each_with_level(objects, &block)\n Iterator.new(objects).each_with_level(&block)\n end",
"def each(&block)\n if block_given?\n ForkJoinPool.new.invoke(Iterator.new(objects, threshold, block))\n else\n objects.each\n end\n end",
"def each(&block)\n end",
"def each\n enum = @head\n while (enum != nil) \n yield enum.value\n enum = enum.next\n end\n end",
"def each\n for each element\n yield(element)\n end\nend",
"def each\n (0...size).each {|i| yield(self[i])}\n nil\n end",
"def my_each_with_index\n return to_enum unless block_given?\n i = 0\n array = []\n while i < size\n yield to_a[i], i\n array << to_a[i]\n i += 1\n end\n array\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield self[i], i\n i += 1\n end\n self\n end",
"def each(&block)\n return enum_for(:each) unless block_given?\n \n # if using the block form only, don't \"next\" for internal iteration\n if @block && !@enum\n @block.call Enumerator::Yielder.new(&block)\n else\n rewind\n\n until end?\n yield self.next\n end\n end\n \n self\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each\n return to_enum(:each) unless block_given?\n @size.times { |position| yield self[position] }\n end",
"def each\n\n\t\t@a.each do |x|\n\t\t\tyield x\n\t\tend\n\tend",
"def each\n return enum_for(:each) unless block_given?\n\n pointer = self\n loop do\n break if pointer.null?\n yield pointer\n pointer = pointer.next\n end\n end",
"def each(&block)\n\n end",
"def test_0660_each_with_object\n @@log.debug \"test_0660_each_with_object starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_object, \"test_0660_each_with_object_respond\")\n # Type check\n enum = @list.each_with_object({})\n result = enum.is_a? Enumerator\n assert(result,\"test_0660_each_with_object_class\") \n # With block - build a Hash\n hash = @list.each_with_object({}) do |item, memo|\n memo[item.last] = item.ndata\n end\n assert_equal(hash,\n {\"Newman\"=>4, \"Barker\"=>3, \"Bronson\"=>2, \"Dev\"=>1},\n \"test_0660_each_with_object_hash\")\n # With block - build an Array\n csvs = @list.each_with_object([]) { |item, memo|\n memo << \"#{item.last}\"\n }.join(\",\")\n assert(csvs == \"Newman,Barker,Bronson,Dev\", \"test_0660_each_with_object_array\")\n #\n @@log.debug \"test_0660_each_with_object ends\" if @@log.debug?\n end",
"def my_each_with_index\n\t\tself.length.times do |index|\n\t\t\tyield(self[index], index)\n\t\tend\n\tend",
"def each()\n self.to_a.each { |elt| yield elt }\n end",
"def each(&block)\n unless block_given?\n return ArrayEnumerator.new(self, :each ) # for 1.8.7\n end\n i = 0\n lim = self.__size\n while i < lim\n block.call(self.__at(i))\n i += 1\n end\n self\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n index = 0\n my_each do |value|\n yield(value, index)\n index += 1\n end\n end",
"def my_each_with_index\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each\n yield self\n end",
"def get_iterator\n\t\tend",
"def each\n\n rewind\n\n n,f,q,c=next_seq\n\n while (!n.nil?)\n yield(n,f,q,c)\n n,f,q,c=next_seq\n end\n\n rewind\n\n end",
"def each &block\n each_with_index {|x, i| block.call(x)}\n end",
"def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end",
"def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end",
"def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end",
"def each(&block)\n return to_enum unless block_given?\n @index.each(&block)\n self\n end",
"def each()\n cur = @first\n while cur\n yield cur.value\n cur = cur.next\n end\n end",
"def each\n while true do\n yield\n break if ! advance\n end\n end",
"def each(&block)\n return to_enum(:each) unless block_given?\n size.times.each { |i| yield @elements[i] }\n self\n end",
"def each( & block )\n \n return atomic_cursor.each( & block )\n\n end",
"def iterate seed, &block\n Enumerator.new do |e|\n current = seed\n loop do\n e << current\n current = yield current\n end\n end\nend",
"def each(&block)\n internal_collection.each(&block)\n end",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def test_0160_each_with_index\n @@log.debug \"test_0160_each_with_index starts\" if @@log.debug?\n assert_respond_to(@list, :each_with_index, \"test_0160_each_with_index_respond\")\n # Basic operation\n ta = []\n @list.each_with_index do |obj, ndx|\n ta << \"#{obj.first}-#{ndx}\"\n end\n assert_equal([\"Alfred-0\", \"Bob-1\", \"Charlie-2\", \"Dilbert-3\"], ta, \"test_0160_each_with_index_basic\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.each_with_index\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0160_each_with_index_enumcheck\")\nelse\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0160_each_with_index_enumenumcheck\")\nend\n @@log.debug \"test_0160_each_with_index ends\" if @@log.debug?\n end",
"def my_each\n return to_enum unless block_given?\n\n i = 0\n arr = to_a\n while i <= arr.length - 1\n yield (arr[i])\n i += 1\n end\n self\nend",
"def each\n return enum_for(:each) unless block_given?\n\n item = @head\n\n while item do\n yield item.value\n item = item.next\n end\n end",
"def each_with_index(&block)\n return to_enum :each_with_index unless block\n\n i = 0\n self.each{|*val|\n block.call(val.__svalue, i)\n i += 1\n }\n self\n end",
"def each(*) end",
"def each(&block)\n return to_enum unless block_given?\n index.each(&block)\n self\n end",
"def each(node, &block); end",
"def each_obj(objs, namespace=nil)\n objs.each_with_index do |obj, i|\n with_obj(obj, Array(namespace) + [i]) do\n yield obj, i\n end\n end\n end",
"def each(&blk)\n to_a.each(&blk)\n end",
"def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end",
"def each\n items.each { |itm| yield itm }\n end",
"def each(&blk)\r\n to_a.each(&blk)\r\n end",
"def each\r\n @many = true\r\n yield(self)\r\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each\n yield self[0]\n yield self[1]\n end",
"def each(&block)\nend",
"def each\n return enum_for(:each) unless block_given?\n n = @head\n while n\n yield n.value\n n = n.next\n end\n end",
"def each\n @gens.each { |g| g.rewind }\n\n loop do\n count = 0\n\n ret = @gens.map { |g|\n if g.end?\n count += 1\n nil\n else\n g.next\n end\n }\n\n if count == @gens.size\n break\n end\n\n yield ret\n end\n\n self\n end",
"def each\n return enum_for unless block_given?\n\n while (chunk = read)\n yield chunk\n end\n end",
"def each\n @items.each { |i| yield i }\n end",
"def each\r\n actual = @head\r\n while actual != nil do\r\n yield actual.value\r\n actual = actual.next\r\n end\r\n end",
"def each\n raise 'Not implemented'\n end",
"def each(&blk); each_value(&blk) ; end",
"def each\n @size.times do |i|\n yield self[i]\n end\n end",
"def iter\n @iter ||= Iterator.new(self)\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each(&block_)\n if @parent\n if block_given?\n vec_ = ::Array.new(@structure.dim, 0)\n @structure.size.times do\n yield(@vals[@offset + @structure._compute_offset_for_vector(vec_)])\n @structure._inc_vector(vec_)\n end\n else\n enum_for\n end\n else\n @vals.each(&block_)\n end\n end",
"def each_index\n return to_enum(__callee__) unless block_given?\n \n each_with_index{ |_, idx| yield(idx) }\n end",
"def each\n @items.each {|x| yield x}\n end",
"def iterate\n raise \"You should implement this\"\n end"
] |
[
"0.7165281",
"0.7165281",
"0.7036953",
"0.70275724",
"0.7010053",
"0.6977278",
"0.6977278",
"0.6977278",
"0.6977278",
"0.6977278",
"0.6977278",
"0.6944076",
"0.6905531",
"0.687465",
"0.68448454",
"0.6825723",
"0.68233407",
"0.6796772",
"0.67934835",
"0.6780284",
"0.6779413",
"0.6741199",
"0.6727165",
"0.6723308",
"0.6717351",
"0.66887236",
"0.66829497",
"0.66736066",
"0.6673433",
"0.6662549",
"0.6658614",
"0.665175",
"0.6635035",
"0.6623236",
"0.6616176",
"0.66097194",
"0.6607264",
"0.65898955",
"0.65842146",
"0.65782416",
"0.6576103",
"0.65738314",
"0.65671116",
"0.656422",
"0.65636414",
"0.6559994",
"0.6559323",
"0.65579677",
"0.6551244",
"0.6548275",
"0.65417683",
"0.653496",
"0.6531371",
"0.6527526",
"0.6525491",
"0.6512248",
"0.6489951",
"0.64838296",
"0.6481774",
"0.6481774",
"0.64772993",
"0.647051",
"0.6463675",
"0.6463124",
"0.64603645",
"0.6459945",
"0.64525414",
"0.6447613",
"0.64455426",
"0.64455426",
"0.64444953",
"0.64417493",
"0.6436472",
"0.643516",
"0.6434295",
"0.64334804",
"0.6426994",
"0.64258444",
"0.64184934",
"0.64183503",
"0.64146316",
"0.6409255",
"0.6404849",
"0.64029384",
"0.63968706",
"0.6396785",
"0.6393869",
"0.63878095",
"0.6384877",
"0.6380281",
"0.63755864",
"0.63736284",
"0.63697815",
"0.6364624",
"0.6356776",
"0.6354999",
"0.6354999",
"0.6349488",
"0.63494414",
"0.6347165",
"0.63448226"
] |
0.0
|
-1
|
same as each but returns index of each block instead of block itself.
|
def each_index
@block_args.each_index do |i|
yield i
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each_index\n return to_enum(__callee__) unless block_given?\n \n each_with_index{ |_, idx| yield(idx) }\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each &block\n each_with_index {|x, i| block.call(x)}\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield self[i], i\n i += 1\n end\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each_with_index(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i),i) }\n end",
"def each_index(&block)\n return enum_for(:each_index) unless block_given?\n 0.upto(size-1, &block)\n self\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield self[i], i\n i += 1\n end\n self\n end",
"def my_each_with_index\n\t\tself.length.times do |index|\n\t\t\tyield(self[index], index)\n\t\tend\n\tend",
"def each(&block_)\n @indexes.each(&block_)\n end",
"def my_each_with_index\n for i in 0..self.length-1\n yield(self[i], i) if block_given?\n end\n self\n end",
"def my_each_with_index\n for i in 0...self.length do\n yield(self[i], i)\n end\n return self\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def my_each_with_index\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each(&block)\n @index.each(&block)\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < length\n yield(self[i], i)\n i += 1\n end\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n index = 0\n my_each do |value|\n yield(value, index)\n index += 1\n end\n end",
"def my_each_with_index\n a = (is_a? Hash) ? to_a : self\n i = 0\n while i < a.count\n yield a[i], i\n i += 1\n end\n end",
"def my_each_with_index\n \ti = 0\n \twhile i < self.length\n \t\tif block_given?\n \t\t\tyield(self[i], i)\n \t\telse\n \t\t\treturn self\n \t\tend\n \t\ti +=1\n \tend\n \tself\n end",
"def each_index(&block)\n @size.times { |index| yield index}\n end",
"def each_index(*_arg0); end",
"def each_with_index(&block)\n return to_enum :each_with_index unless block\n\n i = 0\n self.each{|*val|\n block.call(val.__svalue, i)\n i += 1\n }\n self\n end",
"def each_index(&block)\n enum = Enumerator.new do |yielder|\n begin\n @each_index = {}\n\n count = 0\n self.each do |ele|\n # Remove previous element to not take up memory.\n count_before = count - 1\n @each_index.delete(count_before) if @each_index.key?(count_before)\n\n # Add current element to cache.\n @each_index[count] = ele\n yield(count)\n\n # Increase count for next run.\n count += 1\n end\n ensure\n @each_index = nil\n end\n end\n\n if block\n enum.each(&block)\n return nil\n else\n return enum\n end\n end",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def my_each_with_index(arr)\n \n\n for element in arr\n index = arr.index(element)\n yield(element, index)\n end\n \n \nend",
"def each_with_index(&block)\n @delegate.each_with_index(&block)\n end",
"def each_index\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield i, j\n }\n }\n self\n end",
"def each_with_index(arr)\n arr.size.times do |i|\n yield(arr[i], i)\n end\n arr\nend",
"def my_each_with_index(&block)\n return to_enum(:my_each_with_index) unless block_given?\n n = 0\n while n < length\n block.call(self[n], n) if is_a?(Array)\n block.call(keys[n], self[keys[n]]) if is_a?(Hash)\n block.call(self[n]) if is_a?(Range)\n n += 1\n end\n self\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def my_each_with_index\n if block_given?\n for i in 0.upto(self.length-1)\n yield self[i], i\n end\n else\n self.to_enum\n end\n end",
"def each_byte_with_index\n\t\t@array.each_with_index { |a,i| yield a,i }\n\tend",
"def each_index\n return enum_for(:each_index) unless block_given?\n\n each_index_root_page_number do |page_number|\n yield index(page_number)\n end\n\n nil\n end",
"def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end",
"def each(&b)\n @index.each(&b)\n end",
"def each_with_index(&block)\n examples.each_with_index(&block)\n end",
"def each(&block)\n @index.each do |key, start_length|\n block.call([key, self[key]])\n end\n end",
"def each(&block)\n return to_enum unless block_given?\n index.each(&block)\n self\n end",
"def eachio_index(&block) # :yield: index\n 0.upto(length-1, &block)\n self\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each\n @indexes.each { |_name, index| yield index }\n end",
"def each(&block)\n return to_enum unless block_given?\n @index.each(&block)\n self\n end",
"def each_with_index\n each_linked_list_item_with_index do |node, index|\n yield node.payload, index\n end\n end",
"def each(&block)\n @size.times { |index| yield self[index]}\n end",
"def each_with_index\n if block_given?\n @fm.each_with_index do |el, index|\n yield el, get_row_from_index(index), get_col_from_index(index)\n end\n end\n end",
"def each_index(&block)\n if block_given?\n @indexes.each(&block)\n self\n else\n @indexes.freeze\n end\n end",
"def each(&block)\n @size.times { |position| yield self.get(position) }\n end",
"def my_each_with_index\n return self unless block_given?\n hash = Hash.new(0)\n for h in self\n yield h, self.index(h)\n hash.merge! self.index(h) => h\n end\n return hash\n end",
"def each_with_index(node=@head)\n i = 0\n until node.nil?\n result = yield(node, i)\n node = node.next_node\n i += 1\n end\n result\n end",
"def each_index(&block)\n if block_given?\n @indexes_hash.each_value(&block)\n self\n else\n @indexes_hash.values\n end\n end",
"def each(&block) # :yields: result\n 0.upto(@size - 1) {|x| yield self[x]}\n end",
"def each\n return to_enum(:each) unless block_given?\n @size.times { |position| yield self[position] }\n end",
"def each_with_index # :yields: e, i, j\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield self[i,j], i, j\n }\n }\n self\n end",
"def each_line_with_index\n c = 0\n each_line do |l|\n yield l, c\n c += 1\n end\n end",
"def each(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i)) }\n end",
"def index()\n INDEXES.find { |i| (self + i).exist? }&.yield_self { |i| self + i }\n end",
"def my_each_with_index\n return to_enum unless block_given?\n i = 0\n array = []\n while i < size\n yield to_a[i], i\n array << to_a[i]\n i += 1\n end\n array\n end",
"def each_with_index\n @h.seek(0, IO::SEEK_SET)\n\n i = 0\n while(record = @h.read(@record_size))\n yield(record, i)\n i += 1\n end\n end",
"def each\n 0.upto(item_count - 1) { | i | yield i }\n end",
"def map_with_index &block\n index = 0\n map do |element|\n result = yield element, index\n index += 1\n result\n end\n end",
"def get_index(i)\n i/BITS_PER_ITEM\n end",
"def my_each_with_index\n return self unless block_given?\n\n if is_a? Array\n length.times { |idx| yield(self[idx], idx) }\n elsif is_a? Hash\n keys = self.keys\n vals = values\n length.times { |idx| yield([keys[idx], vals[idx]], idx) }\n else\n warn 'Incompatible type!'\n end\n self\n end",
"def each_with_index &block\n latch = CountDownLatch.new(size)\n __getobj__.each_with_index {|x, index|\n @@pool << -> {\n begin\n block.call(x, index)\n rescue\n $!.print_stack_trace\n ensure\n latch.count_down\n end\n }\n }\n latch.wait\n self\n end",
"def each_file_with_index\n index = 0\n\n each_file do |file|\n yield file, index\n index += 1\n end\n end",
"def each_mid(&block)\n \n end",
"def each_child_with_index\n end",
"def each(&block)\n unless block_given?\n return ArrayEnumerator.new(self, :each ) # for 1.8.7\n end\n i = 0\n lim = self.__size\n while i < lim\n block.call(self.__at(i))\n i += 1\n end\n self\n end",
"def shift_out_with_index(&block)\n each_with_index(&block)\n end",
"def each_index\n\t\t@data.each_index do |y|\n\t\t\t@data[y].each_index do |x|\n\t\t\t\tyield x, y\n\t\t\tend\n\t\tend \n\tend",
"def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end",
"def each_child_index\n end",
"def map_with_index(array, &block)\n result = []\n index = 0\n array.each do |element|\n result << block.call(element, index)\n index += 1\n end\n result\nend",
"def each\n (0...size).each {|i| yield(self[i])}\n nil\n end",
"def each_with_index(zeroes = false, &_block)\n return enum_for :each_with_index, zeroes unless block_given?\n if zeroes\n row_count.times do |row|\n column_count.times do |_col|\n element = self[row, column]\n yield [element, row, column]\n end\n end\n else\n ia.each_cons(2).each_with_index do |indexes, row|\n row_start, row_end = *indexes\n a[row_start...row_end].each_with_index do |element, index|\n yield [element, row, ja[row_start + index]]\n end\n end\n end\n end",
"def each_entry_with_index\n @index.each_with_index do |hash, idx|\n next if hash.nil?\n entry = '' \n hash.each {|x| entry << pack(x.sha1, @block_ary[x.block].start, @block_ary[x.block].size, x.buflocation, x.size) }\n yield entry, idx \n end\n end",
"def each\r\n res = self.to_a\r\n 0.upto(res.length - 1) do |x|\r\n yield res[x]\r\n end\r\n end",
"def each()\n i = 0\n while i < @total\n yield at(i)\n i += 1\n end\n self\n end",
"def each_with_index\n return nil if @head.nil?\n node_index = 1 #I'll consider first node as 1 \n entry = @head\n until entry.nil?\n yield entry, node_index\n entry = entry.next\n node_index +=1\n end\n end",
"def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend",
"def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each\n @size.times do |i|\n yield self[i]\n end\n end",
"def each_pair(&block)\n block or return enum_for __method__\n each {|index| block.call([index.name, index]) }\n end",
"def each\n if block_given?\n (0...Count()).each { |i| yield self[i] }\n else\n (0...Count()).map { |i| self[i] }\n end\n end",
"def each_identity; end",
"def each_with_index\n\t\t@array.each_with_index do |v,i|\n\t\t\tyield v & 0x0F, i * 2 #Bottom Nibble\n\t\t\tyield (v >> 4) & 0x0F, i * 2 + 1#Top Nibble\n\t\tend\n\tend",
"def each(&block)\n @current = self.head\n position = @current\n if block_given?\n while position do\n block.call( position.value.dup )\n position = position.next\n break if position.equal?(@current)\n end\n else\n Enumerator.new do |yielder|\n while position do\n yielder << position.value.dup\n position = position.next\n break if position.equal?(@current)\n end\n end\n end\n end",
"def each_tile_with_index level\n\t\t\tidx = 0\n\t\t\tsize = tile_size level\n\t\t\t(0...size).each do |y|\n\t\t\t\t(0...size).each do |x|\n\t\t\t\t\tyield(x, y, idx) if block_given?\n\t\t\t\t\tidx += 1\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def map_with_index(array, index = 0, &block)\n result = []\n i = index\n array.each do |element|\n result << block.call(element, i)\n i += 1\n end\n result\nend",
"def each &block\n end"
] |
[
"0.7734222",
"0.7663159",
"0.7663159",
"0.76547736",
"0.76475453",
"0.7624016",
"0.76234496",
"0.76048094",
"0.7553684",
"0.7546723",
"0.74547505",
"0.7449822",
"0.7435243",
"0.7407649",
"0.7403577",
"0.73991257",
"0.73741364",
"0.7366451",
"0.73591226",
"0.735764",
"0.73392904",
"0.7288462",
"0.7288234",
"0.72528046",
"0.7154986",
"0.7141394",
"0.7140906",
"0.70538414",
"0.705209",
"0.7030149",
"0.7009043",
"0.6986357",
"0.69855165",
"0.69612956",
"0.6952159",
"0.6945854",
"0.69371206",
"0.6927015",
"0.69188815",
"0.69102263",
"0.69059426",
"0.6901836",
"0.68990046",
"0.68990046",
"0.68990046",
"0.6878067",
"0.6871866",
"0.6835075",
"0.6811744",
"0.67858714",
"0.6768315",
"0.6750706",
"0.6748565",
"0.6746531",
"0.6734486",
"0.67268145",
"0.67260355",
"0.6722177",
"0.67211115",
"0.66989475",
"0.66807425",
"0.6680584",
"0.6680566",
"0.6670168",
"0.665643",
"0.6630445",
"0.6621232",
"0.6613583",
"0.65726465",
"0.65565944",
"0.65555936",
"0.6519871",
"0.6515962",
"0.65133685",
"0.64871913",
"0.6460673",
"0.64306307",
"0.6413645",
"0.6403372",
"0.63983226",
"0.6395787",
"0.63832754",
"0.6352035",
"0.6350556",
"0.6350556",
"0.63482493",
"0.63482493",
"0.63482493",
"0.63482493",
"0.63482493",
"0.63482493",
"0.6325839",
"0.63074887",
"0.6298638",
"0.62921274",
"0.6288237",
"0.6284065",
"0.62790304",
"0.62689924",
"0.62648654"
] |
0.7645553
|
5
|
GET /cpanel/tags GET /cpanel/tags.json
|
def index
@cpanel_tags = Cpanel::Tag.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tags\n get('tags')\n end",
"def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end",
"def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end",
"def tags\n\t\tresponse = self.server.run_with_json_template( :tags )\n\t\treturn response.flatten.map {|tag| Hglib::Repo::Tag.new(self, **tag) }\n\tend",
"def tags\n response[\"tags\"]\n end",
"def tags\n @data['tags']\n end",
"def tags\n _get(\"/query/image/tags\") { |json| json }\n end",
"def tags\n @obj['tags']\n end",
"def tags\n return head :unauthorized unless current_user\n @tags = current_user.owned_tags.where(\"name like ?\", \"%#{params[:tag]}%\").\n page(params[:page]).per(20)\n if @tags.empty?\n @tags = [current_user.owned_tags.new(name: I18n.t('record.tag_list.no_tags'))]\n end\n respond_with(@tags)\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def get_tag_list\n # body = {\n # cmd: \"get_tag_list\"\n # }\n\n end",
"def tag\n require_admin_permissions\n @model = 'tag'\n @key = 'tag'\n @values = Tag.all.pluck(:tag)\n render 'tags'\n end",
"def tags\n @tags ||= get(\"/repos/show/#{owner.login}/#{name}/tags\")['tags']\n end",
"def tags\n get.tagGuids\n end",
"def tags(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Tags\", params: params)\n end",
"def index\n @tags, @tags_attached = TagService.list(current_user.id)\n end",
"def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end",
"def index\n tags = Tag.all\n render json: tags, status: :ok\n end",
"def tags(client)\n client.get(\"#{PATH}/tags\")\n end",
"def tags() ; info[:tags] ; end",
"def tags() ; info[:tags] ; end",
"def index # This is what we'll need if we want our url/tags page to exist\n @tags = Tag.all\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Node.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Node.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags\n send_tags('tags', @handle, @security)\n end",
"def all\n response= handle_errors{ self.class.get('/get')}\n response[\"tags\"][\"tag\"].collect do |tag| \n t= Rubycious::Tag.new(tag)\n end\n end",
"def index\n authorize @user\n render :json => @user.tags\n end",
"def index\n tags = Array.wrap params.permit(:tags)[:tags]\n @clips = @allclips = Clip.where(session_id: session.id)\n @clips = @allclips.tagged_with(tags, any: true) if tags.any?\n @available_tags = Clip.available_tags_for(session.id)\n end",
"def get_user_tags username, password\n do_request 'get_user_tags', username: username, password: password\n end",
"def tags\n return false if params[:q] and params[:q].size < 3\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n respond_to do |format|\n format.json { render :json => @tags.map{|t| {:id => t.name, :name => t.name }}}\n end\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Video.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Video.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def index\n @has_project_tags = HasProjectTag.all\n render json: @has_project_tags\n end",
"def index\n @tags = Tag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tags }\n end\n end",
"def show_my_tags\n tags = Tag.where('customer_id = ? AND active = ?', current_customer.id, true)\n\n if tags.nil?\n return_error_infos(400, 'No tags found', 'NoTagsFound', nil)\n else\n json_tags = []\n\n tags.each { |tag| json_tags << create_tag_infos(tag, nil) }\n\n render :status => 200, :json => { :tags => json_tags }\n end\n end",
"def index\n authorize @ticket\n render :json => @ticket.tags\n end",
"def index\n @tags = Tag.order('name')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n authorize @organization\n render :json => @organization.tags\n end",
"def index\n tags_list = []\n @user.tags.find_each do |tag|\n tags_list << tag_as_hash(tag, false)\n end\n\n render :status => 200,\n :json => {\n status: 200,\n tags: tags_list\n }\n end",
"def index\n @tags = ActsAsTaggableOn::Tag.order(:name).all\n end",
"def index\n authorize Tag\n @tags = Tag.order(name: :asc).page params[:page]\n end",
"def index\n @tags = Tag.used.clone #This is a Hash with keys(tags) ordered from most used to least\n respond_with @taglist\n end",
"def show\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tags_of_novel }\n end\n end",
"def top_tags()\n get(:standard, {:method => \"tag.getTopTags\"})\n end",
"def show\n\t @tags = @posts.tags\n end",
"def index\n return render_json_for_api(Tag.map) if params[:map] == \"true\" && api_call?\n @tags_with_counts = Tag.\n joins(:vulnerabilities).\n group(\"tags.id\").\n select(\"tags.name\",\n \"tags.shortname\",\n \"tags.color\",\n \"tags.icon\",\n \"tags.id\",\n \"tags.family\",\n 'count(*) AS num_vulns').\n having('count(*) > 1')\n\n @tags = Tag.order(name: :asc).\n select(\"\n *,\n substring(tags.description from 0 for 240) || '...' as short_desc\n \")\n @articleTags = ArticleTag.joins(:article).distinct(:article_id).select(:title, :blurb, :art)\n if @tags == nil\n flash[:error] = \"Error: Tag not found\"\n redirect_to controller: 'tags', :action => 'index'\n else\n render_json_for_api(@tags)\n end\n end",
"def tags\n @tags = User.tag_counts_on(:tags, :conditions => \"name LIKE '\" + (params[:query] || \"\") + \"%'\").limit(50).order('count desc')\n respond_to do |format|\n format.html # tags.html.erb\n format.json { render json: @tags }\n format.xml { render xml: @tags }\n end\n end",
"def get_tag_list\n args = receive_should_validate?\n get('redtube.Tags.getTagList', {}, [], args[:should_validate])\n end",
"def tags\n @tags ||= []\n end",
"def index\n @taggables = current_user.taggables\n @taggable_center = current_user.taggables.first\n \n\n if !@taggable_center.nil?\n @url_no_path = URI.parse(@taggable_center.photo.url(:editable)).path[%r{[^/]+\\z}]\n @url_path = URI.parse(@taggable_center.photo.url(:editable)).path\n @tags = @taggable_center.tags\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taggables }\n end\n end",
"def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end",
"def tags\n object.tags.each do |tag|\n tag.name\n end\n end",
"def index\n @tags = @tags.uniq\n respond_with(@tags)\n end",
"def tags\n @tags ||= []\n end",
"def access_tags\n tags = []\n tags << 'admin' if admin?\n tags << 'speaker' if speaker?\n tags << 'staff' if staff?\n tags\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def list\n tags = api_client.tags.by_resource(resource_hrefs:\n [api_client.get_instance.href]).first.tags\n ::MachineTag::Set.new(tags.map { |tag| tag['name'] })\n end",
"def retrieve_tags\n # noop\n end",
"def index\n\t\t@tags = Tag.all\n end",
"def index\n render json: @project.tags, \n each_serializer: TagSerializer, :root => \"tags\"\n end",
"def resources\n %w(tags posts bundles)\n end",
"def getTags\r\n\t\t\t\t\treturn @tags\r\n\t\t\t\tend",
"def index\n @tags = Tag.all\n end",
"def index\n @posttags = Posttag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posttags }\n end\n end",
"def show\n @tags = @image.tag_list\n end",
"def tags\n attributes[:tags] || []\n end",
"def index\n #@tags = Tag.all\n end",
"def index\n @tags = Tag.all\n render :index, status: 200\n end",
"def index\n\n@tags = Tag.all\n\nrespond_to do |format|\n format.html #index.html.erb\n format.json { render json: @tags }\nend\nend",
"def show\n @taggable = current_user.taggables.find(params[:id])\n @tags = @taggable.tags\n @url_no_path = URI.parse(@taggable.photo.url).path[%r{[^/]+\\z}]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taggable }\n end\n end",
"def index\n @tags = Tag.where(:parent_id => nil).order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n\t\t# Check for optional limit parameter.\n\t\tif params[:limit].nil?\n\t\t\tparams[:limit] = params[:default][:limit]\n\t\tend\n\n\t\t# GET /api/v1/tags\n\t\t@tags = Tag.paginate(:page => params[:page], :per_page => params[:limit])\n\n\t\t# GET api/v1/resources/:resource_id/tags\n\t\t# Return all tags used by a specific resource.\n\t\tif params[:resource_id]\n\t\t\t@tags = Resource.find_by(id: params[:resource_id]).tags.paginate(:page => params[:page])\n\t\tend\n\tend",
"def activities_tags\n\t\ttags = ActivityTag.tags_for_teacher(@current_teacher_user.id)\n\n\t\trender json: {status: \"success\" , tags: tags}\n\tend",
"def index\n @all = Tag.all\n render json: @all.collect{|tag| tag.strip}\n end",
"def list(user_id)\n @_client.get(\"/users/#{user_id}/tags\")\n end",
"def tags\n query = params[:q]\n if query[-1,1] == \" \"\n query = query.gsub(\" \", \"\")\n Tag.find_or_create_by_name(query)\n end\n\n #Do the search in memory for better performance\n\n @tags = ActsAsTaggableOn::Tag.all\n @tags = @tags.select { |v| v.name =~ /#{query}/i }\n respond_to do |format|\n format.json{ render :json => @tags.map(&:attributes) }\n end\n end",
"def tags\n tags = get_user_tags\n # prevents resource from being applied on every run if clearing tags with ''\n tags = [''] if tags == []\n tags\n end",
"def index\n @tags = Tag.order(\"tagtext ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def get_tags_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CategoriesApi.get_tags ...\"\n end\n # resource path\n local_var_path = \"/tags\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourcestring')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def tag\n @session_user = User.find(session[:user_id])\n @page = @session_user.page\n @tags = Array.new \n for panel in @page.panels.order(:created_at)\n #Use a max function on :panelid and :newpanelid?\n if !(panel_has_tag(panel, params[:tagname]))\n if panel.id > (params[:panelid]).to_i && panel.id >= (params[:newpanelid]).to_i \n tag = Tag.new\n tag.name = params[:tagname]\n tag.page_id = @page.id\n tag.panel_id = panel.id\n tag.panel_type = panel.type\n tag.save\n @tags.push(tag)\n end\n end\n end\n render json: @tags\n end",
"def get_tags()\n db = connect_to_database()\n return db.execute(\"SELECT * FROM tags\")\n end",
"def show\n @tagname = params[:id].to_s\n @tags = Tag.name_is(@tagname).descend_by_updated_at.reject {|r| !r.tagable.read_allowed?(current_user) }.paginate(\n :page => params[:page], :per_page => POSTINGS_PER_PAGE)\n @tagables = @tags.map { |t| \n t.tagable\n }.sort { |b,a| a.updated_at <=> b.updated_at }\n end",
"def tags\n klass = Object.const_get(\"Concepts\").const_get(params[:tag_class])\n results = klass.search_for_label_starting_with(params[:term]).map(&:label)\n render :json => results.uniq.sort\n end",
"def show_tags\n tag_list = \"\"\n self.tags.each do |t|\n tag_list << \"#{t.name} \"\n end\n tag_list\n end",
"def tags\n @values.fetch('tags') { \n @values['tags'] = {}\n }\n end",
"def show_contact_tags(**params)\n get('contactTags', params)\n end",
"def index\n @tags ||= Tag.paging(params[:page])\n respond_with(@tags)\n end"
] |
[
"0.8089872",
"0.751737",
"0.74441135",
"0.74037737",
"0.73850274",
"0.7211302",
"0.7208338",
"0.7162299",
"0.71619993",
"0.71595573",
"0.71595573",
"0.71595573",
"0.71595573",
"0.71595573",
"0.7140949",
"0.713974",
"0.7107557",
"0.70756036",
"0.70202917",
"0.7018946",
"0.7017658",
"0.6999047",
"0.6971506",
"0.6859503",
"0.6859503",
"0.6854223",
"0.6830861",
"0.6822554",
"0.6822554",
"0.6822554",
"0.6822554",
"0.6822554",
"0.6812367",
"0.6785853",
"0.6773129",
"0.67245245",
"0.6716538",
"0.67024994",
"0.6685731",
"0.66845846",
"0.66757584",
"0.66701806",
"0.66699255",
"0.6660589",
"0.6633485",
"0.6632778",
"0.6619112",
"0.66190046",
"0.66174126",
"0.66154903",
"0.66141266",
"0.6602971",
"0.6585274",
"0.65732735",
"0.6568925",
"0.6567307",
"0.6549058",
"0.6546317",
"0.65423554",
"0.65380865",
"0.653492",
"0.65282",
"0.65252554",
"0.65252554",
"0.65252554",
"0.65252554",
"0.65252554",
"0.65252554",
"0.65252554",
"0.6508144",
"0.64930254",
"0.6485067",
"0.6478349",
"0.6469825",
"0.64560264",
"0.6455357",
"0.6435994",
"0.64346284",
"0.6434295",
"0.64025724",
"0.6402421",
"0.64010483",
"0.6394019",
"0.63915277",
"0.63889396",
"0.63820094",
"0.6381807",
"0.6378445",
"0.63761795",
"0.6361557",
"0.6358478",
"0.6357077",
"0.6356489",
"0.6346104",
"0.6330444",
"0.63287896",
"0.63281",
"0.6311527",
"0.6296869",
"0.6291323"
] |
0.7524852
|
1
|
GET /cpanel/tags/1 GET /cpanel/tags/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tags\n get('tags')\n end",
"def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end",
"def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end",
"def index\n @cpanel_tags = Cpanel::Tag.all\n end",
"def tags\n\t\tresponse = self.server.run_with_json_template( :tags )\n\t\treturn response.flatten.map {|tag| Hglib::Repo::Tag.new(self, **tag) }\n\tend",
"def tag\n require_admin_permissions\n @model = 'tag'\n @key = 'tag'\n @values = Tag.all.pluck(:tag)\n render 'tags'\n end",
"def tags\n _get(\"/query/image/tags\") { |json| json }\n end",
"def tags\n response[\"tags\"]\n end",
"def index\n tags = Tag.all\n render json: tags, status: :ok\n end",
"def tags\n @data['tags']\n end",
"def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end",
"def get_tag_list\n # body = {\n # cmd: \"get_tag_list\"\n # }\n\n end",
"def tags\n @obj['tags']\n end",
"def tags(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Tags\", params: params)\n end",
"def tags\n return head :unauthorized unless current_user\n @tags = current_user.owned_tags.where(\"name like ?\", \"%#{params[:tag]}%\").\n page(params[:page]).per(20)\n if @tags.empty?\n @tags = [current_user.owned_tags.new(name: I18n.t('record.tag_list.no_tags'))]\n end\n respond_with(@tags)\n end",
"def show\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tags_of_novel }\n end\n end",
"def tags\n @tags ||= get(\"/repos/show/#{owner.login}/#{name}/tags\")['tags']\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def index\n @tags, @tags_attached = TagService.list(current_user.id)\n end",
"def tags(client)\n client.get(\"#{PATH}/tags\")\n end",
"def index\n @tags = Tag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tags }\n end\n end",
"def index # This is what we'll need if we want our url/tags page to exist\n @tags = Tag.all\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Node.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Node.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def index\n @tags = Tag.order('name')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def all\n response= handle_errors{ self.class.get('/get')}\n response[\"tags\"][\"tag\"].collect do |tag| \n t= Rubycious::Tag.new(tag)\n end\n end",
"def index\n @has_project_tags = HasProjectTag.all\n render json: @has_project_tags\n end",
"def tags\n get.tagGuids\n end",
"def index\n render json: @project.tags, \n each_serializer: TagSerializer, :root => \"tags\"\n end",
"def tags() ; info[:tags] ; end",
"def tags() ; info[:tags] ; end",
"def show\r\n render json: Tag.find(params[:id])\r\n end",
"def index\n authorize @user\n render :json => @user.tags\n end",
"def index\n return render_json_for_api(Tag.map) if params[:map] == \"true\" && api_call?\n @tags_with_counts = Tag.\n joins(:vulnerabilities).\n group(\"tags.id\").\n select(\"tags.name\",\n \"tags.shortname\",\n \"tags.color\",\n \"tags.icon\",\n \"tags.id\",\n \"tags.family\",\n 'count(*) AS num_vulns').\n having('count(*) > 1')\n\n @tags = Tag.order(name: :asc).\n select(\"\n *,\n substring(tags.description from 0 for 240) || '...' as short_desc\n \")\n @articleTags = ArticleTag.joins(:article).distinct(:article_id).select(:title, :blurb, :art)\n if @tags == nil\n flash[:error] = \"Error: Tag not found\"\n redirect_to controller: 'tags', :action => 'index'\n else\n render_json_for_api(@tags)\n end\n end",
"def index\n @tags = @tags.uniq\n respond_with(@tags)\n end",
"def index\n tags = Array.wrap params.permit(:tags)[:tags]\n @clips = @allclips = Clip.where(session_id: session.id)\n @clips = @allclips.tagged_with(tags, any: true) if tags.any?\n @available_tags = Clip.available_tags_for(session.id)\n end",
"def index\n @taggables = current_user.taggables\n @taggable_center = current_user.taggables.first\n \n\n if !@taggable_center.nil?\n @url_no_path = URI.parse(@taggable_center.photo.url(:editable)).path[%r{[^/]+\\z}]\n @url_path = URI.parse(@taggable_center.photo.url(:editable)).path\n @tags = @taggable_center.tags\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taggables }\n end\n end",
"def index\n tags_list = []\n @user.tags.find_each do |tag|\n tags_list << tag_as_hash(tag, false)\n end\n\n render :status => 200,\n :json => {\n status: 200,\n tags: tags_list\n }\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Video.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Video.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def show\n\t @tags = @posts.tags\n end",
"def index\n authorize @ticket\n render :json => @ticket.tags\n end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def show_my_tags\n tags = Tag.where('customer_id = ? AND active = ?', current_customer.id, true)\n\n if tags.nil?\n return_error_infos(400, 'No tags found', 'NoTagsFound', nil)\n else\n json_tags = []\n\n tags.each { |tag| json_tags << create_tag_infos(tag, nil) }\n\n render :status => 200, :json => { :tags => json_tags }\n end\n end",
"def index\n @posttags = Posttag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posttags }\n end\n end",
"def show\n @taggable = current_user.taggables.find(params[:id])\n @tags = @taggable.tags\n @url_no_path = URI.parse(@taggable.photo.url).path[%r{[^/]+\\z}]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taggable }\n end\n end",
"def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end",
"def tags\n @tags = User.tag_counts_on(:tags, :conditions => \"name LIKE '\" + (params[:query] || \"\") + \"%'\").limit(50).order('count desc')\n respond_to do |format|\n format.html # tags.html.erb\n format.json { render json: @tags }\n format.xml { render xml: @tags }\n end\n end",
"def index\n @tags = Tag.used.clone #This is a Hash with keys(tags) ordered from most used to least\n respond_with @taglist\n end",
"def show\n @tags = @image.tag_list\n end",
"def tags\n return false if params[:q] and params[:q].size < 3\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n respond_to do |format|\n format.json { render :json => @tags.map{|t| {:id => t.name, :name => t.name }}}\n end\n end",
"def index\n authorize Tag\n @tags = Tag.order(name: :asc).page params[:page]\n end",
"def index\n @all = Tag.all\n render json: @all.collect{|tag| tag.strip}\n end",
"def index\n @tags = Tag.where(:parent_id => nil).order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = ActsAsTaggableOn::Tag.order(:name).all\n end",
"def index\n @tags = Tag.all\n render :index, status: 200\n end",
"def index\n authorize @organization\n render :json => @organization.tags\n end",
"def top_tags()\n get(:standard, {:method => \"tag.getTopTags\"})\n end",
"def show\n @tag = Tag.find(params[:id])\n render json: JSON.parse(@tag.to_json)\n end",
"def index\n\n@tags = Tag.all\n\nrespond_to do |format|\n format.html #index.html.erb\n format.json { render json: @tags }\nend\nend",
"def index\n\t\t@tags = Tag.all\n end",
"def tag\n @session_user = User.find(session[:user_id])\n @page = @session_user.page\n @tags = Array.new \n for panel in @page.panels.order(:created_at)\n #Use a max function on :panelid and :newpanelid?\n if !(panel_has_tag(panel, params[:tagname]))\n if panel.id > (params[:panelid]).to_i && panel.id >= (params[:newpanelid]).to_i \n tag = Tag.new\n tag.name = params[:tagname]\n tag.page_id = @page.id\n tag.panel_id = panel.id\n tag.panel_type = panel.type\n tag.save\n @tags.push(tag)\n end\n end\n end\n render json: @tags\n end",
"def index\n\t\t# Check for optional limit parameter.\n\t\tif params[:limit].nil?\n\t\t\tparams[:limit] = params[:default][:limit]\n\t\tend\n\n\t\t# GET /api/v1/tags\n\t\t@tags = Tag.paginate(:page => params[:page], :per_page => params[:limit])\n\n\t\t# GET api/v1/resources/:resource_id/tags\n\t\t# Return all tags used by a specific resource.\n\t\tif params[:resource_id]\n\t\t\t@tags = Resource.find_by(id: params[:resource_id]).tags.paginate(:page => params[:page])\n\t\tend\n\tend",
"def index\n @tags = Tag.order(\"tagtext ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n @tags = Tag.all\n end",
"def show\n @tagname = params[:id].to_s\n @tags = Tag.name_is(@tagname).descend_by_updated_at.reject {|r| !r.tagable.read_allowed?(current_user) }.paginate(\n :page => params[:page], :per_page => POSTINGS_PER_PAGE)\n @tagables = @tags.map { |t| \n t.tagable\n }.sort { |b,a| a.updated_at <=> b.updated_at }\n end",
"def show\n get_status\n @tag = Tag.find(params[:id])\n taggings = Tagging.where(:tag_id => params[:id])\n\n post_ids = []\n taggings.each do |tagging|\n post_ids << tagging.post_id\n end\n post_ids.compact!\n\n @posts = Post.where(:id => post_ids).order('created_at DESC').page(params[:page]).per(5)\n @labels = [\"<span class=\\\"label\\\">\",\"<span class=\\\"label label-success\\\">\",\"<span class=\\\"label label-warning\\\">\",\"<span class=\\\"label label-important\\\">\",\"<span class=\\\"label label-info\\\">\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end",
"def index\n #@tags = Tag.all\n end",
"def tags\n send_tags('tags', @handle, @security)\n end",
"def list\n tags = api_client.tags.by_resource(resource_hrefs:\n [api_client.get_instance.href]).first.tags\n ::MachineTag::Set.new(tags.map { |tag| tag['name'] })\n end",
"def index # p \"TagsController.index: params=#{params.inspect}\"\n # p \"params['example_id']=#{params['example_id']}, params[:example_id]=#{params[:example_id]}\"\n if (params[:example_id])\n @tags = Tag.where(\"example_id=?\", params[:example_id])\n else\n @tags = Tag.all\n end\n\n p \"@tags=#{@tags.inspect}\"\n\n respond_to do |format|\n format.html {}\n format.json {render :json => @tags }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts, :include => :tags }\n end\n end",
"def retrieve_tags\n # noop\n end",
"def index\n @tags ||= Tag.paging(params[:page])\n respond_with(@tags)\n end",
"def get_user_tags username, password\n do_request 'get_user_tags', username: username, password: password\n end",
"def tag(id, params = {})\n get \"tags/#{id}\", {query: params}\n end",
"def show\n @expense = Expense.find(params[:id])\n\n @tags = @expense.get_tags\n end",
"def show\n @label = Label.find_by_id(params[:id])\n if @label.nil?\n @label = Label.find_by_name(params[:id])\n end\n\n @repos = Repo.tagged_with(@label.name, on: :labels).order(\"watchers DESC\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @label }\n end\n end",
"def get_tags_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CategoriesApi.get_tags ...\"\n end\n # resource path\n local_var_path = \"/tags\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourcestring')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def tags\n @tags ||= []\n end",
"def index\n @tag = Tag.all\n end",
"def index\n unless params[:tag].blank?\n @recipes = current_user.recipes.tagged_with(params[:tag]).order(\"created_at desc\").page(params[:page]).per(10)\n else\n @recipes = current_user.recipes.order(\"created_at desc\").page(params[:page]).per(10) \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def show\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_tag }\n end\n end",
"def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end",
"def show\n if @tag == nil\n flash[:error] = \"Error: Tag not found\"\n redirect_to controller: 'tags', :action => 'index'\n return\n end\n @vulns = Vulnerability.\n joins(:tags).\n joins(:project).\n where('vulnerability_tags.tag_id' => @tag.id).\n select('*').\n select('projects.name').\n select(\"\n substring(vulnerabilities.description from 0 for 280)\n || '...' as short_desc\n \").\n select('vulnerability_tags.note as tag_note').\n order('vulnerabilities.upvotes desc')\n if @vulns == nil\n flash[:error] = \"Error: Tag not found\"\n redirect_to controller: 'tags', :action => 'index'\n else\n render_json_for_api(@vulns)\n end\n end",
"def tags\n object.tags.each do |tag|\n tag.name\n end\n end",
"def index\n @tags = Tag.all\nend",
"def index\n @tagged_items = TaggedItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tagged_items }\n end\n end"
] |
[
"0.7779269",
"0.73845357",
"0.73795176",
"0.7331087",
"0.71544605",
"0.71344113",
"0.71050936",
"0.708074",
"0.7032825",
"0.6960143",
"0.69230896",
"0.6874273",
"0.68694156",
"0.6828036",
"0.68220276",
"0.6807662",
"0.680135",
"0.67931074",
"0.67931074",
"0.67931074",
"0.67931074",
"0.67931074",
"0.67793053",
"0.6779253",
"0.6735709",
"0.6729034",
"0.67025906",
"0.66947716",
"0.6675943",
"0.6674321",
"0.6672136",
"0.6666346",
"0.6655688",
"0.6655688",
"0.6626742",
"0.66011727",
"0.65919125",
"0.6569705",
"0.6568978",
"0.65654933",
"0.6559855",
"0.65570754",
"0.65540886",
"0.6547122",
"0.6542685",
"0.6542685",
"0.6542685",
"0.6542685",
"0.6542685",
"0.65371346",
"0.6516598",
"0.650759",
"0.65058804",
"0.64981806",
"0.64980733",
"0.64973646",
"0.6493903",
"0.6485187",
"0.6470888",
"0.64689267",
"0.6465188",
"0.6465188",
"0.6465188",
"0.6465188",
"0.6465188",
"0.6465188",
"0.6465188",
"0.6460561",
"0.6460263",
"0.64553756",
"0.64531535",
"0.64363426",
"0.6416569",
"0.6412557",
"0.6406006",
"0.64001054",
"0.63979733",
"0.6396993",
"0.63789314",
"0.63704395",
"0.63694984",
"0.63473296",
"0.6338338",
"0.6323211",
"0.6298979",
"0.6295382",
"0.6292077",
"0.62895477",
"0.6286751",
"0.6279603",
"0.6276318",
"0.6275741",
"0.626078",
"0.6260107",
"0.6259337",
"0.6252758",
"0.6249861",
"0.6249464",
"0.624761",
"0.62436223",
"0.6242632"
] |
0.0
|
-1
|
POST /cpanel/tags POST /cpanel/tags.json
|
def create
@cpanel_tag = Cpanel::Tag.new(cpanel_tag_params)
respond_to do |format|
if @cpanel_tag.save
format.html { redirect_to @cpanel_tag, notice: 'Tag was successfully created.' }
format.json { render action: 'show', status: :created, location: @cpanel_tag }
else
format.html { render action: 'new' }
format.json { render json: @cpanel_tag.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tag!(params = {})\n self.post params, edge: :tags\n end",
"def tags\n send_tags('tags', @handle, @security)\n end",
"def create_tags\n\tend",
"def tag\n @session_user = User.find(session[:user_id])\n @page = @session_user.page\n @tags = Array.new \n for panel in @page.panels.order(:created_at)\n #Use a max function on :panelid and :newpanelid?\n if !(panel_has_tag(panel, params[:tagname]))\n if panel.id > (params[:panelid]).to_i && panel.id >= (params[:newpanelid]).to_i \n tag = Tag.new\n tag.name = params[:tagname]\n tag.page_id = @page.id\n tag.panel_id = panel.id\n tag.panel_type = panel.type\n tag.save\n @tags.push(tag)\n end\n end\n end\n render json: @tags\n end",
"def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end",
"def modify_tag tag\n data = {\n \"tag\" => params\n }\n temp = data[\"servers\"]\n data[\"servers\"] = { \"server\" => temp }\n\n json = JSON.generate data\n\n response = put \"tag/#{tag}\", json\n return response unless response.code == 200\n\n body = JSON.parse response.body\n body[\"tag\"]\n end",
"def tag\n require_admin_permissions\n @model = 'tag'\n @key = 'tag'\n @values = Tag.all.pluck(:tag)\n render 'tags'\n end",
"def create\n #...\n params[:cat].permit(...:tag_ids: []) #allow tag_ids and expect it to be an Array\n end",
"def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end",
"def tags\n get('tags')\n end",
"def create\n @tag = Tag.new(tag_params)\n if @tag.save\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end",
"def add_new_tag\n puts \"******* add_new_tag *******\"\n puts \" ** params: #{params.inspect}\"\n\n @post_id = params[:post_id]\n\n # == create brand new tag; add to Tags\n if params[:new_tag] != \"new\"\n\n # == check if tag already exists\n check_tag = Tag.where(tag_name: params[:new_tag])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n # == create new tag if not existing and assign to post\n if check_tag.length == 0\n @tag = Tag.create(tag_name: params[:new_tag], tag_rank: 0)\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: @tag[:id])\n puts \" ** NEW TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n\n # == assign existing tag if selected from select box (not \"ng\")\n if params[:tag_id] != \"ng\"\n\n # == check if tag already assigned to post\n check_tag = PostTag.where(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n if check_tag.length == 0\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** EXISTING TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n @post_tags = PostTag.where(post_id: params[:post_id])\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n\n new_tags = params[:tags].split(',')\n\n new_tags.each do |stag|\n @event.tags.create(tag: stag)\n end\n\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cpanel_tags = Cpanel::Tag.all\n end",
"def create\n authorize @organization\n if @organization.update_attributes(tag_list: @tags)\n render :json => @organization.reload.tags, :status => :created\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end",
"def create\r\n @tag = Tag.new(tag_params)\r\n\r\n if @tag.save\r\n render json: @tag\r\n else\r\n render json: { error: \"Tag creating error\" }, status: :unprocessable_entity\r\n end\r\n end",
"def postEntityAdvertiserTag( gen_id, entity_id, language, tags_to_add, tags_to_remove)\n params = Hash.new\n params['gen_id'] = gen_id\n params['entity_id'] = entity_id\n params['language'] = language\n params['tags_to_add'] = tags_to_add\n params['tags_to_remove'] = tags_to_remove\n return doCurl(\"post\",\"/entity/advertiser/tag\",params)\n end",
"def create\n authorize @user\n if @user.update_attributes(tag_list: @tags)\n render :json => @user.reload.tags, :status => :created\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def create\n params[:tag_names].split(',').each do |name|\n @tag = Tag.find_or_create_by_name name.strip\n @tagging = Tagging.new(params[:tagging])\n @tagging.tag = @tag\n @tags_saved = @tagging.save\n end\n \n respond_to do |format|\n if @tags_saved\n format.html { redirect_to @tagging.taggable, notice: 'Tagged.' }\n format.json { render json: @tagging, status: :created, location: @tagging }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def tags; end",
"def update\n authorize @organization\n @organization.tag_list.add @tags\n if @organization.save\n render :json => @organization.reload.tags\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end",
"def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end",
"def tags\n\t\tresponse = self.server.run_with_json_template( :tags )\n\t\treturn response.flatten.map {|tag| Hglib::Repo::Tag.new(self, **tag) }\n\tend",
"def create\n create_tags = params[:create_tags]\n\t@good = Good.new(params[:good])\n\t\n\tif @good.save\n\t\tif create_tags == '1'\n\t\t\tvalues = params[:good][:name].split(':')\n\t\t\tname = values[values.size-1]\n\t\t\tlasttag = values.size-2\n\t\t\tfor i in 0..lasttag\n\t\t\t\ttag_name = values[i]\n\t\t\t\ttag = Tag.find_or_create_by_name(tag_name)\n\t\t\t\ttag.save\n\t\t\t\tgt = GoodsTag.new(:tag=>tag,:good=>@good)\n\t\t\t\tgt.save\n\t\t\tend\n\t\tend\n\t respond_to do |format|\n\t\t\tformat.html { redirect_to :action=>\"index\" }\n\t\t\tformat.json { render :json => @good, :status => :created, :location => @good }\n\t\tend\n else\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"new\" }\n\t\t\tformat.json { render :json => @good.errors, :status => :unprocessable_entity }\n\t\tend\n end\n end",
"def tag_params\n params.require(:tag).permit(:tag)\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Node.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Node.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def tag_set(id, tags)\n wf_event_id?(id)\n tags = Array(tags)\n tags.each { |t| wf_string?(t) }\n api.post([id, 'tag'].uri_concat, tags, 'application/json')\n end",
"def create\n @post = Post.new(params[:post])\n@post.user=current_user\n\tcurrent_user.tag(@post, :with => params[:post][:tag_list], :on => :tags)\n\tputs @post.save\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags << tag\n # end\n url.tags << tag\n else\n tag = Tag.new(name: params[:tag])\n url.tags << tag\n end\n render json: {code: 200, tags: url.tags}\n end",
"def create\n @tags_of_novel = TagsOfNovel.new(params[:tags_of_novel])\n\n respond_to do |format|\n if @tags_of_novel.save\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully created.' }\n format.json { render json: @tags_of_novel, status: :created, location: @tags_of_novel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n if params['tag_field'] != nil\n tags_array = params['tag_field'].split(\",\")\n tags_array.each do |tag|\n @post.tags << Tag.find_or_create_by_etiqueta_and_post_id(tag.strip, @post.id)\n end\n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tag_params\n params.require(:tag).permit(:name, tag_task_id: [])\n end",
"def cpanel_tag_params\n params.require(:cpanel_tag).permit(:name, :section_id)\n end",
"def create\n @api_tag = Api::Tag.new(params[:api_tag])\n\n respond_to do |format|\n if @api_tag.save\n format.html { redirect_to @api_tag, notice: 'Tag was successfully created.' }\n format.json { render json: @api_tag, status: :created, location: @api_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tags\n @data['tags']\n end",
"def tag_params\n params.require(:tag).permit(:id, :name, :description)\n end",
"def create\n @tags_post = TagsPost.new(tags_post_params)\n\n respond_to do |format|\n if @tags_post.save\n format.html { redirect_to @tags_post, notice: 'Tags post was successfully created.' }\n format.json { render :show, status: :created, location: @tags_post }\n else\n format.html { render :new }\n format.json { render json: @tags_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tags=(value)\n @tags = value\n end",
"def tags=(value)\n @tags = value\n end",
"def tags=(value)\n @tags = value\n end",
"def tags_params\n params.require(:tag).permit(:name)\n end",
"def update\n authorize @ticket\n @ticket.tag_list.add @tags\n if @ticket.save\n render :json => @ticket.reload.tags\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end",
"def update\n authorize @user\n @user.tag_list.add @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def tag_params\n params.fetch(:tag, {}).permit(:name, tag_ids: [])\n end",
"def create\n #tags are sent to the controller as a string array\n #we'll create our own way to find the Tag objects\n tags = equipment_params[:tags]\n\n tags_object_collection = []\n\n tags.each do |tag|\n if tag == ''\n next\n end\n\n tag_obj = Tag.find(tag)\n\n if tag_obj != nil\n tags_object_collection.push(tag_obj)\n end\n end\n\n new_equipment_params = equipment_params.except(:tags)\n\n @equipment = Equipment.new(new_equipment_params)\n @equipment.tags = tags_object_collection\n\n respond_to do |format|\n if @equipment.save\n format.html { redirect_to equipment_index_path, notice: 'Equipment was successfully created.' }\n format.json { render json: @equipment, status: :created, location: @equipment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @equipment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag dodany do bazy tagów' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_tag_params\n params.require(:post_tag).permit(:post_id, :tag)\n end",
"def create\n @post = Post.create(post_params)\n @post.tag_list=(params[:tag_list])\n respond_with @post\n end",
"def create\n authorize @ticket\n if @ticket.update_attributes(tag_list: @tags)\n render :json => @ticket.reload.tags, :status => :created\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end",
"def tag_params\n params.require(:tag).permit(:name, :description)\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to tags_url, :notice => 'Tag was successfully created.' }\n format.json { render :json => @tag, :status => :created, :location => @tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_tag_to_server server_uuid, tags\n tag = (tags.respond_to? :join && tags.join(\",\") || tags)\n\n post \"server/#{server_uuid}/tag/#{tag}\"\n end",
"def admin_tag_params\n params.fetch(:tag, {}).permit(:name)\n end",
"def post_v1_tags(body, opts = {})\n data, _status_code, _headers = post_v1_tags_with_http_info(body, opts)\n data\n end",
"def create\n @post = Post.new(params[:post])\n @post.tag_list = params[:tags]\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Video.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Video.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def create\n @posttag = Posttag.new(params[:posttag])\n\n respond_to do |format|\n if @posttag.save\n format.html { redirect_to @posttag, :notice => 'Posttag was successfully created.' }\n format.json { render :json => @posttag, :status => :created, :location => @posttag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @posttag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def admin_panel_tag_params\n params.require(:admin_panel_tag).permit(:name, :description)\n end",
"def create\n \n # special case for multiple tags\n tags = params[\"_json\"]\n if (tags.class.name == 'Array')\n Tag.delete_all\n puts \"this is an array\"\n success = true\n @tag = nil \n tags.each do |tag_hash|\n puts \"params are going from #{tag_hash} to #{tag_in_array_params(tag_hash)}\"\n @tag = Tag.new(tag_in_array_params(tag_hash))\n success &= @tag.save \n break unless success\n end\n respond_to do |format|\n if success\n format.json { render action: 'show', status: :created, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n return \n else \n puts \"class is #{tags.class}\"\n end\n \n @tag = Tag.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tag }\n else\n format.html { render action: 'new' }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_tag_list\n # body = {\n # cmd: \"get_tag_list\"\n # }\n\n end",
"def tag\n params.require(:tag).permit(:example_id, :tag)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:tagname)\n end",
"def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, :notice => 'Tag was successfully created.' }\n format.json { render :json => @tag, :status => :created, :location => @tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n tag = Tag.new(params.permit(:name))\n \n if tag.save\n render json: tag, status: :created\n else\n render json: tag.errors, status: :unprocessable_entity\n end\n end",
"def field_params\n params.require(:tag).permit(:tag)\n end",
"def create\n @blog = Blog.create(blog_params)\n params[:tags][:tag_id].each do |p|\n @tagging = Tagging.create(tag_id: p.to_i, blog_id: @blog.id)\n end\n respond_to do |format|\n\n format.html { redirect_to @blog, notice: 'Blog was successfully created.' }\n format.json { render :show, status: :created, location: @blog }\n\n end\nend",
"def tag_params\n params.require(:tag).permit(:category, :description)\n end",
"def new\n @taggable = current_user.taggables.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taggable }\n end\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name)\n end",
"def tag_params\n params.require(:tag).permit(:name, :description)\n end",
"def create\n if current_user && current_user.email == 'zoe@test.com'\n resource = Resource.new(resource_params)\n #array of tag_ids from f.check_box_tag comes in as an array of strings\n tag_ids = params[:tag_ids].map(&:to_i)\n tag_array = []\n tag_ids.each do |id|\n tag = Tag.find(id)\n tag_array.push(tag)\n end\n if resource.save\n resource.tags << tag_array\n redirect_to resources_path\n end\n else\n redirect_to root_path\n flash[:error] = \"You do not have permission to perform this action.\"\n end\n end",
"def tags\n response[\"tags\"]\n end",
"def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end",
"def create\n @post = Post.new(post_params.except(:tags))\n tags = post_params[:tags].split(',')\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n @post.add_tags_with_check(tags)\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end",
"def tags\n @values.fetch('tags') { \n @values['tags'] = {}\n }\n end",
"def create\n repo = Repo.find(params[:repo_id])\n\n label_name = params[:label_name].downcase\n \n respond_to do |format|\n format.html { \n # Which ActsAsTaggableOn Context do we want to tag?\n if params[\"add_label\"]\n repo.label_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"remove_label\"]\n repo.label_list << label_name\n repo.label_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"add_framework\"]\n repo.framework_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_framework\"]\n repo.framework_list << label_name\n repo.framework_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"add_language\"]\n repo.language_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_language\"]\n repo.language_list << label_name\n repo.language_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n else\n #no particular action wish was send along\n redirect_to :back, notice: \"Tagging action did not succeed. Please mail my creators that I did not receive instruction where to put this tag or label.\" \n end \n }\n end\n end",
"def added_tags=(value)\n @added_tags = value\n end",
"def test_tagged_request_for_no_tags\n login_as(:quentin)\n post :tagged, {:tags=>nil}\n assert_response :success\n assert_nil assigns(:tag)\n assert_equal [], assigns(:selected_tags)\n assert_equal Hash[], assigns(:remove_tag_links)\n assert_equal Hash['Good'=>'Good', 'Bad'=>'Bad', 'Ugly'=>'Ugly', 'Question'=>'Question', 'Crazy sugar'=>'Crazy sugar', 'Pretty'=>'Pretty'], assigns(:add_tag_links)\n assert_equal 4, assigns(:samples).size\n end",
"def garden_tag_params\n params.require(:garden_tag).permit(:tag_id)\n end",
"def tag_params\n params.require(:tag).permit(:name, :description, :color)\n end"
] |
[
"0.7175724",
"0.6999948",
"0.6811086",
"0.67192256",
"0.6650813",
"0.65976113",
"0.65713054",
"0.65681833",
"0.6511931",
"0.6503915",
"0.64171827",
"0.6399328",
"0.6350125",
"0.634897",
"0.633181",
"0.6286692",
"0.6277253",
"0.6269605",
"0.62690544",
"0.6263475",
"0.6263475",
"0.6263475",
"0.6263475",
"0.6263475",
"0.6256382",
"0.623223",
"0.62275636",
"0.622583",
"0.62066966",
"0.61978835",
"0.6197024",
"0.6196353",
"0.61843383",
"0.61839473",
"0.6172557",
"0.61695665",
"0.6165175",
"0.6165175",
"0.6165175",
"0.6165175",
"0.6165175",
"0.6164495",
"0.61614835",
"0.61534536",
"0.6136813",
"0.6127414",
"0.6124357",
"0.6119829",
"0.6119829",
"0.6119829",
"0.6117378",
"0.6116994",
"0.61136687",
"0.6103657",
"0.61019635",
"0.6094426",
"0.6085435",
"0.6076144",
"0.607522",
"0.60673684",
"0.6065389",
"0.60641",
"0.6056051",
"0.60530823",
"0.60517585",
"0.60495216",
"0.6049402",
"0.6044669",
"0.6040906",
"0.6034547",
"0.6032167",
"0.60318613",
"0.60318613",
"0.60318613",
"0.6026636",
"0.6018507",
"0.60072905",
"0.6005177",
"0.60043526",
"0.5995453",
"0.5991056",
"0.59871376",
"0.5986393",
"0.5986393",
"0.5986393",
"0.5986393",
"0.5986393",
"0.5986393",
"0.5985656",
"0.5984473",
"0.59758365",
"0.5973424",
"0.59710455",
"0.5962972",
"0.59610045",
"0.59546244",
"0.5946489",
"0.5943744",
"0.59425515",
"0.5942046"
] |
0.6844606
|
2
|
PATCH/PUT /cpanel/tags/1 PATCH/PUT /cpanel/tags/1.json
|
def update
respond_to do |format|
if @cpanel_tag.update(cpanel_tag_params)
format.html { redirect_to @cpanel_tag, notice: 'Tag was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @cpanel_tag.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def modify_tag tag\n data = {\n \"tag\" => params\n }\n temp = data[\"servers\"]\n data[\"servers\"] = { \"server\" => temp }\n\n json = JSON.generate data\n\n response = put \"tag/#{tag}\", json\n return response unless response.code == 200\n\n body = JSON.parse response.body\n body[\"tag\"]\n end",
"def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end",
"def update\n authorize @ticket\n @ticket.tag_list.add @tags\n if @ticket.save\n render :json => @ticket.reload.tags\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end",
"def update\n if @tag.update(tag_params)\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end",
"def update\n authorize @organization\n @organization.tag_list.add @tags\n if @organization.save\n render :json => @organization.reload.tags\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end",
"def update\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n if @api_tag.update_attributes(params[:api_tag])\n format.html { redirect_to @api_tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update_and_respond(@tag, tag_params)\n end",
"def update\n render json: @tag.errors unless @tag.update(tag_params)\n end",
"def update\n authorize @user\n @user.tag_list.add @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def update\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n if @tags_of_novel.update_attributes(params[:tags_of_novel])\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n current_user.tag(@post, :with => params[:post][:tag_list], :on => :tags)\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # @post.delete_all_tags\n # @post.tag(post_params[:tags], current_user) if post_params[:tags]\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @task.tags.each { |t| t.delete}\n\n respond_to do |format|\n if @task.update(task_params)\n create_multiple_tags(task_params[\"tag\"], @task.id)\n\n format.html { redirect_to @task.list, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update\n if @app && @tag\n @tag.update(tag_params)\n if @tag.valid?\n head :no_content\n else\n head :bad_request\n end\n else\n head :not_found\n end\n end",
"def update\n params[:post][:tag_ids] ||= []\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to [@post.user, @post], notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n tags = equipment_params[:tags]\n\n tags_object_collection = []\n\n tags.each do |tag|\n if tag == ''\n next\n end\n\n tag_obj = Tag.find(tag)\n\n if tag_obj != nil\n tags_object_collection.push(tag_obj)\n end\n end\n\n new_equipment_params = equipment_params.except(:tags)\n\n @equipment = Equipment.find(params[:id])\n @equipment.tags = tags_object_collection\n\n respond_to do |format|\n if @equipment.update_attributes(new_equipment_params)\n format.html { redirect_to equipment_index_path, notice: 'Equipment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @equipment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @image_tags = ActsAsTaggableOn::Tag.all\n\n tag_list = params[:image][:tag_list]\n @image.tag_list = tag_list.keys.select{|t| tag_list[t] == \"1\"}\n\n\n respond_to do |format|\n if @image.update(image_params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n tag = Tag.find_by_id(params[:id])\n if tag.update(params.permit(:name))\n render json: tag, status: :ok\n else\n respond_with tag.errors, status: :unprocessable_entity\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to tags_url, :notice => 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n if @tag.update_attributes(params[:tag])\n render json: JSON.parse(@tag.to_json)\n else\n render json: JSON.parse(@tag.errors.to_json)\n end\n end",
"def update\n respond_to do |format|\n if @climb_tag.update(climb_tag_params)\n format.html { redirect_to @climb_tag, notice: 'Climb tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @climb_tag }\n else\n format.html { render :edit }\n format.json { render json: @climb_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, :notice => 'Tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.update(tag_params)\n format.json { render :show, status: :ok, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/tags/#{gid}\", body: data, options: options)).first)\n end",
"def update\n get_status\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @expert_tag.update_attributes(:tag_name => params[:tag_name], :user_id => params[:user_id])\n format.html { redirect_to @expert_tag, notice: 'Expert tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @expert_tag }\n else\n format.html { render :edit }\n format.json { render json: @expert_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @tagarr = params[:post][\"tags_attributes\"][\"0\"][:name].split(\" \")\n puts @tagarr\n @tag = {}\n @tagarr.each_with_index do |tag,i|\n @tag[i] = {:name =>tag}\n end\n\n @tagreset = params[:post]\n @tagreset[\"tags_attributes\"] ={}\n @tagreset[\"tags_attributes\"] = @tag\n @post.tags=[]\n #puts @tagreset\n #render :layout => false\n respond_to do |format|\n if @post.update_attributes(@tagreset)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taggable = current_user.taggables.find(params[:id])\n\n respond_to do |format|\n logger.debug(params)\n if @taggable.update_attributes(params[:taggable])\n format.html { redirect_to @taggable, notice: 'Taggable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n \n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @post.tag_list = params[:tags]\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post.update_attributes(post_params)\n @post.tag_list=(params[:tag_list])\n respond_with @post\n end",
"def update\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.tags = @tags\n \n if @joke.update_attributes(params[:joke].except(:tags))\n format.html { redirect_to @joke, :notice => 'Joke was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entity_tag = EntityTag.find(params[:id])\n\n respond_to do |format|\n if @entity_tag.update_attributes(params[:entity_tag])\n format.html { redirect_to @entity_tag, notice: 'Entity tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entity_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag editada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: t('.updated') }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_tag.update(admin_tag_params)\n format.html { redirect_to admin_tags_path, notice: 'Tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_tag }\n else\n format.html { render :edit }\n format.json { render json: @admin_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag zaktualizowany' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @posttag = Posttag.find(params[:id])\n\n respond_to do |format|\n if @posttag.update_attributes(params[:posttag])\n format.html { redirect_to @posttag, :notice => 'Posttag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @posttag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find params[:id]\n if !@tag.admin.nil? && @tag.admin != current_user\n render json: { error: '403 requested operation not permitted' }, status: 403\n elsif @tag.update tag_params\n render :show, status: 200\n else\n render json: { error: '422 unprocessable entity' }, status: 422\n end\n end",
"def update\n real_post_path = @tag.post\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to post_path(real_post_path), notice: 'updated tag' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @has_tag.update(has_tag_params)\n format.html { redirect_to @has_tag, notice: 'Has tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @has_tag }\n else\n format.html { render :edit }\n format.json { render json: @has_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if params[:tags].nil?\n @question.tags = []\n else\n @question.tags = Tag.find(params[:tags])\n end\n\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to admin_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t @tags = @posts.tags\n respond_to do |format|\n\n if @posts.update(post_params)\n format.html { redirect_to post_path(@posts), notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @posts }\n\n else\n format.html { render :edit }\n format.json { render json: @posts.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def update\n #@post = process_tags(@post)\n @post.save\n\n respond_to do |format|\n if @post.update(post_params.except(:tags))\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end",
"def update\n respond_to do |format|\n if @tag_one.update(tag_one_params)\n format.html { redirect_to @tag_one, notice: 'Tag one was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag_one }\n else\n format.html { render :edit }\n format.json { render json: @tag_one.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n \t# update tags\n \t@question.tag_with(params[:question][:tag_list])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @engine_tag.update(engine_tag_params)\n format.html { redirect_to @engine_tag, notice: 'Engine tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @engine_tag }\n else\n format.html { render :edit }\n format.json { render json: @engine_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project_tag = ProjectTag.find(params[:id])\n\n respond_to do |format|\n if @project_tag.update_attributes(params[:project_tag])\n format.html { redirect_to @project_tag, notice: 'Project tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respondent = SurveyRespondent.find(params[:respondent_id])\n tag_context = params[:context] # tag context\n tag_list = params[:tags] # comma seperated list of tags\n\n if getTagOwner\n getTagOwner.tag(respondent, :with => tag_list, :on => tag_context)\n else\n respondent.set_tag_list_on(tag_context, tag_list) # set the tag list on the respondent for the context\n end\n \n respondent.save\n \n render :layout => 'content'\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n new_tags = params[:problem].to_unsafe_h[\"tag_list\"].scan(/\\w+/)\n new_tags.each do |tag|\n @problem.tag_list.add(tag)\n end\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem }\n else\n format.html { render :edit }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tags_post.update(tags_post_params)\n format.html { redirect_to @tags_post, notice: 'Tags post was successfully updated.' }\n format.json { render :show, status: :ok, location: @tags_post }\n else\n format.html { render :edit }\n format.json { render json: @tags_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tags_list = Tag.all\n @fact = Fact.find(params[:id])\n @fact.fact_text = params[:fact][:fact_text]\n @fact.page = params[:fact][:page]\n @fact.notes = params[:fact][:notes]\n @fact.last_modified_by = current_user.name\n @fact.tags.clear\n tags = params[:fact][:tags_attributes]\n Array(tags).each do |tag|\n if tag[1][:_destroy] != \"1\"\n temptag = Tag.find_by tag_word: tag[1][:tag_word]\n if @fact.tags.include?(temptag) == false\n @fact.tags << temptag\n end\n end\n end\n\n respond_to do |format|\n # Added by RB because updating wasn't working at all\n if @fact.update(fact_params)\n format.html { redirect_to @fact, notice: 'Fact was successfully updated.' }\n format.json { render :show, status: :ok, location: @fact }\n else\n format.html { redirect_to @fact, notice: 'Fact was sort of successfully updated. There was an error, but we think it is ok' }\n format.json { render :show, status: :ok, location: @fact }\n end\n\n\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to tag_success_path, notice: \"Tag was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @server = Server.find(params[:id])\n if params[:tag_ids]\n @server.tags = params[:tag_ids].map { |id| Tag.find(id) }\n end\n respond_to do |format|\n if @server.update_attributes(params[:server])\n format.html { redirect_to servers_path, notice: 'Server was successfully updated.' }\n format.json { render json: @server, status: :updated, location: @server }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n tags = params[:tags]\n @piece.taggings.destroy_all\n\n tags.downcase.split(',').each do |tag_name|\n tag = Tag.find_or_create_by(name: tag_name.strip)\n @piece.taggings.create(user_id: current_user.id, tag_id: tag.id)\n end\n\n if @piece.update(piece_params)\n redirect_to @piece, notice: 'Piece was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n @events_tag = EventsTag.find(params[:id])\n\n respond_to do |format|\n if @events_tag.update_attributes(params[:events_tag])\n format.html { redirect_to @events_tag, notice: 'Events tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @events_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mf_api_user_update_tags\n\n # Get User From DB with client_id\n user = User.where(clientid: params[:client_id]).first\n\n # If user not found, return error response\n if user.empty?\n response = {\n success: false,\n message: 'User with ClientID not found'\n }\n\n render json: response\n end\n\n # Get the Infusionsoft contact info\n contact = Infusionsoft.data_load('Contact', user.clientid, [:Groups])\n\n # Update User Tags\n user.put('', {\n :client_tags => contact['Groups']\n })\n\n\n response = {\n success: true,\n message: 'User Tags Updated'\n }\n\n render json: response\n\n end",
"def update\n @post.short_body = post_params[:body].split('</p>')[0] + '</p>'\n @post.tags.delete_all\n set_tags\n\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @tag\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to admin_tags_path, notice: 'Tag was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag.update(instance_params)\n format.html { redirect_to show_path, success: I18n.t(\"admin.flash.tags.success.update\") }\n format.json { render :show, status: :ok, location: admin_tag_url(@tag) }\n else\n format.html { render_edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_conversation_tags(id, tags)\n data = { tags: tags }\n put(\"conversations/#{id}/tags\", { body: data })\n end",
"def update\n @tagging = @object\n tag = @tagging.tag\n return unless filter_perms(@auth,tag,['updater'])\n taggable = @tagging.taggable\n return unless filter_perms(@auth,taggable,['updater'])\n\n respond_to do |format|\n if @tagging.update_attributes(params[:tagging])\n flash[:notice] = 'Tagging was successfully updated.'\n format.html { redirect_to tagging_url(@tagging) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tagging.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tag.name = tag_params[:name]\n @tag.style = tag_params[:style]\n\n if @tag.save\n render :nothing => true, :status => :ok\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n end",
"def update\n if @building.update(update_params)\n if t = params.permit(:tags)[:tags]\n tag_names = t.split(\", \")\n tags = [Tag.create_with(name: \"building\").find_or_create_by(name: \"building\")]\n for n in tag_names\n tags += [Tag.create_with(name: n).find_or_create_by(name: n)]\n end\n @building.tags = tags\n end\n @notice = \"Updated successfully.\"\n render :file => \"#{Rails.root}/public/success\", :layout => false\n else\n @notice = \"Update failed.\"\n render :file => \"#{Rails.root}/public/error\", :layout => false\n end\n end",
"def update\n respond_to do |format|\n if @image_tag.update(image_tag_params)\n format.html { redirect_to @image_tag, notice: 'Image tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @image_tag }\n else\n format.html { render :edit }\n format.json { render json: @image_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tags(tags = nil)\n set_tags(tags)\n write_tags_to_repo\n read_tags_from_repo\n save!\n end",
"def update\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if params[:tags_id].present?\n arr = params[:tags_id].split(',')\n @poem.tags = Tag.find(arr)\n end\n\n respond_to do |format|\n if @poem.update(poem_params)\n format.html { redirect_to @poem, notice: 'Poem was successfully updated.' }\n format.json { render :show, status: :ok, location: @poem }\n else\n format.html { render :edit }\n format.json { render json: @poem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = FeedEntry.find(params[:id])\n\n tags = params['tags' + params[:id]]\n\n respond_to do |format|\n if FeedEntry.add_tag(@entry, tags)\n format.html {render action: 'index'}\n format.json {head :no_content}\n else\n format.html {render action: 'index'}\n format.json {render json: @entry.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update_tags(metricDefinition)\n @client.http_put(\"/#{@resource}/#{metricDefinition.id}/tags\",metricDefinition.hash[:tags])\n end",
"def update(group, tags)\n body = {:tags => tags}.to_json\n url = build_url(group)\n response = rest_patch(url, body)\n response.return!\n end",
"def update_tags!\n return unless @params.key?(:tags)\n\n tags_to_remove.each do |tag_title|\n TaskTag.where(task: task).joins(:tag).merge(Tag.where(title: tag_title)).destroy_all\n end\n\n tags_to_add.each do |tag_title|\n TaskTag.where(task: task, tag: tag_from_title(tag_title)).first_or_create!\n end\n end",
"def update\n story = Story.find(params[:id])\n authorize story # check policies/story_policy.rb for auth rules\n\n if story_params[:tags]\n story_params[:tags].each do |tag|\n # If tag exists then use existing tag name\n if Tag.exists?(tag)\n story.tags << Tag.find_by_name(tag[\"name\"])\n else\n story.tags << Tag.new(tag)\n end\n end\n end\n\n if story.update(story_params.except(:tags)) && story.save\n response_with('Story successfully saved', 200)\n else\n response_with('Could not update story', 400)\n end\n end",
"def update\n super\n\n if resource.save\n params.permit(:tags_interest_areas => [])\n @interest_tags = params[:tags_interest_areas]\n\n resource.interest_areas.destroy_all\n\n if not @interest_tags.nil?\n @interest_tags.each do |tag|\n temp_tag = Tag.find_by_tag_name(tag)\n if not temp_tag.nil?\n resource.interest_areas << temp_tag if not resource.interest_areas.include?(temp_tag) \n else\n resource.interest_areas << Tag.create(tag_name: tag)\n end\n end\n end\n\n params.permit(:tags_expertise_areas => [])\n @expertise_tags = params[:tags_expertise_areas]\n\n resource.expertise_areas.destroy_all\n\n if not @expertise_tags.nil?\n @expertise_tags.each do |tag|\n temp_tag = Tag.find_by_tag_name(tag)\n if not temp_tag.nil?\n resource.expertise_areas << Tag.find_by_tag_name(tag) if not resource.expertise_areas.include?(temp_tag) \n else\n resource.expertise_areas << Tag.create(tag_name: tag)\n end\n end\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to :tags, notice: 'Метка успешно обновлена.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @photo_tag.update(photo_tag_params)\n format.html { redirect_to @photo_tag, notice: 'Photo tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tag = Tag.find(params[:id])\n @tag.update_attributes(params[:tag])\n respond_to do |format|\n format.js\n end\n end",
"def update_tags(host_id, tags, source=nil)\n @tag_svc.update(host_id, tags, source)\n end",
"def update\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to(asset_manager_asset_tags_path(@tag.asset_id), :notice => 'Tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tag_ref.update(tag_ref_params)\n format.html { redirect_to @tag_ref, notice: 'Zmodyfikowano Tag.' }\n format.json { render :show, status: :ok, location: @tag_ref }\n else\n format.html { render :edit }\n format.json { render json: @tag_ref.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @activity_tag = ActivityTag.find(params[:id])\n\n respond_to do |format|\n if @activity_tag.update_attributes(params[:activity_tag])\n format.html { redirect_to @activity_tag, notice: 'Activity tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @activity_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @has_project_tag.update(has_project_tag_params)\n render json: @has_project_tag, status: :ok#, location: @has_project_tag\n else\n render json: @has_project_tag.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @asset_tag.update(asset_tag_params)\n format.html { redirect_to @asset_tag, notice: 'Asset tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_tag }\n else\n format.html { render :edit }\n format.json { render json: @asset_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_tag = UserTag.find(params[:id])\n\n respond_to do |format|\n if @user_tag.update_attributes(params[:user_tag])\n format.html { redirect_to @user_tag, notice: 'User tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post_tag.update(post_tag_params)\n format.html { redirect_to @post_tag, notice: 'Tagia muokattu' }\n format.json { render :show, status: :ok, location: @post_tag }\n else\n @alert = @post_tag.errors\n format.html { render :edit }\n format.json { render json: @post_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prd_tag.update(prd_tag_params)\n format.html { redirect_to @prd_tag, notice: 'Prd tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @prd_tag }\n else\n format.html { render :edit }\n format.json { render json: @prd_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mytag.update(mytag_params)\n format.html { redirect_to root_path, info: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @mytag }\n else\n format.html { render :edit }\n format.json { render json: @mytag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tag!(params = {})\n self.post params, edge: :tags\n end"
] |
[
"0.7226494",
"0.6899246",
"0.6704542",
"0.6684745",
"0.6621449",
"0.65921783",
"0.6515848",
"0.64672214",
"0.6466572",
"0.64545995",
"0.6452774",
"0.6401909",
"0.63852096",
"0.63628",
"0.63628",
"0.6337545",
"0.62948054",
"0.6288853",
"0.62865406",
"0.62737775",
"0.62584",
"0.62570405",
"0.6241836",
"0.6226385",
"0.6222965",
"0.62218845",
"0.620463",
"0.6204299",
"0.61982477",
"0.6187726",
"0.6174844",
"0.6172494",
"0.6169635",
"0.61590934",
"0.6150323",
"0.6143569",
"0.61279935",
"0.61259943",
"0.612283",
"0.612283",
"0.6118727",
"0.61171055",
"0.611325",
"0.61056477",
"0.610465",
"0.61015075",
"0.6095181",
"0.6095181",
"0.60848725",
"0.6080146",
"0.60770965",
"0.6074704",
"0.6071974",
"0.6056813",
"0.6049734",
"0.603761",
"0.60235965",
"0.6016111",
"0.60156953",
"0.60156953",
"0.60156953",
"0.6011854",
"0.5985696",
"0.5980045",
"0.5962689",
"0.5957852",
"0.5956771",
"0.59366167",
"0.59292644",
"0.59257334",
"0.5925681",
"0.59214854",
"0.5920746",
"0.5920543",
"0.5909534",
"0.5904152",
"0.5899624",
"0.5899349",
"0.5899259",
"0.5896168",
"0.58948416",
"0.58926374",
"0.58913654",
"0.5882727",
"0.58745444",
"0.5863279",
"0.58475006",
"0.583942",
"0.58359724",
"0.5834428",
"0.5831697",
"0.58294225",
"0.5822895",
"0.58070636",
"0.58027685",
"0.58023596",
"0.57999486",
"0.57943",
"0.57865345",
"0.5785787"
] |
0.666079
|
4
|
DELETE /cpanel/tags/1 DELETE /cpanel/tags/1.json
|
def destroy
@cpanel_tag.destroy
respond_to do |format|
format.html { redirect_to cpanel_tags_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_tag tag\n delete \"tag/#{tag}\"\n end",
"def destroy\n @tags_of_novel = TagsOfNovel.find(params[:id])\n @tags_of_novel.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_of_novels_url }\n format.json { head :no_content }\n end\n end",
"def delete(tag)\n api_client.tags.multi_delete(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def destroy\n @api_tag = Api::Tag.find(params[:id])\n @api_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to api_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n \n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end",
"def delete()\n\n client.delete(\"/tags/#{gid}\") && true\n end",
"def destroy\n # @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n get_status\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @posttag = Posttag.find(params[:id])\n @posttag.destroy\n\n respond_to do |format|\n format.html { redirect_to posttags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_collection = TagCollection.find(params[:id])\n @tag_collection.destroy\n render json: {}\n \n end",
"def destroy\n @taggable = current_user.taggables.find(params[:id])\n\n #destroy each tag in the taggable\n @taggable.tags.each do |tag|\n tag.destroy\n end\n\n @taggable.destroy\n\n respond_to do |format|\n format.html { redirect_to taggables_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n tag = tag.find(params[:id])\n\n if tag.destroy\n render json: {\"message\": \"Record was deleted\", status: :ok, }, status: :ok\n else\n render json: {\"message\": \"You are not authorized to delete this tag\"}, status: :unauthorized\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_path, success: I18n.t(\"admin.flash.tags.success.destroy\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def delete_tags(name); end",
"def destroy\n @tag.destroy\n head :no_content\n end",
"def destroy\n @post_tag.destroy\n respond_to do |format|\n format.html { redirect_to post_tags_url, notice: 'Tagi poistettu' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.destroy\n format.json { render json: {:id => @tag.id}, status: :ok }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @tagging.destroy\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_tag.destroy\n respond_to do |format|\n format.html { redirect_to admin_tags_url, notice: 'Tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb_tag.destroy\n respond_to do |format|\n format.html { redirect_to climb_tags_url, notice: 'Climb tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n real_post_path = @tag.post\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to post_path(real_post_path), notice: 'tag deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete\n resource.delete_tags([self])\n nil\n end",
"def destroy\n tag = @user.tags.find_by_tid(params[:id])\n if tag.nil?\n render json_status_response(404, \"Tag not found\")\n return\n end\n\n tag.destroy\n render json_status_response(200, \"Tag removed successfully\")\n end",
"def remove_tag\n @kyu_entry.tag_list.remove(params[:tag])\n @kyu_entry.save\n render json: true\n end",
"def destroy\n @tag_one.destroy\n respond_to do |format|\n format.html { redirect_to tag_ones_url, notice: 'Tag one was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # @post.delete_all_tags\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_identity = Identity.find(params[:id])\n @tag_identity.destroy\n\n respond_to do |format|\n format.html { redirect_to tag_identities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_tag = ProjectTag.find(params[:id])\n @project_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to project_tags_url }\n format.json { head :no_content }\n end\n end",
"def deleteEntityTag( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/tag\",params)\n end",
"def destroy\n @taggable.destroy\n\n respond_to do |format|\n format.html { redirect_to(taggables_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tagging = Tagging.find(params[:id])\n @tagging.destroy\n\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ad_tag = AdTag.find(params[:id])\n @ad_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_tags_url }\n format.json { head :ok }\n end\n end",
"def delete\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @activity_tag = ActivityTag.find(params[:id])\n @activity_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @tag_cloud = TagCloud.find(params[:id])\r\n @tag_cloud.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(tag_clouds_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @tagg = Tagg.find(params[:id])\n @tagg.destroy\n\n respond_to do |format|\n format.html { redirect_to taggs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n validate_presence_of :name\n wrapper.delete_tag(@name) || raise(OperationFailed)\n end",
"def destroy\n @events_tag = EventsTag.find(params[:id])\n @events_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to events_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n if @tag.errors.any?\n flash[:alert] = t('.message')\n else\n flash[:notice] = t('.destroy')\n end\n respond_to do |format|\n format.html { redirect_to tags_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @asset_tag = AssetTag.find(params[:id])\n @asset_tag.destroy\n render json: {}\n \n end",
"def destroy\n @tagging = Tagging.find(params[:id])\n @tagging.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_taggings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tagged_item = TaggedItem.find(params[:id])\n @tagged_item.destroy\n\n respond_to do |format|\n format.html { redirect_to all_items_tagged_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prd_tag.destroy\n respond_to do |format|\n format.html { redirect_to prd_tags_url, notice: 'Prd tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\tflash[:error] = @tag.errors[:base]\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @buildchecktag.destroy\n respond_to do |format|\n format.html { redirect_to buildchecktags_url, notice: 'Buildchecktag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n @tag.destroy\n redirect_to(tags_url)\n end",
"def destroy\n authorize @user\n @tags = @user.tag_list if @tags.empty?\n @user.tag_list.remove @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def destroy\n @tags_post.destroy\n respond_to do |format|\n format.html { redirect_to tags_posts_url, notice: 'Tags post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @has_project_tag.destroy.destroy\n render json: {has_project_tag: \"ELIMINADO\"} ,status: :ok #, location: @category\n else\n render json: @has_project_tag.destroy, status: :unprocessable_entity\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: 'Tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: 'Tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n tag = Tag.find_by_id(params[:id])\n #If tag does exist\n if !tag.nil?\n tag.destroy\n head :no_content\n else\n respond_with message: \"Resource not found\", status: :not_found\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: \"Tag was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_album_tag.destroy\n respond_to do |format|\n format.html { redirect_to admin_album_tags_url, notice: \"#{t 'activerecord.successful.messages.album_tag_deleted'}\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t\t\n\t@tag = Tag.find(params[:id])\n @tag.destroy\n\t\t\n respond_to do |format|\n format.html { redirect_to(tags_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @profile_diet_tag.destroy\n respond_to do |format|\n format.html { redirect_to profile_diet_tags_url, notice: 'Profile diet tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @organization\n @tags = @organization.tag_list if @tags.empty?\n @organization.tag_list.remove @tags\n if @organization.save\n render :json => @organization.reload.tags\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end",
"def destroy\n @tag_tag = TagTag.find(params[:id])\n @tag_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tag_tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url(parent: @parent_tag)) }\n format.json { head :ok }\n end\n end",
"def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end",
"def destroy\n @mytag.destroy\n respond_to do |format|\n format.html { redirect_to root_path, danger: 'Category was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @has_tag.destroy\n respond_to do |format|\n format.html { redirect_to has_tags_url, notice: 'Has tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion_tag.destroy\n respond_to do |format|\n format.html { redirect_to promotion_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n tag = Tag.find_by_name(params[:id])\n render(json: {error: \"Tag with name #{params[:id]} does not exists.\"}, status: :not_found) and return if tag.nil?\n if tag.destroy\n render text: '{\"success\": true}', status: :no_content, location: tag_path(params[:version], tag.name)\n else\n Rails.logger.error \"cannot destroy tag because there were errors deleting the tag #{tag.attributes.inspect} ... #{tag.errors.to_hash}\"\n render(json: tag.errors, status: :bad_request)\n end\n end",
"def destroy\n @image.tags.destroy_all\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image_tag.destroy\n respond_to do |format|\n format.html { redirect_to image_tags_url, notice: 'Image tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to :tags, notice: 'Метка успешно удалена.' }\n end\n end",
"def destroy\n @asset_tag.destroy\n respond_to do |format|\n format.html { redirect_to asset_tags_url, notice: 'Asset tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quotetags = Quotetags.find(params[:id])\n @quotetags.destroy\n\n respond_to do |format|\n format.html { redirect_to(quotetags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n #@admin_tag.destroy\n @admin_tag.soft_delete\n respond_to do |format|\n format.html { redirect_to admin_tags_path, notice: 'Marca eliminada con éxito.' }\n end\n end",
"def destroy\n @engine_tag.destroy\n respond_to do |format|\n format.html { redirect_to engine_tags_url, notice: 'Engine tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @door_tag.destroy\n respond_to do |format|\n format.html { redirect_to door_tags_url, notice: 'Door tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @ticket\n @tags = @ticket.tag_list if @tags.empty?\n @ticket.tag_list.remove @tags\n if @ticket.save\n render :json => @ticket.reload.tags\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end",
"def destroy\n @mwod_tag = MwodTag.find(params[:id])\n @mwod_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to mwod_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n end",
"def destroy\n @tag.destroy\n end",
"def destroy\n @alternative_tag_name.destroy\n respond_to do |format|\n format.html { redirect_to alternative_tag_names_url, notice: \"Alternative tag name was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance_eni_tag.destroy\n respond_to do |format|\n format.html { redirect_to instance_eni_tags_url, notice: 'Instance eni tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thetag.destroy\n respond_to do |format|\n format.html { redirect_to thetags_url, notice: 'Thetag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skill_tag = SkillTag.find(params[:id])\n @skill_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to skill_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @tag\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to admin_tags_path, notice: 'Tag was successfully destroyed.' }\n end\n end",
"def destroy\n @local_tag = LocalTag.find(params[:id])\n @local_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to local_tags_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_manager_asset_tags_path(@asset)) }\n format.xml { head :ok }\n end\n end",
"def delete_tag\n tag = Tag.find(params[:id])\n tag.destroy\n flash[:notice] = 'Tag deleted.'\n redirect_to :action => :list, :id => 'tag'\n end",
"def destroy\n @photo_tag.destroy\n respond_to do |format|\n format.html { redirect_to photo_tags_url, notice: 'Photo tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_tag = QuestionTag.find(params[:id])\n @question_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to question_tags_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7276123",
"0.7219809",
"0.71863914",
"0.7176537",
"0.7154785",
"0.71402436",
"0.71328014",
"0.71023256",
"0.7083655",
"0.70803547",
"0.7077671",
"0.70524395",
"0.70261616",
"0.70261616",
"0.70261616",
"0.70125365",
"0.7012272",
"0.70014805",
"0.7000115",
"0.6989769",
"0.6987283",
"0.69839734",
"0.6983345",
"0.69649345",
"0.696477",
"0.69543153",
"0.6944885",
"0.6940755",
"0.69109035",
"0.69057786",
"0.6904288",
"0.6900511",
"0.68745756",
"0.68715286",
"0.68704844",
"0.68454087",
"0.6838862",
"0.68237126",
"0.68196297",
"0.6809239",
"0.6802272",
"0.6798576",
"0.67852163",
"0.67851067",
"0.67773694",
"0.6762497",
"0.675662",
"0.67507327",
"0.67431706",
"0.67414534",
"0.6741368",
"0.6734661",
"0.6732633",
"0.67121863",
"0.6707494",
"0.6704077",
"0.669594",
"0.6688436",
"0.66860396",
"0.66834337",
"0.66834337",
"0.6683418",
"0.6675141",
"0.6669205",
"0.6658234",
"0.66568524",
"0.6652897",
"0.66512525",
"0.6649113",
"0.66462225",
"0.66423905",
"0.663807",
"0.6633057",
"0.66320866",
"0.6630833",
"0.6628997",
"0.66276133",
"0.66276133",
"0.66276133",
"0.66276133",
"0.66267157",
"0.66190344",
"0.66176885",
"0.6616828",
"0.6615139",
"0.66102177",
"0.6609587",
"0.6607085",
"0.66060245",
"0.66060245",
"0.66058034",
"0.66046613",
"0.659562",
"0.6595571",
"0.6591536",
"0.65876603",
"0.65858763",
"0.65831536",
"0.6571159",
"0.65666777"
] |
0.7599052
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_cpanel_tag
@cpanel_tag = Cpanel::Tag.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def cpanel_tag_params
params.require(:cpanel_tag).permit(:name, :section_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586",
"0.629103",
"0.6282451",
"0.6243152",
"0.62413",
"0.6219024",
"0.6213724",
"0.62103724",
"0.61945",
"0.61786324",
"0.61755824",
"0.6173267",
"0.6163613",
"0.6153058",
"0.61521065",
"0.6147508",
"0.61234015",
"0.61168665",
"0.6107466",
"0.6106177",
"0.6091159",
"0.60817343",
"0.6071238",
"0.6062299",
"0.6021663",
"0.60182893",
"0.6014239",
"0.6011563",
"0.60080767",
"0.60080767",
"0.60028875",
"0.60005623",
"0.59964156",
"0.5993086",
"0.5992319",
"0.5992299",
"0.59801805",
"0.59676576",
"0.59606016",
"0.595966",
"0.59591126",
"0.59589803",
"0.5954058",
"0.5953234",
"0.5944434",
"0.5940526",
"0.59376484",
"0.59376484",
"0.5935253",
"0.5930846",
"0.5926387",
"0.59256274",
"0.5917907",
"0.5910841",
"0.590886",
"0.59086543",
"0.59060425",
"0.58981544",
"0.5898102",
"0.5896809",
"0.5895416",
"0.58947027",
"0.58923644",
"0.5887903",
"0.58830196",
"0.5880581",
"0.5873854",
"0.58697754",
"0.5869004",
"0.58669055",
"0.5866886",
"0.58664906",
"0.5864619",
"0.58630043",
"0.5862495",
"0.5861368",
"0.5859712",
"0.5855544",
"0.58551925",
"0.5851284",
"0.5850602"
] |
0.0
|
-1
|
sum = 0 while !n %2==0 || !n %3==0 end puts sum end
|
def prob_three
max = 600851475143**0.5
for i in (1..max).step(2)
if 600851475143 % i == 0
if is_prime(i)
ans = i
end
end
end
ans
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend",
"def findSum(n)\n theFinal = 0\n for i in 3..n do\n if (i % 3 == 0 || i % 5 == 0) \n theFinal += i\n end\n end\n puts theFinal\nend",
"def solution(n)\n sum = 0\n (1...n).each { |num| num % 3 == 0 || num % 5 == 0 ? sum += num : false }\n sum\nend",
"def iter_sums_three_five (n)\n sum = 0\n\n (1...n).each do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num\n end\n end\n sum\nend",
"def sum(n)\n\n s = 0\n\n for i in 1...n\n if i % 3 == 0 || i % 5 == 0\n s += i\n end\n end\n\n return s\n\nend",
"def multisum(n)\n sum = 0\n (1..n).each do |x|\n sum += x if (x % 3 == 0) || (x % 5 == 0)\n end\n sum\nend",
"def sum_multiples_three_five\n sum = 0\n n = 0\n while n < 1000\n if(((n%3) == 0) || ((n%5) == 0))\n sum += n\n end\n n+=1\n end\n puts \"#{sum}\"\nend",
"def wild_sum(n)\r\n # your code here\r\n wild_sum = 0\r\n\r\n for i in 1 ... n\r\n\r\n if i % 2 == 0 && i % 3 != 0\r\n wild_sum += i\r\n\r\n elsif i % 3 == 0 && i % 2 != 0\r\n wild_sum += i\r\n end\r\n end\r\n wild_sum\r\n\r\nend",
"def sumdivby3or5(n)\n result = 0\n 1.upto(n) { |e| result += e if (e % 3 == 0) || (e % 5 == 0) }\n puts result\nend",
"def adding some_number\ni = 0\nsum = 0\n while i < some_number\n if i % 5 == 0 or i % 3 == 0\n sum += i\n end\n i += 1\n end\n puts sum\nend",
"def multiplies(n)\n# i = 1\n# sum = 0\n# while i <= n\n# if i % 15 == 0\n# sum +=i\n# elsif i % 5 == 0\n# sum +=i\n# elsif i % 3 == 0\n# sum+=i\n# end\n# i+=1\n# end\n# sum\n# end\n\nsum = 0\n(0..n).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend",
"def natural_sum(num)\n sum = 0\n index = 0\n while index < num\n if index % 3 == 0 || index % 5 == 0\n sum += index\n end\n index += 1\n end\n p sum\nend",
"def sumn2(n)\n result = 0\n 1.upto(n) { |e| result += e if (e % 3 == 0) ^ (e % 5 == 0) }\n puts result\nend",
"def solve\n sum = 0\n (1..999).each do |n|\n if n % 3 == 0 or n % 5 == 0\n sum += n\n end\n end\n sum\nend",
"def sumOf(n)\n i = 0\n multiples = []\n while i < n do\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n i += 1\n end\n multiples.inspect\n multiples.reduce(:+)\nend",
"def iter_soln\n\ttotal = 0\n\t(0..999).each do |i|\n\t\ttotal += i if(i%3 == 0 || i%5 == 0)\n\tend\n\n\tputs total\nend",
"def sum_multiples(n1,n2,limit)\n sum = 0\n for i in 1...limit\n sum+= i if(i%n1 == 0 or i%n2 == 0)\n end \n sum\nend",
"def multisum(number)\n sum = 0\n\n 1.upto(number) { |i| sum += i if i % 3 == 0 || i % 5 == 0 }\n sum\nend",
"def sumOfMultiples()\n sum = 0\n 1.upto(999) do |i|\n if (i % 3 == 0) or (i % 5 == 0)\n sum += i\n end\n end\n sum\nend",
"def multisum(number)\n sum = 0\n (1..number).each do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num\n end\n end\n sum\nend",
"def sum_3_5(n)\n x = 3\n multiple_sum = 0\n while x < n\n current = x\n if (current % 3 == 0) or (current % 5 == 0)\n multiple_sum += current\n end\n x += 1\n end\n multiple_sum\nend",
"def multiple_sum int\n (1..int).select { |n| (n % 3 == 0 || n % 5 == 0) }.sum\nend",
"def sum_of_3_or_5_multiples(n)\n n = n.to_i\n #compteur de boucle\n i = 0\n #tableu incluant les multiple de 3 et 5\n result_array = []\n while i < n\n a = i%3\n b = i%5\n if a == 0 || b == 0\n result_array << i\n i+=1\n else\n i+=1\t\n end\n \n end\n sum = 0\n result_array.each do |p|\n \t sum = sum + p\n end\n return sum \nend",
"def euler_1\n number = 1\n sum = 0\n while number < 1000\n if (number % 3 == 0 || number % 5 == 0)\n sum += number \n end\n number += 1\n end\n p sum\nend",
"def multisum(num)\n sum = 0\n 1.upto(num) {|number| sum += number if (number % 3 == 0 || number % 5 == 0)}\n sum\nend",
"def sum_multiples\n sum = 0\n\n (1...1000).each do |n|\n sum += n if n % 3 == 0 || n % 5 == 0\n end\n\n sum\nend",
"def sum_of_multiples_of_three_and_five(n)\r\n (1...n).to_a.select{|x| x % 3 == 0 || x % 5 == 0 }.reduce(:+)\r\nend",
"def sum_of_multiples(n)\n (1...n).select{ |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend",
"def compute_sum_of_threes_and_fives\r\n sum = 0\r\n (1...1000).each do |n|\r\n sum += n if n % 3 == 0 || n % 5 == 0\r\n end\r\n sum\r\nend",
"def solution(number)\n sum = 0\n for i in 1..number - 1\n if (i % 3 == 0 or i % 5 == 0)\n sum += i\n end\n i += i\n end\n return sum\nend",
"def solution(number)\n sum = 0\n Array(1..number-1).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend",
"def sum_multiples_of_3_or_5(n)\n (1...n).inject(0) do |sum, n|\n sum + if n % 3 == 0 || n % 5 == 0\n n\n else\n 0\n end\n end\nend",
"def multisum(num)\n (1..num).to_a.select { |n| n % 3 == 0 || n % 5 == 0 }.sum\nend",
"def multisum(integer)\n total = 0\n (1..integer).each do |num|\n total += num if (num % 3 ==0) || (num % 5 == 0)\n end\n total\nend",
"def sum_multiples()\n index = sum = 0\n while index < 1000\n sum += index if index%3 == 0 || index%5 == 0\n index+=1\n end\n sum\nend",
"def run\n (3...1000).inject(0){|sum, num| (num % 3 == 0 || num % 5 == 0) ? sum += num : sum }\nend",
"def multisum(num)\n 1.upto(num).select { |number| number % 3 == 0 || number % 5 == 0 }.sum\nend",
"def multiples_of_3_and_5\r\n total = 0\r\n (3...1000).each do |x|\r\n if x % 3 == 0 || x % 5 == 0\r\n # puts x\r\n total += x\r\n end\r\n end\r\n total\r\nend",
"def solution(number)\n return 0 if number <= 3\n\n sum = 0\n (1..(number - 1)).each do |n|\n if (n % 3 == 0) || (n % 5 == 0)\n sum += n\n end\n end\n\n sum\nend",
"def multisum(num)\n (1..num).select{ |x| (x % 3 == 0) || (x % 5 == 0) }.sum\nend",
"def multisum(int)\n sum = 0\n 1.upto(int) { |num| sum += num if num % 3 == 0 || num % 5 == 0 }\n sum\nend",
"def three_five_sum\n outcome = (1...1000).to_a.select do |num|\n num % 3 == 0 || num % 5 == 0\n end\n total = 0\n outcome.each do |num|\n total += num\n end\n total\nend",
"def multisum(max)\n sum = 0\n 1.upto(max) { |num| sum += num if num % 3 == 0 || num % 5 == 0 }\n sum\nend",
"def solve( maxValue )\n\n return if maxValue < 1\n\n sum = 0;\n count = 1;\n while count < maxValue\n sum += count if count % 3 == 0 or count % 5 == 0\n count += 1\n end\n puts sum\nend",
"def oddball_sum(numbers) \n result = 0 \n numbers.each { |n| result += n if n % 2 != 0}\n \n return result \nend",
"def multiples(n)\n (1...n).select do |num|\n num if (num % 3).zero? || (num % 5).zero?\n end.reduce(:+)\nend",
"def solution(number)\n [*1...number].select {|n| (n % 3 == 0) or (n % 5 == 0)}.sum\nend",
"def multisum(number)\n (0..number).reduce { |sum, n| n % 5 == 0 || n % 3 == 0 ? sum + n : sum }\nend",
"def row_sum_odd_numbers(n)\n b = (1..n).sum * 2 - 1\n a = b - 2 * (n - 1)\n (a..b).select{|i| i.odd?}.sum\n\n # # other solution:\n # n ** 3\nend",
"def sum_of_multiples_3_5_below(n)\n (1...n).select {|x| x%3==0 || x%5==0}.inject(&:+)\nend",
"def multisum(num)\n 1.upto(num).inject(0) {|sum, num| num % 3 == 0 || num % 5 == 0 ? sum += num : sum}\nend",
"def multisum2(number)\n 1.upto(number).select { |num| num % 3 == 0 || num % 5 == 0 }.reduce(:+)\nend",
"def multisum(limit)\n (1..limit).select { |num| (num % 3).zero? || (num % 5).zero? }.sum\nend",
"def row_sum_odd_numbers(n)\n\tn**3\nend",
"def problem5(n)\n\tnum = n * 2\n\twhile not divisible?(num, n)\n\t\tnum += n\n\tend\n\tnum\nend",
"def two\n first = 1\n second = 2\n third = 0\n acc = second #initialized to first even term\n begin\n third = first + second\n if third > 4000000\n break\n end\n puts third\n if third%2 == 0\n acc+=third\n end\n first = second\n second = third\n end while true\n acc\nend",
"def sum_of_multiples(n)\n multiples_of_3_or_5 = []\n for i in 1..n\n if i % 3 == 0 || i % 5 == 0\n multiples_of_3_or_5 << i\n end\n end\n multiples_of_3_or_5.sum\nend",
"def multiples_of_three_and_five(number)\n total = 0\n\n (1..(number - 1)).each { |n| total += n if n % 3 == 0 || n % 5 == 0 }\n \n return total\nend",
"def multiples\n numbers = (1...1000)\n sum = 0\n\n numbers.each do |num|\n sum += num if num % 5 == 0 || num % 3 == 0\n end\n sum\nend",
"def solution(number)\n return 0 if number < 3\n result = 0\n count = 3\n \n until count > number\n if count % 3 == 0 || count % 5 == 0\n result += count \n end\n count += 1\n end\n \n result\nend",
"def multiples\n sum = (1..999).select {|num| num % 3 == 0 || num % 5 == 0}.reduce(:+)\n puts sum\nend",
"def sum_divisors(n)\r\n (1...n).select { |x| (n % x).zero? }.sum - 1\r\nend",
"def multisum(num)\n (1..num).select { |num| num % 3 == 0 || num % 5 == 0 }.reduce(:+)\nend",
"def find_sum_of_multiples_of_3_and_5_below_1000\n answer = 0\n for number in 1...1000\n answer += number if number % 3 == 0 || number % 5 == 0\n end\n answer\nend",
"def euler1\n sum = 0;\n 1..1000.times do |x|\n y = x + 1\n if (x % 3).zero? || (x % 5).zero?\n sum = sum + x\n end\n end\n p sum\nend",
"def sum_of_three(num)\n multi = 0\n sum = 0\n loop do\n multi += 1\n break if 3 * multi > num\n sum += 3 * multi\n end\n sum\nend",
"def solution(number)\n arr = [];\n i = 1;\n while i < number\n if i % 3 == 0 || i % 5 == 0\n arr.push(i)\n end\n i += 1\n end\n\n puts arr.sum\nend",
"def multisum(number)\n (0..number).select { |num| num % 3 == 0 || num % 5 == 0 }.inject(:+)\nend",
"def multisum(number) # number 1..10 determines which numbers are divisible by 3 and 5\n sum = 0\n 1.upto(number) do |num|\n if num % 3 == 0 || num % 5 == 0\n sum += num # this adds the numbers from 1..num that either are multiples of 3 or 5\n end\n end\n sum # returns sum, need this here to run program successfully\nend",
"def so(max)\n a, b = 1, 2\n sum = 2\n\n while (c = a + b) < max do\n sum += c if c % 2 == 0\n a, b = b, c\n end\n\n puts sum\nend",
"def sum_of_multiples(number)\n sum_three = 0\n sum_five = 0\n sum_total = 0\n count_three = 3\n count_five = 5\n\n if number < 5\n sum_five\n else\n while count_five < number\n sum_five += count_five\n count_five += 5\n end\n end\n\n if number < 3\n sum_three\n else\n while count_three < number\n if count_three % 5 != 0\n sum_three += count_three\n end\n count_three += 3\n end\n end\n\n sum_total = sum_five + sum_three\n\n puts sum_total\n return sum_total\nend",
"def row_sum_odd_numbers(n)\n row = 1\n num = 1\n sum = 0\n while row <= n\n row.times do\n if row == n\n sum += num\n end\n num += 2\n end\n row += 1\n end\n return sum\nend",
"def multisum(limit)\n nums = []\n 1.upto(limit) { |num| nums << num if (num % 3 == 0 || num % 5 == 0)}\n nums.sum\nend",
"def multisum(num)\n (1..num).select { |i| i % 3 == 0 || i % 5 == 0 }.reduce(:+)\nend",
"def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend",
"def multisum(num)\n divisables = []\n 1.upto(num) {|num| num % 3 == 0 || num % 5 == 0 ? divisables << num : next}\n divisables.sum\nend",
"def find_multiples_of_3_or_5_below_x x\n sum = 0\n n = 3\n while n < x\n sum += n\n n += 3\n end\n n = 5\n while n < x\n sum += n if n % 3 != 0\n n += 5\n end\n sum\nend",
"def threes_and_fives\n for i in 100..4000000\n if (i % 3 == 0 and not i % 5 == 0) or (i % 5 == 0 and not i % 3)\n puts i\n end\n end\nend",
"def multisum(num)\n arr = []\n (1..num).map do |n|\n if n % 3 == 0 || n % 5 == 0\n arr << n\n end\n end\n arr.inject { |n, sum| n + sum }\nend",
"def summation_of_primes(n)\n sum, flags = 2, []\n\n 0.upto(n / 2) { flags.push(false, true) }\n\n i = 3\n until i * i > n\n (i * i).step(n, i) { |k| flags[k] = false } if flags[i] == true\n i += 1\n end\n\n 3.upto(n) { |j| sum += j if flags[j] == true }\n\n sum\nend",
"def euler_sum\n sum = (0..999).select {|n| n%3==0 || n%5==0}.inject(0) {|s,n| s+=n}\n sum\nend",
"def mult_3_5\n\n p=0\n for x in 1..999 do \n if (x % 3 == 0) || (x % 5 == 0)\n p += x\n end\n end\n return p\nend",
"def multisum(num)\n arr = [*1..num]\n multiples_3_5 = arr.select{ |ele| ele % 3 == 0 || ele % 5 == 0}\n multiples_3_5.sum\nend",
"def sumOfDivisors(number)\n\tsum=0\n\tlimit=number/2\n\ti=1\n\twhile i<=limit\n\t\tif number%i==0\n\t\t\tsum+=i\n\t\tend\n\t\ti+=1\n\tend\n\treturn sum\nend",
"def euler001(max)\n\ti = 1\n\tsum = 0\n\tmax.times do |i|\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tsum += i\n\t\tend\n\tend\n\tprint(sum, \"\\n\")\nend",
"def multiples_3_5_v2\n\tsum = 0\n\n\t1.upto(999) do |i|\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tsum = sum + i\n\t\tend\n\tend\n\n\treturn sum\nend",
"def fizzbuzzsum(n)\n (3...n).select{ |i| i % 3 == 0 || i % 5 == 0 }.reduce(&:+)\nend",
"def mult \n\tsum = 0\n (0...1000).select do |i| \n\t\tif (i % 3 === 0 || i % 5 === 0)\n\t\t\tsum += i\n\t\tend\n\tend\n\tputs sum\nend",
"def sum_multiples2(numbers, mutiple)\n sum = 0\n for num in numbers\n if num % mutiple == 0\n sum += num\n end\n end\n sum\nend",
"def divby2not6(n)\n 1.upto(n) { |e| puts e if (e % 2 == 0) && !(e % 6 == 0) }\nend",
"def multisum(int)\r\n (1..int).select{|x| x % 3 == 0 || x % 5 == 0 }.reduce(:+)\r\nend",
"def multiples_three_five(max_number)\n sum = 0\n max_number = max_number - 1\n (0..max_number).each do |number|\n if number % 3 == 0 || number % 5 == 0\n sum = sum + number\n end\n end\n return sum\nend",
"def multisum(num)\n count = 0\n (1..num).each { |idx| count += idx if (idx % 3).zero? || (idx % 5).zero? }\n count\nend",
"def solution(number)\n counter = 3\n sol = 0\n while counter < number\n if (counter % 3 == 0) && (counter % 5 == 0)\n sol += counter\n elsif (counter % 3 == 0) || (counter % 5 == 0)\n sol += counter\n end\n counter += 1\n end\n p sol\nend",
"def primesum(n)\n sum = 5\n i = 1\n until (6*i + 1 > n) do\n sum += (6*i + 1) if (6*i + 1).prime?\n sum += (6*i - 1) if (6*i - 1).prime?\n i += 1\n end\n sum\nend",
"def multisum(num)\n counter = 1\n arr = []\n while counter <= num\n if counter % 3 == 0 || counter % 5 == 0\n arr << counter\n end\n counter += 1\n end\n arr.sum\nend",
"def multisum(number)\n (1..number).select { |multiple| multiple % 3 == 0 || multiple % 5 == 0 }.inject(:+)\nend",
"def sum_factors(n)\n sum = 0\n for factor in 1..(n / 2)\n if n % factor == 0\n sum += factor\n end\n end\n return sum \nend",
"def sum_multiples_of_3_and_5(num)\n arr = Array(0..(num-1))\n keep = arr.select do |n|\n n % 3 == 0 || n % 5 == 0\n end\n puts keep.reduce(:+)\nend",
"def multiples_sums(int)\n sum = 0\n (1...int).to_a.each do |x|\n \tif x % 3 == 0 || x % 5 == 0\n \t\tsum += x.to_int\n \tend\n end\n sum\nend",
"def sum_multiples_3_and_5(number)\n\tsum = 0\n\t(1...number).each do |x|\n\t\tif x % 3 == 0\n\t\t\tsum += x\n\t\telsif x % 5 == 0\n\t\t\tsum += x\n\t\tend\n\tend\n\tsum\nend"
] |
[
"0.8117247",
"0.8114005",
"0.8062517",
"0.80507076",
"0.80402356",
"0.8012201",
"0.79993814",
"0.79921454",
"0.7988418",
"0.7920752",
"0.78322285",
"0.7813181",
"0.77627844",
"0.7729503",
"0.766986",
"0.76513755",
"0.7626816",
"0.75789535",
"0.75603974",
"0.75565386",
"0.75503916",
"0.75426865",
"0.7534839",
"0.7533557",
"0.75198555",
"0.7509908",
"0.7504633",
"0.7502381",
"0.74740875",
"0.7471901",
"0.74630815",
"0.7461123",
"0.7451953",
"0.74353904",
"0.7419647",
"0.7419024",
"0.74093056",
"0.74004316",
"0.73953766",
"0.73761755",
"0.73393536",
"0.73188215",
"0.7293739",
"0.7290252",
"0.7266881",
"0.7266844",
"0.7258084",
"0.7235917",
"0.7231528",
"0.72006685",
"0.7198189",
"0.7187781",
"0.7181074",
"0.7180671",
"0.7171067",
"0.7167686",
"0.7165293",
"0.71599865",
"0.7159331",
"0.7154825",
"0.71522886",
"0.71511143",
"0.71202785",
"0.7118966",
"0.7115659",
"0.70825124",
"0.7082247",
"0.70802945",
"0.7079651",
"0.707033",
"0.7069893",
"0.7065824",
"0.7064822",
"0.7062277",
"0.70554",
"0.7029741",
"0.70035714",
"0.7002827",
"0.6998393",
"0.6998267",
"0.69934607",
"0.69832665",
"0.6978246",
"0.6968472",
"0.69608516",
"0.6959865",
"0.69516516",
"0.6948406",
"0.6947117",
"0.6944975",
"0.69448173",
"0.6938224",
"0.69290805",
"0.69281983",
"0.69266135",
"0.6921912",
"0.6920569",
"0.68973416",
"0.6891534",
"0.68876404",
"0.6887235"
] |
0.0
|
-1
|
Custom validation methods Check if the user has, at least, one role
|
def roles_presence
if roles.size == 0
errors.add(:roles, "User must have, at least, one role")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def must_have_a_role\n errors.add(:roles, \"Must have a staff or admin role\") unless admin_or_staff?\n end",
"def role_required?\n @role_required || false\n end",
"def role_valid\n if (APP_CONFIG[\"user_roles\"]+SYSTEM_DATA[\"user_roles\"]).select{|role| role[\"name\"] == self.role}.empty?\n errors.add(:role, \"Role does not exist in config\")\n end\n end",
"def role_valid\n if !role_data\n errors.add(:role, :invalid)\n end\n end",
"def invalid_role?\r\n self.role.blank? || self.role < 0\r\n end",
"def validates_role\n self.role = Role.find_by_name \"Technician\" if self.role.nil?\n end",
"def has_role_blank?( user_role )\n self.role_id.blank?\n end",
"def validate\n return false if @role_array.empty?\n\n @role_array.each do |role|\n return false unless ROLES[role]\n end\n\n return true\n end",
"def check_role!\n add_role :user if roles.blank?\n if has_role?(:admin)\n add_role :editor unless has_role?(:editor)\n add_role :user unless has_role?(:user)\n end\n end",
"def role_allowed?(required_role)\n if role_hierarchy.find_index(required_role.to_sym)\n role_hierarchy.find_index(role.to_sym) >= role_hierarchy.find_index(required_role.to_sym)\n else\n false\n end\n end",
"def valid_role?(role)\n redirect_to root_path(locale: I18n.locale), :notice => t('shared.msgs.not_authorized') if !current_user || !((role.is_a?(String) && current_user.is?(role)) || (role.is_a?(Array) && role.include?(current_user.role.name)))\n end",
"def has_role?(arg) \n if arg.is_a?(Array)\n required_roles = arg.collect {|role| role.to_s}\n else\n required_roles = arg.to_s.to_a\n end\n not (self.roles.to_s.split(' ') & required_roles).empty?\n end",
"def check_user_role \t \n redirect_to root_path unless current_user.roles.first.name == \"empleado\" or current_user.roles.first.name == \"supervisor\"or current_user.roles.first.name == \"admin\" \n end",
"def accepts_role?( role_name, user )\n user.has_role? role_name, self\n end",
"def check_for_role\n self.role = ROLES[:user] if self.role.nil?\n end",
"def has_any_role? user_role\n role_subject && role_subject.has_any_role?(user_role)\n end",
"def has_role?\n Role.roles.include? role.try(:name)\n end",
"def has_role(r)\n self.role == r\n end",
"def has_role?(role) \n return self.roles.include?(role)\n end",
"def has_at_least_one_of_roles(atts)\n if !atts[:roles]\n return true\n end\n\n for role in atts[:roles]\n if has_role( { :role => role, :user => atts[:user] } )\n return true\n end\n end\n\n return false\n end",
"def accepts_role( role_name, user )\n user.has_role role_name, self\n end",
"def requires_role(role)\n yield if current_user && current_user.has_role?(role)\n end",
"def role?(role)\n\t self.role.name == role\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def validate_user(*permitted_roles,user_role_list,redirection_page)\n return if (User.has_role(Role.ADMINISTRATOR,user_role_list))\n permitted_roles.each do |role|\n return if (User.has_role(role,user_role_list))\n end\n redirect_to redirection_page, :flash => {:info => MadConstants.permission_denied}\n end",
"def check_role\n if user_signed_in? && current_user.role_id ==nil\n redirect_to new_reg_path\n\n end\n end",
"def role_exists?\n roles.presence\n end",
"def role?(role)\n self.role == role.to_s ? true : false\n end",
"def role?(role)\n !(roles.map(&:name) & Array(role)).empty?\n end",
"def has_role? user_role\n role_subject && role_subject.has_role?(user_role)\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role(the_role)\n answer = false\n roles = self.roles\n\n roles.each do |role|\n if role.roleable_type == the_role\n answer = true \n end \n end \n return answer\n\n end",
"def has_a_role_of( role )\n return self.role.name == role\n end",
"def role?(role)\n\t self.role == role\n\tend",
"def role?(role)\n self.role.to_s == role.to_s\n end",
"def any_role?(user)\n user_id = user.id if user.is_a?(User)\n !self.roles.index{ |rol| rol.user_id == user_id }.nil?\n end",
"def should_validate_organization?\n\t\troles.include?('Customer')\n\tend",
"def role?(role)\n if self.role == role.to_s\n return true\n else\n return false\n end\n end",
"def role?(role)\n roles && roles.include?(role)\n end",
"def has_role?(the_role)\n\t\tthe_role==self.role ? true : false\n\tend",
"def role?(role)\n roles.include? role\n end",
"def roles_contain_one_of?(allowed_roles)\n roles.any? do |role|\n allowed_roles.include? role\n end\n end",
"def role?(role)\n self.role&.name == role\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def has_role?(role)\n if self.roles.exists? then\n self.roles.find_by(:name => role).present?\n end\n end",
"def has_role?(role)\n case role\n when :admin then admin?\n when :member then true\n else false\n end\n end",
"def ensure_valid_role_for_commentable\n allowed_roles = commentable.class.commentable_options[:roles]\n\n if allowed_roles.any?\n errors.add(:role, :invalid) unless allowed_roles.include?(self.role)\n else\n errors.add(:role, :invalid) unless self.role.blank?\n end\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n # User master always have access to all\n # Given a nil role or a blank list also retun access granted\n return true if role.blank?\n list ||= self.roles.collect(&:name)\n role.is_a?(Array) ? rolelist = role : rolelist = [role]\n rolelist.any? { |r| list.include?(r.to_s) } || list.include?('admin') || self.master?\n end",
"def has_role?(role)\n role = role.name if role.is_a?(Role)\n self.my_roles.include?(role)\n end",
"def roles_permit?(obj)\n roles.blank? || roles_overlap?(obj)\n end",
"def role?(role) \n roles.any? { |r| r.name.underscore.to_sym == role } \n end",
"def accepts_no_role( role_name, user )\n user.has_no_role role_name, self\n end",
"def check_for_role\n\t\tself.role = ROLES[:user] if !self.role.present?\n\tend",
"def user_role?\n roles.any? { |role| Roles.user_roles.include?(role) }\n end",
"def is_valid_role? (role_in)\n # Rails.logger.debug(\"* Models::UserRoles.is_valid_role? *** instance *** - role_in:#{role_in.inspect.to_s}\")\n valid_role? (role_in)\n end",
"def role?\n false\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s)\n end",
"def has_role?(role)\n current_user.role.name.gsub(/ /, '').underscore.to_sym.eql?(role) if current_user\n end",
"def role?(r)\n self.role == r.to_s\n end",
"def has_role?(name_or_role)\n if name_or_role.is_a?(Role)\n self.roles.include?(name_or_role)\n else\n self.roles.exists?(name: name_or_role)\n end\n end",
"def check_for_role\n\t\tself.role = ROLES[:user] if self.role.nil?\n\tend",
"def check_roles\n return access_denied unless self.class.user_authorized_for?(usuario_actual, params, binding)\n\n true\n end",
"def has_no_role?\n self.roles.where(\"name != 'errata'\").empty?\n end",
"def role?(role_name)\n role == role_name\n \n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(base_role)\n return false unless role # A user have a role attribute. If not set, the user does not have any roles.\n ROLES.index(base_role.to_s) <= ROLES.index(role)\n end",
"def role?(base_role)\n return false unless role # A user have a role attribute. If not set, the user does not have any roles.\n ROLES.index(base_role.to_s) <= ROLES.index(role)\n end",
"def role?(role)\n \n if self.is_admin\n return true\n end\n \n self.roles.each do |item|\n if item.name.to_s == role.to_s\n return true\n end\n end\n \n return false\n end",
"def role?(authorized_role)\n return false if self.employee.nil?\n return false if self.employee.role.nil?\n self.employee.role.downcase.to_sym == authorized_role\n end",
"def current_user_has_any_role?(node)\n current_user.present? && current_user.has_any_role?(node)\n end",
"def has_role?(*role_names)\n self.roles.where(:name => role_names).present?\n end",
"def is_role?(*roles)\n roles.include? role\n end",
"def user_has_role?(role, user = nil)\n return true if role.blank?\n user = current_user if user.nil? && defined?(current_user)\n case user\n when User then user.has_role?(role)\n when nil then false\n else raise \"#{__method__}: invalid user: #{user.inspect}\"\n end\n end",
"def has_role? (role_in)\n # Rails.logger.debug(\"* Models::UserRoles.has_role? self.roles:#{self.roles}, role_in:#{role_in}\")\n (to_array_if_not(self.roles)).index(role_in.to_s) != nil\n end",
"def is?(role)\n self.roles.pluck(:name).include?(role.to_s)\n end",
"def has_one_of_roles?(roles)\n !roles.select {|r| has_role?(r)}.empty?\n end",
"def has_role?( user, object )\n false\n end",
"def role?(role)\n \troles.include? role.to_s\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def is?( requested_role )\n self.role == requested_role.to_s\n end",
"def role?(role_id)\r\n return @user.role?(role_id)\r\n end",
"def has_role?(role_name)\n return false unless User.roles.keys.include?(role_name)\n r = User.roles[role_name]\n self.role & (1 << r) != 0\n end",
"def role?(role)\n roles.pluck(:name).include? role.to_s\n end",
"def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end",
"def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end",
"def has_role?( role )\n\t\treturn self.role.title.to_sym == role if self.role\n\t\tfalse\n\tend"
] |
[
"0.79573935",
"0.7698732",
"0.7675534",
"0.7653518",
"0.75591224",
"0.75169206",
"0.73782134",
"0.73148614",
"0.73056096",
"0.72914416",
"0.7278201",
"0.7247163",
"0.703482",
"0.7000041",
"0.6947494",
"0.6918426",
"0.68983364",
"0.68725675",
"0.6865548",
"0.6848384",
"0.6839891",
"0.68276805",
"0.68123084",
"0.6804043",
"0.6804043",
"0.67888755",
"0.67680323",
"0.6759811",
"0.67536634",
"0.67523164",
"0.6739287",
"0.6735583",
"0.6735583",
"0.6735583",
"0.6735583",
"0.6735583",
"0.6735583",
"0.6733042",
"0.6712592",
"0.6712562",
"0.6709991",
"0.6705744",
"0.67011243",
"0.67005265",
"0.66988933",
"0.6696045",
"0.6694936",
"0.66861194",
"0.6679452",
"0.6670408",
"0.6670408",
"0.66697645",
"0.66658485",
"0.6664593",
"0.6651845",
"0.6651845",
"0.66449976",
"0.6639354",
"0.6632577",
"0.66269904",
"0.66259885",
"0.66191226",
"0.6616634",
"0.66150415",
"0.66009045",
"0.65962976",
"0.65956193",
"0.6593111",
"0.6591195",
"0.659093",
"0.6583766",
"0.657011",
"0.6569795",
"0.6548161",
"0.6548161",
"0.6548161",
"0.65478665",
"0.65478665",
"0.6540759",
"0.654062",
"0.653788",
"0.6532192",
"0.6527433",
"0.65274155",
"0.65249604",
"0.65241915",
"0.65215975",
"0.651439",
"0.65120286",
"0.6500104",
"0.6500104",
"0.6500104",
"0.6500104",
"0.64992756",
"0.64918786",
"0.64831716",
"0.6478253",
"0.6477923",
"0.6477923",
"0.64713085"
] |
0.7429432
|
6
|
Check if user has a given role
|
def role?(role)
return !!self.roles.find_by_name(role.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n current_user && current_user.has_role?(role)\n end",
"def has_role?(role)\n if self.roles.exists? then\n self.roles.find_by(:name => role).present?\n end\n end",
"def has_role(r)\n self.role == r\n end",
"def has_role?(role)\n case role\n when :admin then admin?\n when :member then true\n else false\n end\n end",
"def has_role?(role)\n current_user.role.name.gsub(/ /, '').underscore.to_sym.eql?(role) if current_user\n end",
"def current_user_has_role?(role, node = nil)\n if node\n @current_user.has_role_on?(role, node.new_record? ? node.parent : node)\n else\n @current_user.has_role?(role)\n end\n end",
"def has_role?(role) \n return self.roles.include?(role)\n end",
"def has_role?(role)\n role = role.name if role.is_a?(Role)\n self.my_roles.include?(role)\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s) || list.include?('admin')\n end",
"def has_role?\n Role.roles.include? role.try(:name)\n end",
"def has_role?(role)\n list ||= self.roles.map(&:name)\n list.include?(role.to_s)\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end",
"def has_role?(the_role)\n\t\tthe_role==self.role ? true : false\n\tend",
"def has_role? user_role\n role_subject && role_subject.has_role?(user_role)\n end",
"def user_in_role(role)\n attrs = session['user_attributes']\n attrs && attrs['role'].split(',').include?(role)\n end",
"def has_role(the_role)\n answer = false\n roles = self.roles\n\n roles.each do |role|\n if role.roleable_type == the_role\n answer = true \n end \n end \n return answer\n\n end",
"def role?(role_id)\r\n return @user.role?(role_id)\r\n end",
"def role?(role)\n roles.include? role\n end",
"def has_a_role_of( role )\n return self.role.name == role\n end",
"def role?(role)\n roles && roles.include?(role)\n end",
"def user_role?\n roles.any? { |role| Roles.user_roles.include?(role) }\n end",
"def has_role?(name)\n role = Role.find_by_name(name)\n # does the role even exist?\n return false unless role != nil\n # role exists, is the user in it?\n return self.roles.first(:conditions => {:name => name}) != nil\n end",
"def has_role?(role_name)\n return false unless User.roles.keys.include?(role_name)\n r = User.roles[role_name]\n self.role & (1 << r) != 0\n end",
"def role?(role)\n\t self.role.name == role\n end",
"def has_role?( user, object )\n false\n end",
"def has_role?(role_name)\n if user_roles\n roles = user_roles.data.map do |role|\n role.name\n end\n\n roles.include?(role_name)\n end\n end",
"def role?(role)\n if self.role == role.to_s\n return true\n else\n return false\n end\n end",
"def role?(role)\n self.role == role.to_s ? true : false\n end",
"def role?(role) \n roles.any? { |r| r.name.underscore.to_sym == role } \n end",
"def has_role_for_user(name, role)\n roles = get_roles_for_user(name)\n roles.include?(role)\n end",
"def has_role?(role_name, resource = nil)\n has_role_helper(role_name, resource)\n end",
"def role?(role)\n \n if self.is_admin\n return true\n end\n \n self.roles.each do |item|\n if item.name.to_s == role.to_s\n return true\n end\n end\n \n return false\n end",
"def has_role?( role )\n\t\treturn self.role.title.to_sym == role if self.role\n\t\tfalse\n\tend",
"def is?(role)\n self.roles.pluck(:name).include?(role.to_s)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def role?(role)\n return !!self.roles.find_by_name(role.to_s.camelize)\n end",
"def user_has_role?(role, user = nil)\n return true if role.blank?\n user = current_user if user.nil? && defined?(current_user)\n case user\n when User then user.has_role?(role)\n when nil then false\n else raise \"#{__method__}: invalid user: #{user.inspect}\"\n end\n end",
"def role?(role)\n\t self.role == role\n\tend",
"def accepts_role?( role_name, user )\n user.has_role? role_name, self\n end",
"def role?(role)\n @roles.any? { |r| r.name == role.to_s }\n end",
"def role?(role)\n roles.pluck(:name).include? role.to_s\n end",
"def role?(r)\n self.role == r.to_s\n end",
"def user?\n has_role? :user\n end",
"def role?(role)\n self.role.to_s == role.to_s\n end",
"def is?(role)\n roles.include?(role.to_s)\n end",
"def role?(role)\n roles.any? {|r| r.name.underscore.to_sym == role}\n end",
"def has_role?(role)\n # User master always have access to all\n # Given a nil role or a blank list also retun access granted\n return true if role.blank?\n list ||= self.roles.collect(&:name)\n role.is_a?(Array) ? rolelist = role : rolelist = [role]\n rolelist.any? { |r| list.include?(r.to_s) } || list.include?('admin') || self.master?\n end",
"def has_member?(user)\n roles.exists?(user_id: user)\n end",
"def has_role?(role)\n # I want to be able to use a symbol\n role = role.to_s\n\n case role\n when 'everyone'\n true\n\n when 'readonly'\n User.current_user.is_readonly?\n\n when 'not_readonly'\n !User.current_user.is_readonly?\n\n else\n # The sub! returns nil if no substition was made\n negated = !!role.sub!(/^not_/,'')\n\n # It's an XOR, cool huh? ;)\n negated ^ User.current_user.in_role?(role)\n end\n end",
"def has_role(rol)\n r = Role.where(:name => rol).first\n roles.include?(r)\n end",
"def role?(role)\n self.role&.name == role\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def role?(role)\n self.role == role.to_s\n end",
"def has_role?(role)\n roles.map {|r| r.to_s.downcase}.include?(role.to_s.downcase)\n end",
"def role?(role)\n \troles.include? role.to_s\n end",
"def has_role?(role_name) # rubocop:disable Naming/PredicateName\n role&.name == role_name.to_s\n end",
"def role? role_name\n self.roles.exists? name: role_name.to_s\n end",
"def has_role?(role)\n self.roles_cached.nil? ? false : self.roles_cached.split(',').include?(role)\n end",
"def is_role(r)\n return r == role\n end",
"def has_role? (role_in)\n # Rails.logger.debug(\"* Models::UserRoles.has_role? self.roles:#{self.roles}, role_in:#{role_in}\")\n (to_array_if_not(self.roles)).index(role_in.to_s) != nil\n end",
"def has_role?(name_or_role)\n if name_or_role.is_a?(Role)\n self.roles.include?(name_or_role)\n else\n self.roles.exists?(name: name_or_role)\n end\n end",
"def has_role?(role)\n role_list ||= roles.map(&:name)\n role_list.include?(role.to_s) || role_list.include?(User::JEDI_MASTER_ROLE)\n end",
"def has?(role)\n role_id = (role.class <= Rend::Acl::Role) ? role.id : role.to_s\n roles.has_key?(role_id)\n end",
"def has_role?(role)\n roles.where(name: Role::NAMES[role]).exists?\n #cached_roles.map(&:name).include?(Role::NAMES[role])\n end",
"def is?( requested_role )\n self.role == requested_role.to_s\n end",
"def role?(authorized_role)\n return false if self.employee.nil?\n return false if self.employee.role.nil?\n self.employee.role.downcase.to_sym == authorized_role\n end",
"def role?(role_name)\n role == role_name\n \n end",
"def has_role?(name)\r\n roles.include?(name.to_s)\r\n end",
"def role? role\n return !!self.roles.find_by_name(role.to_s)\n end",
"def role?(authorized_role)\n return false if employee.nil?\n employee.role.downcase.to_sym == authorized_role\n end",
"def accepts_role( role_name, user )\n user.has_role role_name, self\n end",
"def is_user_in_role (security_user_id, role)\n SecurityUser.joins(:security_users_roles)\n .where(security_users_roles:{role:role})\n .exists?([\"security_users.id=#{security_user_id.to_s}\"])\n end",
"def is_an?(role)\n roles.include?(role.to_s)\n end",
"def role_exists?\n roles.presence\n end",
"def any_role?(user)\n user_id = user.id if user.is_a?(User)\n !self.roles.index{ |rol| rol.user_id == user_id }.nil?\n end",
"def role?(role)\n !(roles.map(&:name) & Array(role)).empty?\n end",
"def check_for_role\n self.role = ROLES[:user] if self.role.nil?\n end",
"def has_role?(role)\n role_symbols.include? role\n end",
"def has_any_role? user_role\n role_subject && role_subject.has_any_role?(user_role)\n end",
"def valid_role?(role)\n redirect_to root_path(locale: I18n.locale), :notice => t('shared.msgs.not_authorized') if !current_user || !((role.is_a?(String) && current_user.is?(role)) || (role.is_a?(Array) && role.include?(current_user.role.name)))\n end",
"def has_role?(name)\n !roles.find_by('lower(name) = ?', name.downcase).nil?\n end",
"def has_role(user_id, role_as_sym)\n if user_id.is_a?(Integer) && role_as_sym.is_a?(Symbol)\n vals = Role.access_values_for(role_as_sym)\n self.roles.where(user_id: user_id, access: vals, active: true).first.present?\n else\n false\n end\n end",
"def authorized?(role)\n current_user[:role] >= User.roles[role]\n end",
"def has_role?(name)\n roles.pluck(:name).member?(name.to_s)\n end",
"def isinrole (roleid)\n is_in_role roleid\n end",
"def member_of?(role_name)\n !!self.roles.find_by_name(role_name.to_s)\n end",
"def check_role!\n add_role :user if roles.blank?\n if has_role?(:admin)\n add_role :editor unless has_role?(:editor)\n add_role :user unless has_role?(:user)\n end\n end",
"def current_user_has_any_role?(node)\n current_user.present? && current_user.has_any_role?(node)\n end",
"def has_role?(role)\n case\n when role == :superuser\n send Rails.application.config.x.aa_refinery.refinery_role_method\n when role == :refinery\n send Rails.application.config.x.aa_refinery.refinery_role_method\n else\n false\n end\n end"
] |
[
"0.8478626",
"0.8478626",
"0.8435144",
"0.8402428",
"0.8399518",
"0.83606",
"0.83278924",
"0.83156085",
"0.82329905",
"0.822057",
"0.822057",
"0.822057",
"0.822057",
"0.822057",
"0.822057",
"0.82067007",
"0.820393",
"0.8198993",
"0.8198993",
"0.8194761",
"0.81928426",
"0.8178198",
"0.81692654",
"0.8168283",
"0.81593305",
"0.81435704",
"0.81250674",
"0.81196547",
"0.81083596",
"0.8103202",
"0.80996776",
"0.80928195",
"0.8091804",
"0.8088175",
"0.80832434",
"0.80589145",
"0.8055332",
"0.8038459",
"0.80382997",
"0.8019334",
"0.8001679",
"0.7974381",
"0.7974381",
"0.7974381",
"0.7974381",
"0.7972935",
"0.7972348",
"0.7969548",
"0.7961425",
"0.7959681",
"0.7953089",
"0.79456717",
"0.79422766",
"0.79292697",
"0.7919653",
"0.7911598",
"0.79107016",
"0.7903173",
"0.7902262",
"0.79005194",
"0.7896207",
"0.7896207",
"0.78848547",
"0.78771174",
"0.7863679",
"0.7842312",
"0.78289694",
"0.78168124",
"0.78121173",
"0.78095007",
"0.78088176",
"0.7808313",
"0.7807747",
"0.78076386",
"0.77926546",
"0.77893186",
"0.77877355",
"0.77791613",
"0.77644575",
"0.77572984",
"0.7752978",
"0.774947",
"0.7745265",
"0.77211964",
"0.7686484",
"0.76864105",
"0.7676464",
"0.7670779",
"0.76550627",
"0.7647221",
"0.7644504",
"0.76407593",
"0.76360434",
"0.7627032",
"0.76225764",
"0.7613383",
"0.7611246",
"0.7597881"
] |
0.80047
|
42
|
GET /enrolls GET /enrolls.json
|
def index
@enrolls = Enroll.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @enrolls }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @enrolls = Enroll.all\n end",
"def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end",
"def show\n @enroll = Enroll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enroll }\n end\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n\n # Search\n @enrollments = @enrollments.search(params[:q]) if params[:q]\n\n # Filter for group\n #@enrollments = @enrollments.relationship(params[:group]) if params[:group]\n\n # Order by\n @enrollments = @enrollments.order(params[:order].gsub(':', ' ')) if params[:order]\n\n # Pagination\n if (params[:offset] && params[:limit])\n @enrollments = @enrollments.page(1).per(params[:limit]).padding(params[:offset])\n else\n @enrollments = @enrollments.page(1).per(25)\n end\n\n render json: @enrollments if stale?(etag: @enrollments.all, last_modified: @enrollments.maximum(:updated_at))\n end",
"def get_enrollments(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n get \"#{users_path}/#{user_id}/enrollments\"\n end",
"def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end",
"def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend",
"def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend",
"def index\n @course = params[:course_id]\n @students = Student.left_join_enrolls @course\n puts @students.as_json\n end",
"def show\n @enroll = Enroll.find(params[:id])\n end",
"def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def index\n @enrollments ||= @committee.enrollments if @committee\n @enrollments ||= @user.enrollments if @user\n @enrollments = @enrollments.ordered\n\n respond_to do |format|\n format.html { render :action => 'index' } # index.html.erb\n format.xml { render :xml => @enrollments }\n end\n end",
"def index\n @enrolleds = Enrolled.all\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolleds }\n end\n end",
"def get_course_enrollments(course_id)\n open_canvas_http\n\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = @canvas_http.request(request)\n info = JSON.parse response.body\n\n info\n end",
"def index\n @enrollments = @parent.enrollments.all\n end",
"def index\n @course = Course.find(params[:course_id])\n @enrollments = @course.enrollments.all\n\n respond_to do |format|\n format.xls\n format.html # index.html.erb\n format.json { render json: @enrollments }\n end\n end",
"def show\n\t @allenrolls = @course.enrolls\n\n end",
"def index\n @enrolments = Enrolment.includes(:student, course: { enrolments: :student }).all\n end",
"def show\n @course = Course.find(params[:id])\n @enrollments = Enrollment.where(\"course_id = ?\", params[:id].to_s)\n end",
"def get_course_enrollments(course_id)\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/enrollments?per_page=100&access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = nil\n if response.code == '200'\n info = get_all_from_pagination(response)\n else\n raise \"Course #{course_id} does not exist. #{response.body}\"\n end\n\n info\n end",
"def index\n raise SecurityTransgression unless Enrollment.can_be_read_by? current_user\n @enrollments = Enrollment.all\n end",
"def get_user_enrollments(user_id)\n open_canvas_http\n\n request = Net::HTTP::Get.new(\n \"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = @canvas_http.request(request)\n info = JSON.parse response.body\n\n info\n end",
"def get_user_enrollments(user_id)\n request = Net::HTTP::Get.new(\n \"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = get_all_from_pagination(response)\n\n info\n end",
"def index\n @pre_enrollments = PreEnrollment.all\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n\n end",
"def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end",
"def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def index\n admin_only\n @consuming_enrollments = ConsumingEnrollment.all\n end",
"def index\n @enrollments = Enrollment.order(created_at: :desc).page params[:page]\n end",
"def show\n @enrolled = Enrolled.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @enrolled }\n end\n end",
"def show\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def index\n @assessment_courses = AssessmentCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assessment_courses }\n end\n end",
"def show\n\t@enrollments = Enrollment.where(:participantID => @participant.participantID)\n end",
"def enrolled_patients\n begin\n patients = enroller_table_data(params, current_user)\n rescue InvalidQueryError => e\n return render json: e, status: :bad_request\n end\n\n render json: patients\n end",
"def index\n @instructors = Instructor.all(:order => :name)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @instructors }\n end\n end",
"def show\n @enrolled = Enrolled.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled }\n end\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def index\n @ledger_accounts = current_user.ledger_accounts.all\n respond_with @ledger_accounts\n end",
"def index\n @ledger_accounts = current_user.ledger_accounts.all\n respond_with @ledger_accounts\n end",
"def index\n @instructors = Instructor.all\n # render json: @instructors.to_json\n render json: @instructors.to_json(only: [:first_name, :last_name, :region, :photo, :email, :bio, :instagram, :experience, :user_id],\n include: [schedules: { only: [:title, :start, :end, :instructor_id, :workout_id]}])\n end",
"def index\n @enterprises = Enterprise.all\n end",
"def show\n @course_enrollments = @course_offering.course_enrollments.page(params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render :json => @course_offering }\n end\n end",
"def index\n @encouragements = Encouragement.all\n end",
"def index\n if params[:student_id]\n @enrollments = Enrollment.where student_id: params[:student_id]\n @student = Student.find params[:student_id]\n else\n @enrollments = Enrollment.all\n end\n\n end",
"def index\n @enrollements = Enrollement.all\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def show\n @projeto = Projeto.find(params[:id])\n @enrollments = Enroll.find_all_by_projeto_id params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projeto }\n end\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def show\n @enrollment = Enrollment.on_db(session[:shard_name]).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @course_roles }\n end\n end",
"def index\n r = @api.get_attendances\n response = JSON.parse(r.body)\n if r.code == 200\n @attendances = response\n else\n redirect_to login_sign_in_admin_path, alert: response['message']\n end\n # @attendances = Attendance.all\n end",
"def index\n @resumes = Resume.all\n render json: @resumes, include: %i[headers educations work_experiences skills]\n end",
"def index\n @grades = Grade.all\n render json: {data: @grades, status: \"SUCCESS\"}, :status => 200\n end",
"def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end",
"def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end",
"def index\n @enrollments = Enrollment.all\n users = User.all\n @users_by_enrollment = {}\n users.each do |user|\n @users_by_enrollment[user.id] = user\n end\n @sections_by_enrollment = {}\n sections = Section.all\n sections.each do |section|\n @sections_by_enrollment[section.id] = section\n end\n courses = Course.all\n @courses_by_enrollment = {}\n courses.each do |course|\n @courses_by_enrollment[course.id] = {course_obj: course, course_short_name: \"\"}\n course_title_raw = course.course_title.split(\" \")\n course_title_fixed = \"\"\n course_title_raw.each do |word|\n if word != \"of\" && word != \"the\"\n course_title_fixed = course_title_fixed + word[0] \n end\n end\n @courses_by_enrollment[course.id][:course_short_name] = course_title_fixed + \" \" + @courses_by_enrollment[course.id][:course_obj][:course_description]\n end\n end",
"def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @enrolled_courses = EnrolledCourse.all\n end",
"def show\n @enrollments = Enrollment.where(:courseID => @course.courseID, :startDate => @course.startDate).where(['enrollments.waitlist_status <> ?', 0])\n end",
"def index\n @employer_liability_insurances = EmployerLiabilityInsurance.all\n end",
"def index\n @educations = Education.all\n end",
"def index\n @educations = Education.all\n end",
"def index\n @admittings = Admitting.all\n render json: @admittings\n end",
"def show\n render json: @educations\n end",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def index\n @issuers = Issuer.all\n end",
"def index\n @first_aid_courses = FirstAidCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @first_aid_courses }\n end\n end",
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def enroll_params\n params.require(:enroll).permit(:user_id, :course_id)\n end",
"def index\n @endorsements = Endorsement.all\n\n render json: @endorsements\n end",
"def set_enrolls\r\n @lecture = Lecture.find(params[:lecture_id])\r\n end",
"def index\n @referral_enrolments = ReferralEnrolment.all\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n periods = current_user.school.periods.all\n\n render json: periods\n end",
"def index\n @employes = Employe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employes }\n end\n end",
"def index\n @enquries = Enqury.all\n end",
"def index\n #@rolls = Roll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rolls }\n end\n end",
"def index\n render json: @authority.all\n end",
"def index\n @educations = Education.all\n\n end",
"def index\n @enrollments = Enrollment.joins(:course, :student).select('enrollments.id, enrollments.course_id, courses.course_name, courses.semester, students.first_name, students.last_name, enrollments.student_id').reorder('last_name ASC')\n if (params.has_key?(:semester))\n if (params[:semester] != 'all')\n @enrollments = @enrollments.where(courses: { semester: params[:semester] })\n end\n end\n\n if current_student\n @enrollments = @enrollments.where(enrollments: { student_id: current_student.id })\n end\n end",
"def index\n @instructors = Instructor.all\n end",
"def index\n @employers = Employer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employers }\n end\n end",
"def index\n @deseases = Desease.order(:id)\n\n render json: @deseases\n end",
"def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end",
"def enroll\n\n response = {}\n status_code = 200\n\n begin\n\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n\n if !user\n status_code = 401\n raise 'Not logged in!'\n end\n\n if !user.is? \"supervisor\"\n status_code = 403\n raise 'Student cannot edit course!'\n end\n\n # If a supervisor\n if user.is? \"supervisor\"\n # Get parameters\n student_id = params[:student_id]\n course_id = params[:course_id]\n\n # Only allowed to enroll students in courses he supervises\n return unless user.courses.find(course_id)\n else\n # If unknown class, do nothing\n return\n end\n\n # Create plan\n plan = Plan.new\n\n group = Group.create!(\n :name => \"Pessoal\",\n :min_credits => nil,\n :min_subjects => nil\n )\n\n # Supervisor only enrolls if student exists\n if Student.find(student_id) != nil\n plan.course = Course.find(course_id)\n plan.student = Student.find(student_id)\n plan.group = group\n\n plan.save\n else\n status_code = 404\n raise 'Student does not exist!'\n end\n\n redirect_back fallback_location: \"/\"\n rescue Exception => e\n response[:status] = 'error'\n response[:error] = \"#{e}\"\n else\n status_code 201\n response[:status] = 'success'\n response[:message] = 'Student was enrolled with success!'\n end\n end",
"def show\n @course = Course.find(params[:id])\n @course_enrollments = @course.enrollments.where(:status => nil)\n @completed_course_enrollments = @course.enrollments.where(:status => \"completed\")\n end",
"def index\n set_enrolment\n if @enrolment\n @student_ids = @enrolment.student_ids\n else\n @student_ids = StudentId.all\n @notice = \"Displaying All Ids\"\n end\n end",
"def get_grades\r\n grade_nodes = BankNodestructure.grade_gather(params[:subject])\r\n render json: grade_nodes.to_json\r\n end",
"def get_course_of_instructor\n instructor_id = params[:instructor_id]\n\n course_ids = if instructor_id.blank?\n []\n else\n Course.where(:user_id => instructor_id).map(&:id).map(&:to_s)\n end\n\n render json: {:course_ids => course_ids}\n end"
] |
[
"0.75139695",
"0.7464566",
"0.7215442",
"0.7062653",
"0.7062653",
"0.7062653",
"0.7062653",
"0.70049214",
"0.68922675",
"0.6869819",
"0.6869684",
"0.6869684",
"0.6835898",
"0.67717296",
"0.67250055",
"0.66916007",
"0.66702443",
"0.6646835",
"0.66368353",
"0.6564454",
"0.652901",
"0.6523011",
"0.64494073",
"0.64313966",
"0.6423031",
"0.6395616",
"0.63703924",
"0.6297204",
"0.6266084",
"0.6265555",
"0.6265555",
"0.6265555",
"0.6265555",
"0.62414485",
"0.6219876",
"0.62026274",
"0.6198716",
"0.6193607",
"0.61925566",
"0.6186836",
"0.6183675",
"0.6142436",
"0.61164105",
"0.6108113",
"0.60961336",
"0.60859704",
"0.6084591",
"0.6084591",
"0.60767525",
"0.6073336",
"0.60561335",
"0.6036365",
"0.60325974",
"0.6023902",
"0.59597415",
"0.5957221",
"0.59409297",
"0.5934143",
"0.5926914",
"0.5924244",
"0.591171",
"0.59004134",
"0.5897622",
"0.5896782",
"0.58967286",
"0.5887629",
"0.5884285",
"0.5882094",
"0.5880214",
"0.5856012",
"0.5850274",
"0.5850274",
"0.58425486",
"0.58414614",
"0.5838179",
"0.58356833",
"0.5833558",
"0.5832371",
"0.5815485",
"0.5814357",
"0.5810134",
"0.5807788",
"0.58049345",
"0.5799502",
"0.57985467",
"0.5783825",
"0.57772094",
"0.577481",
"0.57733375",
"0.5772412",
"0.576464",
"0.57616615",
"0.5757146",
"0.57499737",
"0.57492054",
"0.57365936",
"0.5732113",
"0.5728278",
"0.57147",
"0.57057464"
] |
0.77163905
|
0
|
GET /enrolls/1 GET /enrolls/1.json
|
def show
@enroll = Enroll.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @enroll }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end",
"def index\n @enrolls = Enroll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolls }\n end\n end",
"def index\n @enrolls = Enroll.all\n end",
"def show\n @enroll = Enroll.find(params[:id])\n end",
"def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def show\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def show\n @course = Course.find(params[:id])\n @enrollments = Enrollment.where(\"course_id = ?\", params[:id].to_s)\n end",
"def index\n @course = params[:course_id]\n @students = Student.left_join_enrolls @course\n puts @students.as_json\n end",
"def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def show\n @enrollment = Enrollment.on_db(session[:shard_name]).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend",
"def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def index\n @enrollments = Enrollment.all\n\n # Search\n @enrollments = @enrollments.search(params[:q]) if params[:q]\n\n # Filter for group\n #@enrollments = @enrollments.relationship(params[:group]) if params[:group]\n\n # Order by\n @enrollments = @enrollments.order(params[:order].gsub(':', ' ')) if params[:order]\n\n # Pagination\n if (params[:offset] && params[:limit])\n @enrollments = @enrollments.page(1).per(params[:limit]).padding(params[:offset])\n else\n @enrollments = @enrollments.page(1).per(25)\n end\n\n render json: @enrollments if stale?(etag: @enrollments.all, last_modified: @enrollments.maximum(:updated_at))\n end",
"def show\n\t @allenrolls = @course.enrolls\n\n end",
"def get_enrollments(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n get \"#{users_path}/#{user_id}/enrollments\"\n end",
"def index\n @course = Course.find(params[:course_id])\n @enrollments = @course.enrollments.all\n\n respond_to do |format|\n format.xls\n format.html # index.html.erb\n format.json { render json: @enrollments }\n end\n end",
"def show\n @enrolled = Enrolled.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @enrolled }\n end\n end",
"def index\n @enrollments = @parent.enrollments.all\n end",
"def index\n @enrollments ||= @committee.enrollments if @committee\n @enrollments ||= @user.enrollments if @user\n @enrollments = @enrollments.ordered\n\n respond_to do |format|\n format.html { render :action => 'index' } # index.html.erb\n format.xml { render :xml => @enrollments }\n end\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def show\n @enrolled = Enrolled.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled }\n end\n end",
"def index\n @enrolleds = Enrolled.all\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolleds }\n end\n end",
"def show\n\t@enrollments = Enrollment.where(:participantID => @participant.participantID)\n end",
"def index\n raise SecurityTransgression unless Enrollment.can_be_read_by? current_user\n @enrollments = Enrollment.all\n end",
"def get_course_enrollments(course_id)\n open_canvas_http\n\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = @canvas_http.request(request)\n info = JSON.parse response.body\n\n info\n end",
"def index\n @pre_enrollments = PreEnrollment.all\n end",
"def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @enrolments = Enrolment.includes(:student, course: { enrolments: :student }).all\n end",
"def show\n @projeto = Projeto.find(params[:id])\n @enrollments = Enroll.find_all_by_projeto_id params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @projeto }\n end\n end",
"def index\n @education_levels = EducationLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @education_levels }\n end\n end",
"def index\n @enrollments = Enrollment.order(created_at: :desc).page params[:page]\n end",
"def show\n if(@enrollment.present?)\n render json: @enrollment.properties_data if stale?(@enrollment)\n else\n render json: {}, status: :not_found\n end\n end",
"def show\n @course_enrollments = @course_offering.course_enrollments.page(params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render :json => @course_offering }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def index\n @assessment_courses = AssessmentCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assessment_courses }\n end\n end",
"def new\n @course = Course.find(params[:course_id])\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def get_user_enrollments(user_id)\n open_canvas_http\n\n request = Net::HTTP::Get.new(\n \"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = @canvas_http.request(request)\n info = JSON.parse response.body\n\n info\n end",
"def get_course_enrollments(course_id)\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/enrollments?per_page=100&access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = nil\n if response.code == '200'\n info = get_all_from_pagination(response)\n else\n raise \"Course #{course_id} does not exist. #{response.body}\"\n end\n\n info\n end",
"def index\n if params[:student_id]\n @enrollments = Enrollment.where student_id: params[:student_id]\n @student = Student.find params[:student_id]\n else\n @enrollments = Enrollment.all\n end\n\n end",
"def show\n @enrollments = Enrollment.where(:courseID => @course.courseID, :startDate => @course.startDate).where(['enrollments.waitlist_status <> ?', 0])\n end",
"def index\n @enterprises = Enterprise.all\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def show\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled_student }\n end\n end",
"def index\n admin_only\n @consuming_enrollments = ConsumingEnrollment.all\n end",
"def show\n @issuer = Issuer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @issuer }\n end\n end",
"def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n format.json { render json: @enrollments.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def index\n @instructors = Instructor.all(:order => :name)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @instructors }\n end\n end",
"def show\n render json: @instructor\n end",
"def index\n @instructors = Instructor.all\n # render json: @instructors.to_json\n render json: @instructors.to_json(only: [:first_name, :last_name, :region, :photo, :email, :bio, :instagram, :experience, :user_id],\n include: [schedules: { only: [:title, :start, :end, :instructor_id, :workout_id]}])\n end",
"def index\n @enrollements = Enrollement.all\n end",
"def get_user_enrollments(user_id)\n request = Net::HTTP::Get.new(\n \"/api/v1/users/#{user_id}/enrollments?access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = get_all_from_pagination(response)\n\n info\n end",
"def index\n @encouragements = Encouragement.all\n end",
"def index\n @first_aid_courses = FirstAidCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @first_aid_courses }\n end\n end",
"def show\n @instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instructor }\n end\n end",
"def show\n @education_level = EducationLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @education_level }\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end",
"def show\n @instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @instructor }\n end\n end",
"def set_enrolls\r\n @lecture = Lecture.find(params[:lecture_id])\r\n end",
"def index\n @enrollments = Enrollment.all\n users = User.all\n @users_by_enrollment = {}\n users.each do |user|\n @users_by_enrollment[user.id] = user\n end\n @sections_by_enrollment = {}\n sections = Section.all\n sections.each do |section|\n @sections_by_enrollment[section.id] = section\n end\n courses = Course.all\n @courses_by_enrollment = {}\n courses.each do |course|\n @courses_by_enrollment[course.id] = {course_obj: course, course_short_name: \"\"}\n course_title_raw = course.course_title.split(\" \")\n course_title_fixed = \"\"\n course_title_raw.each do |word|\n if word != \"of\" && word != \"the\"\n course_title_fixed = course_title_fixed + word[0] \n end\n end\n @courses_by_enrollment[course.id][:course_short_name] = course_title_fixed + \" \" + @courses_by_enrollment[course.id][:course_obj][:course_description]\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @course_roles }\n end\n end",
"def set_enrollment\n @enrollment = Participantstudysite.find(params[:id])\n end",
"def enroll_params\n params.require(:enroll).permit(:user_id, :course_id)\n end",
"def index\n @issuers = Issuer.all\n end",
"def show\n @course = Course.find(params[:id])\n @course_enrollments = @course.enrollments.where(:status => nil)\n @completed_course_enrollments = @course.enrollments.where(:status => \"completed\")\n end",
"def get_course_of_instructor\n instructor_id = params[:instructor_id]\n\n course_ids = if instructor_id.blank?\n []\n else\n Course.where(:user_id => instructor_id).map(&:id).map(&:to_s)\n end\n\n render json: {:course_ids => course_ids}\n end",
"def show\n @instructor1 = Instructor1.find(params[:id])\n\t@instructorcourses = Instructorcourse.where(instructoremail: @instructor1.email)\n\t@s=Instructor1.find(session[:user_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instructor1 }\n end\n end",
"def show\n render json: @educations\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def enrolled_patients\n begin\n patients = enroller_table_data(params, current_user)\n rescue InvalidQueryError => e\n return render json: e, status: :bad_request\n end\n\n render json: patients\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def index\n @employer_liability_insurances = EmployerLiabilityInsurance.all\n end",
"def index\n @grades = Grade.all\n render json: {data: @grades, status: \"SUCCESS\"}, :status => 200\n end",
"def index\n r = @api.get_attendances\n response = JSON.parse(r.body)\n if r.code == 200\n @attendances = response\n else\n redirect_to login_sign_in_admin_path, alert: response['message']\n end\n # @attendances = Attendance.all\n end",
"def show\n @assessment = Assessment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assessment }\n end\n end",
"def index\n @resumes = Resume.all\n render json: @resumes, include: %i[headers educations work_experiences skills]\n end",
"def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end",
"def show\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @enrollment }\n end\n end",
"def show\n @entrant = Entrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entrant }\n end\n end",
"def show\n @entrant = Entrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entrant }\n end\n end",
"def index\n @ledger_accounts = current_user.ledger_accounts.all\n respond_with @ledger_accounts\n end",
"def index\n @ledger_accounts = current_user.ledger_accounts.all\n respond_with @ledger_accounts\n end",
"def index\n @educations = Education.all\n end",
"def index\n @educations = Education.all\n end",
"def index\n @employes = Employe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employes }\n end\n end"
] |
[
"0.7857512",
"0.75780815",
"0.7383003",
"0.73398715",
"0.7039861",
"0.69629484",
"0.69629484",
"0.69629484",
"0.69629484",
"0.69476426",
"0.68799406",
"0.68404394",
"0.68404394",
"0.68404394",
"0.68404394",
"0.6828348",
"0.6741487",
"0.6740403",
"0.665598",
"0.66470414",
"0.6609013",
"0.6609013",
"0.65868485",
"0.65827566",
"0.65804523",
"0.6563067",
"0.6524797",
"0.64785606",
"0.64759445",
"0.64732057",
"0.64558965",
"0.6393403",
"0.63744855",
"0.6345134",
"0.632946",
"0.6319083",
"0.62337255",
"0.6229466",
"0.6219478",
"0.62075204",
"0.62023574",
"0.6188103",
"0.6185506",
"0.61495024",
"0.6122104",
"0.6122104",
"0.61087084",
"0.6108156",
"0.61073196",
"0.6080995",
"0.60642886",
"0.60531545",
"0.60393804",
"0.60305333",
"0.60242045",
"0.6018933",
"0.6011118",
"0.59814215",
"0.59767467",
"0.5964141",
"0.5955114",
"0.5954999",
"0.59506744",
"0.5942845",
"0.59362036",
"0.59358156",
"0.5932037",
"0.5908778",
"0.5908778",
"0.59062564",
"0.5904427",
"0.5897495",
"0.58875054",
"0.58839464",
"0.5869898",
"0.5863016",
"0.5859551",
"0.585861",
"0.58551264",
"0.5852807",
"0.5833948",
"0.58302224",
"0.58253574",
"0.5820902",
"0.5818495",
"0.5818495",
"0.5811498",
"0.5809712",
"0.5801972",
"0.5800625",
"0.5793856",
"0.57927334",
"0.57890546",
"0.5783199",
"0.5783199",
"0.57821333",
"0.57821333",
"0.5769491",
"0.5769491",
"0.57692033"
] |
0.7685274
|
1
|
GET /enrolls/new GET /enrolls/new.json
|
def new
@actions = [{"YGO战网" => users_path}, "参加比赛"]
@enroll = Enroll.new
@enroll.name = @current_user.name if @current_user.id != 0
@enroll.tournament = Tournament.find params[:tournament_id] if params[:tournament_id]
respond_to do |format|
format.html # new.html.erb
format.json { render json: @enroll }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def new\n @course = Course.find(params[:course_id])\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def new\n @enrolled = Enrolled.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @enrolled }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\n @assessment_course = AssessmentCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assessment_course }\n end\n end",
"def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @issuer = Issuer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issuer }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @entrant = Entrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entrant }\n end\n end",
"def new\n @enrolled_student = EnrolledStudent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrolled_student }\n end\n end",
"def new\n @encounter = Encounter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @encounter }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @enrollment }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @enrollment }\n end\n end",
"def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n format.json { render json: @enrollments.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def new\n @enterprise = Enterprise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enterprise }\n end\n end",
"def new\n @instructor = Instructor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instructor }\n end\n end",
"def new\n @education_level = EducationLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @education_level }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course_offering }\n end\n end",
"def new\n @grade = Grade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grade }\n end\n end",
"def new\n @exprience = Exprience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exprience }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_role }\n end\n end",
"def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end",
"def create\n @enrolled = Enrolled.new(:student_id => current_student.student_id, :course_id => params[:course_id])\n\n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully created.' }\n format.json { render json: @enrolled, status: :created, location: @enrolled }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @earned_award = EarnedAward.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @earned_award }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @manage_instructor = Instructor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manage_instructor }\n end\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end",
"def new\n @course = Course.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @life_insurance = LifeInsurance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @life_insurance }\n end\n end",
"def new\n @study_course = StudyCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @study_course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html\n format.json { render json: @course }\n end\n end",
"def new\r\n @course = Course.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @course}\r\n end\r\n end",
"def new\n @class_group_enrollment = ClassGroupEnrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_group_enrollment }\n end\n end",
"def new\n @course = Course.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course_status = CourseStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course_status }\n end\n end",
"def new\n @award = Award.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @award }\n end\n end",
"def new\n @award = Award.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @award }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=> @course }\n end\n end",
"def new\n @course = Course.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def new\n @grade = Grade.new\n\n respond_to do |format|\n format.html { render :layout => false }\n format.json { render json: @grade }\n end\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def new\n @leave = Leave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leave }\n end\n end",
"def new\n @employ = Employ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @employ }\n end\n end",
"def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @interested = Interested.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interested }\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\n @visit = Visit.new\n @visit.enrollments << Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit }\n end\n end",
"def new\n @assessment = Assessment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assessment }\n end\n end",
"def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end",
"def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end",
"def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end",
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @endurance = Endurance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @endurance }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest }\n end\n end",
"def new\n @assignment = Assignment.find(params[:assignment_id])\n @essay = Essay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @essay }\n end\n end",
"def new\n @studentgrade = Studentgrade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @studentgrade }\n end\n end",
"def new\n @industry = Industry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @industry }\n end\n end",
"def new\n @course =Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def new\n @income = Income.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @income }\n end\n end",
"def new\n @employe = Employe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @employe }\n end\n end",
"def new\n @first_aid_course = FirstAidCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @first_aid_course }\n end\n end",
"def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end",
"def new\n @illness = Illness.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @illness }\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def new\n @course_request = CourseRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_request }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @certification }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @assist = Assist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assist }\n end\n end",
"def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end",
"def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end",
"def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end",
"def new\n @enrolled = Enrolled.new\n end",
"def new\n @online_student = OnlineStudent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @online_student }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @inschool = Inschool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inschool }\n end\n end",
"def new\n @type_course = TypeCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_course }\n end\n end",
"def new\n @course = Course.new\n authorize! :create, @course\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @learn = Learn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @learn }\n end\n end",
"def new\n @news_agency = NewsAgency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_agency }\n end\n end"
] |
[
"0.78642637",
"0.78642637",
"0.7677734",
"0.7499671",
"0.71483815",
"0.7146724",
"0.711371",
"0.71082497",
"0.7101876",
"0.7101876",
"0.70664245",
"0.7041032",
"0.70106286",
"0.70106286",
"0.701044",
"0.7010137",
"0.70066035",
"0.69908917",
"0.6989849",
"0.6966022",
"0.69013435",
"0.6891021",
"0.68837285",
"0.6876066",
"0.68712145",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.6870651",
"0.686817",
"0.68657506",
"0.6855794",
"0.68427277",
"0.6841648",
"0.682131",
"0.6810478",
"0.6807581",
"0.68063575",
"0.6804386",
"0.6791211",
"0.678695",
"0.67806435",
"0.67806435",
"0.6774064",
"0.67721516",
"0.6769661",
"0.6765512",
"0.67615217",
"0.6760441",
"0.6758265",
"0.6758265",
"0.6753441",
"0.67527467",
"0.6745554",
"0.67429256",
"0.6742184",
"0.67387396",
"0.67352545",
"0.67352545",
"0.67312276",
"0.6729744",
"0.67275906",
"0.6726836",
"0.67230487",
"0.67218846",
"0.67181337",
"0.67149097",
"0.67126536",
"0.6710736",
"0.67107266",
"0.67084163",
"0.6707074",
"0.6707074",
"0.6704225",
"0.6701666",
"0.6701611",
"0.6697417",
"0.6696707",
"0.6696707",
"0.6696707",
"0.6696327",
"0.66949606",
"0.66949606",
"0.66949606",
"0.6694341",
"0.66939837",
"0.6691308",
"0.66883314",
"0.66883314",
"0.66875887",
"0.66847247",
"0.66793334",
"0.6673014",
"0.66684484"
] |
0.6873895
|
24
|
POST /enrolls POST /enrolls.json
|
def create
file = params[:enroll][:deck]
params[:enroll][:deck] = nil
@enroll = Enroll.new(params[:enroll])
@enroll.score = -1
@enroll.user = @current_user
@enroll.tournament = Tournament.find params[:enroll][:tournament_id]
if @enroll.tournament.need_deck
if file
extname = File.extname file.original_filename
if [".ydk", ".txt", ".deck"].include?(extname)
@enroll.deck = Deck.parse(file.read, extname)
@enroll.deck.name = File.basename(file.original_filename, extname)
else
@enroll.errors.add(:deck, '无法识别的卡组,如果你的卡组格式正确依然报此问题,请联系zh99998@gmail.com')
end
else
@enroll.errors.add(:deck, '请上传卡组')
end
end
if @enroll.tournament.need_team and @enroll.team.blank?
@enroll.errors.add(:team, '不能为空')
end
if @enroll.tournament.need_user and @enroll.team.blank?
@enroll.errors[:base] << '只有注册用户才能参加这个比赛'
end
respond_to do |format|
if !@enroll.errors.any? and @enroll.save
format.html { redirect_to @enroll.tournament, notice: 'Enroll was successfully created.' }
format.json { render json: @enroll, status: :created, location: @enroll }
else
format.html { render action: "new" }
format.json { render json: @enroll.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end",
"def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n format.json { render json: @enrollments.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end",
"def create\n @course = Course.find(params[:course_id])\n @enrollment = @course.enrollments.create(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n format.html { render :template => 'enrollments/success', notice: 'ya' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def index\n @enrolls = Enroll.all\n end",
"def index\n @enrolls = Enroll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolls }\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll_params\n params.require(:enroll).permit(:user_id, :course_id)\n end",
"def create\n course = Course.find(params[:course_id])\n student = Student.find_by(dni: params[:student_id])\n @enroll = Enroll.new( student: student, course: course)\n TestCourse.of(course).each do |tc|\n Score.create( student: student, test_id: tc.test_id, value: -2)\n end\n \n respond_to do |format|\n if @enroll.save\n format.html { redirect_to course_enrolls_path(course), notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: course_enrolls_path(course) }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll\n\n response = {}\n status_code = 200\n\n begin\n\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n\n if !user\n status_code = 401\n raise 'Not logged in!'\n end\n\n if !user.is? \"supervisor\"\n status_code = 403\n raise 'Student cannot edit course!'\n end\n\n # If a supervisor\n if user.is? \"supervisor\"\n # Get parameters\n student_id = params[:student_id]\n course_id = params[:course_id]\n\n # Only allowed to enroll students in courses he supervises\n return unless user.courses.find(course_id)\n else\n # If unknown class, do nothing\n return\n end\n\n # Create plan\n plan = Plan.new\n\n group = Group.create!(\n :name => \"Pessoal\",\n :min_credits => nil,\n :min_subjects => nil\n )\n\n # Supervisor only enrolls if student exists\n if Student.find(student_id) != nil\n plan.course = Course.find(course_id)\n plan.student = Student.find(student_id)\n plan.group = group\n\n plan.save\n else\n status_code = 404\n raise 'Student does not exist!'\n end\n\n redirect_back fallback_location: \"/\"\n rescue Exception => e\n response[:status] = 'error'\n response[:error] = \"#{e}\"\n else\n status_code 201\n response[:status] = 'success'\n response[:message] = 'Student was enrolled with success!'\n end\n end",
"def create\n @enrollment = current_user.enrollments.build(enrollment_params)\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to user_enrollment_path(current_user, @enrollment), notice: 'We have received your request for enrollment. We\\'ll contact you with further details.' }\n else\n flash[:alert] = @enrollment.errors.full_messages.to_sentence\n format.html { redirect_to request.referrer }\n end\n end\n end",
"def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def enroll_params\r\n params.require(:enroll).permit(:user_id, :lecture)\r\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to [:admin, @enrollment], notice: 'enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll_params\n params.require(:enrollment).permit(:course_id, :user_id)\n end",
"def enroll!(course_id)\n self.enrollments.create!(course_id:course_id)\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def index\n @enrollments = Enrollment.all\n end",
"def create_enrollment\n\n end",
"def enroll_params\n params.require(:enroll).permit(:student_id, :course_id, :percentage, :lettergrade)\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def create\n @enrollment = Enrollment.new(instructor: true)\n @course = Course.new(course_params)\n @course.enrollments << @enrollment\n current_user.enrollments << @enrollment\n\n respond_to do |format|\n if @enrollment.save and @course.save and current_user.save\n format.html { redirect_to root_url, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrolled = Enrolled.new(:student_id => current_student.student_id, :course_id => params[:course_id])\n\n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully created.' }\n format.json { render json: @enrolled, status: :created, location: @enrolled }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll_params\n params.require(:enroll).permit(:firstname, :lastname, :phone, :email, :childname, :childage, :question, :consent, :startdate, :enddate, :typeofday)\n end",
"def create\n @enrollment = @parent.enrollments.build enrollment_params\n if @enrollment.save\n render :show, status: :created, location: api_v1_mutant_enrollment_url(@enrollment.mutant_id, @enrollment)\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Matrícula criada com sucesso.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n\t@enrollment.save\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: tr(\"enrollment_created\") }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @enrolment = Enrolment.new(enrolment_params)\n\n respond_to do |format|\n if @enrolment.save\n format.html { redirect_to @enrolment, notice: \"Enrolment was successfully created.\" }\n format.json { render :show, status: :created, location: @enrolment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @enrolment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enrollment_params\n params.require(:enrollment).permit(:user_id, :course_id, :approve, :deny, :grade)\n\n end",
"def enroll_params\n params.fetch(:enroll, {})\n end",
"def enrollment_params\n params.require(:enrollment).permit(:student_id, :course_id)\n end",
"def create\n @enrolled = Enrolled.new(params[:enrolled])\n \n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @enrolled.class.model_name.human) }\n format.json { render :json => @enrolled, :status => :created, :location => @enrolled }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @enrolled.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n @enrollment.student = Student.find(params[:student_for_enrollment])\n @enrollment.subject = Subject.find(params[:subject])\n @enrollment.year = DateTime.now.year\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to '/students', notice: 'La Cursada se creó exitosamente.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end",
"def create\n \n\t# create a new student as well if there is not already a student associated with this user.\n\t#Student.new({:user_id => session[:id], :student_number => params[:enrollment][:student_number]})\n\t\n\t# give correct user id.\n\tparams[:enrollment][:user_number] = session[:user_id]\n @enrollment = Enrollment.new(params[:enrollment])\n\t\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instructor = Instructor.new(trainer_params)\n if @instructor.save\n render json: @instructor\n else\n render json: @instructor.errors\n end\n end",
"def enrollment_params\n params.require(:enrollments).permit(:user_id, :lesson_id)\n end",
"def create\n @pre_enrollment = PreEnrollment.new(pre_enrollment_params)\n\n respond_to do |format|\n if @pre_enrollment.save\n format.html { redirect_to @pre_enrollment, notice: 'Pre enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @pre_enrollment }\n else\n format.html { render :new }\n format.json { render json: @pre_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n @enrollment = Enrollment.shard_for( params[:enrollment][:classroom_id] ).create!( params[:enrollment] )\n if @enrollment\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render json: @enrollment, status: :created, location: @enrollment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @attendance_record = AttendanceRecord.new(attendance_record_params)\n #\n # respond_to do |format|\n # if @attendance_record.save\n # format.html { redirect_to @attendance_record, notice: 'Attendance record was successfully created.' }\n # format.json { render :show, status: :created, location: @attendance_record }\n # else\n # format.html { render :new }\n # format.json { render json: @attendance_record.errors, status: :unprocessable_entity }\n # end\n # end\n enrollments = Enrollment.where(section_id: params[:section_id])\n enrollments.each do |e|\n if (params[\"ar_p-#{e.student_id}\"])\n primary = params[\"ar_p-#{e.student_id}\"]\n secondary = params[\"ar_s-#{e.student_id}\"] ? params[\"ar_s-#{e.student_id}\"] : nil\n ar_params = {}\n ar_params[:student_id] = e.student_id\n ar_params[:section_id] = params['section_id']\n ar_params[:primary] = primary\n ar_params[:secondary] = secondary\n ar_params[:attendance_date] = Date.today\n AttendanceRecord.create(ar_params)\n end\n end\n end",
"def enrollment_params\n params.require(:enrollment).permit(:date, :method, :remarks, :coordinator_id, :registry_id, :participant_id)\n end",
"def enroll\n\t\traise \"Invalid role!\" unless current_user.role_student?\n\n\t\t# We *shouldn't* get here if we already have requests, but just in case - DESTROY THEM\n\t\t@seminar.seminar_students.for_student_user(current_user).each{|x| x.destroy} \n\n\t\t@enrollment = @seminar.seminar_students.create!(:student_user => current_user, :student_confirmed => true)\n\t\tflash[:notice] = \"Enrollment requested\"\n\t\tredirect_to @seminar\n\tend",
"def enrollment_params\n params.require(:enrollment).permit(:attended, :user_id, :training_session_id)\n end",
"def create\n\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n\n if @enroll.save\n\n format.html { redirect_to promotions_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n\n end\n end\n end",
"def create\n\n @enrollment = Enrollment.new(properties_data: enrollment_properties_params)\n #debugger\n #@enrollment = Enrollment.new()\n #render json: request.raw_post(), status: :created\n\n if @enrollment.save\n render json: {:reference_number => @enrollment.reference_number}, status: :created\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end",
"def do_enroll\n rrid = params[:enrollment][:registration_role_id]\n rr = RegistrationRole.find rrid\n do_creator_action :enroll do\n\tflash_notice(\"Your registration request is successfully sent to #{rr.event}\") if valid?\n\tfalse #force default rendering\n end\n end",
"def create\n @enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n flash[:notice] = 'Enrollment was successfully created.'\n format.html { redirect_to(department_lecture_path(@enrollment.lecture.department, @enrollment.lecture)) }\n format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def enrollment_params\n params.require(:enrollment).permit(:course_id,:student_id, :grade)\n end",
"def create \n if current_user && current_user.university_id\n begin \n params[:enrollment][:user_id] = current_user.id \n params[:enrollment][:university_id] = current_user.university_id\n @enrollment = Enrollment.renew( params[:enrollment] )\n render :show\n rescue \n render json: {error: \"Enrollment not created.\"}\n end\n else\n render json: {error: \"Enrollment not created.\"}\n end\n end",
"def enrollment_params\n params.require(:enrollment).permit(:user_id, :course_code)\n end",
"def create\n admin_only\n @consuming_enrollment = ConsumingEnrollment.new(consuming_enrollment_params)\n\n respond_to do |format|\n if @consuming_enrollment.save\n format.html { redirect_to @consuming_enrollment, notice: 'Consuming enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @consuming_enrollment }\n else\n format.html { render :new }\n format.json { render json: @consuming_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment = Enrollment.new(enrollment_params)\n @registry = @enrollment.registry\n @participants = Participant.all - @registry.participants\n @coordinators = @registry.coordinators\n\n respond_to do |format|\n if @enrollment.save\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enroll }\n end\n end",
"def create\n @enrollment = Enrollment.new\n @enrollment.student_id = params[:enrollment][:student]\n @enrollment.course_id = params[:enrollment][:course_id]\n \n if !@enrollment.student_id.nil? and !@enrollment.course_id.nil?\n @enrollment.save\n end\n redirect_to enrollments_index_path(:course_id=>@enrollment.course_id) \n end",
"def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end",
"def index\n @course = params[:course_id]\n @students = Student.left_join_enrolls @course\n puts @students.as_json\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrollment_ta = EnrollmentTa.new(enrollment_ta_params)\n\n respond_to do |format|\n if @enrollment_ta.save\n format.html { redirect_to @enrollment_ta, notice: 'Enrollment ta was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment_ta }\n else\n format.html { render :new }\n format.json { render json: @enrollment_ta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enrollment_params\n params.permit(:course_id, :andrew_id, :active)\n end",
"def index\n @pre_enrollments = PreEnrollment.all\n end",
"def create_enrollment\n Enrollment.create!([{\n subject_id: 1,\n student_id: 1\n },\n {\n subject_id: 2,\n student_id: 2\n },\n {\n subject_id: 3,\n student_id: 3\n },\n {\n subject_id: 1,\n student_id: 4\n },\n {\n subject_id: 2,\n student_id: 5\n },\n {\n subject_id: 3,\n student_id: 6\n },\n {\n subject_id: 1,\n student_id: 7\n },\n {\n subject_id: 2,\n student_id: 8\n },\n {\n subject_id: 3,\n student_id: 9\n },\n {\n subject_id: 1,\n student_id: 10\n }])\nend",
"def enrollment_params\n params.require(:enrollment).permit(:section_id, :student_id)\n end",
"def enrollment_params\n params.require(:enrollment).permit(:enrollment_date, :year, :active, :paid, :student_id, :course_id)\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def index\n @enrollments = Enrollment.all\n\n # Search\n @enrollments = @enrollments.search(params[:q]) if params[:q]\n\n # Filter for group\n #@enrollments = @enrollments.relationship(params[:group]) if params[:group]\n\n # Order by\n @enrollments = @enrollments.order(params[:order].gsub(':', ' ')) if params[:order]\n\n # Pagination\n if (params[:offset] && params[:limit])\n @enrollments = @enrollments.page(1).per(params[:limit]).padding(params[:offset])\n else\n @enrollments = @enrollments.page(1).per(25)\n end\n\n render json: @enrollments if stale?(etag: @enrollments.all, last_modified: @enrollments.maximum(:updated_at))\n end",
"def create\n user_id = @current_user.id\n date = DateTime.strptime(params[:date], '%s')\n schedule_id = params[:id]\n\n e = Enrollment.find_by user_id: user_id, date: date, schedule_id: schedule_id\n\n # avoid duplicating enrollments\n unless e.present?\n\n @enrollment = Enrollment.create(\n user_id: user_id,\n date: date,\n schedule_id: schedule_id\n )\n\n end\n\n redirect_to bookings_path\n\n end",
"def enrollment\n \n connection =\n HTTParty.post('https://eastus.api.cognitive.microsoft.com/speaker/identification/v2.0/text-independent/profiles',\n :body => JSON.generate(\"locale\": 'en-us'),\n :headers => { 'Content-Type' => 'application/json',\n 'Ocp-Apim-Subscription-Key' => \"3c43bca9ad884fe39518a5cf3925e707\" })\n @parsed = JSON.parse(connection.body)\n create_DB_profile();\n create_profile();\n redirect_to ('/speech')\n end",
"def enrollment_params\n params.require(:enrollment).permit(:client_id, :service_id, :preferences)\n end",
"def enrollment_params\n params.permit(:id, :participant_id, :studysite_id, :study_id)\n #params.require(:participantstudysites).permit(:id, :participant_id, :studysite_id )\n end",
"def create\n @education = Education.new(education_params)\n\n if @education.save\n render json: @education, status: :created, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end",
"def index\n @enrollments = @parent.enrollments.all\n end",
"def index\n @enrollments ||= @committee.enrollments if @committee\n @enrollments ||= @user.enrollments if @user\n @enrollments = @enrollments.ordered\n\n respond_to do |format|\n format.html { render :action => 'index' } # index.html.erb\n format.xml { render :xml => @enrollments }\n end\n end",
"def request_enroll(applicant)\n url = \"#{root_url}/ivs-ippaas-api/IPPRest/resources/rest/optInIPPApplicant\"\n body = {\n sponsorID: sponsor_id,\n uniqueID: applicant.unique_id,\n firstName: applicant.first_name,\n lastName: applicant.last_name,\n streetAddress: applicant.address,\n city: applicant.city,\n state: applicant.state,\n zipCode: applicant.zip_code,\n emailAddress: applicant.email,\n IPPAssuranceLevel: '1.5',\n }\n\n res = faraday.post(url, body, dynamic_headers) do |req|\n req.options.context = { service_name: 'usps_enroll' }\n end\n Response::RequestEnrollResponse.new(res.body)\n end",
"def set_enrolls\r\n @lecture = Lecture.find(params[:lecture_id])\r\n end",
"def create\n raise SecurityTransgression unless Enrollment.can_be_created_by? current_user\n @enrollment = Enrollment.new(enrollment_params)\n\n if @enrollment.save\n redirect_to welcome_index_path, notice: 'Enrollment was successfully created.'\n else\n render action: 'new'\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n end",
"def enrollment_params\n params.require(:enrollment).permit(:section_id, :user_id)\n end",
"def create\n @enrollment = Participantstudysite.new(enrollment_params)\n @study_id=Studysite.where(:id=> enrollment_params[:studysite_id]).pluck(:study_id).first\n\n @enrollment.study_id=@study_id\n @allstudy= Studysite.select(\"sites.name||'('||sites.location||')-'||studies.title||'('||studies.principal_investigator||')' as text,studysites.id as key\").joins(:site,:study)\n @participants = Participant.all\n\n respond_to do |format|\n if @enrollment.save\n\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully created.' }\n format.json { render :show, status: :created, location: @enrollment }\n else\n format.html { render :new }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def new\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end",
"def create\n @enrolled_student = EnrolledStudent.new(params[:enrolled_student])\n\n respond_to do |format|\n if @enrolled_student.save\n format.html { redirect_to @enrolled_student, notice: 'Enrolled student was successfully created.' }\n format.json { render json: @enrolled_student, status: :created, location: @enrolled_student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll\n @tournament = Tournament.find(params[:id])\n @participation = TournamentPlayer.new(player: current_player, tournament: @tournament)\n authorize! :create, @participation\n\n respond_to do |format|\n if @participation.save\n format.html { redirect_to request.referer, notice: 'Successfully signed up to the tournament.' }\n format.json { render json: @participation, status: :created, location: @participation }\n else\n format.html { redirect_to request.referer, :alert => \"Can't sign up for this tournament.\" }\n format.json { render json: @participation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def guardian_create_enrollment_ticket(body)\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty?\n\n path = \"#{guardian_enrollments_path}/ticket\"\n post(path, body)\n end",
"def index\n @enrolleds = Enrolled.all\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolleds }\n end\n end",
"def enrollment_params\n params.require(:enrollment).permit(:event_group_id, :user_id, :coupon_id, :opp_status_id, :guest_id)\n end",
"def create\n if params[:education][:accomplishment][\"0\"] != \"\"\n @education = Education.new(education_params)\n if @education.save\n params[:education][:accomplishment].each do |i, acc|\n EducationAccomplishment.create(description: acc, education_id: @education.id)\n end\n redirect_to '/'\n else\n redirect_to :back, flash: {alert: @education.errors.full_messages}\n end\n else\n redirect_to :back, flash: {alert: \"Must have at least one accomplishment\"}\n end\n end",
"def new\n @actions = [{\"YGO战网\" => users_path}, \"参加比赛\"]\n @enroll = Enroll.new\n @enroll.name = @current_user.name if @current_user.id != 0\n @enroll.tournament = Tournament.find params[:tournament_id] if params[:tournament_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enroll }\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_enrollments(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n get \"#{users_path}/#{user_id}/enrollments\"\n end",
"def enrolment_params\n params.require(:enrolment).permit(:course_id, :student_id)\n end",
"def new\n @course = Course.find(params[:course_id])\n @enrollment = Enrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enrollment }\n end\n end"
] |
[
"0.7566068",
"0.74632406",
"0.72054386",
"0.718063",
"0.6777213",
"0.6672076",
"0.66152406",
"0.6612462",
"0.65868115",
"0.65868115",
"0.65717965",
"0.6530254",
"0.6508454",
"0.64719474",
"0.6457346",
"0.64413095",
"0.64152694",
"0.63479143",
"0.63470614",
"0.633733",
"0.633733",
"0.633733",
"0.633733",
"0.6293262",
"0.6277812",
"0.6258315",
"0.6257187",
"0.6257187",
"0.6257187",
"0.6257187",
"0.62165385",
"0.6202409",
"0.6201493",
"0.61596894",
"0.6105759",
"0.61026347",
"0.6099617",
"0.6082588",
"0.6081998",
"0.6059172",
"0.6055721",
"0.60475326",
"0.6035989",
"0.60159445",
"0.59965837",
"0.5991812",
"0.59737",
"0.59733254",
"0.59729165",
"0.59699",
"0.5967198",
"0.5956959",
"0.59334546",
"0.5929816",
"0.59117585",
"0.59111077",
"0.588872",
"0.58768547",
"0.58759236",
"0.58695817",
"0.58629835",
"0.5841083",
"0.58213794",
"0.5813866",
"0.58079565",
"0.5798383",
"0.5798383",
"0.5794483",
"0.579269",
"0.5788826",
"0.5787472",
"0.57792884",
"0.57750183",
"0.57689834",
"0.57616955",
"0.5752245",
"0.5747977",
"0.5741868",
"0.5739328",
"0.57373095",
"0.5734861",
"0.5726517",
"0.5718708",
"0.5712588",
"0.5682186",
"0.5664869",
"0.56527084",
"0.5624121",
"0.56109583",
"0.56109583",
"0.56010145",
"0.5589808",
"0.5589779",
"0.558155",
"0.5576472",
"0.556058",
"0.55587155",
"0.5552668",
"0.5543467",
"0.5540441",
"0.55324256"
] |
0.0
|
-1
|
PUT /enrolls/1 PUT /enrolls/1.json
|
def update
@enroll = Enroll.find(params[:id])
@enroll.tournament = Tournament.find params[:enroll][:tournament_id]
respond_to do |format|
if @enroll.update_attributes(params[:enroll])
format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @enroll.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @enroll.update(enroll_params)\n format.html { redirect_to @enroll, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @enroll }\n else\n format.html { render :edit }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_enroll\n @enroll = Enroll.find(params[:id])\n\n end",
"def update\n #debugger\n if @enrollment.update(update_params)\n head :no_content\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end",
"def update\n \n @enrollment = Enrollment.find(params[:id])\n\t# give correct user id.\n\t\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n\n if @enrollment && @enrollment.update(enrollment_params)\n render :show\n else\n render json: {error: \"Enrollment not updated.\"}\n end\n end",
"def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end",
"def update\n\n @enrollment = Enrollment.shard_for( params[:enrollment][:classroom_id] ).find(params[:id])\n\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @enrollment = Enrollment.find(params[:id])\n if @enrollment.update(enrollment_params)\n redirect_to enrollments_index_path(:course_id=>@enrollment.course_id) \n end\n \n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enroll = Enroll.new(enroll_params)\n\n respond_to do |format|\n if @enroll.save\n format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: @enroll }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @enrolled = Enrolled.find(params[:id])\n\n respond_to do |format|\n if @enrolled.update_attributes(params[:enrolled])\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end",
"def update\n if @instructor.update(instructor_params)\n render json: @instructor\n else\n render json: @instructor.errors\n end\n end",
"def enroll_params\n params.require(:enroll).permit(:user_id, :course_id)\n end",
"def update\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n flash[:notice] = 'Enrollment was successfully updated.'\n format.html { redirect_to(@enrollment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @enrollment.student = @student_for_enrollment\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to '/students', notice: 'La Cursada se actualizó exitosamente.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_enrollment(subdomain, course_id, enrollment_id, state)\n canvas_url = \"https://#{subdomain}.instructure.com\"\n token = get_token\n\n canvas_delete(\"#{canvas_url}/api/v1/courses/#{course_id}/enrollments/#{enrollment_id}\",\n token,\n {\n task: state\n }\n )\n end",
"def update\n respond_to do |format|\n if @pre_enrollment.update(pre_enrollment_params)\n format.html { redirect_to @pre_enrollment, notice: 'Pre enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @pre_enrollment }\n else\n format.html { render :edit }\n format.json { render json: @pre_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to @enrollment, notice: 'Matrícula editada com sucesso.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @instructor1 = Instructor1.find(params[:id])\n\n respond_to do |format|\n if @instructor1.update_attributes(params[:instructor1])\n format.html { redirect_to @instructor1, notice: 'Instructor1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instructor1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll\n\n response = {}\n status_code = 200\n\n begin\n\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n\n if !user\n status_code = 401\n raise 'Not logged in!'\n end\n\n if !user.is? \"supervisor\"\n status_code = 403\n raise 'Student cannot edit course!'\n end\n\n # If a supervisor\n if user.is? \"supervisor\"\n # Get parameters\n student_id = params[:student_id]\n course_id = params[:course_id]\n\n # Only allowed to enroll students in courses he supervises\n return unless user.courses.find(course_id)\n else\n # If unknown class, do nothing\n return\n end\n\n # Create plan\n plan = Plan.new\n\n group = Group.create!(\n :name => \"Pessoal\",\n :min_credits => nil,\n :min_subjects => nil\n )\n\n # Supervisor only enrolls if student exists\n if Student.find(student_id) != nil\n plan.course = Course.find(course_id)\n plan.student = Student.find(student_id)\n plan.group = group\n\n plan.save\n else\n status_code = 404\n raise 'Student does not exist!'\n end\n\n redirect_back fallback_location: \"/\"\n rescue Exception => e\n response[:status] = 'error'\n response[:error] = \"#{e}\"\n else\n status_code 201\n response[:status] = 'success'\n response[:message] = 'Student was enrolled with success!'\n end\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def enroll_params\n params.require(:enrollment).permit(:course_id, :user_id)\n end",
"def update\n @instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n if @instructor.update_attributes(params[:instructor])\n format.html { redirect_to @instructor, notice: 'Instructor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instructor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @issuer = Issuer.find(params[:id])\n\n respond_to do |format|\n if @issuer.update_attributes(params[:issuer])\n format.html { redirect_to issuers_path, notice: 'Issuer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @issuer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n admin_only\n respond_to do |format|\n if @consuming_enrollment.update(consuming_enrollment_params)\n format.html { redirect_to @consuming_enrollment, notice: 'Consuming enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @consuming_enrollment }\n else\n format.html { render :edit }\n format.json { render json: @consuming_enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll!(course_id)\n self.enrollments.create!(course_id:course_id)\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @enrolment.update(enrolment_params)\n format.html { redirect_to @enrolment, notice: \"Enrolment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @enrolment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @enrolment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t \n\t @enrollment = Enrollment.find(params[:enrollment_id], :include => :contract)\n\t @meeting = Meeting.find(params[:meeting_id])\n\t if @enrollment\n\t privs = @enrollment.contract.privileges(@user)\n\t render :text => \"You don't have privileges to do this.\", :status=>500 and return unless privs[:edit]\n\t \n\t participant = update_attendance_for_enrollment(@meeting, @enrollment, params)\n\t end\n \n render :json => {:id => participant.id}.to_json\n\tend",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def set_enrollment\n @enrollment = Enrollment.find(params[:id])\n end",
"def update\n @enrolled = Enrolled.find(params[:id])\n \n respond_to do |format|\n if @enrolled.update_attributes(params[:enrolled])\n format.html { redirect_to @enrolled, :notice => t('selecao_admin.flash_messages.successfully_updated.', :model => @enrolled.class.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @enrolled.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_enrollment\n @enrollment = Participantstudysite.find(params[:id])\n end",
"def set_enrolls\r\n @lecture = Lecture.find(params[:lecture_id])\r\n end",
"def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n format.json { render json: @enrollments.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n enrollment.update!(\n selected_location_details: update_params.as_json,\n issuer: current_sp&.issuer,\n )\n add_proofing_component\n\n render json: { success: true }, status: :ok\n end",
"def index\n @enrolls = Enroll.all\n @enroll = Enroll.new\n end",
"def update\n respond_to do |format|\n if @enrollment_ta.update(enrollment_ta_params)\n format.html { redirect_to @enrollment_ta, notice: 'Enrollment ta was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment_ta }\n else\n format.html { render :edit }\n format.json { render json: @enrollment_ta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll_params\r\n params.require(:enroll).permit(:user_id, :lecture)\r\n end",
"def show\n @enroll = Enroll.find(params[:id])\n end",
"def update\n @services = Service.all\n respond_to do |format|\n if @enrollment.update(enrollment_params)\n format.html { redirect_to [:admin, @enrollment], notice: 'enrollment was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrollment }\n else\n format.html { render :edit }\n format.json { render json: @enrollment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enroll }\n end\n end",
"def update\n respond_to do |format|\n if @vopportunity_enrolment.save(vopportunity_enrolment_params)\n format.html { redirect_to @vopportunity_enrolment, notice: 'Enrolled! Congratulations!' }\n format.json { render :show, status: :ok, location: @vopportunity_enrolment }\n else\n format.html { render :edit }\n format.json { render json: @vopportunity_enrolment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instructor.update(instructor_params)\n format.html { redirect_to @instructor, notice: 'Instructor was successfully updated.' }\n format.json { render :show, status: :ok, location: @instructor }\n else\n format.html { render :edit }\n format.json { render json: @instructor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @roll = Roll.find(params[:id])\n\n respond_to do |format|\n if @roll.update_attributes(params[:roll])\n format.html { redirect_to @roll, notice: 'Roll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manage_instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n if @manage_instructor.update_attributes(params[:manage_instructor])\n format.html { redirect_to @manage_instructor, notice: 'Instructor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manage_instructor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n if @enrolled_student.update_attributes(params[:enrolled_student])\n format.html { redirect_to @enrolled_student, notice: 'Enrolled student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enrolled_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @assessment = Assessment.find(params[:id])\n\n respond_to do |format|\n if @assessment.update_attributes(params[:assessment])\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @enterprise = Enterprise.find(params[:id])\n\n respond_to do |format|\n if @enterprise.update_attributes(params[:enterprise])\n format.html { redirect_to \"/enterprises\", notice: 'Enterprise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @enterprise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end",
"def update\n raise SecurityTransgression unless current_user.can_update? @enrollment\n if @enrollment.update(enrollment_params)\n redirect_to course_path(@enrollment.course_id), notice: 'Enrollment was successfully updated.'\n else\n render action: 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @issuer.update(issuer_params)\n format.html { redirect_to @issuer, notice: 'Issuer was successfully updated.' }\n format.json { render :show, status: :ok, location: @issuer }\n else\n format.html { render :edit }\n format.json { render json: @issuer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @education.update(education_params)\n render :show, status: :ok, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end",
"def update\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n if @exprience.update_attributes(params[:exprience])\n format.html { redirect_to @exprience, notice: 'Exprience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exprience.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enroll_params\n params.require(:enroll).permit(:student_id, :course_id, :percentage, :lettergrade)\n end",
"def enroll\n\t\traise \"Invalid role!\" unless current_user.role_student?\n\n\t\t# We *shouldn't* get here if we already have requests, but just in case - DESTROY THEM\n\t\t@seminar.seminar_students.for_student_user(current_user).each{|x| x.destroy} \n\n\t\t@enrollment = @seminar.seminar_students.create!(:student_user => current_user, :student_confirmed => true)\n\t\tflash[:notice] = \"Enrollment requested\"\n\t\tredirect_to @seminar\n\tend",
"def update\n respond_to do |format|\n if @student_id.update(student_id_params)\n if @enrolment\n format.html { redirect_to enrolment_student_ids_path(@enrolment), notice: 'Student was successfully updated.' }\n else\n format.html { redirect_to @student_id, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student_id }\n end\n else\n format.html { render :edit }\n format.json { render json: @student_id.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n update_resource @ride, ride_params\n end",
"def update\n respond_to do |format|\n if @enrolled_course.update(enrolled_course_params)\n format.html { redirect_to @enrolled_course, notice: 'Enrolled course was successfully updated.' }\n format.json { render :show, status: :ok, location: @enrolled_course }\n else\n format.html { render :edit }\n format.json { render json: @enrolled_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n if current_user && current_user.university_id\n begin \n params[:enrollment][:user_id] = current_user.id \n params[:enrollment][:university_id] = current_user.university_id\n @enrollment = Enrollment.renew( params[:enrollment] )\n render :show\n rescue \n render json: {error: \"Enrollment not created.\"}\n end\n else\n render json: {error: \"Enrollment not created.\"}\n end\n end",
"def index\n @enrolls = Enroll.all\n end",
"def update\n @instructor = Instructor.find(params[:id])\n render :action => :edit unless @instructor.update_attributes(params[:instructor])\n \n end",
"def update\n @assessment_course = AssessmentCourse.find(params[:id])\n\n respond_to do |format|\n if @assessment_course.update_attributes(params[:assessment_course])\n format.html { redirect_to @assessment_course, notice: 'Assessment course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assessment_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @instructor = Instructor.find(params[:id])\n\n respond_to do |format|\n if @instructor.update_attributes(params[:instructor])\n format.html { redirect_to @instructor, :notice => 'Instructor was successfully updated.' }\n format.json { head :ok }\n else\n @aircraft_types = AircraftType.by_name.collect{|at| [at.name, at.id]}\n\n format.html { render :action => \"edit\" }\n format.json { render :json => @instructor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n format.html { redirect_to business_membership_enrollment_path(@business, @membership, @enrollment), notice: 'Enrollment was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment.update(assessment_params)\n format.html { redirect_to [@course, @assessment], notice: 'Attempt was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment }\n else\n format.html { render :edit }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment.update(assessment_params)\n format.html { redirect_to [@course, @assessment], notice: 'Attempt was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment }\n else\n format.html { render :edit }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment.update(assessment_params)\n format.html { redirect_to @assessment, notice: 'Assessment was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment }\n else\n format.html { render :edit }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment.update(assessment_params)\n format.html { redirect_to @assessment, notice: 'Assessment was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment }\n else\n format.html { render :edit }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @assignment = Assignment.find(params[:assignment_id])\n @essay = Essay.find(params[:id])\n \n respond_to do |format|\n if @essay.update_attributes(params[:essay])\n format.html { redirect_to assignment_essay_url(@essay.assignment_id, @essay.id), notice: 'Essay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @essay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end",
"def update\n respond_to do |format|\n if @enrollement.update(enrollement_params)\n format.html { redirect_to @enrollement, notice: \"Enrollement was successfully updated.\" }\n format.json { render :show, status: :ok, location: @enrollement }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @enrollement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def enrollment_params\n params.require(:enrollment).permit(:student_id, :course_id)\n end",
"def update\n respond_to do |format|\n if @employer_liability_insurance.update(employer_liability_insurance_params)\n # format.html { redirect_to @employer_liability_insurance, notice: 'Accident insurance was successfully updated.' }\n format.html { redirect_to insurances_url, notice: 'Insurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @employer_liability_insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trainer = Trainer.find(params[:id])\n\n if @trainer.update(trainer_params)\n head :no_content\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def update\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n format.html { redirect_to(@education, :notice => 'Education was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.77015555",
"0.73457915",
"0.73457915",
"0.71257854",
"0.71257854",
"0.71257854",
"0.71257854",
"0.7108434",
"0.70981526",
"0.68159974",
"0.6729866",
"0.6627292",
"0.6578257",
"0.6570706",
"0.65609324",
"0.65262467",
"0.65262467",
"0.65262467",
"0.65262467",
"0.65262467",
"0.64287037",
"0.6332218",
"0.63278145",
"0.6317646",
"0.63113415",
"0.62893176",
"0.6288452",
"0.6286522",
"0.6270093",
"0.6242705",
"0.62413865",
"0.6217985",
"0.6214865",
"0.6214865",
"0.620282",
"0.620101",
"0.61941504",
"0.6160987",
"0.61500067",
"0.6146304",
"0.61296666",
"0.6119195",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6115744",
"0.6103452",
"0.60864806",
"0.6079575",
"0.6078056",
"0.60611725",
"0.60577005",
"0.6024228",
"0.60193413",
"0.60134006",
"0.60003364",
"0.5983348",
"0.5978861",
"0.59711313",
"0.59649855",
"0.5943387",
"0.5943269",
"0.59309703",
"0.5925403",
"0.5924545",
"0.58903855",
"0.5887844",
"0.5886452",
"0.588311",
"0.5877793",
"0.5869291",
"0.5861514",
"0.583361",
"0.5833226",
"0.5832378",
"0.5830362",
"0.5814783",
"0.5795172",
"0.5792527",
"0.5786184",
"0.57859814",
"0.57843024",
"0.57843024",
"0.5774431",
"0.5774431",
"0.5757431",
"0.5756739",
"0.5756079",
"0.57545733",
"0.5753677",
"0.5749055",
"0.5744928",
"0.5730064",
"0.57211304"
] |
0.71183705
|
7
|
DELETE /enrolls/1 DELETE /enrolls/1.json
|
def destroy
@enroll = Enroll.find(params[:id])
@enroll.destroy
respond_to do |format|
format.html { redirect_to enrolls_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end",
"def destroy\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to enrolls_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_enroll }\n end\n end",
"def destroy\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to enrolls_url, notice: 'Enroll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to enrollments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n\n head :no_content\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to admin_enrollments_url, notice: 'enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to enrollments_url, notice: 'Matrícula excluída com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.delete\n end",
"def destroy \n if @enrollment && @enrollment.destroy \n render json: {success: \"Delete Successfully.\"}, status: 200\n else\n render json: {error: \"Enrollment not deleted.\"}\n end \n end",
"def destroy\n admin_only\n @consuming_enrollment.destroy\n respond_to do |format|\n format.html { redirect_to consuming_enrollments_url, notice: 'Consuming enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n respond_to do |format|\n format.html { redirect_to '/students', notice: 'La Cursada se borró exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment = Enrollment.shard_for( params[:classroom_id] ).find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to enrollments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to(enrollment_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @pre_enrollment.destroy\n respond_to do |format|\n format.html { redirect_to pre_enrollments_url, notice: 'Pre enrollment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrolled = Enrolled.find(params[:id])\n @enrolled.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolleds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instructor1 = Instructor1.find(params[:id])\n @instructor1.destroy\n\n respond_to do |format|\n format.html { redirect_to instructor1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n current_user.enrollments.where(course_id: @course.id).first.destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_url, :flash => { :success => 'Course was successfully deleted.' } }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @enrollment_ta.destroy\n respond_to do |format|\n format.html { redirect_to enrollment_tas_url, notice: 'Enrollment ta was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lease = Lease.find(params[:id])\n @lease.destroy\n\n respond_to do |format|\n format.html { redirect_to leases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrolment.destroy\n respond_to do |format|\n format.html { redirect_to enrolments_url, notice: \"Enrolment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_level = EducationLevel.find(params[:id])\n @education_level.destroy\n\n respond_to do |format|\n format.html { redirect_to education_levels_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrolled_student = EnrolledStudent.find(params[:id])\n @enrolled_student.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolled_students_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @instructor = Instructor.find(params[:id])\n @instructor.destroy\n\n respond_to do |format|\n format.html { redirect_to instructores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @course = Course.find(params[:id])\n @student = Student.find(params[:student_id])\n\n if Enrollment.where(course_id: @course.id, student_id: @student.id).count == 0\n render json: {\"message\": \"student is not enrolled in the course\"}\n return\n end\n\n @enrollment = Enrollment.find_by(course_id: @course.id, student_id: @student.id)\n \n if @enrollment.destroy\n render json: {\"message\": \"Student de-enrolled successfully\"}\n else\n render json: {\"message\": \"some server issue\"}\n end\n rescue\n render json: {\"message\": \"Course or Student not found\"}\n end\n end",
"def destroy\n @education_entry.destroy\n respond_to do |format|\n format.html { redirect_to education_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to assessments_url, notice: 'Assessment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to assessments_url, notice: 'Assessment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to assessments_url, notice: 'Assessment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment = Assessment.find(params[:id])\n @assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @life_insurance.destroy\n\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employer_liability_insurance.destroy\n respond_to do |format|\n format.html { redirect_to employer_liability_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instructor = Instructor.find(params[:id])\n @instructor.destroy\n\n respond_to do |format|\n format.html { redirect_to instructors_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @lease.destroy\n respond_to do |format|\n format.html { redirect_to leases_url, notice: 'Lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment = Assessment.find(params[:id])\n authorize! :destroy, @assessment\n\n @assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to assessments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @life_insurance.destroy\n respond_to do |format|\n format.html { redirect_to life_insurances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip_enrollment = TripEnrollment.find(params[:id])\n @trip_enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to(trip_enrollments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n authorize @lease\n @lease.destroy\n respond_to do |format|\n format.html { redirect_to leases_url, notice: 'Lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first_aid_course = FirstAidCourse.find(params[:id])\n @first_aid_course.destroy\n\n respond_to do |format|\n format.html { redirect_to first_aid_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to business_membership_url(@business, @membership) }\n end\n end",
"def destroy\n @education_accomplishment.destroy\n respond_to do |format|\n format.html { redirect_to education_accomplishments_url, notice: 'Education accomplishment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @essay = Essay.find(params[:id])\n @essay.destroy\n\n respond_to do |format|\n format.html { redirect_to essays_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @enrollment = Enrollment.find(params[:id])\n student = @enrollment.student\n course_id = @enrollment.course_id\n @enrollment.destroy\n\n respond_to do |format|\n flash[:notice] = student.name_first_last + ' unenrolled'\n format.html { redirect_to course_url(course_id) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to course_assessments_url(@course), notice: 'Attempt was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment.destroy\n respond_to do |format|\n format.html { redirect_to course_assessments_url(@course), notice: 'Attempt was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issuer = Issuer.find(params[:id])\n @issuer.destroy\n\n respond_to do |format|\n format.html { redirect_to issuers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enterprise = Enterprise.find(params[:id])\n @enterprise.destroy\n\n respond_to do |format|\n format.html { redirect_to enterprises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: \"Education was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: 'Education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education.destroy\n respond_to do |format|\n format.html { redirect_to educations_url, notice: 'Education was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend",
"def destroy\n @agreement_renewal.destroy\n respond_to do |format|\n format.html { redirect_to agreement_renewals_url, notice: 'Agreement renewal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @referral_enrolment.destroy\n respond_to do |format|\n format.html { redirect_to referral_enrolments_url, notice: 'Referral enrolment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission.destroy\n respond_to do |format|\n format.html { redirect_to admissions_url, notice: 'Admission was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to claims_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @edu_detail = EduDetail.find(params[:id])\n @edu_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to edu_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employe = Employe.find(params[:id])\n @employe.destroy\n\n respond_to do |format|\n format.html { redirect_to employes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollement.destroy\n respond_to do |format|\n format.html { redirect_to enrollements_url, notice: \"Enrollement was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @educate.destroy\n respond_to do |format|\n format.html { redirect_to educates_url, notice: 'Educate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exalt = Exalt.find(params[:id])\n @exalt.destroy\n\n respond_to do |format|\n format.html { redirect_to exalts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @essay = Essay.find(params[:id])\n @essay.destroy\n\n respond_to do |format|\n format.html { redirect_to assignment_essays_path(params[:assignment_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @excercise = Excercise.find(params[:id])\n @excercise.destroy\n\n respond_to do |format|\n format.html { redirect_to excercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @hold_request.destroy\n respond_to do |format|\n format.html { redirect_to student_requests_path, notice: 'Hold request was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assay = Assay.find(params[:id])\n @assay.destroy\n\n respond_to do |format|\n format.html { redirect_to assays_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enrollment=Enrollment.find(params[:id])\n if @enrollment.present?\n @enrollment.destroy\n end\n redirect_to request.referrer\n end",
"def destroy\n @encuestum = Encuestum.find(params[:id])\n @encuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to encuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_level.destroy\n respond_to do |format|\n format.html { redirect_to education_levels_url, notice: 'Education level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ledger.destroy\n respond_to do |format|\n format.html { redirect_to ledgers_url, notice: 'Ledger was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ledger.destroy\n respond_to do |format|\n format.html { redirect_to ledgers_url, notice: 'Ledger was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agreement.destroy\n respond_to do |format|\n format.html { redirect_to agreements_url, notice: 'Agreement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claimant = Claimant.find(params[:id])\n @claimant.destroy\n\n respond_to do |format|\n format.html { redirect_to claimants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roll.destroy\n respond_to do |format|\n format.html { redirect_to rolls_url, notice: 'Roll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @enqury.destroy\n respond_to do |format|\n format.html { redirect_to enquries_url, notice: 'Enqury was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @acquirement = Acquirement.find(params[:id])\n @acquirement.destroy\n\n respond_to do |format|\n format.html { redirect_to acquirements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @payroll.destroy\n respond_to do |format|\n format.html { redirect_to payrolls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n course = Course.find(params[:course_id])\n TestCourse.of(course).each do |tc|\n Score.where( student_id: @enroll.student_id, test_id: tc.test_id).each do |score|\n score.destroy\n end\n end\n @enroll.destroy\n respond_to do |format|\n format.html { redirect_to course_enrolls_path(course), notice: 'Enroll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission.destroy\n respond_to do |format|\n format.html { redirect_to admissions_url, notice: 'Admission information was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accident_item.destroy\n respond_to do |format|\n format.html { redirect_to accident_items_url }\n format.json { head :no_content }\n end\n end",
"def delete\n\t\trender json: Investor.delete_by_id(params[:id])\n\tend",
"def destroy\n @entrant = Entrant.find(params[:id])\n @entrant.destroy\n\n respond_to do |format|\n format.html { redirect_to entrants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instructor.destroy\n respond_to do |format|\n format.html { redirect_to instructors_url, notice: 'Instructor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instructor.destroy\n respond_to do |format|\n format.html { redirect_to instructors_url, notice: 'Instructor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entrant = Entrant.find(params[:id])\n @entrant.destroy\n\n respond_to do |format|\n format.html { redirect_to entrants_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @enterprise.destroy\n respond_to do |format|\n format.html { redirect_to enterprises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employ = Employ.find(params[:id])\n @employ.destroy\n\n respond_to do |format|\n format.html { redirect_to employs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @signed_lease.destroy\n respond_to do |format|\n format.html { redirect_to signed_leases_url, notice: 'Signed lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assessment = Assessment.find(params[:id])\n @assessment.destroy\n \n respond_to do |format|\n format.html { redirect_to(assessments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ride_passenger.destroy\n respond_to do |format|\n format.html { redirect_to @root }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manage_instructor = Instructor.find(params[:id])\n @manage_instructor.destroy\n\n respond_to do |format|\n format.html { redirect_to manage_instructors_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.78918463",
"0.769313",
"0.7638765",
"0.76297796",
"0.7512439",
"0.73133063",
"0.73133063",
"0.73133063",
"0.73133063",
"0.73133063",
"0.72751975",
"0.72677577",
"0.7267682",
"0.7247389",
"0.7242299",
"0.7142559",
"0.7133361",
"0.7058846",
"0.70414436",
"0.6952568",
"0.6947864",
"0.6924245",
"0.68964714",
"0.68346274",
"0.6814537",
"0.67907023",
"0.6778205",
"0.67703617",
"0.6725418",
"0.66967726",
"0.66880983",
"0.66742384",
"0.6671639",
"0.6668469",
"0.6665036",
"0.6665036",
"0.6665036",
"0.6654608",
"0.66462153",
"0.664113",
"0.66382825",
"0.66375375",
"0.6636853",
"0.6628679",
"0.66241676",
"0.66237515",
"0.6621631",
"0.66201097",
"0.6620005",
"0.6613087",
"0.66014785",
"0.65964824",
"0.6596413",
"0.6596413",
"0.65953696",
"0.6592285",
"0.6585964",
"0.65854686",
"0.65854686",
"0.6584284",
"0.6580657",
"0.6564601",
"0.65579844",
"0.65578353",
"0.6552861",
"0.65482277",
"0.65460217",
"0.6542352",
"0.65410465",
"0.65402937",
"0.65350395",
"0.65235996",
"0.65213037",
"0.6520123",
"0.65187037",
"0.65179926",
"0.6516806",
"0.6515855",
"0.6505908",
"0.6505908",
"0.6503908",
"0.650184",
"0.6499016",
"0.64968234",
"0.64964104",
"0.64933705",
"0.6487418",
"0.64856464",
"0.64825594",
"0.6481877",
"0.648033",
"0.6479743",
"0.6479743",
"0.6479443",
"0.6479027",
"0.6472086",
"0.64704597",
"0.64701986",
"0.64689225",
"0.6463889"
] |
0.7937095
|
0
|
GET /rooms GET /rooms.json
|
def index
# @rooms = Room.searchroom(params[:r])
# @rooms = Room.where("admin_id = ?",current_admin.id)
@areas = Area.where(admin_id: current_admin.id).map { |a| [a.name, a.id] }
@room1 = ActiveRecord::Base.connection.execute("select r.id ,r.name,r.status,r.admin_id, b.total,s.datebegin,s.dateend from rooms r,services_rooms s,billings b where b.payment = 0 and r.admin_id = "+current_admin.id.to_s+" and r.id = s.room_id and s.id = b.services_room_id").to_a
if params[:r]
@rooms = Room.where("admin_id = ? and name LIKE ?",current_admin.id,"%#{params[:r]}%").order('created_at DESC')
else
if params[:commit]
if params[:commit] == 'All'
@rooms = Room.where("admin_id = ?",current_admin.id).order('created_at DESC')
elsif params[:commit] == "Debt"
@rooms = Room.where("admin_id = ? ",current_admin.id).order('created_at DESC')
@room = ActiveRecord::Base.connection.execute("select r.id ,r.name,r.status,r.admin_id, b.total,s.datebegin,s.dateend from rooms r,services_rooms s,billings b where b.payment = 0 and r.admin_id = "+current_admin.id.to_s+" and r.id = s.room_id and s.id = b.services_room_id").to_a
else
@rooms = Room.where("admin_id = ? and status = ?",current_admin.id,params[:commit].downcase)
end
else
@rooms = Room.where("admin_id = ?",current_admin.id).order('created_at DESC')
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:user_id]\n @room_ids = Member.where(user_id: @user_id).pluck(:room_id)\n\n @rooms = Room.find(@room_ids)\n #render json: @rooms\n \n @roomList = []\n #@rooms.each { |room|\n for room in @rooms do\n #@room = Room.find_by(id: room_id)\n temp = {}\n temp.store(\"room_id\",room.id)\n temp.store(\"room_name\", room.name) \n temp.store(\"room_token\", room.token)\n @roomList.push(temp)\n end\n render json: {rooms: @roomList}, status: 200\n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def get_all_rooms(params = {})\n res = call_api(:method => :get, :uri => @api_base.merge(\"room\"), :query_params => params)\n return unless res.successful?\n Rooms.new(res.data)\n end",
"def index\n rooms = Room.includes(:problems, :registrations, :users, :owner)\n if params[:name]\n render json: rooms.where(name: params[:name])\n else\n render json: rooms\n end\n end",
"def get_rooms(request_parameters)\r\n http_service.request_get(\"/json/bookings.getRooms\", request_parameters)\r\n # https://distribution-xml.booking.com/json/bookings.getRooms?rows=10&hotel_ids=121543\r\n end",
"def get_rooms(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.get '/messages/v3/' + company + '/rooms', params\n end",
"def list_all_rooms\n return @rooms\n end",
"def get_rooms \n json_rooms = IO.popen(\"curl -u #{@config['campfire_config']['API_KEY']}:X #{@config['campfire_config']['URL']}/presence.json\") \n parsed_rooms = JSON.parse(json_rooms.readlines.first)[\"rooms\"]\n rooms = parsed_rooms.collect {|room| [room[\"name\"],room[\"id\"]]} \nend",
"def index\n if authorise(request)\n auth_token = request.headers['Authorization1'].split(' ').last\n req = GetRoomsRequest.new(auth_token)\n serv = RoomServices.new\n resp = serv.get_rooms(req)\n render json: { status: resp.success, message: resp.message, data: resp.data }, status: :ok\n else\n render json: { status: false, message: 'Unauthorized' }, status: 401\n end\n end",
"def index\n @branch_rooms = Room.get_all_rooms(params[:branch_id])\n \n render json: @branch_rooms\n end",
"def show\n @rooms = Room.all\n end",
"def index\n @user = User.find(params[:user_id])\n @rooms = @user.rooms.all\n render json: @rooms if stale?(etag: @rooms.all, last_modified: @rooms.maximum(:updated_at))\n end",
"def index\n @rooms = current_user.rooms.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all.map do |rm|\n Room.cleanFetch(rm, current_user)\n end\n end",
"def index\n @rooms = Room.all\n \n respond_to do |f|\n f.html\n end\n end",
"def get_rooms(page)\n page.links.collect { |link| { :name => link.to_s, :uri => link.uri } if link.uri.to_s[\"#{uri.to_s}/room\"] }.reject { |room| room.nil? }\n end",
"def show\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n end\n end",
"def rooms\n Hpricot(get.body).search(\"//h2/a\").collect do |a|\n Room.new(self, room_id_from_url(a.attributes['href']), a.inner_html)\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def index\n @restrooms = Restroom.all\n end",
"def index\n case current_type\n when 'owner'\n @rooms = owner_rooms\n when 'access'\n @rooms = access_rooms\n else\n @rooms = public_rooms\n end\n end",
"def index\n @hostel_rooms = HostelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hostel_rooms }\n end\n end",
"def index\n @request_rooms = RequestRoom.all\n end",
"def show\n @room = Room.find(params[:id])\n\n render '/api/rooms/show'\n end",
"def index\n @hotel_rooms = HotelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotel_rooms }\n end\n end",
"def find \n @user = User.find(params[:user_id])\n @room = @user.rooms.where(:name => params[:name])\n render json: @room if stale?(etag: @room.all, last_modified: @room.maximum(:updated_at))\n end",
"def show\n @rooms = { \n items: Room.all, \n }\n if room = Room.find_by(id: params[:id])\n response_data = {\n room: room,\n messages: module_get_messages(room)\n }\n status= :ok\n else \n status= :unprocessable_entity\n end\n\n #puts \"#######################\"\n #puts @room.as_json(:include => @messages)\n #puts Room.includes(:messages.limit(2)).find(params[:id] || 1).as_json(:include => :messages)\n\n respond_to do |format|\n format.html\n format.json { render json: response_data, status: status }\n end\n end",
"def show\n @rooms = @blueprint.rooms\n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rooms }\n end\n end",
"def room_list\n @rooms = Room.where(active: true)\n render partial: \"room_list\"\n end",
"def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def index\n @rooms = Room.all\n room_list = []\n @rooms.each do |room|\n room_list << room.to_hash_with_users(current_user)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: room_list.to_json}\n end\n end",
"def index\n bookings = Room.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all rooms', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def index\n @rooms = Room.paginate(:page => params[:page])\n end",
"def user_rooms\n @rooms = Room.where(user_id: params[:user_id], state: \"published\")\n .page(params[:page]).per(10)\n paginate_rooms @rooms\n end",
"def fetch(room_id)\n url = NSURL.URLWithString \"#{settings.host}/rooms/#{room_id}.json\"\n puts \"Requesting #{settings.host}/#{room_id}.json\"\n request = ASIHTTPRequest.requestWithURL(url)\n request.setDelegate self\n request.addRequestHeader \"X-Talker-Token\", value:settings.token\n request.startAsynchronous\n end",
"def show\n @user=User.find(params[:user_id])\n @room=@user.rooms.find(params[:id])\n render json: @room if stale?(@room)\n end",
"def list_rooms\n @rooms.each do |room_name, cap| \n puts \"#{room_name} #{cap.available_space()}\"\n end\n end",
"def rooms\n response = self.class.get(@api.user_joined_rooms_config[:url],\n :query => { :auth_token => @token }.merge(@api.user_joined_rooms_config[:query_params]),\n :headers => @api.headers\n )\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n User.new(@token, response.merge(:api_version => @api.version))\n end",
"def room_list\n @roomtype = DetailRoom.all_types\n @time = Room.all_times\n @day_list = Room.all_days\n if session[:admin] == nil\n redirect_to rooms_path\n end\n @admin = session[:admin]\n @rooms = {} \n @roomtype.each do |type|\n @rooms[type] = DetailRoom.find_all_by_room_type(type)\n end \n end",
"def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def list_rooms \\\n page_size,\n page_token,\n options: nil,\n &block\n request = {\n page_size: page_size,\n page_token: page_token\n }.delete_if { |_, v| v.nil? }\n request = Google::Gax.to_proto request, Google::Showcase::V1alpha3::ListRoomsRequest\n @list_rooms.call(request, options, &block)\n end",
"def index\n @rooms_count = Room.all.count\n\n search = \"(r:Room)-[]->(b:Building)\"\n request = ActiveGraph::Base.new_query.match(search).order(@sort_string).skip(@skip).limit(@limit)\n\n @rooms = request.pluck('r')\n end",
"def index\n @kind_rooms = KindRoom.all\n end",
"def index\n ota_rooms = Array.new\n if params[:room].nil? && params[:ota].nil?\n # 自分の施設情報だけを返す\n\n current_user.ota.select do |otum|\n otum.provider == 'default'\n end.each do |otum|\n ota_rooms.concat(otum.ota_rooms)\n end\n elsif params[:ota].nil?\n room = Room.find_by(id: params[:room].to_i)\n # 部屋IDが存在しない場合\n if room.nil?\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != room.user.id\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(room.ota_rooms)\n elsif params[:room].nil?\n otum = Otum.find_by(id: params[:ota].to_i)\n # OTA IDが存在しない場合\n if otum.nil?\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != otum.user.id\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(otum.ota_rooms)\n else\n # facility=[facility_id]\n facility = Facility.find_by(id: params[:facility].to_i)\n # 施設IDが存在しない場合\n if facility.nil?\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n # ユーザーの施設IDでない場合\n if facility.user_id != current_user.id\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(facility.ota_rooms)\n end\n\n render json: {\n status: 'Success',\n message: '',\n ota_rooms: ota_rooms.as_json(except: [\n :created_at,\n :updated_at\n ])\n }, status: 200\n end",
"def show\n @request = Request.find(params[:id])\n\n if current_user.admin?\n @available_rooms = get_available_rooms @request\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end",
"def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend",
"def find_available_rooms(rooms, start_date: Date.today, end_date: Date.today + 2)\n return Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n end",
"def list_all_rooms_in_hotel\n\n return @rooms.map { |room| room }\n end",
"def rooms_list\n\t\t\t@rooms.map {|room| \"Room: #{room.id}\"}.join(\", \")\n\t\tend",
"def index\n @classrooms = Classroom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @classrooms }\n end\n end",
"def index\n @rooms = Room.where(\"status != 'CANCELLED'\").order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def search_rooms\n end",
"def index\n @meetingrooms = @space.meetingrooms.all\n end",
"def show\n if params[:id]\n current_user # initialize @current_user\n\n @room = {\n \t:name => params[:id],\n \t:url => RTCHelper::getRoomURL(params[:id]),\n \t:token => RTCHelper::getAuthToken(params[:id], @current_user)\n }\n else\n #\n # if there is no room, we really wanted to go to /rooms/index\n #\n redirect_to :action => 'index'\n end\n end",
"def local_rooms\n @local_rooms ||= begin\n room_hashes = @data['rooms'] || []\n room_hashes.map { |hash| Room.new(hash) }\n end\n end",
"def list_reserved_rooms\n unless @rooms.empty?\n @rooms.each do |key, room|\n puts room.report_lister\n end\n end\n end",
"def get_room(id)\n @rooms[id]\n end",
"def index\n @rooms = Room.includes(:hotel, :users).order('hotels.name ASC, number')\n\n respond_to do |format|\n format.html\n format.json { render json: @rooms }\n end\n end",
"def index\n @about_rooms = AboutRoom.all\n end",
"def index\n @rooms = Room.all\n @rooms = @rooms.search(params[:search]) if params[:search].present?\n end",
"def get_room(params)\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}\"), :query_params => params)\n return unless res.successful?\n Room::Detail.new(res.data)\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def all_rooms\n @rooms.each do |room|\n puts \"Room Number: #{room.number} | Nightly Rate: #{room.cost}\"\n end \n end",
"def new\n @room = Room.new\n\n render :json => @room \n end",
"def index\n @rooms = Room.all\n @room = Room.new\n end",
"def refresh\n @room = Room.find(params[:room_id])\n respond_to do |format|\n format.json { render :json => @room }\n format.html\n end\n end",
"def fetch_rooms_values(lcode, dfrom, dto, rooms = nil, token = @token)\n if rooms != nil then\n response = server.call(\"fetch_rooms_values\", token, lcode, dfrom.strftime('%d/%m/%Y'), dto.strftime('%d/%m/%Y'), rooms)\n else\n response = server.call(\"fetch_rooms_values\", token, lcode, dfrom.strftime('%d/%m/%Y'), dto.strftime('%d/%m/%Y'))\n end\n\n handle_response(response, \"Unable to fetch room values\")\n end",
"def show\n\t\trender json: @room_user\n\tend",
"def index\n @rooms = Room.all\n @rooms = @venue.rooms.all\n end",
"def index\n @reservation_rooms = ReservationRoom.all\n end",
"def index\n\t\t#this is the home page\n\t\t@rooms = Room.limit(5)\n\tend",
"def get_room_messages(company, room_id, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.get '/messages/v3/' + company + '/rooms/' + room_id + '/stories', params\n end",
"def index\n @search = @rooms.search(params[:q])\n @rooms = @search.result.paginate(:page => params[:page])\n end",
"def show\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tddbc_room }\n end\n end",
"def index\n @occupied_rooms = OccupiedRoom.all\n end",
"def index\n @reserved_rooms = ReservedRoom.all\n end",
"def show\n @room = Room.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @room }\n format.js {}\n end\n end",
"def show\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_room }\n end\n end",
"def show\n @room_items = RoomItem.all\n end"
] |
[
"0.788489",
"0.78231525",
"0.7690326",
"0.76826984",
"0.76242465",
"0.7573095",
"0.75299007",
"0.737599",
"0.7297831",
"0.72899485",
"0.7252718",
"0.7222336",
"0.7193262",
"0.71638155",
"0.7132772",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7118043",
"0.7018054",
"0.6999112",
"0.69862443",
"0.69712985",
"0.696389",
"0.69285285",
"0.69276303",
"0.69276303",
"0.69276303",
"0.69048995",
"0.6885724",
"0.6864905",
"0.68485343",
"0.6825147",
"0.6815783",
"0.6808111",
"0.679196",
"0.6733203",
"0.67190737",
"0.6715162",
"0.66928303",
"0.66906226",
"0.6667032",
"0.6653976",
"0.6640101",
"0.66392946",
"0.6635087",
"0.6634294",
"0.6613107",
"0.66095996",
"0.66090167",
"0.6604269",
"0.6603369",
"0.66013664",
"0.65879565",
"0.6571818",
"0.65639085",
"0.65591896",
"0.6552621",
"0.65491664",
"0.6543772",
"0.6536506",
"0.6531011",
"0.64976573",
"0.64809763",
"0.6480943",
"0.6479337",
"0.6478856",
"0.64691377",
"0.6441961",
"0.64201057",
"0.64024615",
"0.63934284",
"0.63934284",
"0.63934284",
"0.63934284",
"0.63934284",
"0.63934284",
"0.6375577",
"0.637298",
"0.63561845",
"0.63236403",
"0.632288",
"0.6307643",
"0.6307394",
"0.630551",
"0.6305326",
"0.62952894",
"0.6287059",
"0.6274789",
"0.626491",
"0.6257439",
"0.6256635",
"0.6255823",
"0.6245572"
] |
0.0
|
-1
|
GET /rooms/1 GET /rooms/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def index\n rooms = Room.includes(:problems, :registrations, :users, :owner)\n if params[:name]\n render json: rooms.where(name: params[:name])\n else\n render json: rooms\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n render '/api/rooms/show'\n end",
"def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:user_id]\n @room_ids = Member.where(user_id: @user_id).pluck(:room_id)\n\n @rooms = Room.find(@room_ids)\n #render json: @rooms\n \n @roomList = []\n #@rooms.each { |room|\n for room in @rooms do\n #@room = Room.find_by(id: room_id)\n temp = {}\n temp.store(\"room_id\",room.id)\n temp.store(\"room_name\", room.name) \n temp.store(\"room_token\", room.token)\n @roomList.push(temp)\n end\n render json: {rooms: @roomList}, status: 200\n end",
"def get_rooms \n json_rooms = IO.popen(\"curl -u #{@config['campfire_config']['API_KEY']}:X #{@config['campfire_config']['URL']}/presence.json\") \n parsed_rooms = JSON.parse(json_rooms.readlines.first)[\"rooms\"]\n rooms = parsed_rooms.collect {|room| [room[\"name\"],room[\"id\"]]} \nend",
"def show\n @restroom = Restroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def show\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n end\n end",
"def show\n @rooms = Room.all\n end",
"def get_room(id)\n @rooms[id]\n end",
"def show\n @user=User.find(params[:user_id])\n @room=@user.rooms.find(params[:id])\n render json: @room if stale?(@room)\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def index\n @rooms = Room.all\n end",
"def get_all_rooms(params = {})\n res = call_api(:method => :get, :uri => @api_base.merge(\"room\"), :query_params => params)\n return unless res.successful?\n Rooms.new(res.data)\n end",
"def show\n if params[:id]\n current_user # initialize @current_user\n\n @room = {\n \t:name => params[:id],\n \t:url => RTCHelper::getRoomURL(params[:id]),\n \t:token => RTCHelper::getAuthToken(params[:id], @current_user)\n }\n else\n #\n # if there is no room, we really wanted to go to /rooms/index\n #\n redirect_to :action => 'index'\n end\n end",
"def get_rooms(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.get '/messages/v3/' + company + '/rooms', params\n end",
"def find \n @user = User.find(params[:user_id])\n @room = @user.rooms.where(:name => params[:name])\n render json: @room if stale?(etag: @room.all, last_modified: @room.maximum(:updated_at))\n end",
"def fetch(room_id)\n url = NSURL.URLWithString \"#{settings.host}/rooms/#{room_id}.json\"\n puts \"Requesting #{settings.host}/#{room_id}.json\"\n request = ASIHTTPRequest.requestWithURL(url)\n request.setDelegate self\n request.addRequestHeader \"X-Talker-Token\", value:settings.token\n request.startAsynchronous\n end",
"def index\n @user = User.find(params[:user_id])\n @rooms = @user.rooms.all\n render json: @rooms if stale?(etag: @rooms.all, last_modified: @rooms.maximum(:updated_at))\n end",
"def show\n @rooms = { \n items: Room.all, \n }\n if room = Room.find_by(id: params[:id])\n response_data = {\n room: room,\n messages: module_get_messages(room)\n }\n status= :ok\n else \n status= :unprocessable_entity\n end\n\n #puts \"#######################\"\n #puts @room.as_json(:include => @messages)\n #puts Room.includes(:messages.limit(2)).find(params[:id] || 1).as_json(:include => :messages)\n\n respond_to do |format|\n format.html\n format.json { render json: response_data, status: status }\n end\n end",
"def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend",
"def index\n @branch_rooms = Room.get_all_rooms(params[:branch_id])\n \n render json: @branch_rooms\n end",
"def get_rooms(request_parameters)\r\n http_service.request_get(\"/json/bookings.getRooms\", request_parameters)\r\n # https://distribution-xml.booking.com/json/bookings.getRooms?rows=10&hotel_ids=121543\r\n end",
"def index\n @rooms = Room.all\n \n respond_to do |f|\n f.html\n end\n end",
"def index\n if authorise(request)\n auth_token = request.headers['Authorization1'].split(' ').last\n req = GetRoomsRequest.new(auth_token)\n serv = RoomServices.new\n resp = serv.get_rooms(req)\n render json: { status: resp.success, message: resp.message, data: resp.data }, status: :ok\n else\n render json: { status: false, message: 'Unauthorized' }, status: 401\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n render :json => @room \n end",
"def get_room(params)\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}\"), :query_params => params)\n return unless res.successful?\n Room::Detail.new(res.data)\n end",
"def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @room = Room.find(params[:id])\n end",
"def show\n @room = Room.find(params[:id])\n end",
"def refresh\n @room = Room.find(params[:room_id])\n respond_to do |format|\n format.json { render :json => @room }\n format.html\n end\n end",
"def index\n @restrooms = Restroom.all\n end",
"def index\n @rooms = current_user.rooms.all\n end",
"def show\n @rooms = @blueprint.rooms\n end",
"def show\n @room = Room.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @room }\n format.js {}\n end\n end",
"def get_rooms(page)\n page.links.collect { |link| { :name => link.to_s, :uri => link.uri } if link.uri.to_s[\"#{uri.to_s}/room\"] }.reject { |room| room.nil? }\n end",
"def show\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tddbc_room }\n end\n end",
"def show\n @request = Request.find(params[:id])\n\n if current_user.admin?\n @available_rooms = get_available_rooms @request\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request }\n end\n end",
"def index\n @hostel_rooms = HostelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hostel_rooms }\n end\n end",
"def show\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_room }\n end\n end",
"def index\n case current_type\n when 'owner'\n @rooms = owner_rooms\n when 'access'\n @rooms = access_rooms\n else\n @rooms = public_rooms\n end\n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rooms }\n end\n end",
"def index\n @hotel_rooms = HotelRoom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotel_rooms }\n end\n end",
"def index\n @rooms = Room.all.map do |rm|\n Room.cleanFetch(rm, current_user)\n end\n end",
"def list_all_rooms\n return @rooms\n end",
"def room\n Room.all.find { |room| room.id == room_id }\n end",
"def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end",
"def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end",
"def show\n buildingId = params[:id]\n @room = Room.where(building_id: buildingId)\n end",
"def index\n @request_rooms = RequestRoom.all\n end",
"def show\n @roombot = Roombot.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roombot }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def show\n @hostel_room = HostelRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hostel_room }\n end\n end",
"def index\n @rooms = Room.all\n @room = Room.new\n end",
"def find_room uri\n payload = { \"uri\" => uri }.to_json\n data = self.post \"#{api_prefix}/rooms\", payload\n\n Room.new(self, data)\n end",
"def show\n @room = Room.includes(:owner).find(params.require(:id))\n if @room\n success(body: @room, options: { include: [:owner] })\n else\n not_found\n end\n end",
"def show\n\t\trender json: @room_user\n\tend",
"def new\n @room = Hotel.find(params[:hotel_id]).rooms.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def index\n @rooms = Room.paginate(:page => params[:page])\n end",
"def show\n @class_room = ClassRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @class_room }\n end\n end",
"def rooms\n Hpricot(get.body).search(\"//h2/a\").collect do |a|\n Room.new(self, room_id_from_url(a.attributes['href']), a.inner_html)\n end\n end",
"def show\n @roomrate = Roomrate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roomrate }\n end\n end",
"def index\n @rooms = Room.where(\"status != 'CANCELLED'\").order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def index\n @kind_rooms = KindRoom.all\n end",
"def index\n bookings = Room.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all rooms', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def new\n @serverroom = Serverroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serverroom }\n end\n end",
"def show\n @room = Room.find(params[:id])\n \n render :json => @room.as_json(:date => params[:date])\n end",
"def show\n respond_to do |format|\n if @room\n format.html { render :show }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :error, status: @error[:status] }\n format.json { render json: {error: @error[:message]}, status: @error[:status] }\n end\n end\n end",
"def show\n @room_message = RoomMessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_message }\n end\n end",
"def index\n @classrooms = Classroom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @classrooms }\n end\n end",
"def get_room_details(company, room_id, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.get '/messages/v3/' + company + '/rooms/' + room_id, params\n end",
"def show\n @screeningroom = Screeningroom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @screeningroom }\n end\n end",
"def show\n @serverroom = Serverroom.find(params[:id])\n @serverrack = Serverrack.new\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serverroom }\n end\n end",
"def show\n @classroom = classroom.find(params[:id])\n\n render json: @classroom\n end",
"def get_room \\\n name,\n options: nil,\n &block\n request = {\n name: name\n }.delete_if { |_, v| v.nil? }\n request = Google::Gax.to_proto request, Google::Showcase::V1alpha3::GetRoomRequest\n @get_room.call(request, options, &block)\n end",
"def index\n ota_rooms = Array.new\n if params[:room].nil? && params[:ota].nil?\n # 自分の施設情報だけを返す\n\n current_user.ota.select do |otum|\n otum.provider == 'default'\n end.each do |otum|\n ota_rooms.concat(otum.ota_rooms)\n end\n elsif params[:ota].nil?\n room = Room.find_by(id: params[:room].to_i)\n # 部屋IDが存在しない場合\n if room.nil?\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != room.user.id\n response = {\n status: 'NotFound',\n message: 'room not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(room.ota_rooms)\n elsif params[:room].nil?\n otum = Otum.find_by(id: params[:ota].to_i)\n # OTA IDが存在しない場合\n if otum.nil?\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n # 権限がない場合\n if current_user.id != otum.user.id\n response = {\n status: 'NotFound',\n message: 'ota not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(otum.ota_rooms)\n else\n # facility=[facility_id]\n facility = Facility.find_by(id: params[:facility].to_i)\n # 施設IDが存在しない場合\n if facility.nil?\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n # ユーザーの施設IDでない場合\n if facility.user_id != current_user.id\n response = {\n status: 'NotFound',\n message: 'ota_rooms not found'\n }\n return render json: response, status: 404\n end\n ota_rooms.concat(facility.ota_rooms)\n end\n\n render json: {\n status: 'Success',\n message: '',\n ota_rooms: ota_rooms.as_json(except: [\n :created_at,\n :updated_at\n ])\n }, status: 200\n end",
"def room_list\n @rooms = Room.where(active: true)\n render partial: \"room_list\"\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @room }\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @room }\n end\n end",
"def index\n @rooms = Room.all\n room_list = []\n @rooms.each do |room|\n room_list << room.to_hash_with_users(current_user)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: room_list.to_json}\n end\n end",
"def index\n @rooms_count = Room.all.count\n\n search = \"(r:Room)-[]->(b:Building)\"\n request = ActiveGraph::Base.new_query.match(search).order(@sort_string).skip(@skip).limit(@limit)\n\n @rooms = request.pluck('r')\n end"
] |
[
"0.7478235",
"0.7468609",
"0.7457006",
"0.7416629",
"0.7338858",
"0.73378056",
"0.73378056",
"0.73378056",
"0.72945076",
"0.7131917",
"0.707778",
"0.7031814",
"0.70124215",
"0.69494665",
"0.6912663",
"0.6889057",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68889284",
"0.68867886",
"0.68825895",
"0.68785167",
"0.6871447",
"0.68700135",
"0.685577",
"0.6843131",
"0.6831034",
"0.68231",
"0.6822931",
"0.67940575",
"0.6781406",
"0.6762789",
"0.6762789",
"0.6762789",
"0.6762789",
"0.6762789",
"0.6762789",
"0.674762",
"0.6736765",
"0.673606",
"0.6728097",
"0.6728097",
"0.67276734",
"0.6688879",
"0.6680902",
"0.6662042",
"0.6598141",
"0.6581501",
"0.6578644",
"0.6577056",
"0.6573992",
"0.65737766",
"0.65724385",
"0.65610325",
"0.6537427",
"0.653421",
"0.65330535",
"0.6529699",
"0.65263927",
"0.65263927",
"0.6499212",
"0.64961064",
"0.64869547",
"0.6462142",
"0.64617926",
"0.6459374",
"0.64571023",
"0.6453178",
"0.64234585",
"0.6419444",
"0.64151645",
"0.6380739",
"0.6376626",
"0.63742566",
"0.6364234",
"0.63615584",
"0.6341172",
"0.6337515",
"0.6331272",
"0.63037974",
"0.62964016",
"0.6284451",
"0.6279403",
"0.62781674",
"0.6270402",
"0.6266842",
"0.62563556",
"0.6227572",
"0.6226138",
"0.62189114",
"0.62189114",
"0.6214463",
"0.61955374"
] |
0.0
|
-1
|
POST /rooms POST /rooms.json
|
def create
@room = Room.new(room_params)
@room.name = "Room " +@room.name
@room.admin_id = current_admin.id
respond_to do |format|
if @room.save
format.html { redirect_to rooms_path , notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @room }
else
format.html { render :new }
format.json { render json: @room.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @room = Room.new(params[:room])\n\n if @room.save\n render :json => @room, :status => :created, :location => @room\n else\n render :json => @room.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @user=User.find(params[:user_id])\n @room = @user.rooms.create(room_params)\n if @room.save\n render json: @room, status: :created\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end",
"def create\n @room = current_user.rooms.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n room = params[:room]\n if Room.find_by_room_id(room[\"room_id\"]) == nil\n @room = Room.new(params[:room])\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"can not add new room\"\n redirect_to new_room_path\n end\n end",
"def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_rooms(rooms_params)\n\t\trooms_params[:extra_info] ||= \"\"\n\n\t\trooms_params[:range].each do |number|\n\t\t\trooms << Room.create( number: number.to_i, \n\t\t\t\t\t\t\t\t\t\t\t\t\t capacity: rooms_params[:capacity].to_i, \n\t\t\t\t\t\t\t\t\t\t\t\t\t extra_info: rooms_params[:extra_info],\n\t\t\t\t\t\t\t\t\t\t\t\t\t name: rooms_params[:name] )\n\t\tend\n\tend",
"def create\n puts room_params\n puts params\n @room = Room.new(room_params)\n\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to \"/rooms/new\", notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@room = Room.new(room_params) \n\n\t\trespond_to do |format|\n\t\t\tif @room.save\n\t\t\t\tformat.html { redirect_to @room, notice: 'Room was successfully created.' }\n\t\t\t\tformat.json { render json: @room, status: :created}\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @room.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @room = TmuAdmin::Room.new(room_params)\n\n if @room.save\n render :json => {}\n else\n error_messages = @room.errors.full_messages.collect { |error_message| \"<li>\" + error_message + \"</li>\" }\n\n render :json => {:errorMsg => \"<ul>\" + error_messages.join(\"\") + \"</ul>\"}\n end\n end",
"def add_item_to_the_room\n @item = Item.find(params[:id])\n @room = Room.find(params[:room_id])\n \n @item.rooms << @room\n \n render json: @item, include: :rooms\n\n end",
"def create\n @room = Room.new(room_params)\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: t('default.room.created') }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @error, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @serverroom = Serverroom.new(params[:serverroom])\n\n respond_to do |format|\n if @serverroom.save\n format.html { redirect_to @serverroom, notice: 'Serverroom was successfully created.' }\n format.json { render json: @serverroom, status: :created, location: @serverroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serverroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n @room.admin_id = current_user.id\n @room.users.push(current_user)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: \"Room was successfully created.\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @room = Hotel.find(params[:hotel_id]).rooms.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def create_room(company, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.post '/messages/v3/' + company + '/rooms', params\n end",
"def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to hotel_path @room.hotel, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @request_room = RequestRoom.new(request_room_params)\n\n respond_to do |format|\n if @request_room.save\n format.html { redirect_to @request_room, notice: 'Request room was successfully created.' }\n format.json { render :show, status: :created, location: @request_room }\n else\n format.html { render :new }\n format.json { render json: @request_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: t('flash.room.create') }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reserved_room = ReservedRoom.new(reserved_room_params)\n\n respond_to do |format|\n if @reserved_room.save\n format.html { redirect_to @reserved_room, notice: 'Reserved room was successfully created.' }\n format.json { render :show, status: :created, location: @reserved_room }\n else\n format.html { render :new }\n format.json { render json: @reserved_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, :flash => { success: 'Room was successfully created.' } }\n format.json { render action: 'show', status: :created, location: @room }\n else\n format.html { render action: 'new' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Помещение успешно добавлено' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, alert: 'Что-то пошло не так' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @room = Room.new\n\n render :json => @room \n end",
"def create\n \n @room = Room.new(room_params)\n \n @room.user_id = current_user&.id\n \n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { redirect_to rooms_path, notice: 'Room was failed.' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n param = room_params\n \n roomtype=Roomtype.new\n roomtype.AC=param[:AC]\n roomtype.beds=param[:beds].to_i\n param.delete(\"AC\")\n param.delete(\"beds\")\n @room = current_hotel.rooms.build(param)\n respond_to do |format|\n if @room.save\n roomtype.room_id=@room.id\n roomtype.save\n format.html { redirect_to @room, notice: \"Room was successfully created.\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restroom = Restroom.new(restroom_params)\n\n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render action: 'show', status: :created, location: @restroom }\n else\n format.html { render action: 'new' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'La Sala ha sido creada correctamente!' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(params[:room])\n @room.room_string = random_string\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to room_path(@room.room_string), notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = current_user.rooms.create({name: params[:room][:name],\n max_user: params[:room][:max_user],\n host_id: current_user.id,\n salvo: params[:room][:salvo],\n occupancy: 1\n })\n @room.set_user_status(current_user, USER_STATUS[:join])\n @room.status = ROOM_STATUS[:open]\n # Broadcast a message\n channel = \"server_channel\"\n respond_message = {\n message: \"a room created\",\n }\n\n self.broadcast_message_to_channel(channel, :room_created, respond_message)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @room = Room.new(room_params)\n \n if @room.user == nil\n room.user = \"\"\n end\n \n respond_to do |format|\n if @room.save\n format.html { redirect_to rooms_path, notice: \"Sala '\" + @room.name + \"' criada com sucesso!\" }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_room = Room.new(admin_room_params)\n @room_detail = @admin_room.room_detail\n\n respond_to do |format|\n if @admin_room.save\n format.html { redirect_to @admin_room, notice: 'Room was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_room }\n else\n format.html { render action: 'new' }\n format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = current_user.rooms.build(room_params)\n if @room.save\n flash[:success] = 'room was created'\n redirect_to rooms_path\n else\n render 'new'\n end\n end",
"def create\n @room = Room.new(room_params)\n\n if @room.save\n redirect_to admin_rooms_path, notice: 'Room was successfully created.'\n else\n render new\n end\n end",
"def create\n config_opentok\n session = @opentok.create_session request.remote_addr\n params[:room][:sessionId] = session.session_id\n \n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render json: @room, status: :created, location: @room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @occupied_room = OccupiedRoom.new(occupied_room_params)\n\n respond_to do |format|\n if @occupied_room.save\n format.html { redirect_to @occupied_room, notice: 'Occupied room was successfully created.' }\n format.json { render :show, status: :created, location: @occupied_room }\n else\n format.html { render :new }\n format.json { render json: @occupied_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def new\n @room = Room.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @room }\n end\n end",
"def create\n p = admin_room_params\n p[:building_id] = params[:building_id]\n @admin_room = Room.new(p)\n\n respond_to do |format|\n if @admin_room.save\n format.html { redirect_to [:admin, @admin_room.building], notice: 'Room was successfully created.' }\n # format.json { render :show, status: :created, location: @admin_room.building }\n else\n format.html { render :new }\n # format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @empty_room = EmptyRoom.new(empty_room_params)\n\n respond_to do |format|\n if @empty_room.save\n format.html { redirect_to @empty_room, notice: 'Empty room was successfully created.' }\n format.json { render :show, status: :created, location: @empty_room }\n else\n format.html { render :new }\n format.json { render json: @empty_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @serverroom = Serverroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serverroom }\n end\n end",
"def create\n @room.save\n respond_with(@room, location: bnb_rooms_url(@bnb))\n end",
"def create\n @hotel_room = HotelRoom.new(params[:hotel_room])\n\n respond_to do |format|\n if @hotel_room.save\n format.html { redirect_to @hotel_room, notice: 'Hotel room was successfully created.' }\n format.json { render json: @hotel_room, status: :created, location: @hotel_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hotel_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n room = Room.new(room_params)\n if room.save\n response_data = {\n room: room,\n txt: ['投稿しました!'],\n }\n render json: response_data, status: :created\n else\n response_data = {\n txt: room.errors.full_messages,\n }\n render json: response_data, status: :unprocessable_entity\n end\n end",
"def create\n @room = Room.new(params[:room])\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to(@room, :notice => 'Room was successfully created.') }\n format.xml { render :xml => @room, :status => :created, :location => @room }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n #authorize! :create, @restroom\n @restroom = Restroom.new(params[:restroom])\n @restroom.user_id=current_user.id \n \n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render json: @restroom, status: :created, location: @restroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #authorize! :create, @restroom\n @restroom = Restroom.new(params[:restroom])\n @restroom.user_id=current_user.id \n \n respond_to do |format|\n if @restroom.save\n format.html { redirect_to @restroom, notice: 'Restroom was successfully created.' }\n format.json { render json: @restroom, status: :created, location: @restroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def create\n if authorise(request)\n auth_token = request.headers['Authorization1'].split(' ').last\n req = CreateEscapeRoomRequest.new(params[:name], auth_token)\n serv = RoomServices.new\n resp = serv.create_escape_room(req)\n render json: { status: 'SUCCESS', message: 'Added room id:', data: resp }, status: :ok\n else\n render json: { status: 'FAILED', message: 'Unauthorized' }, status: 401\n end\n end",
"def create\n @reservation_room = ReservationRoom.new(reservation_room_params)\n @reservations = Reservation.all\n \n respond_to do |format|\n if @reservation_room.save\n format.html { redirect_to @reservation_room, notice: 'La habitacion se ha asignado a la reserva correctamente.' }\n format.json { render action: 'show', status: :created, location: @reservation_room }\n else\n format.html { render action: 'new' }\n format.json { render json: @reservation_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @services_room = ServicesRoom.new(services_room_params)\n\n respond_to do |format|\n if @services_room.save\n format.html { redirect_to room_services_rooms_path(@services_room.room_id,@services_room.id), notice: 'Services room was successfully created.' }\n format.json { render :show, status: :created, location: @services_room }\n else\n format.html { render :new }\n format.json { render json: @services_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n respond_to do |format|\n if @room.save\n if params[:hotel_id].present?\n @room.hotel = params[:hotel_id]\n end\n create_amenity\n create_damage\n format.html { redirect_to hotel_path(@room.hotel_id), notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @room_item = RoomItem.create(params.require(:room_item).permit(:Room_id, :Item_id))\n respond_to do |format|\n if @room_item.save\n format.html { redirect_to @room_item, notice: \"Room item was successfully created.\" }\n format.json { render :show, status: :created, location: @room_item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @room_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meetingroom = @space.meetingrooms.new(meetingroom_params)\n @meetingroom.user = current_user\n\n respond_to do |format|\n if @meetingroom.save\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully created.' }\n format.json { render :show, status: :created, location: [@space, @meetingroom] }\n else\n format.html { render :new }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n\n @room = Room.new(room_params)\n if @room.save\n redirect_to @room\n else\n render 'new'\n end\n end",
"def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end",
"def new\n @restroom = Restroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @restroom }\n end\n end",
"def create\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n seatQuantity = (@room.rows * @room.columns)\n (1..seatQuantity).each do |i|\n @seating = Seating.create! slot: true,\n room_id: @room.id\n @seating.save\n end\n format.html { redirect_to edit_room_path(@room), notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user.utype == \"admin\"\n @room = Room.new(room_params)\n\n respond_to do |format|\n if @room.save\n format.html { redirect_to @room }\n flash[:success] ='Room was successfully created.'\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to unauthorized_url\n end\n end",
"def create_rooms(rooms_id_array)\n if self.room_areas.empty?\n 1.upto(self.bedrooms) do \n room_area = RoomArea.new(:property_id => self.id,\n :room_id => Room.find_by_name(\"Room\").id)\n room_area.save\n end\n end\n for room_id in rooms_id_array do\n room_area = RoomArea.new(:property_id => self.id,\n :room_id => room_id)\n room_area.save\n end\n end",
"def get_rooms\n # DO NOT DELETE. Condition used for load testing\n @user_id = (params.has_key? :user_id) ? params[:user_id] : session[:user_id]\n @room_ids = Member.where(user_id: @user_id).pluck(:room_id)\n\n @rooms = Room.find(@room_ids)\n #render json: @rooms\n \n @roomList = []\n #@rooms.each { |room|\n for room in @rooms do\n #@room = Room.find_by(id: room_id)\n temp = {}\n temp.store(\"room_id\",room.id)\n temp.store(\"room_name\", room.name) \n temp.store(\"room_token\", room.token)\n @roomList.push(temp)\n end\n render json: {rooms: @roomList}, status: 200\n end",
"def create\n @room = Room.new(room_params)\n @room.hotel = Hotel.find_by_name(params[:room][:hotel])\n \n respond_to do |format|\n if @room.save\n format.html { redirect_to crew_rooms_path, notice: 'Quarto foi criado com sucesso.' }\n format.json { render :edit, status: :created, location: @room }\n else\n format.html do\n set_hotel_names\n render :new \n end \n\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tddbc_room = Tddbc::Room.new(params[:tddbc_room])\n\n respond_to do |format|\n if @tddbc_room.save\n format.html { redirect_to @tddbc_room, notice: 'Room was successfully created.' }\n format.json { render json: @tddbc_room, status: :created, location: @tddbc_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tddbc_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n @room = @venue.rooms.new(room_params)\n\n if @room.save\n redirect_to venue_rooms_path\n else\n render :action => 'new'\n end\n end",
"def create\n @roomtable = Roomtable.new(roomtable_params)\n\n respond_to do |format|\n if @roomtable.save\n format.html { redirect_to @roomtable, notice: 'Roomtable was successfully created.' }\n format.json { render :show, status: :created, location: @roomtable }\n else\n format.html { render :new }\n format.json { render json: @roomtable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_a_room_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RoomsApi.add_a_room ...'\n end\n # resource path\n local_var_path = '/rooms'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n auth_names = ['OAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse201')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoomsApi#add_a_room\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def room_params\n params.require(:room).permit(:name, :ubication, :location_id, :noise, :sockets, :availability)\n end",
"def create\n operation = params[:operation]\n case operation\n when 'add_public'\n if authorise(request)\n auth_token = request.headers['Authorization1'].split(' ').last\n req = AddPublicRoomRequest.new(auth_token, params['escape_room_id'])\n resp = @@serv.add_public_room(req)\n render json: { success: resp.success, message: resp.message }, status: :ok\n end\n when 'add_rating'\n auth_token = request.headers['Authorization1'].split(' ').last\n req = AddRatingRequest.new(params[:roomID], auth_token, params[:rating])\n resp = @@serv.add_rating(req)\n render json: { success: resp.success, message: resp.message }, status: :ok\n else\n render json: { success: false, message: 'Operation does not exist' }, status: :bad_request\n end\n end",
"def room_params\n params.require(:room).permit(:name)\n end",
"def room_params\n params.require(:room).permit(:name)\n end",
"def room_params\n params.require(:room).permit(:name, :description, :floor_id, :capacity,\n :computers, :roomtype_id)\n end",
"def room_params\n params.require(:room).permit(:room_name)\n end",
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def index\n @rooms = Room.all\n @room = Room.new\n end",
"def create\n @screeningroom = Screeningroom.new(params[:screeningroom])\n\n respond_to do |format|\n if @screeningroom.save\n format.html { redirect_to @screeningroom, notice: 'Screeningroom was successfully created.' }\n format.json { render json: @screeningroom, status: :created, location: @screeningroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @screeningroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kind_room = KindRoom.new(kind_room_params)\n\n respond_to do |format|\n if @kind_room.save\n format.html { redirect_to @kind_room, notice: 'Kind room was successfully created.' }\n format.json { render :show, status: :created, location: @kind_room }\n else\n format.html { render :new }\n format.json { render json: @kind_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hostel_room = HostelRoom.new(params[:hostel_room])\n\n respond_to do |format|\n if @hostel_room.save\n format.html { redirect_to @hostel_room, notice: 'Hostel room was successfully created.' }\n format.json { render json: @hostel_room, status: :created, location: @hostel_room }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hostel_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@room_user = Post.new(room_user_params)\n\n\t\tif @room_user.save\n\t\t\trender json: @room_user\n\t\telse\n\t\t\trender json: @room_user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def create\n authorize room\n\n if room_params[:public]\n authorize room, :create_public?\n end\n\n respond_to do |format|\n if room.save\n current_or_guest_user.add_role :owner, room\n\n format.html { redirect_to room, notice: I18n.t('rooms.successfully_created') }\n format.json { render :show, status: :created, location: room }\n else\n format.html { render :new }\n format.json { render json: room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def room_params\n params.require(:room).permit(:room_no, :size, :lib_name, :status)\n end",
"def create\n \n @chatroom = Chatroom.new(params[:chatroom])\n \n respond_to do |format|\n if @chatroom.save\n format.html { redirect_to @chatroom, notice: 'Chatroom was successfully created.' }\n format.json { render json: @chatroom, status: :created, location: @chatroom }\n else\n format.html { render action: \"new\" }\n format.json { render json: @chatroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def room_params\n params.require(:room).permit(:title, :location, :description, :user_id)\n end",
"def create\n @about_room = AboutRoom.new(about_room_params)\n\n respond_to do |format|\n if @about_room.save\n format.html { redirect_to @about_room, notice: 'About room was successfully created.' }\n format.json { render :show, status: :created, location: @about_room }\n else\n format.html { render :new }\n format.json { render json: @about_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message_room = MessageRoom.new(message_room_params)\n\n respond_to do |format|\n if @message_room.save\n format.html { redirect_to @message_room, notice: 'Message room was successfully created.' }\n format.json { render :show, status: :created, location: @message_room }\n else\n format.html { render :new }\n format.json { render json: @message_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def room_params\n params.require(:room).permit(:code, :leader, :farmer_count, :robber_count, :investigator_count, :donator_count, :number_of_rounds, :time_per_round)\n end",
"def room_params\n params.require(:room).permit(:title, :code, :building_id)\n end",
"def room_params\n params.require(:room).permit(:title, :code, :building_id)\n end",
"def create_room\n Room.new\n end",
"def room_params\n params.require(:room).permit(:name, :description)\n end",
"def create\n @workroom = Workroom.new(workroom_params)\n\n respond_to do |format|\n if @workroom.save\n format.html { redirect_to @workroom, notice: 'Workroom was successfully created.' }\n format.json { render :show, status: :created, location: @workroom }\n else\n format.html { render :new }\n format.json { render json: @workroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roombot = Roombot.new(params[:roombot])\n\n respond_to do |format|\n if @roombot.save\n format.html { redirect_to @roombot, notice: 'Roombot was successfully created.' }\n format.json { render json: @roombot, status: :created, location: @roombot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @roombot.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.72056574",
"0.707968",
"0.69656384",
"0.6932348",
"0.68974215",
"0.68974215",
"0.6837064",
"0.68087316",
"0.67632353",
"0.67632353",
"0.67632353",
"0.67160654",
"0.66814065",
"0.66665167",
"0.6651527",
"0.6645849",
"0.6636827",
"0.66291404",
"0.65891176",
"0.656336",
"0.6555926",
"0.6538023",
"0.65296626",
"0.65290177",
"0.65281487",
"0.651995",
"0.6514537",
"0.65104264",
"0.64985245",
"0.6484565",
"0.646282",
"0.64611435",
"0.64525217",
"0.6434874",
"0.6402733",
"0.6384345",
"0.63728553",
"0.6367823",
"0.63643587",
"0.633572",
"0.6288495",
"0.6284896",
"0.6284896",
"0.6284896",
"0.6284896",
"0.6284896",
"0.6284896",
"0.62728065",
"0.6249037",
"0.6245662",
"0.6241023",
"0.6237167",
"0.62072337",
"0.6193557",
"0.6180268",
"0.6180268",
"0.6157319",
"0.6156418",
"0.6142758",
"0.61390215",
"0.61363196",
"0.6128983",
"0.612417",
"0.6112441",
"0.6107057",
"0.6107057",
"0.60953456",
"0.60919267",
"0.6085313",
"0.6084979",
"0.6082165",
"0.60727996",
"0.6066288",
"0.6060117",
"0.60601014",
"0.60433507",
"0.6033855",
"0.6028125",
"0.6028125",
"0.6026116",
"0.6022354",
"0.60146785",
"0.60006475",
"0.59845626",
"0.59837985",
"0.5974961",
"0.59672576",
"0.5945533",
"0.59287345",
"0.5925831",
"0.5905422",
"0.58984447",
"0.5892322",
"0.5888316",
"0.58879614",
"0.58879614",
"0.5884531",
"0.5880813",
"0.587872",
"0.58731794"
] |
0.635287
|
39
|
PATCH/PUT /rooms/1 PATCH/PUT /rooms/1.json
|
def update
respond_to do |format|
if @room.update(room_params)
format.html { redirect_to rooms_path, notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @room }
else
format.html { render :edit }
format.json { render json: @room.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @room = Room.find(params[:id])\n\n if @room.update_attributes(params[:room])\n head :ok\n else\n render :json => @room.errors, :status => :unprocessable_entity \n end\n end",
"def update\n if @room.update(room_params)\n render json: @room, status: :ok, serializer: RoomSerializer\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @room.update(room_params)\n head :no_content\n else\n render json: @room.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @request_room.update(request_room_params)\n format.html { redirect_to @request_room, notice: 'Request room was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_room }\n else\n format.html { render :edit }\n format.json { render json: @request_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to staff_path(@room.id), notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: staff_path(@room.id).errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update_attributes(room_params)\n format.html { redirect_to room_path(@room.slug), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: t('default.room.updated') }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @error, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @room.update(room_params_update)\n format.html { redirect_to @room, :flash => { success: 'Room was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @serverroom = Serverroom.find(params[:id])\n\n respond_to do |format|\n if @serverroom.update_attributes(params[:serverroom])\n format.html { redirect_to @serverroom, notice: 'Serverroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serverroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Filter only those valid to be updated\n updated_attributes = {}\n updated_attributes[:name] = params[:room][:name]\n updated_attributes[:max_user] = params[:room][:max_user]\n @room = current_user.rooms.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(updated_attributes)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render json: @room.to_hash_with_users(current_user).to_json }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to rooms_path, notice: \"Sala '\" + @room.name + \"' atualizada com sucesso!\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @room.update(room_params)\n\t\t\t\tformat.html { redirect_to @room, notice: 'Room was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @room }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @room.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to admin_rooms_path, notice: 'Room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n format.html { redirect_to(@room, :notice => 'Room was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @room.update_attributes(params[:room])\n respond_with(@room, location: bnb_rooms_url(@room.bnb))\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, alert: 'Что-то пошло не так' }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rooms\n if params[:coordinator_id].to_i == 0\n @coordinator = Coordinator.new\n else\n @coordinator = Coordinator.find(params[:coordinator_id])\n end\n core = Core.find(params[:core_id])\n @rooms = core.rooms\n @core = core\n\n respond_to do |format|\n format.js if request.xhr?\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: 'La Sala ha sido actualizada correctamente!' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n p '~~~update~~~'\n p user_params\n\n if @user.update(user_params)\n render json: @user.to_json(include: :rooms), status: :ok\n else\n render json: {error: @user.errors.full_messages.first}, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @admin_room.update(admin_room_params)\n format.html { redirect_to [:admin, @admin_room.building], notice: 'Room was successfully updated.' }\n # format.json { render :show, status: :ok, location: @admin_room }\n else\n format.html { render :edit }\n # format.json { render json: @admin_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @chatroom = Chatroom.find(params[:id])\n\n respond_to do |format|\n if @chatroom.update_attributes(params[:chatroom])\n format.html { redirect_to @chatroom, notice: 'Chatroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chatroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to hotel_path(@room.hotel_id), notice: 'Room was successfully updated.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @empty_room.update(empty_room_params)\n format.html { redirect_to @empty_room, notice: 'Empty room was successfully updated.' }\n format.json { render :show, status: :ok, location: @empty_room }\n else\n format.html { render :edit }\n format.json { render json: @empty_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hotel_room = HotelRoom.find(params[:id])\n\n respond_to do |format|\n if @hotel_room.update_attributes(params[:hotel_room])\n format.html { redirect_to @hotel_room, notice: 'Hotel room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotel_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_room\n\t@room_options = {}\n\t@room_options[\"data\"] = {}\n\trooms = Room.where(\"building_id = ?\",params[:building_id])\n\tif rooms.length == 0\n\t\t@room_options[\"data\"][\"\"] = \"\"\n\telse\n\t\trooms.each {|room|\n\t\t\t@room_options[\"data\"][room.id.to_s] = room.room_name\n\t\t}\n\tend\n\t@room_options[\"select_id\"] = \"#room_select_\" + params[:course_id]\n\tcourse_assignment = get_course_assignment(params[:course_id])\n\troom_id = course_assignment.room_id.to_s\n\tif room_id != nil\n\t\t@room_options[\"selected_val\"] = room_id\n\telse\n\t\t@room_options[\"selected_val\"] = \"\"\n\tend\n\trespond_to do |format|\n\t\tformat.json {render json: @room_options}\n\tend\n end",
"def update\n room = Room.find(params[:id])\n\n if room.update(room_params)\n response_data = {\n room: room,\n txt: ['更新しました!'],\n }\n render json: response_data, status: :ok\n else\n response_data = {\n txt: room.errors.full_messages,\n }\n render json: response_data, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @chat_room.update_attributes(params[:chat_room])\n format.html { redirect_to @chat_room, notice: 'Chat room was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chat_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n\n if @room.update(room_params)\n redirect_to @room\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to school_room_path(@room.school,@room), notice: 'Room update successful.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @room.update(room_params)\n redirect_to admin_rooms_path, notice: 'Room was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room}\n flash[:success] ='Room was successfully updated.'\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize room\n\n if room_params[:public]\n authorize room, :create_public?\n end\n\n respond_to do |format|\n if room.update(room_params)\n format.html { redirect_to room, notice: I18n.t('rooms.successfully_updated') }\n format.json { render :show, status: :ok, location: room }\n else\n format.html { render :edit }\n format.json { render json: room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.update(params.require(:id), room_attributes)\n if @room.valid?\n success\n else\n validation_errors(@room)\n end\n end",
"def update\n respond_to do |format|\n if @occupied_room.update(occupied_room_params)\n format.html { redirect_to @occupied_room, notice: 'Occupied room was successfully updated.' }\n format.json { render :show, status: :ok, location: @occupied_room }\n else\n format.html { render :edit }\n format.json { render json: @occupied_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rooms\n if params[:educator_id].to_i == 0\n @educator = Educator.new\n else\n @educator = Educator.find(params[:educator_id])\n end\n core = Core.find(params[:core_id])\n @rooms = core.rooms\n\n respond_to do |format|\n format.js if request.xhr?\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @kind_room.update(kind_room_params)\n format.html { redirect_to @kind_room, notice: 'Kind room was successfully updated.' }\n format.json { render :show, status: :ok, location: @kind_room }\n else\n format.html { render :edit }\n format.json { render json: @kind_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reserved_room.update(reserved_room_params)\n format.html { redirect_to @reserved_room, notice: 'Reserved room was successfully updated.' }\n format.json { render :show, status: :ok, location: @reserved_room }\n else\n format.html { render :edit }\n format.json { render json: @reserved_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @roombot = Roombot.find(params[:id])\n\n respond_to do |format|\n if @roombot.update_attributes(params[:roombot])\n format.html { redirect_to @roombot, notice: 'Roombot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @roombot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room_item.update(room_item_params)\n format.html { redirect_to @room_item, notice: \"Room item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room_item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n if @meeting_room.update(room_params)\n redirect_to meeting_rooms_path\n else\n render 'edit'\n end\n end",
"def edit\n @rooms = { \n items: Room.all, \n }\n end",
"def update\n @telecom_room = TelecomRoom.find(params[:id])\n\n respond_to do |format|\n if @telecom_room.update_attributes(params[:telecom_room])\n format.html { redirect_to(@telecom_room, :notice => 'TelecomRoom was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @telecom_room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @services_room.update(services_room_params)\n format.html { redirect_to room_services_rooms_path(@services_room.room_id), notice: 'Services room was successfully updated.' }\n format.json { render :show, status: :ok, location: @services_room }\n else\n format.html { render :edit }\n format.json { render json: @services_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meetingroom.update(meetingroom_params)\n format.html { redirect_to [@space, @meetingroom], notice: 'Meetingroom was successfully updated.' }\n format.json { render :show, status: :ok, location: [@space, @meetingroom] }\n else\n format.html { render :edit }\n format.json { render json: @meetingroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_room = MyRoom.find(params[:my_room_id])\n respond_to do |format|\n if @my_rack.update(my_rack_params)\n format.html { redirect_to my_room_my_rack_path(@my_room, @my_rack), notice: 'Стелаж успешно обновлен.' }\n format.json { render :show, status: :ok, location: @my_rack }\n else\n format.html { render :edit }\n format.json { render json: @my_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @roomtable.update(roomtable_params)\n format.html { redirect_to @roomtable, notice: 'Roomtable was successfully updated.' }\n format.json { render :show, status: :ok, location: @roomtable }\n else\n format.html { render :edit }\n format.json { render json: @roomtable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hostel_room = HostelRoom.find(params[:id])\n\n respond_to do |format|\n if @hostel_room.update_attributes(params[:hostel_room])\n format.html { redirect_to @hostel_room, notice: 'Hostel room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hostel_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def refresh\n @room = Room.find(params[:room_id])\n respond_to do |format|\n format.json { render :json => @room }\n format.html\n end\n end",
"def update\n @room.hotel = Hotel.find_by_name(params[:room][:hotel])\n \n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to crew_rooms_path, notice: 'Quarto atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @rooms = Room.all\n @groups = Group.all\n @passenger = Passenger.new\n @passengers = Passenger.all\n @enterprise = Enterprise.new\n @enterprises = Enterprise.all\n @room_types = RoomType.all\n\n @reservation.update_attributes( reservation_params )\n\n respond_to do |format|\n if @reservation.guardar( new_reservation_rooms )\n format.html { redirect_to @reservation, notice: 'Los datos de la reserva ha sido modificados correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reservation2_room.update(reservation2_room_params)\n format.html { redirect_to @reservation2_room, notice: 'Reservation2 room was successfully updated.' }\n format.json { render :show, status: :ok, location: @reservation2_room }\n else\n format.html { render :edit }\n format.json { render json: @reservation2_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room_information.update(room_information_params)\n format.html { redirect_to @room_information, notice: 'Room information was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_information }\n else\n format.html { render :edit }\n format.json { render json: @room_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_room_metadata(company, room_id, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.put '/messages/v3/' + company + '/rooms/' + room_id, params\n end",
"def update\n respond_to do |format|\n if @cleaning_room.update(cleaning_room_params)\n format.html { redirect_to @cleaning_room, notice: 'Cleaning room was successfully updated.' }\n format.json { render :show, status: :ok, location: @cleaning_room }\n else\n format.html { render :edit }\n format.json { render json: @cleaning_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reservation_room.update(reservation_room_params)\n format.html { redirect_to @reservation_room, notice: 'Los datos de la reserva de la habitacion se han modificado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reservation_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tddbc_room = Tddbc::Room.find(params[:id])\n\n respond_to do |format|\n if @tddbc_room.update_attributes(params[:tddbc_room])\n format.html { redirect_to @tddbc_room, notice: 'Room was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tddbc_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @employee_room.update(employee_room_params)\n format.html { redirect_to @employee_room, notice: 'Employee room was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_room }\n else\n format.html { render :edit }\n format.json { render json: @employee_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room.update(room_params)\n format.html { redirect_to @room, notice: t('flash.room.upadate') }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @room = Room.find(params[:id])\n \n @room.criterias.delete_all\n params[:criteria].each_pair do |k,v|\n @room.criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n @room.not_criterias.delete_all \n params[:not_criteria].each_pair do |k,v|\n @room.not_criterias << Criteria.find(k.to_i) if v == \"1\"\n end\n\n respond_to do |format|\n if @room.update_attributes(params[:room])\n flash[:notice] = 'Room was successfully updated.'\n format.html { redirect_to agency_site_room_path(params[:agency_id], params[:site_id], @room.id) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @screeningroom = Screeningroom.find(params[:id])\n\n respond_to do |format|\n if @screeningroom.update_attributes(params[:screeningroom])\n format.html { redirect_to @screeningroom, notice: 'Screeningroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @screeningroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @room_message = RoomMessage.find(params[:id])\n\n respond_to do |format|\n if @room_message.update_attributes(params[:room_message])\n format.html { redirect_to @room_message, notice: 'Room message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @room_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @room_occupation.update(room_occupation_params)\n format.html { redirect_to @room_occupation, notice: 'Room occupation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @room_occupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n param=room_params\n actype=param[:AC]\n bedcount=param[:beds]\n param.delete(\"AC\")\n param.delete(\"beds\")\n @room=Room.find_by(roomid:param[:roomid])\n respond_to do |format|\n if @room.update(param)\n roomtype=@room.roomtype\n roomtype.update(AC:actype,beds:bedcount)\n format.html { redirect_to @room, notice: \"Room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @chatroom.update(chatroom_params)\n format.html { redirect_to @chatroom, notice: 'Chatroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @chatroom }\n else\n format.html { render :edit }\n format.json { render json: @chatroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chatroom.update(chatroom_params)\n format.html { redirect_to @chatroom, notice: 'Chatroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @chatroom }\n else\n format.html { render :edit }\n format.json { render json: @chatroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @about_room.update(about_room_params)\n format.html { redirect_to @about_room, notice: 'About room was successfully updated.' }\n format.json { render :show, status: :ok, location: @about_room }\n else\n format.html { render :edit }\n format.json { render json: @about_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @message_room.update(message_room_params)\n format.html { redirect_to @message_room, notice: 'Message room was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_room }\n else\n format.html { render :edit }\n format.json { render json: @message_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workroom.update(workroom_params)\n format.html { redirect_to @workroom, notice: 'Workroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @workroom }\n else\n format.html { render :edit }\n format.json { render json: @workroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chat_room.update(chat_room_params)\n format.html { redirect_to user_chat_rooms_path, notice: \"Chat room was successfully updated.\" }\n format.json { render :show, status: :ok, location: @chat_room }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @chat_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @chatroom.update(chatroom_params)\n\t\t\t\tformat.html { redirect_to @chatroom, notice: 'Chatroom was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @chatroom }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @chatroom.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @room_facility.update(room_facility_params)\n format.html { redirect_to @room_facility, notice: 'Room facility was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_facility }\n else\n format.html { render :edit }\n format.json { render json: @room_facility.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @chat_room = ChatRoom.find(params[:id])\n\n respond_to do |format|\n if @chat_room.update_attributes(params[:chat_room])\n flash[:notice] = 'ChatRoom was successfully updated.'\n format.html { redirect_to(@chat_room) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chat_room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @roomlist.update(roomlist_params)\n #format.html { redirect_to @roomlist, notice: 'Roomlist was successfully updated.' }\n format.html { redirect_to @roomlist, notice: 'Room was successfully Allocated.' }\n format.json { render :show, status: :ok, location: @roomlist }\n else\n format.html { render :edit }\n format.json { render json: @roomlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end"
] |
[
"0.71675444",
"0.7049212",
"0.7000274",
"0.6996011",
"0.69671804",
"0.6927408",
"0.6926342",
"0.6926342",
"0.690636",
"0.68662703",
"0.68121725",
"0.6795969",
"0.6792735",
"0.674421",
"0.674305",
"0.67349285",
"0.6731771",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.67010766",
"0.66950226",
"0.6681837",
"0.667964",
"0.6656364",
"0.6623932",
"0.6601358",
"0.65859896",
"0.65410745",
"0.6491224",
"0.64484614",
"0.6427326",
"0.63854545",
"0.6376103",
"0.6358736",
"0.6355656",
"0.63485914",
"0.63373893",
"0.63320404",
"0.63168234",
"0.6300356",
"0.6280123",
"0.6255521",
"0.62521094",
"0.6243716",
"0.6235442",
"0.62340486",
"0.6224649",
"0.6221757",
"0.62213373",
"0.6206813",
"0.6199404",
"0.61888665",
"0.6187819",
"0.6184296",
"0.61745936",
"0.6169497",
"0.6153012",
"0.6144474",
"0.613844",
"0.6132887",
"0.61237746",
"0.6110956",
"0.611075",
"0.6109743",
"0.6102987",
"0.6100921",
"0.6100219",
"0.6066241",
"0.60385543",
"0.60342866",
"0.6033833",
"0.6013987",
"0.6006102",
"0.6002679",
"0.59893805",
"0.5986231",
"0.59768516",
"0.59766465",
"0.5959158",
"0.59572655",
"0.5954253",
"0.5954253",
"0.59278756",
"0.5924346",
"0.5919042",
"0.5918085",
"0.5915471",
"0.59088373",
"0.5908338",
"0.59072065",
"0.5891215",
"0.5855802",
"0.58378845"
] |
0.6773955
|
13
|
DELETE /rooms/1 DELETE /rooms/1.json
|
def destroy
@room.destroy
respond_to do |format|
format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room = current_user.rooms.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n head :ok \n end",
"def destroy\n @admin_room.destroy\n respond_to do |format|\n format.html { redirect_to admin_rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @serverroom = Serverroom.find(params[:id])\n @serverroom.destroy\n\n respond_to do |format|\n format.html { redirect_to serverrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to crew_rooms_path, notice: 'Quarto foi apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: t('default.room.destroyed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to(rooms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tddbc_room = Tddbc::Room.find(params[:id])\n @tddbc_room.destroy\n\n respond_to do |format|\n format.html { redirect_to tddbc_rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restroom = Restroom.find(params[:id])\n @restroom.destroy\n authorize! :destroy, @restroom\n\n respond_to do |format|\n format.html { redirect_to restrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n @restroom.destroy\n respond_to do |format|\n format.html { redirect_to restrooms_path, notice: 'Restroom deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n redirect_to rooms_path\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Room was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Room was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to @room.floor, notice: t('flash.room.delete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request_room.destroy\n respond_to do |format|\n format.html { redirect_to request_rooms_url, notice: 'Request room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to staffs_path, notice: 'Room was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n room = Room.find(params[:id])\n if room.destroy\n head :no_content\n return\n else\n response_data = {\n txt: ['削除できませんでした!'],\n }\n render json: response_data, status: :unprocessable_entity\n end\n end",
"def destroy\n #Ao apagar uma sala, suas cartas devem ser apagadas.\n Poker.where(room: @room).destroy_all\n \n @room.destroy\n \n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"Sala '\" + @room.name + \"' foi apagada com sucesso!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_room = MyRoom.find(params[:my_room_id])\n @my_rack.destroy\n respond_to do |format|\n format.html { redirect_to @my_room, notice: 'Стелаж успешно удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to admin_rooms_path(id: @room.hotel.id), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to location_path(@room.location), notice: 'La Sala ha sido eliminada correctamente!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @empty_room.destroy\n respond_to do |format|\n format.html { redirect_to empty_rooms_url, notice: 'Empty room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hotel_room = HotelRoom.find(params[:id])\n @hotel_room.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @hostel_room = HostelRoom.find(params[:id])\n @hostel_room.destroy\n\n respond_to do |format|\n format.html { redirect_to hostel_rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room.destroy\n respond_with(@room)\n end",
"def destroy\n @chat_room.destroy\n\n respond_to do |format|\n format.html { redirect_to chat_rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reservation_room.destroy\n respond_to do |format|\n format.html { redirect_to reservation_rooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roombot = Roombot.find(params[:id])\n @roombot.destroy\n\n respond_to do |format|\n format.html { redirect_to roombots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to hotelprofile_path, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n respond_to do |format|\n format.html { redirect_to rooms_url :flash => { success: 'Room was successfully destroyed.' } }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chatroom = Chatroom.find(params[:id])\n @chatroom.destroy\n\n respond_to do |format|\n format.html { redirect_to chatrooms_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @admin_room.destroy\n respond_to do |format|\n format.html { redirect_to admin_building_path(params[:building_id]), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @telecom_room = TelecomRoom.find(params[:id])\n @telecom_room.destroy\n\n respond_to do |format|\n format.html { redirect_to(telecom_rooms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @room.destroy\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to(agency_site_rooms_url(params[:agency_id], params[:site_id])) }\n format.xml { head :ok }\n end\n end",
"def destroy\n authorize room\n\n room.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: I18n.t('rooms.successfully_destroyed') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @room = @user.room.find(params[:id])\n @room.destroy\n head :no_content\n end",
"def destroy\n @roomtype.destroy\n respond_to do |format|\n format.html { redirect_to roomtypes_url, notice: 'Roomtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@room.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy_rooms\n rooms.destroy_all\n end",
"def destroy\n @room_item.destroy\n respond_to do |format|\n format.html { redirect_to room_items_url, notice: \"Room item was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room.destroy\n redirect_to admin_rooms_path, notice: 'Room was successfully destroyed.'\n end",
"def destroy\n @occupied_room.destroy\n respond_to do |format|\n format.html { redirect_to occupied_rooms_url, notice: 'Occupied room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reserved_room.destroy\n respond_to do |format|\n format.html { redirect_to reserved_rooms_url, notice: 'Reserved room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hotel = @room.hotel.id\n @room.destroy\n respond_to do |format|\n format.html { redirect_to hotel_url(@hotel), notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reservation2_room.destroy\n respond_to do |format|\n format.html { redirect_to reservation2_rooms_url, notice: 'Reservation2 room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n filteredParams = params.require(:room).permit(:room_id)\n @room = Room.find(filteredParams[\"room_id\"]) rescue nil\n if !@room\n res_with_error(\"Unknown room\", :bad_request)\n return (false)\n end \n @room.members.destroy_all\n @room.admins.destroy_all\n @room.room_messages.destroy_all\n RoomMute.where(room: @room).destroy_all\n RoomBan.where(room: @room).destroy_all\n @room.destroy\n respond_to do |format|\n ActionCable.server.broadcast \"room_channel\", type: \"rooms\", description: \"Room Destroyed\", user: current_user\n format.html { redirect_to :index, notice: 'Room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roomtable.destroy\n respond_to do |format|\n format.html { redirect_to roomtables_url, notice: 'Roomtable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @about_room.destroy\n respond_to do |format|\n format.html { redirect_to about_rooms_url, notice: 'About room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room_occupation.destroy\n respond_to do |format|\n format.html { redirect_to room_occupations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kind_room.destroy\n respond_to do |format|\n format.html { redirect_to kind_rooms_url, notice: 'Kind room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @services_room.destroy\n respond_to do |format|\n format.html { redirect_to room_services_rooms_path, notice: 'Services room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roomlist.destroy\n respond_to do |format|\n format.html { redirect_to roomlists_url, notice: 'Roomlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chat_room = ChatRoom.find(params[:id])\n @chat_room.destroy\n\n respond_to do |format|\n format.html { redirect_to(chat_rooms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @switch_room.destroy\n respond_to do |format|\n format.html { redirect_to switch_rooms_url, notice: 'Switch room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @show_room = ShowRoom.find(params[:id])\n @show_room.destroy\n\n respond_to do |format|\n format.html { redirect_to(show_rooms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @venue = Venue.find(params[:venue_id])\n @room = Room.find(params[:id])\n @room.destroy\n respond_to do |format|\n format.html { redirect_to venue_rooms_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cleaning_room.destroy\n respond_to do |format|\n format.html { redirect_to cleaning_rooms_url, notice: 'Cleaning room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @screeningroom = Screeningroom.find(params[:id])\n @screeningroom.destroy\n\n respond_to do |format|\n format.html { redirect_to screeningrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_room.destroy\n respond_to do |format|\n format.html { redirect_to message_rooms_url, notice: 'Message room was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chatroom.destroy\n respond_to do |format|\n format.html { redirect_to chatrooms_url, notice: 'Chatroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chatroom.destroy\n respond_to do |format|\n format.html { redirect_to chatrooms_url, notice: 'Chatroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chatroom.destroy\n respond_to do |format|\n format.html { redirect_to chatrooms_url, notice: 'Chatroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chat_room.destroy\n respond_to do |format|\n format.html { redirect_to chat_rooms_url, notice: \"Chat room was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room_message = RoomMessage.find(params[:id])\n @room_message.destroy\n\n respond_to do |format|\n format.html { redirect_to room_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if can? :destroy, @room\n ActionCable.server.broadcast(\"rooms\", { id: @room.id, action: \"destroy\" })\n Room.find(params[:id]).destroy\n UserRoom.where(room_id: params[:id]).map(&:destroy)\n end\n # respond_to do |format|\n # format.html { redirect_to rooms_path }\n # format.js { render } unless params[:room_scope] == \"show\"\n # end\n end",
"def destroy\n @roomrate = Roomrate.find(params[:id])\n @roomrate.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_roomrates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meetingroom.destroy\n respond_to do |format|\n format.html { redirect_to space_meetingrooms_url(@space), notice: 'Meetingroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Roommate.destroy(@roommate.id)\n set_roommates\n respond_to do |format|\n format.html { redirect_to roommates_url, notice: 'Roommate was successfully deleted.' }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @bathroom.destroy\n respond_to do |format|\n format.html { redirect_to bathrooms_url, notice: 'Bathroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bathroom.destroy\n respond_to do |format|\n format.html { redirect_to bathrooms_url, notice: 'Bathroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @roommaster = Roommaster.find(params[:id])\n @roommaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(roommasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asteroid.destroy\n respond_to do |format|\n format.html { redirect_to asteroids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@room.destroy\n\t\trespond_to do |format|\n\t\t\tback_page = rooms_url\n\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\tformat.html { redirect_to back_page, notice: 'Room was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n\t\t@chatroom.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to chatrooms_url, notice: 'Chatroom was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @room_information.destroy\n\n respond_to do |format|\n if room_information_destroyed?\n format.html { redirect_to room_informations_url, notice: \"Rooms information/type was destroyed\" }\n format.json { head :no_content }\n else\n format.html { redirect_to room_informations_url, \n alert: \"Rooms information/type was not destroyed; try deleting dependant rooms first\" }\n end\n end\n end",
"def destroy\n @room_facility.destroy\n respond_to do |format|\n format.html { redirect_to room_facilities_url, notice: 'Room facility was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @room_room_attribute_link.destroy\n respond_to do |format|\n format.html { redirect_to room_room_attribute_links_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @classroom = Classroom.find(params[:id])\n @classroom.destroy\n\n respond_to do |format|\n format.html { redirect_to classrooms_url }\n format.json { head :no_content }\n end\n end",
"def delete_room room_instance_id\n raise \"pending\"\n end"
] |
[
"0.7635934",
"0.7620118",
"0.761992",
"0.7589228",
"0.7583094",
"0.7565785",
"0.7555699",
"0.75015026",
"0.7446661",
"0.7445735",
"0.7438515",
"0.73450273",
"0.7341036",
"0.7299027",
"0.7295218",
"0.72534937",
"0.72534937",
"0.725146",
"0.72453046",
"0.72278804",
"0.72278804",
"0.72008985",
"0.71972936",
"0.7190607",
"0.71816504",
"0.71688277",
"0.7124362",
"0.7102746",
"0.70990914",
"0.709863",
"0.70887476",
"0.70758015",
"0.7074073",
"0.704902",
"0.7037947",
"0.7025829",
"0.70178676",
"0.70174956",
"0.70154357",
"0.7009159",
"0.6998993",
"0.6986678",
"0.69790536",
"0.69641846",
"0.6958299",
"0.6958089",
"0.69538707",
"0.6952521",
"0.69338834",
"0.6928051",
"0.69219345",
"0.6913284",
"0.6865887",
"0.6843531",
"0.6820841",
"0.68150973",
"0.68137217",
"0.6792528",
"0.6776137",
"0.6763586",
"0.67501026",
"0.674656",
"0.67348117",
"0.67311907",
"0.67259",
"0.67053694",
"0.67007846",
"0.6695503",
"0.6692519",
"0.66903245",
"0.66901255",
"0.66896975",
"0.6668256",
"0.66635686",
"0.6647125",
"0.6617918",
"0.6616972",
"0.6604636",
"0.65959674",
"0.65959674",
"0.65889",
"0.65743643",
"0.65636855",
"0.6534086",
"0.65308154",
"0.65031046",
"0.6491253",
"0.6490586",
"0.6486339",
"0.6479574"
] |
0.72336674
|
28
|
Use callbacks to share common setup or constraints between actions.
|
def set_room
@room = Room.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def room_params
params.require(:room).permit(:name, :status, :price, :slot, :area_id,:admin_id,:r,:quantity,:deposit,:av)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586",
"0.629103",
"0.6282451",
"0.6243152",
"0.62413",
"0.6219024",
"0.6213724",
"0.62103724",
"0.61945",
"0.61786324",
"0.61755824",
"0.6173267",
"0.6163613",
"0.6153058",
"0.61521065",
"0.6147508",
"0.61234015",
"0.61168665",
"0.6107466",
"0.6106177",
"0.6091159",
"0.60817343",
"0.6071238",
"0.6062299",
"0.6021663",
"0.60182893",
"0.6014239",
"0.6011563",
"0.60080767",
"0.60080767",
"0.60028875",
"0.60005623",
"0.59964156",
"0.5993086",
"0.5992319",
"0.5992299",
"0.59801805",
"0.59676576",
"0.59606016",
"0.595966",
"0.59591126",
"0.59589803",
"0.5954058",
"0.5953234",
"0.5944434",
"0.5940526",
"0.59376484",
"0.59376484",
"0.5935253",
"0.5930846",
"0.5926387",
"0.59256274",
"0.5917907",
"0.5910841",
"0.590886",
"0.59086543",
"0.59060425",
"0.58981544",
"0.5898102",
"0.5896809",
"0.5895416",
"0.58947027",
"0.58923644",
"0.5887903",
"0.58830196",
"0.5880581",
"0.5873854",
"0.58697754",
"0.5869004",
"0.58669055",
"0.5866886",
"0.58664906",
"0.5864619",
"0.58630043",
"0.5862495",
"0.5861368",
"0.5859712",
"0.5855544",
"0.58551925",
"0.5851284",
"0.5850602"
] |
0.0
|
-1
|
For some reason this doesn't work, so a workaround is used load_and_authorize_resource :event, through: :program
|
def index
@events = Event.accessible_by(current_ability).where(program: @program)
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
@events_with_requirements = @events.where.not(description: ['', nil])
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
@missing_event_speakers = EventUser.joins(:event)
.where('event_role = ? and program_id = ?', 'speaker', @program.id)
.where.not(user_id: attended_registrants_ids)
.where(event_id: @events.pluck(:id))
.includes(:user, :event)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_resource\n #apply policy scope\n @event = EventPolicy::Scope.new(current_user, Event).resolve.find(params[:id])\n end",
"def set_event\n @event = Event.find(params[:id])\n authorize @event\n end",
"def show\n authorize @event\n end",
"def authorize_admin\n authorize! :update, convention.events.new\n end",
"def edit_start_time\n authorize @event\n end",
"def show\n authorize! :show, Evento\n end",
"def require_authorization!\n unless current_user == @event.user\n render json: {}, status: :forbidden\n end\n end",
"def user_action_on_resource_authorized\n end",
"def index\n #@event_users = EventUser.where(event: @event)\n #@event_users = EventUserPolicy::Scope.new(current_user, [:admin, EventUser]).resolve\n @event_users = policy_scope(EventUser.where(event: @event))\n authorize @event_users\n\n add_breadcrumb \"#{@event.code}\", :admin_event_path\n add_breadcrumb \"Usuários\", :admin_event_users_path\n end",
"def security_events\r\n SecurityEventsController.instance\r\n end",
"def create\n @event = Event.new params[:event]\n authorize! :manage, @event\n @event.save!\n render 'show'\n end",
"def show\n\t\tauthorize! :show, AsistenciaEvento\n end",
"def set_event\n @event = Event.find(params[:id])\n skip_authorization\n end",
"def main_index\n @events = Event.order('starts_at ASC').upcoming.includes(:lab)\n @past_events = Event.order('starts_at DESC').past.includes(:lab)\n #authorize_action_for @events\n end",
"def index\n @lab = Lab.friendly.find(params[:lab_id])\n #authorize_action_for Event\n end",
"def new\n @event = Event.new\n authorize @event, :new?\n end",
"def index\n @events = Event.all\n authorize! :index, Event.new, :message => 'Not authorized as an administrator.'\n end",
"def load_collection\n current_ability.scope_for(authorization_action, resource_class) do\n resource_base.accessible_by(current_ability, authorization_action)\n end\n end",
"def authorize_inherited_resource!\n authorize! :show, parent if parent?\n authorize! authorizable_action, authorize_resource? ? resource : resource_class\n end",
"def show\n @event = Event.shod(params[:id])\n @batches ||= Batch.all\n @departments ||= EmployeeDepartment.all\n authorize! :read, @event\n end",
"def authorize_edit\n authorize! :edit, @opportunity\n end",
"def event_requirement; end",
"def index\n @teams = policy_scope(Team.where(event: @event))\n authorize @event, :show?\n\n add_breadcrumb \"#{@event.code}\", :admin_event_path\n add_breadcrumb \"Equipes\", :admin_event_teams_path\n\n end",
"def volunteer_portal\n authorize! :volunteer_portal, :Reservation\n end",
"def not_signed_in\n can [:index, :conferences, :code_of_conduct], Organization\n can [:index], Conference\n can [:show], Conference do |conference|\n conference.splashpage&.public == true\n end\n # Can view the schedule\n can [:schedule, :events], Conference do |conference|\n conference.program.cfp && conference.program.schedule_public\n end\n\n can :show, Event do |event|\n event.state == 'confirmed'\n end\n\n can [:show, :events, :app], Schedule do |schedule|\n schedule.program.schedule_public\n end\n\n # can view Commercials of confirmed Events\n can :show, Commercial, commercialable: Event.where(state: 'confirmed')\n can [:show, :create], User\n\n can [:index, :show], Survey, surveyable_type: 'Conference'\n\n # Things that are possible without ichain enabled that are **not*+ possible with ichain mode enabled.\n if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) != 'true'\n # There is no reliable way for this workflow (enable not logged in users to fill out a form, then telling\n # them to sign up once they submit) in ichain. So enable it only without ichain.\n\n # FIXME: The following abilities need to be checked. Are they about the type of workflow mentioned above? Or are\n # they just here because they worked in development mode (without ichain). We are suspicious that it's the latter!\n can :show, Registration do |registration|\n registration.new_record?\n end\n\n can [:new, :create], Registration do |registration|\n conference = registration.conference\n conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?\n end\n\n can :show, Event do |event|\n event.new_record?\n end\n\n can [:new, :create], Event do |event|\n event.program.cfp_open? && event.new_record?\n end\n end\n end",
"def find_event\n @event = @conference.events.is_public.accepted.scheduled.find(params[:event_id])\n end",
"def showdep\n @departments ||= EmployeeDepartment.all\n authorize! :create, Event\n end",
"def load_event\n @event = Event.find(params[:event_id])\n end",
"def load_event\n @event = Event.find(params[:id])\n end",
"def authorize_resource\n EffectiveResources.authorize!(self, action_name.to_sym, resource)\n end",
"def authorize\n run_callbacks :authorize do\n\n policy = Pundit.policy!(context.fetch(:current_token), @model)\n permission = \"#{context.fetch(:current_action)}?\"\n\n unless policy.public_send(permission)\n raise Pundit::NotAuthorizedError.new(query:permission, record: @model, policy: policy)\n end\n end\n end",
"def index\n @events = Event.order(created_at: :desc)\n authorize @events, :index?\n end",
"def authorize_admin\n permission = params[:action] == 'update' ? :manage : :read\n authorize! permission, convention.event_proposals.new(status: 'reviewing')\n end",
"def create\n @event = Event.new(event_params)\n authorize @event\n\n if(current_account && current_account.accountable_type == \"Business\")\n @event.business = current_account.accountable\n end\n\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_access\n @access = @current_event.accesses.find(params[:id])\n authorize @access\n end",
"def load_permissions\n authorize! :manage, :all\n end",
"def set_resource\n @course = Course.find(params[:id])\n authorize @course\n end",
"def show\n if current_user != @event.creator && !@event.invitees.include?(current_user) && !@event.attendees.include?(current_user)\n redirect_to root_path, alert: \"You don't have permission to do that\"\n else \n if !current_user.attending_events.include?(@event) && @event.invitees.include?(current_user)\n current_user.attending_events << @event\n current_user.user_events.find_by(event_id: @event.id).destroy\n end\n end\n end",
"def authorized_user\n @event = Event.friendly.find(params[:id])\n if @event.creator_id != current_user.id\n if current_user.email == 'pubudu@eventhub.lk' || current_user.email == 'pavithra@eventhub.lk'\n return true\n end\n redirect_to root_path, alert: \"Oops! You don't have permission to do that\"\n end\n end",
"def authorize_resource(*args); end",
"def relevant_events_scope\n events\n end",
"def post_event_course_org\n event = params[:id] == 'new' ? Event.new : Event.friendly.find(params[:id])\n\n # This should change to params.dig(:event_group, :id) when the event-staging app supports event_groups\n event_group = EventGroup.find_or_initialize_by(id: event.event_group_id)\n course = Course.find_or_initialize_by(id: params.dig(:course, :id))\n organization = Organization.find_or_initialize_by(id: params.dig(:organization, :id))\n\n persisted_resources = [event, event_group, course, organization].select(&:persisted?)\n skip_authorization if persisted_resources.empty?\n persisted_resources.each { |resource| authorize resource }\n\n setter = EventCourseOrgSetter.new(event: event, event_group: event_group, course: course, organization: organization, params: params)\n setter.set_resources\n if setter.status == :ok\n render json: setter.resources.map { |resource| [resource.class.to_s.underscore, resource] }.to_h, status: setter.status\n else\n render json: {errors: setter.resources.map { |resource| jsonapi_error_object(resource) }}, status: setter.status\n end\n end",
"def skip_load_and_authorize_resource(*args)\n skip_load_resource(*args)\n skip_authorize_resource(*args)\n end",
"def find_event\n if Event.exists?(params[:id])\n if !Event.find(params[:id]).latitude.nil? && !Event.find(params[:id]).longitude.nil?\n @event = Event.find(params[:id])\n authorize @event\n else\n redirect_to(events_path)\n end\n else\n redirect_to(events_path)\n end\n end",
"def before_authorization(action, role, resource_config)\n raise NotImplementedError\n end",
"def set_event\n exist_event = Event.where(id: params[:id])\n if exist_event != [] and logged_in?\n @event = Event.find(params[:id])\n else\n flash[:danger] = \"You don't have permission to perform this action.\"\n if !logged_in?\n redirect_to root_path\n else\n redirect_to events_path\n end\n end\n end",
"def display_resource(event)\n event.name\n end",
"def event_params\n permitted = params.require(:calendars_event).permit(policy(@event).permitted_attributes)\n permitted[:privileged_changer] = true if policy(@event).privileged_change?\n permitted\n end",
"def index\n authorize! :index, @event, :message => 'Not authorized as an administrator.'\n @events = Event.find(:all, order: \"created_at DESC\")\n @event = Event.new\n end",
"def common_abilities_for_admins(user)\n can :access, Admin\n can :manage, :all if user.is_admin?\n\n conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)\n conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)\n conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)\n\n if conf_ids_for_organizer\n # To access splashpage of their conference if it is not public\n can :show, Conference, id: conf_ids_for_organizer\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_organizer\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_organizer }\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)\n end\n\n if conf_ids_for_cfp\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_cfp }\n end\n\n if conf_ids_for_info_desk\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_info_desk\n end\n end",
"def set_event\n # Get only current user events\n @event = current_user.events.find(params[:id])\n end",
"def permitted_events\n events = self.states_events_config.map { |se| se[:event] }\n events.delete_if { |e| !event_permitted(e) }\n end",
"def pre_authorize_cb; end",
"def validate_permission\n unless current_user.permissions.include?(:events)\n flash[:error] = 'You do not have permission to edit Events.'\n redirect_to '/admin'\n end\n end",
"def show\n # @event = Event.find(params[:id])\n raise ApiAccessEvanta::RecordOutOfScope unless current_user.allowed_to?(action: :view, object: @event)\n render json: @event\n end",
"def post_event_course_org\n course = Course.find_or_initialize_by(id: params[:course][:id])\n authorize course unless course.new_record?\n\n organization = Organization.find_or_initialize_by(id: params[:organization][:id])\n authorize organization unless organization.new_record?\n\n setter = EventCourseOrgSetter.new(event: @event, course: course, organization: organization, params: params)\n setter.set_resources\n if setter.status == :ok\n render json: setter.resources.map { |resource| [resource.class.to_s.underscore, resource.to_json] }.to_h, status: setter.status\n else\n render json: {errors: setter.resources.map { |resource| jsonapi_error_object(resource) }}, status: setter.status\n end\n end",
"def authenticate_scope!\r\n send(:\"authenticate_#{resource_name}!\")\r\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\r\n end",
"def check_permission(event, role)\n case role\n when 'botmaster'\n {\n granted: event.user.id == BOTMASTER_ID,\n allowed: ['botmasters']\n }\n else\n names = Role.owners(role).pluck(:username)\n {\n granted: Role.exists(event.user.id, role),\n allowed: role.pluralize #names\n }\n end\nend",
"def events\r\n load_private_events\r\n load_completed_private_events\r\n end",
"def resource_check(verb, id = params[:id], klass = controller_name.classify.constantize)\n return unless RBAC::Access.enabled?\n\n permission_check(verb, klass)\n\n raise Exceptions::NotAuthorizedError, \"#{verb.titleize} access not authorized for #{klass} with id: #{id}\" unless resource_instance_accessible?(klass.table_name, id)\n end",
"def resource_check(verb, id = params[:id], klass = controller_name.classify.constantize)\n return unless RBAC::Access.enabled?\n\n permission_check(verb, klass)\n\n raise Exceptions::NotAuthorizedError, \"#{verb.titleize} access not authorized for #{klass} with id: #{id}\" unless resource_instance_accessible?(klass.table_name, id)\n end",
"def get_user\n @current_user = current_user\n @can_manage = can? :manage, Event\n end",
"def resourceType\n 'AuditEvent'\n end",
"def create\n authorize! :create, Event\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/events/#{@event.id}/edit\", notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_load_voyage\n return if authorise_for_web(program_name?,'create')== false\n render_new_load_voyage\n end",
"def event_data\n\n authorize @event\n if @event.available_live\n render partial: 'live/events/event_data.json.ruby'\n else\n render partial: 'live/events/live_entry_unavailable.json.ruby'\n end\n end",
"def index\n # Do not use CanCan load_resource here (see skip_load_resource above)\n @data = Event.data_for_list\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def resource_check(verb, id = params[:id], klass = controller_name.classify.constantize)\n return unless Insights::API::Common::RBAC::Access.enabled?\n\n permission_check(verb, klass)\n\n raise Exceptions::NotAuthorizedError, \"#{verb.titleize} access not authorized for #{klass} with id: #{id}\" unless resource_instance_accessible?(klass.table_name, id)\n end",
"def require_same_organizer\n if current_organizer != @event.organizer and !current_organizer.admin?\n flash[:danger] = \"You can only edit or delete your own events\"\n redirect_to root_path\n end \n end",
"def show\n\t\t@event = Event.find(params[:id])\n\n\t\tunless @event.user == current_user\n\t\t\traise CanCan::AccessDenied\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @event }\n\t\tend\n\tend",
"def initialize(user)\n user ||= User.new # guest user (not logged in)\n\n can [:create, :update, :destroy], Idea, :book_event => { :user_id => user.id }\n can [:create, :update, :destroy], BookEvent, :user_id => user.id\n\n end",
"def index\n @video_calls = policy_scope(VideoCall).all\n authorize @video_calls\n end",
"def create\n @event = Event.new(event_params)\n @event.slug ||= @event.name.parameterize if @event.name\n authorize @event\n if @event.save\n redirect_to event_path( @event ), notice: 'Event was successfully created.'\n else\n render :new\n end\n end",
"def event_permitted(event)\n case event\n when :review\n [:pending, :requested].include? current_state\n when :confirm\n if !has_digital_items?\n [:pending, :reviewing].include? current_state\n else\n current_state == :reviewing\n end\n when :begin_work\n current_state == :pending && any_items_ready?\n when :complete_work\n current_state == :in_progress\n when :fulfill\n if reproduction_order?\n current_state == :work_complete\n else\n all_items_ready? && (current_state == :confirmed)\n end\n when :activate\n current_state == :fulfilled\n when :close\n if reproduction_order?\n current_state == :fulfilled\n else\n (current_state == :fulfilled) && finished?\n end\n end\n end",
"def show\n require 'uri'\n @event = EventOwner.find(params[:id])\n @is_admin = current_user && current_user.id == @event.id\n end",
"def create\n # Do not use CanCan load_resource here (see skip_load_resource above)\n respond_to do |format|\n if Event.add_event(params, current_user)\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end \n end",
"def new\n authorize! :create, @event.event_registrations.new\n @event_registration = @event.event_registrations.new(user: current_user)\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def authorize_admin_profiles\n authorize convention, :view_attendees?\n end",
"def event_collection(project_id, event_collection)\n resource \"projects/#{project_id}/events/#{event_collection}\"\n end",
"def authorize_resource\n authorize!(:disburse, @disbursement)\n @disbursement.experience_points_records.each do |record|\n authorize!(:create, record)\n end\n end",
"def show\n #TODO\n if !current_user.has_role?(:admin)\n redirect_to events_path\n return\n end\n end",
"def pre_authorize_cb=(_arg0); end",
"def new\n @event = Event.new\n if !(can? :manage, :all)\n flash[:error] = \"Access Denied.\"\n redirect_to root_url\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end\n end",
"def show\n if (@account.can_modify_event?)\n @event = Event.find(params[:id])\n else \n @event = Event.find_with_account(params[:id], @account)\n end\n respond_not_found unless @event\n redirect_to(event_clients_path(:event_id => @event.id))\n end",
"def update\n authorize @event\n if @event.update(event_params)\n redirect_to event_path( @event ) , notice: 'Event was successfully updated.'\n else\n render :edit\n end\n end",
"def create\n @event = Event.new(event_params)\n authorize! :create, @event, :message => 'Not authorized as an administrator.'\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_event\n @event = Event.find(params[:id])\n @current_user_is_participating = @event.participants.find_by(user_id: current_user.id) != nil if user_signed_in?\n end",
"def index\n if current_user && current_user.is_admin? && params_user_id\n @events = User.find(params_user_id).events.where(is_validated:true)\n elsif params_user_id && params_user_id.to_i == current_user.id\n @events = current_user.events.where(is_validated:true)\n elsif params_user_id && params_user_id.to_i != current_user.id \n redirect_to root_path\n else\n @events= Event.where(is_validated:true)\n end\n end",
"def event_collections(project_id)\n resource \"projects/#{project_id}/events\"\n end",
"def set_and_authorize_measure\n @measure = policy_scope(base_object).find(params[:id])\n authorize @measure\n end",
"def index\n @events = Event.where.not(id: current_user.events.ids + current_user.belongs_events.pluck(:id))\n @event = Event.new\n end",
"def event\n resource.event :name => event_name, :desired_value => should, :property => self, :source_description => path\n end",
"def list_policy_events(id:)\n get(\"policies/#{id}/events\")\n end",
"def index\n @user_games = policy_scope(UserGame).order(created_at: :desc)\n @user = User.find(params[:user_id])\n @user_game = UserGame.new\n authorize @user_game\n end",
"def qualified_event; end",
"def qualified_event; end",
"def show\n @origin = 'room'\n if params[:origin]\n @origin = params[:origin]\n end\n @event = Event.find(params[:id])\n @members = @event.users\n if current_user\n @is_moderator = ModeratorRole.exists?(user_id: current_user.id, course_id: @event.course_id)\n if current_user.id == @event.user_id\n @is_member = true\n else\n @is_member = UserEvent.exists?(user_id: current_user.id, event_id: @event.id)\n end\n allowed = false\n denied = 'Acción Inválida!'\n if @event.e_type == 'Study'\n allowed = UserCourse.exists?(user_id: current_user.id, course_id: @event.course_id)\n unless allowed\n denied = 'Debes inscribirte primero en el curso del evento!'\n end\n elsif @event.e_type == 'Search'\n allowed = UserCourse.exists?(user_id: current_user.id, course_id: @event.course_id, role: 'Alumno')\n unless allowed\n denied = 'Debes inscribirte como alumno primero en el curso del evento!'\n end\n end\n if params[:join] && !@is_member\n if allowed\n if @event.e_type == 'Study' && (@members.length + 2 <= @event.max_amount)\n current_user.events << @event\n notice = 'Te has unido al evento!'\n elsif @event.e_type != 'Study'\n current_user.events << @event\n notice = 'Te has unido al evento!'\n else\n notice = 'No se permiten más miembros en este grupo de estudio!'\n end\n else\n notice = denied\n end\n respond_to do |format|\n format.html { redirect_to event_url(:id => @event, :origin => @origin), notice: notice }\n format.json { head :no_content }\n end\n elsif params[:unjoin] && @is_member\n if @event.user_id != current_user.id\n @relation = UserEvent.find_by(user_id: current_user.id, event_id: @event.id)\n @relation.delete\n @relation.destroy\n respond_to do |format|\n format.html { redirect_to event_url(:id => @event.id, :origin => @origin),\n notice: 'Te has salido del evento!' }\n format.json { head :no_content }\n end\n end\n end\n end\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def edit\n @event = current_user.events.find(params[:id])\n end",
"def allow( event )\n return nil if @level > event.level\n @filters.each do |filter|\n break unless event = filter.allow(event)\n end\n event\n end"
] |
[
"0.6791258",
"0.677467",
"0.6675366",
"0.6483827",
"0.6156664",
"0.6090217",
"0.6069886",
"0.6021218",
"0.589772",
"0.5872916",
"0.5749754",
"0.57417494",
"0.57368666",
"0.57301223",
"0.56887525",
"0.566999",
"0.56336766",
"0.56028837",
"0.55934423",
"0.5578263",
"0.5520868",
"0.54979044",
"0.5496524",
"0.54764605",
"0.5474237",
"0.5464832",
"0.5420926",
"0.5416177",
"0.54081684",
"0.54072595",
"0.54068154",
"0.540013",
"0.53971833",
"0.539244",
"0.53889126",
"0.53639364",
"0.53476274",
"0.5337172",
"0.53288776",
"0.528735",
"0.52833855",
"0.5278165",
"0.5273909",
"0.52726",
"0.5269891",
"0.526121",
"0.5241551",
"0.5230054",
"0.52238387",
"0.5220483",
"0.5212666",
"0.51717466",
"0.51682246",
"0.51626706",
"0.51617974",
"0.515592",
"0.5149967",
"0.5144657",
"0.5136454",
"0.5134797",
"0.5134797",
"0.51339096",
"0.5124535",
"0.51214564",
"0.51178724",
"0.5115226",
"0.51123077",
"0.51117134",
"0.5105359",
"0.5099423",
"0.50991863",
"0.5095251",
"0.50826806",
"0.50816816",
"0.50797904",
"0.5076562",
"0.50736606",
"0.50668466",
"0.5046866",
"0.5036794",
"0.5030377",
"0.5029928",
"0.50289756",
"0.5025699",
"0.50216365",
"0.5005923",
"0.49984714",
"0.49984553",
"0.49971965",
"0.4996045",
"0.49935302",
"0.4989788",
"0.4983939",
"0.49829906",
"0.49779153",
"0.49779153",
"0.49763507",
"0.49604028",
"0.49604028",
"0.4958905",
"0.4957711"
] |
0.0
|
-1
|
questions: did the candidate design a method or a class? any thoughts regarding testing? followon: modify to print the first N digits how flexible is the implementation? How much rework involved, if any?
|
def fibonacci(n)
a = 0
b = 1
n.times do
temp = a
a = b
b = temp + b
end
a
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solution(n)\r\n unit = UNITS[n % 10]\r\n dozen = DOZENS[(n % 100) / 10]\r\n hundred = HUNDREDS[(n % 1000) / 100]\r\n thousand = THOUSAND * (n / 1000)\r\n [thousand, hundred, dozen, unit].join\r\nend",
"def print_number(number, number_string_length, required_length)\n puts \"#{number}, #{number_string_length}, #{required_length}\"\n number.to_s[number.to_s.length - (number_string_length.modulo(required_length) + 1), 1]\nend",
"def integer_print_10\nend",
"def get_first_digit n \n n / 10**length(n) \nend",
"def new_numeral_maker(num)\n i = 'I' * ((num % 5) / 1)\n v = 'V' * ((num % 10) / 5)\n x = 'X' * ((num % 50) / 10)\n l = 'L' * ((num % 100) / 50)\n c = 'C' * ((num % 500) / 100)\n\n four_error = 'IIII'\n nine_error = 'VIIII'\n forty_error = 'XXXX'\n ninety_error = 'LXXXX'\n four_hundred_error = 'CCCC'\n\n # hundreds\n if c == four_hundred_error\n print('DC')\n else\n print(c)\n end\n\n # tens\n if l + x == ninety_error\n print('XC')\n elsif x == forty_error\n print('XL')\n else\n print(x)\n end\n\n # ones and teens\n if v + i == nine_error\n print('IX')\n elsif i == four_error\n print('IV')\n else\n print(v + i)\n end\nend",
"def last_n_digits(num, n)\n # your code goes here\n puts num.digits.first(n)\nend",
"def printword(digit)\n ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\n tens = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\n tenones = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen','seventeen', 'eighteen', 'nineteen']\n if digit < 10\n return ones[digit]\n elsif digit < 20\n onesplace = digit % 10\n return tenones[onesplace]\n elsif digit < 100\n tensdigit = (digit / 10).floor\n onesdigit = digit % 10\n return \"#{tens[tensdigit - 2]} #{ones[onesdigit]}\"\n elsif digit < 1_000\n hunddigit = (digit / 100).floor\n hundremainder = digit % 100\n return \"#{printword(hunddigit)} hundred #{printword(hundremainder)}\"\n elsif digit < 1_000_000\n thoudigit = (digit / 1000).floorx\n thouremainder = digit % 1000\n return \"#{printword(thoudigit)} thousand #{printword(thouremainder)}\"\n elsif digit < 1_000_000_000\n milldigit = (digit / 1_000_000).floor\n millremainder = digit % 1_000_000\n return \"#{printword(milldigit)} million #{printword(millremainder)}\"\n elsif digit < 1_000_000_000_000\n billdigit = (digit / 1_000_000_000).floor\n billremainder = digit % 1_000_000\n return \"#{printword(billdigit)} billion #{printword(billremainder)}\"\n end\nend",
"def digitize(n)\n n.digits\nend",
"def n2e(num)\n\n return '' if num.kind_of?(String) and (num =~ /^[0]+$/)\n return '' if num.kind_of?(String) and (num !~ /^\\d+$/)\n \n num = num.to_i if num.kind_of?(String)\n n = num.to_s.split(//)\n len = n.size\n \n # To create constance inside a function, we need to use instance\n # variables. Ruby 1.9 is very picky about this subject!\n\n @Hundred = 'hundred'\n @Thousand= 'thousand'\n @Million = 'million'\n @Billion = 'billion'\n\n h = { :ones => %w(zero one two three four five six seven\n eight nine ten eleven twelve thirteen\n fourteen fifteen sixtee seventeen eigthteen\n nineteen),\n :twos => %w(nil ten twenty thirty forty fifty sixty \n seventy eighty ninety)\n }\n\n if num < 20\n str = h[:ones][num] \n elsif len == 2\n str = (n[0] > \"1\") ? h[:twos][n[0].to_i] : h['tens'][n[0].to_i-1] \n str += (n[1] > \"0\" ) ? (' ' + h[:ones][n[1].to_i]) : ''\n elsif len == 3\n str = n2e(n[0])+' '+@Hundred+' '+ n2e(n[1]+n[2])\n elsif len == 4\n str = n2e(n[0])+' '+@Thousand+' '+ n2e(n[1]+n[2]+n[3])\n elsif len == 5 \n str = n2e(n[0]+n[1])+' '+ @Thousand +' '\n str += n2e(n[2]+n[3]+n[4])\n elsif len == 6 \n str = n2e(n[0]+n[1]+n[2])+' '+ @Thousand +' '\n str += n2e(n[3]+n[4]+n[5])\n elsif len == 7 \n str = h[:ones][n[0].to_i]+' '+@Million+' '\n str += n2e(n[1]+n[2]+n[3]+n[4]+n[5]+n[6])\n elsif len == 8 \n str = n2e(n[0]+n[1])+' '+ @Million + ' '\n str += n2e(n[2]+n[3]+n[4]+n[5]+n[6]+n[7])\n elsif len == 9 \n str = n2e(n[0]+n[1]+n[2])+' '+ @Million + ' '\n str += n2e(n[3]+n[4]+n[5]+n[6]+n[7]+n[8])\n elsif len == 10 \n str = h[:ones][n[0].to_i]+' '+@Billion+' '\n str += n2e(n[1]+n[2]+n[3]+n[4]+n[5]+n[6]+n[7]+n[8]+n[9])\n elsif len == 11 \n str = n2e(n[0]+n[1])+' '+@Billion+' '\n str += n2e(n[2]+n[3]+n[4]+n[5]+n[6]+n[7]+n[8]+n[9]+n[10])\n elsif len == 12 \n str = n2e(n[0]+n[1]+n[2])+' '+@Billion+' '\n str += n2e(n[3]+n[4]+n[5]+n[6]+n[7]+n[8]+n[9]+n[10]+n[11])\n else\n abort(\"Number Overflow\\n\")\n end\n return str\nend",
"def featured(integer)\n return \"There is no possible number that fulfills those requirements\" if \n integer >= 9_876_543_210\n integer += 1\n until integer % 7 == 0 && integer.odd? && integer.digits.uniq! == nil\n integer += 1\n end\n integer\nend",
"def look_and_say(n)\n prev = \"1\"\n curr = \"\"\n\n while(n > 1)\n i = 0\n\n while(i < prev.length)\n\n char = prev[i]\n count = count_digits(i, prev)\n i += count\n\n curr << count.to_s << char\n end\n\n prev = curr.dup\n curr = \"\"\n n -= 1\n end\n\n prev\nend",
"def handle_ten (num)\n num2str=''\n if (num%10==0)\n num2str+=NUM_MAP[num]\n elsif (num>10 && num<20)\n num2str+=NUM_MAP[num]\n else\n num2str+=NUM_MAP[num/10*10]+'-'+NUM_MAP[num%10]\n end\n return num2str\nend",
"def stringy(int)\n (int/2).times { print 10 }\n 1 if int.odd?\nend",
"def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend",
"def digit; end",
"def leading_zeroes(max_num_length)\n 101.times do |i|\n num_of_zeroes = max_num_length - i.digits.length\n puts \"0\" * num_of_zeroes + i.to_s\n end\nend",
"def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend",
"def super_digit(n)\n return n if n < 10\n count = add_digits(n)\n return super_digit(count)\n\nend",
"def featured(i) # found digits method but only works > v2.4 so...\n i = i - i % 7\n loop do\n i += 7\n list = []\n x = i\n while x > 0 do\n list.unshift(x % 10)\n x /= 10\n end\n if list.length > 9; return \"There is no possible number that fulfills those requirements\" end\n if list == list.uniq; break end\n end \n i\nend",
"def test_19\n expected = [\"12345\", \"12345\", \"12345\", \"12345\", \"12345\", \" 12345\",\n \" 12345\", \" 12345\", \" 12345\", \" 12345\", \" 12345\"]\n 0.upto(10) do |i|\n assert_equal(expected[i], '~#d'.format(12345, *Array.new(i)))\n end\n end",
"def persistence(n, count = 0)\n return count if n < 10\n i = 0\n arr = n.to_s.split('')\n if arr.length > 1\n tot = arr.map(&:to_i).inject(:*)\n i += 1\n count += 1\n tot.to_i >= 10 ? persistence(tot.to_i, count) : count\n end\nend",
"def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend",
"def length n\n Math.log10(n).floor \nend",
"def decent_number(n)\n\tleft = 0\n\tright = 0\n\t(n+1).times do |i|\n\t\tleft = n - i \n\t\tright = n - left\n\t#\tputs \"#{left}%3 = #{left%3} | #{right}%5 = #{right%5}\"\n\t\tbreak if left % 3 == 0 && right % 5 == 0\n\tend\n\t#puts \"**l = #{left} r = #{right}\"\n\n\tif left % 3 == 0 && right % 5 == 0\n\t\tfives = \"5\"*left\n\t\tthrees = \"3\"*right\n\t\tputs fives+threes\n\telse\n\t\tputs -1\n\tend\nend",
"def newrmn(a)\n rmn = []\n n = a.to_i\n thousands = (n / 1000)\n hundreds = (n % 1000 / 100)\n tens = (n % 100 / 10)\n ones = (n % 10)\n thousands.times {rmn.push(\"M\")}\n if hundreds == 9\n rmn.push(\"CM\")\n elsif hundreds == 4\n rmn.push(\"CD\")\n else\n ((n % 1000) / 500).times {rmn.push(\"D\")}\n ((n % 500) / 100).times {rmn.push(\"C\")}\n end\n\n if tens == 9\n rmn.push(\"XC\")\n elsif tens == 4\n rmn.push(\"XL\")\n else\n ((n % 100) / 50).times {rmn.push(\"L\")}\n ((n % 50) / 10).times {rmn.push(\"X\")}\n end\n\n if ones == 9\n rmn.push(\"IX\")\n elsif ones == 4\n rmn.push(\"IV\")\n else\n ((n % 10) / 5).times {rmn.push(\"V\")}\n (n % 5).times {rmn.push(\"I\")}\n end\n puts rmn.join()\nend",
"def refined_super_digit(n, k)\n refined = \"\"\n\n k.times do \n refined += n.to_s \n end \n refined = refined.to_i\n\n super_digit(refined)\n\nend",
"def numbers(n)\n\nend",
"def super_digit(n)\n super_digit_helper({}, n)\n \nend",
"def prime_digit_replacement()\r\n\treturner = 1000000\r\n\t# Loop through not repeated digits\r\n\tfor digits in (11..999).step(2)\r\n\t\t# Sum of 3 repeated digits is divisable by 3\r\n\t\tnext if digits % 3 == 0\r\n\t\t# The last digit is 1, 3, 7 or 9\r\n\t\tnext if digits % 5 == 0\r\n\t\t\r\n\t\t\r\n\t\tthe_patterns = (digits < 100)? five_digit_pattern() : \r\n\t\t\t\t\t\t\t\t\t\tsix_digit_pattern()\r\n\t\t\r\n\t\tfor a_pattern in the_patterns\r\n\t\t\t# Check 'the smallest' members of '8 primes' family\r\n\t\t\tfor repeated_d in (0..2)\r\n\t\t\t\tnext if ((a_pattern[0] == 0) and (repeated_d == 0))\r\n\t\t\t\t\r\n\t\t\t\t# Create a number\r\n\t\t\t\tto_test = []\r\n\t\t\t\ttmp_digits = digits\r\n\t\t\t\tfor i in a_pattern.reverse()\r\n\t\t\t\t\tif i == 1\r\n\t\t\t\t\t\tto_test.unshift(tmp_digits % 10)\r\n\t\t\t\t\t\ttmp_digits /= 10\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tto_test.unshift(repeated_d)\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t\ta_number = to_test.inject(0){ |multi, val| multi*10 + val }\r\n#\t\t\t\tputs \"\\t#{a_number}\"\r\n\t\t\t\t\r\n\t\t\t\t# Check for prime\r\n\t\t\t\tif (a_number < returner) && (Prime.prime?(a_number))\r\n\t\t\t\t\t# Check for family\r\n\t\t\t\t\tfamily_size = 0\r\n\t\t\t\t\tfor i in (repeated_d..9)\r\n\t\t\t\t\t\ttmp = to_test.map{ |a| (a == repeated_d)? i : a }\r\n\t\t\t\t\t\ttmp_num = tmp.inject(0){ |multi, val| multi*10 + val }\r\n\t\t\t\t\t\tif Prime.prime?(tmp_num)\r\n\t\t\t\t\t\t\tfamily_size += 1\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\t\treturner = a_number if family_size > 7\r\n\t\t\t\t\t\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\treturn returner\r\nend",
"def refined_super_digit(n, k)\n return n if n < 10\n super_digit(n.digits.sum * k) # k magic hint from https://www.hackerrank.com/challenges/super-digit/forum\nend",
"def fetch_number_strings(number,factor,and_flag)\n first_part = number % factor\n (and_flag) ? and_string = \" and \" : and_string = \" \"\n if factor.eql?(10)\n second_part = number - first_part\n \"#{generate_number_str(second_part,true)}#{and_string}#{int_strings[first_part]}\"\n else\n second_part = (number - first_part)/factor\n \"#{generate_number_str(second_part,true)} #{int_strings[factor]}#{and_string}#{generate_number_str(first_part,true)}\"\n end\n end",
"def refined_super_digit(n, k)\n \nend",
"def refined_super_digit(n, k)\n \nend",
"def refined_super_digit(n, k)\n \nend",
"def raindrops( number )\n\n output = ''\n\n # Does the number have 3 as a factor?\n # if number % 3 == 0\n # output += 'Pling'\n # end\n\n output += 'Pling' if (number % 3 == 0)\n output += 'Plang' if (number % 5 == 0)\n output += 'Plong' if (number % 7 == 0)\n\n # Check if any of the above were factors, i.e. is output still empty?\n # if output.empty?\n # return number # return early with the original number\n # end\n return number if output.empty?\n\n output # return output string from function\nend",
"def persistence(n)\n n < 10 ? 0 : 1 + persistence(n.digits.reduce(&:*))\nend",
"def test_for_bigger_numbers\n\t\tassert_equal(\"MCXCI\", roman_converter(1191))\n\t\tassert_equal(\"MLXVI\", roman_converter(1066))\n\t\tassert_equal(\"XLIX\", roman_converter(49))\n\t\tassert_equal(\"CMXCIX\", roman_converter(999))\n\t\tassert_equal(\"DCLXVI\", roman_converter(666))\n\tend",
"def nth(n)\n if n > 9 and n.to_s[-2..-1].to_i.between?(10,19)\n \"#{n}th\"\n elsif n.to_s[-1].to_i == 1\n \"#{n}st\"\n elsif n.to_s[-1].to_i == 2\n \"#{n}nd\"\n elsif n.to_s[-1].to_i == 3\n \"#{n}rd\"\n else\n \"#{n}th\"\n end \n end",
"def superDigit(n, k)\n target = n.split('').map(&:to_i).sum * k\n\n until target < 10\n target = target.digits.sum\n end\n\n target\nend",
"def featured(n)\n n += 1\n n += 1 until n % 7 == 0 && n.odd?\n loop do\n break if n.to_s.chars.uniq.join == n.to_s\n n += 14\n if n > 9876543210\n puts \"There is no possible number that fulfills those requirements\"\n return nil\n end\n end\n n\nend",
"def number_letters_count\n ones = { \n 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five',\n 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten',\n 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen',\n 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen',\n 19 => 'nineteen' \n }\n \n tens = { \n 20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', \n 70 => 'seventy', 80 => 'eighty', 90 => 'ninety' \n }\n\n (1..1000).to_a.map do |num|\n digits = num.to_s.chars.map(&:to_i)\n if num < 20\n num = ones[num]\n elsif num >= 20 && num < 100\n if digits[1] == 0\n num = tens[digits[0] * 10]\n else \n num = tens[digits[0] * 10] + ' ' + ones[digits[1]]\n end\n elsif num >= 100 && num < 1000\n if digits[1] == 0 && digits[2] == 0\n num = ones[digits[0]] + ' hundred'\n elsif digits[1] == 0 && digits[2] != 0\n num = ones[digits[0]] + ' hundred' + ' and ' + ones[digits[2]]\n elsif ones.include? digits[1..2].join.to_i\n num = ones[digits[0]] + ' hundred' + ' and ' + ones[digits[1..2].join.to_i]\n elsif digits[1] != 0 && digits[2] == 0\n num = ones[digits[0]] + ' hundred' + ' and ' + tens[digits[1] * 10]\n elsif digits[1] != 0 && digits[2] != 0\n num = ones[digits[0]] + ' hundred' + ' and ' + tens[digits[1] * 10] + ' ' + ones[digits[2]]\n end\n elsif num == 1000\n num = 'one thousand'\n end\n end.map { |word| word.gsub(' ', '') }.join.length\nend",
"def slippery_numbers(n)\nend",
"def nhs_numberize\n return self unless length == 10\n self[0..2] + ' ' + self[3..5] + ' ' + self[6..9]\n end",
"def digit_factorials\n max = biggest_possible_digit_factorial\n results = []\n \n test_number = 10\n \n while test_number <= max\n results << test_number if is_curious?(test_number)\n test_number += 1\n end\n \n print results\n results.inject(:+)\nend",
"def super_digit(n)\n\n return n if n < 10\n super_digit(n.digits.sum)\n\nend",
"def raindrops num\n output = \"\"\n output << \"Pling\" if num % 3 == 0\n output << \"Plang\" if num % 5 == 0\n output << \"Plong\" if num % 7 == 0\n output.empty? ? num.to_s : output\nend",
"def validate(n)\nl = n.to_s.length\ni = 0\nsplit = n.to_s.reverse.split(//).map!{|x|x.to_i}\ndestination = []\n l.times do\n if i.odd?\n if split[i] * 2 <= 9\n destination << split[i] * 2\n else\n destination << (split[i] * 2 - 9)\n end\n else \n destination << split[i] \n end\n i += 1\n end\n p destination\n if destination.reduce(:+) %10 == 0\n true\n else\n false\n end\nend",
"def fb_build_report(number)\n result = ''\n result << 'Fizz' if (number % 3).zero?\n result << 'Buzz' if (number % 5).zero?\n result << 'Dazz' if (number % 7).zero?\n result << 'Kezz' if (number % 11).zero?\n result.empty? ? number : result\nend",
"def four_digit_parse(num)\n thousands = get_high_order(num,1000)\n num = get_remainder(num, 1000)\n hundreds = get_high_order(num, 100)\n num = get_remainder(num, 100)\n tens = get_high_order(num, 10)\n ones = get_remainder(num, 10)\n \n print \"The number is #{thousands} \" + pluralize(\"thousand\", thousands)\n print \" #{hundreds} \" + pluralize(\"hundred\", hundreds) + \" #{tens} \"\n print pluralize(\"ten\", tens) + \" and #{ones} \" + pluralize(\"one\", ones) + \".\\n\"\nend",
"def featured(integer)\n return \"Error: There is no possible number that fulfills those requirements\" if integer >= 9_876_543_210\n counter = integer + 1\n counter += 1 until counter % 7 == 0 && counter.odd?\n \n loop do\n return counter if counter.digits.uniq.size == counter.digits.size\n counter += 14\n end\nend",
"def super_digit(n)\n #has to be a single digit \n if n < 10 \n return n\n else \n return super_digit(n.digits.sum)\n end \n \n \nend",
"def solution(number)\n\nm, r_1 = number.divmod(1000)\ncd, r_2 = r_1.divmod(100)\nlx, r_3 = r_2.divmod(10)\nvi, r_4 = r_3.divmod(1)\n\nroman = []\n\nm.times { roman << \"M\" }\n\nif cd <= 3\n\tcd.times { roman << \"C\" }\nelsif cd == 4\n\troman << \"CD\"\nelsif cd == 5\n\troman << \"D\"\nelsif cd > 5 && cd < 9\n\troman << \"D\"\n\t(cd - 5).times { roman << \"C\" }\nelsif cd == 9\n\troman << \"CM\"\nend\n\nif lx <= 3\n\tlx.times { roman << \"X\" }\nelsif lx == 4\n\troman << \"XL\"\nelsif lx == 5\n\troman << \"L\"\nelsif lx > 5 && lx < 9\n\troman << \"L\"\n\t(lx - 5).times { roman << \"X\" }\nelsif lx == 9\n\troman << \"XC\"\nend\n\nif vi <= 3\n\tvi.times { roman << \"I\" }\nelsif vi == 4\n\troman << \"IV\"\nelsif vi == 5\n\troman << \"V\"\nelsif vi > 5 && vi < 9\n\troman << \"V\"\n\t(vi - 5).times { roman << \"I\" }\nelsif vi == 9\n\troman << \"IX\"\nend\n\nroman.join\n\nend",
"def power_powers(digit)\r\n\t#Add all n^n numbers in sequence to get answers\r\n\tanswer = (1..digit).inject {|sum, num| sum + num**num}\r\n\t#Output last 10 digits of answer\r\n\tputs answer.to_s[-10..-1]\r\nend",
"def triple_digit_breakdown(digits_hash)\n base_nums = {0=>'', 1=>'one', 2=>'two', 3=>'three', 4=>'four', 5=>'five', 6=>'six', 7=>'seven', 8=>'eight', 9=>'nine'}\n ten_to_nineteen = {10=>'ten', 11=>'eleven', 12=>'twelve', 13=>'thirteen', 14=>'fourteen', 15=>'fifteen', 16=>'sixteen', 17=>'seventeen', 18=>'eighteen', 19=>'nineteen'}\n multiples_of_ten = {0=>'', 2=>'twenty ', 3=>'thirty ', 4=>'forty ', 5=>'fifty ', 6=>'sixty ', 7=>'seventy ', 8=>'eighty ', 9=>'ninety '}\n\n ones = digits_hash[1]\n tens = digits_hash[2]\n hundreds = digits_hash[3]\n\n val_str = hundreds > 0 ? \"#{base_nums[hundreds]} hundred \" : \"\"\n val_str += tens == 1 ? ten_to_nineteen[(tens*10)+ones] : multiples_of_ten[tens] + base_nums[ones]\n end",
"def rounds_of_look_and_see(rounds, num)\n input = num\n (1..rounds).each do |round|\n input = look_and_see(input)\n puts input\n end\n input\nend",
"def magic_numbers(count)\nend",
"def find_hundreds (n)\n words =\"\"\n num_words = Hash.new(0)\n num_words = {1=>\"One\",2=>\"Two\",3=>\"Three\",4=>\"Four\",5=>\"Five\",6=>\"Six\",7=>\"Seven\",8=>\"Eight\",9=>\"Nine\",10=>\"Ten\",11=>\"Eleven\",12=>\"Twelve\",13=>\"Thirteen\",14=>\"Fourteen\",15=>\"Fifteen\",16=>\"Sixteen\",17=>\"Seventeen\",18=>\"Eighteen\",19=>\"Nineteen\",20=>\"Twenty\",30=>\"Thirty\",40=>\"Fourty\",50=>\"Fifty\",60=>\"Sixty\",70=>\"Seventy\",80=>\"Eighty\",90=>\"Ninety\"}\n\n if n/100 > 0\n # Append the String you get to the string that holds the words\n words = num_words[n/100] +\" Hundred \"\n if n%10 !=0\n words= words + \"and \"\n end\n n=n%100\n end\n\n if n/10 > 0\n if n/10 == 1\n words = words+num_words[n]+ \" \"\n elsif n%10 == 0\n words = words +num_words[n]\n else\n words = words +num_words[n/10*10] +\" \"+ num_words[n%10]\n end\n elsif n == 0\n words\n else\n words = words +num_words[n]\n end\n words\nend",
"def refined_super_digit(n, k)\n s = \"\"\n k.times do\n s += n.to_s\n end\n return super_digit(s.to_i)\nend",
"def square_digits (n)\n print n.digits.map{|n|n*n}.join\nend",
"def f(n)\n sum = (\"1\"*n).to_i # the last number of the sequence is n 1's\n # start with single digit if possible\n sum += n if n.to_s.length == 1\n # 2 digits next\n x = 2\n puts terms_of_n_with_length_x(n,x).inspect\n puts \"got here\"\n puts n-1\n (1..(n-1)).to_a.reverse.each do |x|\n puts x\n puts eat_2s(x)\n end\n return sum\nend",
"def test_format_print_two_fake\n simulator = Sim.new(nil, nil, nil)\n assert_equal simulator.ruby_format_print([0, 2]), \"\\tFound 2 fake rubies in Enumerable Canyon.\\n\"\n end",
"def featured(number)\n number += 1\n\n until number % 7 == 0 && number.odd?\n number += 1\n end\n\n loop do\n if number.digits.uniq == number.digits\n return number\n else\n number += 14\n end\n break if number.digits.size > 10\n end\n\n \"Error\"\nend",
"def stringy(num, start=1)\n string = '10' * (num/2)\n if start == 1\n num.even? ? string : string + '1'\n else\n num.even? ? string.reverse : string.reverse + '0'\n end\nend",
"def refined_super_digit(n, k)\n new_num = 0\n times = k\n numbers = n.to_s.split(\"\")\n if numbers.length <= 1\n return n\n end\n numbers.each do |i|\n new_num += i.to_i\n end\n new_n = times * new_num\n return super_digit(new_n) \nend",
"def featured(num)\n return 'Error! No featured numbers exist over 10 digits!' if num >= 9876543210\n loop do\n num += 1\n break if num.odd? && (num % 7).zero? && num.digits.uniq! == nil\n end\n num\nend",
"def main\n max = 10 ** 9 + 7\n all = 1\n zero = 1\n nine = 1\n zn = 1\n N.times.each do\n all = all * 10 % max\n zero = zero * 9 % max\n nine = nine * 9 % max\n zn = zn * 8 % max\n end\n return (all - zero - nine + zn) % max\nend",
"def handle_hundred (num)\n num2str=''\n if (num%100==0)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]\n elsif (num%100>=10 && num%100 <= 99)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_ten(num%100)\n elsif (num%100>=1 && num%100 <= 9)\n num2str+=NUM_MAP[num/100]+ ' '+ NUM_MAP[100]+ ' ' +handle_bit(num%100)\n end\n return num2str\nend",
"def super_digit(n)\n return n if n / 10 == 0\n return super_digit(digit_helper(n))\nend",
"def round_1_sig_fig n \n get_first_digit(n) * 10**length(n)\nend",
"def digits_of_answer(digits)\n n = 0\n previous = 0\n i = 1\n\n\n\n while i.to_s.length < digits\n n += 1\n i, previous = previous, previous + i\n end\n\n (n-1)\nend",
"def s(n)\n ((9*n-1)*(10**n)+1)/9\nend",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def display_number\n # \n ('X' * (account_number.to_s.length - last_digits.size)) + last_digits\n # account_number.to_s[0..last_digits.size].to_s.size + \n # last_digits.to_s\n end",
"def longest_digit_run(digit)\nend",
"def featured(n)\n (n..9_999_999_999).each {|number| return number if number_valid?(n, number)}\n return \"There is no possible number that fulfills those requirements.\"\nend",
"def digit_match(n, m)\n\nend",
"def print_num(num)\n puts num\nend",
"def print_num(num)\n puts num\nend",
"def print_num(num)\n puts num\nend",
"def test_leading_zeros\n [ \n ['02161711150', '21-61711150'],\n ['002161711150', '21-61711150'],\n ['0002161711150', '21-61711150'],\n ].each do |test, expected |\n x = CnPhoneNumber.new test\n assert_equal expected, x.to_pretty_s, \"failed on #{test}\"\n end\n end",
"def cout(n)\n\tw=[0,1,2,3,4,5,6,7,8,9]\n\tx=[]\n\tk=1\n\twhile x!=w do \n\t\tm=n*k\n\t\t\twhile m>0 do\n\t\t\t\tt=m%10\n\t\t\t\tx=x.push(t)\n\t\t\t\tx.sort!\n\t\t\t\tx.uniq!\n\t\t\t\tm=m/10\t\n\t\t\tend\n\t\tk=k+1\n\tend\nreturn (k-1)*n\nend",
"def to_digits(n = 3)\n str = self.to_s\n return str if str.size >= n\n ret = \"\"\n (n - str.size).times { ret += \"0\" }\n return ret + str\n end",
"def generate_production_number\n start_digits = rand(10000..99999)\n end_digits = rand(10000..99999)\n alphabet = (\"A\"..\"Z\").to_a\n middle_digits = \"2017\"\n 5.times { middle_digits << alphabet.sample}\n \"#{start_digits}-#{middle_digits}-#{end_digits}\"\n end",
"def generate_production_number\n start_digits = rand(10000..99999)\n end_digits = rand(10000..99999)\n alphabet = (\"A\"..\"Z\").to_a\n middle_digits = \"2017\"\n 5.times { middle_digits << alphabet.sample}\n \"#{start_digits}-#{middle_digits}-#{end_digits}\"\n end",
"def fizzbuzz_without_modulo\n 1.upto(100) do |n|\n str = ''\n if (n / 3.0).round == (n / 3.0)\n str << 'Fizz'\n end\n\n if (n / 5.0).round == (n / 5.0)\n str << 'Buzz'\n end\n puts str.empty? ? n : str\n end\nend",
"def number_letters(number)\n\nsingles = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']\n\nteens = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\n\ntens = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\nnumber_word = nil\n if number == 1000\n return 'one thousand'\n elsif number >= 100 && number < 1000\n hundreds_digit = number / 100\n remainder = number % 100\n if remainder == 0\n number_word = singles[hundreds_digit - 1] + ' hundred'\n else\n number_word = singles[hundreds_digit - 1] + ' hundred and ' + \"#{number_letters(remainder)}\"\n end\n elsif number >= 20 && number <= 99\n tens_digit = number / 10\n remainder = number % 10\n if remainder == 0\n number_word = tens[tens_digit - 1]\n else\n number_word = tens[tens_digit - 1] + '-' + singles[remainder - 1]\n end\n elsif number >= 11 && number <= 19\n remainder = number % 10\n number_word = teens[remainder - 1]\n elsif number == 10\n return 'ten'\n else\n number_word = singles[number - 1]\n end\nnumber_word\nend",
"def human_display(number)\n base_number = digits(number)\n if base_number.length == 11 && base_number.first == '1'\n \"(#{base_number[1..3]}) #{base_number[4..6]}-#{base_number[7..10]}\"\n elsif base_number.length > 0\n \"+#{base_number}\"\n else\n nil\n end\n end",
"def solution(value)\n answer = \"\"\n number_string = value.to_s\n ( 5 - number_string.length).times do\n answer += \"0\"\n end\n answer = answer + number_string\n \"Value is #{answer}\"\nend",
"def print_num n\n prep = n < 0 ? \"\" : \" \"\n print \"#{prep}%.2f | \" % n\nend",
"def digit_match(n, m)\n # not enough time to get to this one, will attempt later on own time\n raise NotImplementedError, \"Method not implemented\"\nend",
"def last_n_digits(num, n)\n # your code goes here\n if n == 1\n return num % 10\n else\n \treturn num % 100\n end\nend",
"def reprint(number)\n\t(1..100).each do |i|\n\t\tif i % 3 == 0 and i % 5 == 0\n\t\t\tputs 'FizzBuzz'\n\t\telsif i % 5 == 0\n\t\t\tputs 'Buzz'\n\t\telsif i % 3 == 0 \n\t\t\tputs 'Fizz'\t\t\n\t\telse\n\t\t\tputs i\t\t\n\t\tend\n\tend\nend",
"def test_06\n -999.upto(999){ |i| assert_equal(\"~d\".format(i), \"~:d\".format(i)) }\n end",
"def super_digit(n)\n return n if n < 10\n sum = super_digit_helper(n, 0)\n super_digit(sum)\nend",
"def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend",
"def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend",
"def solution(digits)\n\tstop = digits.length - 4\n\tgo = 0\n\tlargest_number = 0\n\tindex = 0\n\n\twhile go < stop\n\t\ttest = \"\"\n\t\textra_index = index\n\t\t5.times do \n\t\t\ttest += digits[extra_index].to_s\n\t\t\textra_index += 1 \n\t\tend\n\t\tif test.to_i > largest_number\n\t\t\tlargest_number = test.to_i\n\t\tend \n\t\tindex += 1\n\t\tgo += 1 \n\tend \n\tlargest_number\nend",
"def solve(n)\n if n.to_s.length >= 6\n num = n.to_s[0..-3] + '.' + n.to_s[-2..-1]\n int_length = num.index('.')\n until int_length <= 3\n comma_idx = int_length - 3\n num = num[0...comma_idx] + ',' + num[comma_idx..-1]\n int_length -= 3\n end\n return num\n else\n return (n.to_f / 100).to_s\n end\nend",
"def super_digit(n)\n return n if n < 10\n\n return super_digit(n.digits.sum)\nend",
"def verbose(card)\n suits = {H: 'Hearts', C: 'Clubs', D: 'Diamonds', S: 'Spades'}\n royals = {K: 'King', Q: 'Queen', J: 'Jack', A: 'Ace'}\n card_val = card[0..-2]\n card_suit = card[-1]\n card_suit = suits[card_suit.to_sym] # Converts abreviation to suit name.\n if card_val.to_i == 0 # checks for royals\n royal = royals[card_val.to_sym]\n \"#{royal} of #{card_suit}\"\n else # numerical cards\n \"#{card_val} of #{card_suit}\"\n end\nend",
"def stringy(num, start = 1)\n return 'Positive integer only' unless num.is_a?(Integer) && num > 0\n return 'Invalid starting number' unless start == 1 || start == 0\n\n string = ''\n num.times do\n string << start.to_s\n start = 1 - start\n end\n string\nend"
] |
[
"0.6485079",
"0.6400109",
"0.63423723",
"0.6289188",
"0.62436855",
"0.6241543",
"0.61501276",
"0.61470395",
"0.61365926",
"0.611719",
"0.61133426",
"0.611205",
"0.61092514",
"0.6084901",
"0.60542333",
"0.60273254",
"0.60240096",
"0.60122144",
"0.6011806",
"0.59990585",
"0.5998356",
"0.5986924",
"0.59784395",
"0.59634954",
"0.5948172",
"0.5943765",
"0.59389544",
"0.59376925",
"0.59209245",
"0.5916481",
"0.5912587",
"0.59069633",
"0.5902796",
"0.5902796",
"0.5898447",
"0.5889412",
"0.5888816",
"0.5865922",
"0.58625966",
"0.5862559",
"0.585169",
"0.5845307",
"0.58429605",
"0.5841",
"0.5839495",
"0.58355737",
"0.58335745",
"0.58265424",
"0.5822529",
"0.58132803",
"0.5807242",
"0.5804405",
"0.5802326",
"0.5801618",
"0.57940316",
"0.5790652",
"0.5788838",
"0.57804346",
"0.57778454",
"0.5777684",
"0.57705754",
"0.57682776",
"0.5767224",
"0.5765782",
"0.5762958",
"0.57588935",
"0.5755411",
"0.57443446",
"0.5740355",
"0.57390964",
"0.5738909",
"0.57383746",
"0.5736343",
"0.57343465",
"0.5729275",
"0.5727516",
"0.57269096",
"0.57269096",
"0.57269096",
"0.5725101",
"0.57185274",
"0.57147324",
"0.57145023",
"0.57145023",
"0.5713739",
"0.5709499",
"0.5707814",
"0.5705179",
"0.56995964",
"0.56975126",
"0.5695896",
"0.5691025",
"0.568871",
"0.56845343",
"0.5682335",
"0.5682335",
"0.5681586",
"0.567947",
"0.5678968",
"0.5671473",
"0.56696755"
] |
0.0
|
-1
|
Constructor de una lista doblemente enlazada
|
def initialize
@Node = Struct.new(:value, :next, :prev)
@head = nil
@tail = nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(list)\n @list = list\n end",
"def initialize(list)\n @list = list\n end",
"def initialize(base_list)\n @list = base_list\n end",
"def initialize\n @lista_contas = []\n end",
"def initialize()\n @contenu = [\n [\"t\", \"i\", \"c\"],\n [\"t\", \"a\", \"c\"],\n [\"t\", \"o\", \"e\"]\n ]\n end",
"def initialize\n @exact = []\n @list = []\n end",
"def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend",
"def initialize\n @lists = []\n bootstrap\n populate\n end",
"def initialize\n @elements = []\n end",
"def initialize\n self.list = []\n end",
"def initialize(nome, comentario)\n @nome = nome\n @comentario = comentario\n @estrelando = []\n end",
"def initialize (nombre, lista_alimentos, lista_cantidades)\n\t\t@nombre = nombre\n\t\t@lista_alimentos = lista_alimentos\n\t\t@lista_cantidades = lista_cantidades\n\tend",
"def initialize\n @elements = []\n end",
"def initialize\n @elements = []\n end",
"def initialize\n super()\n @elements = [ ]\n end",
"def initialize\n @listOfItem = Array.new\n end",
"def initialize data\n @listOfItem = data\n end",
"def initialize(new_array)\n\t\t@list = new_array\n\tend",
"def initialize()\n\t@list_arr\t= []\nend",
"def initialize(item_list)\n\t\t@item_list = item_list\n\tend",
"def initialize\n\t\t@e = []\n\tend",
"def initialize(nombre,lista,listagr)\n super(nombre,lista,listagr)\n @gei = 0\n\t\t@terreno = 0\n end",
"def initialize(nome = \"Sem nome\")\r\n @nome = nome\r\n @livros = []\r\n end",
"def initialize(elements)\n @elements = elements\n end",
"def initialize(d = [])\n super()\n @data = d\n end",
"def initialize\n @list = {}\n end",
"def initialize(list)\n @list = list.sort\n end",
"def initialize attributes = {}\n @nombre = attributes[:nombre]\n @nit = attributes[:nit]\n @empleados = []\n @clientes = []\n end",
"def initialize \n @rechnungen = []\n end",
"def initialize(list_title)\n @title = list_title\n @items = Array.new\n end",
"def initialize\n @rechnungen = []\n end",
"def initialize\n @rechnungen = []\n end",
"def initialize(include_head = true)\n\t\t@include_head = include_head\n\t\t@list = build_list\n\tend",
"def initialize\n super()\n @i_keys = List.new()\n @i_values = List.new()\n end",
"def initialize(*elements)\n @elements = elements\n end",
"def initialize\n @list = {}\n end",
"def initialize\n @items = []\n end",
"def initialize(values = [])\n @count = 0\n build_list_from_array(values)\n end",
"def initialize\n super()\n self.keys = List.new()\n self.values = List.new()\n end",
"def initialize\n @items_list = []\n end",
"def initialize\n @items = []\n end",
"def initialize list\n\t\traise \"La lista #{list} no puede ser vacía.\" if list.empty?\n\n\t\tself.list = list.uniq\n\t\tself.list.each do |m|\n\t\t\tif m != :Rock and m != :Paper and m != :Scissors\n\t\t\t\traise \"Los elementos de la lista #{list} deben ser \"\\\n\t\t\t\t\"':Rock', ':Paper' o ':Scissors'.\"\n\t\t\tend\n\t\tend\n\t\tself.gen = Random.new(SEED)\n\tend",
"def initialize array_of_items\n\tend",
"def new\n @list = List.new\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def initialize\n @items = []\n end",
"def initialize(list)\n super(list.first, :view, list)\n end",
"def initialize ()\n\t\t# inicializa la variable baraja como un array vacio\n\t\t@baraja = []\n\t\t# recorre el array con todos los palos\n\t\tConstantes::PALOS.each do |p|\n\t\t\t# Recorre el array con todos los valores\n\t\t\tConstantes::VALORES.each do |v|\n\t\t\t\t# Para cada combinacion de palo/valor crea un objeto Carta y lo guarda en la baraja\n\t\t\t\tc = Carta.new v,p\n\t\t\t\t@baraja << (Carta.new v,p)\n\n\t\t\tend\n\t\tend\n\tend",
"def initialize(list_title)\n @title = list_title\n @items = Array.new\n end",
"def initialize(items = [])\n @items = items\n end",
"def initialize\r\n self.items = []\r\n end",
"def new\n @list = List.new\n end",
"def initialize (books_list)\n @books_list = books_list\nend",
"def initialize(items=[])\n \traise IllegalArgument if items.nil?\n \t@items = []\n items.each do |item|\n @items.push Item.new(item)\n end\n end",
"def initialize\n self.list = []\n self.refresh\n end",
"def create_list\n @list = Array.new(6) { |i| DexButton.new(@viewport, i) }\n end",
"def initialize\n self.daily = Array.new\n self.incluidos=Array.new\n self.ingresados=Array.new\n\n end",
"def initialize(list, serializer)\n @item_serializer = serializer\n @list = list.map { |obj| serializer.new(obj) }\n end",
"def create_list\n\t{}\nend",
"def initialize(list_title)\n @title = list_title\n @items = Array.new # Starts empty! No Items yet!\n @tdate = Time.now.strftime(\"%m/%d/%Y\") # Todays' Date\n end",
"def new\n @list = List.new\nend",
"def initialize\n self.list = {}\n self.origins = []\n end",
"def initialize(nombre,alimentos,cantidad)\n @nombre_plato = nombre # Nombre del Plato\n @lista_alimentos = alimentos # Lista con los alimentos que forman el plato\n @lista_cantidades = cantidad # Lista con las cantidades que hay que usar de cada alimento\n end",
"def initialize(structures=[])\n super()\n @records[Structure] = @list = structures\n end",
"def initialize\n @data = []\n end",
"def initialize(*args)\n super\n self.items ||= []\n end",
"def initialize()\n @llist = nil\n end"
] |
[
"0.7614568",
"0.7565089",
"0.73375154",
"0.7317544",
"0.71179426",
"0.70677465",
"0.7060995",
"0.69934046",
"0.6993102",
"0.6980053",
"0.6974631",
"0.6966772",
"0.69313204",
"0.69313204",
"0.6904812",
"0.68217254",
"0.6801455",
"0.67572653",
"0.67567945",
"0.674178",
"0.6727644",
"0.6673818",
"0.667296",
"0.66665107",
"0.6647744",
"0.66301906",
"0.66296244",
"0.6603188",
"0.65993476",
"0.6584223",
"0.6574736",
"0.6574736",
"0.65740067",
"0.6568167",
"0.6523221",
"0.6497359",
"0.64963645",
"0.64916867",
"0.6489549",
"0.6464578",
"0.64589643",
"0.64525175",
"0.64402145",
"0.64208704",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.64043957",
"0.6371738",
"0.6346347",
"0.6333878",
"0.6302341",
"0.62878025",
"0.6285558",
"0.62798464",
"0.627037",
"0.6269166",
"0.6247484",
"0.6244725",
"0.62378216",
"0.62344444",
"0.6231999",
"0.62228996",
"0.61954194",
"0.6184928",
"0.61766976",
"0.61525327",
"0.6142956",
"0.6135717",
"0.61309415"
] |
0.0
|
-1
|
Ver que valores vas a comparar de la lista
|
def what(v)
@v=v
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_similar_property_value_list?( property_value_list )\n property_value_list.each do |property_value_pair|\n if self.property_values.where(:property_id => property_value_pair[:property_id], \n :value_id => property_value_pair[:value_id]).count == 0 \n next\n else\n return true \n end\n end\n \n return false \n \n end",
"def ueberein_alle?(liste, vergleich)\r\n ergebnis = false\r\n zaehler = 0\r\n liste.each do |el| \r\n vergleich.each do |vg|\r\n zaehler += 1 if el == vg\r\n end\r\n end\r\n if zaehler == vergleich.count\r\n ergebnis = true\r\n end\r\n ergebnis\r\n end",
"def cmp(reference, checked)\n reference.each do |k,v|\n return false if checked[k] != v\n end\n \n return true\n end",
"def in?(*list)\n for item in list\n self === item and return true\n end\n false\n end",
"def contains?(other_list)\n other_list.list.all?{|other_item, other_value| self.list.any?{|item, value| other_item.equal?(item) }}\n end",
"def >(other_list)\n return false if self.list.empty?\n return true if other_list.list.empty?\n\n return self.min_item[1] > other_list.max_item[1]\n end",
"def compare_all(first_operand, arglist, operation)\n if arglist.empty?\n result = true\n else\n result = first_operand.value.send(operation, arglist[0].value)\n if result\n arglist.each_cons(2) do |(operand1, operand2)|\n value1 = operand1.value\n result &&= value1.send(operation, operand2.value)\n end\n end\n end\n boolean(result)\n end",
"def <(other_list)\n return false if other_list.list.empty?\n return true if self.list.empty?\n\n return self.max_item[1] < other_list.min_item[1]\n end",
"def eval_list(list, list_to_compare, context)\n list.zip(list_to_compare).map do |value, pattern|\n pattern.nil? || check_match(value, pattern, context)\n end.all?\n end",
"def par_compare(a, b)\n if a.par_price.price > b.par_price.price\n -1\n elsif a.par_price.price < b.par_price.price\n 1\n else\n @formed.find_index(a) < @formed.find_index(b) ? -1 : 1\n end\n end",
"def >=(other_list)\n return false if self.list.empty?\n return true if other_list.list.empty?\n\n return (\n self.min_item[1] >= other_list.min_item[1] &&\n self.max_item[1] >= other_list.max_item[1]\n )\n end",
"def compare_by_row_vectors(rows)\n my_rows = @rows\n sz = my_rows.size \n return false unless sz == rows.size\n \n for i in 0..sz-1 do\n return false unless my_rows[i] == rows[i]\n end\n true\n end",
"def testa_comparacao_entre_dinheiro\n COMPARACAO.each { |comparacao| assert comparacao }\n end",
"def item_before_in_list(check, list)\n list.each do |item|\n list.each do |inner_item|\n if item == inner_item\n puts \"do something\"\n end\n end\n end\nend",
"def item_in_list(to_check, the_list)\n the_list.each { |item|\n if to_check == item\n return true\n end\n }\n false\nend",
"def include?(val)\n self.each {|item|\n if item.equal?(val)\n return true\n end\n }\n return false\n end",
"def compare(x, y); end",
"def cmp(x)\r\n x2 = []\r\n x.each {|y|\r\n if y !=nil\r\n x2 << y\r\n end\r\n }\r\n return x2\r\nend",
"def compare(a, b)\n #YOUR WORK HERE\n end",
"def compare(val1,val2)\n status = false\n if(val1.eql?val2)\n status = true\n end\n status\n end",
"def happens_before(v)\n #need to ensure there is at least one element that is strictly less-than\n strictly_less = false\n\n for client in (v.get_clients+self.get_clients).uniq\n if (!@vector.has_key?(client) && v[client] != 0) || @vector[client] < v[client]\n strictly_less = true\n elsif @vector[client] > v[client]\n return false\n end\n end\n \n return strictly_less\n end",
"def item_in_list?(to_check, the_list)\n\tthe_list.each do |element|\n\t\tif to_check == element\n\t\t\treturn true\n\t\tend\n\tend\n\tfalse\nend",
"def insync?(current_value)\n if current_value.is_a? Array and @should.is_a? Array\n current_value.sort == @should.sort\n else\n current_value == @should\n end\n end",
"def is_equal?(scoresObj)\n @scores.each { |score|\n elements = scoresObj.scores.select {|scoreObj| scoreObj.studentId == score.studentId}\n if !elements[0] then return false end\n if !elements[0].value == score.value then return false end\n }\n return true\n end",
"def escala?\n valores = @mi_mano.sort_by {|k, v| v[:valor]}.to_h.map{|k, v| [v[:valor]] }.flatten\n valores.each_with_index do |val, index|\n return false unless val == (valores[index + 1] - 1)\n return true if index == (valores.size - 2)\n end\n end",
"def check_for_inconsistency(elements)\n elements.any?{|e| e != elements.first}\n end",
"def happens_before_non_strict(v)\n #need to ensure there is at least one element that is strictly less-than\n for client in (v.get_clients+self.get_clients).uniq\n if @vector.has_key?(client) && @vector[client] > v[client]\n return false\n end\n end\n\n return true\n end",
"def verificaciones_valid\n return false unless self.verificaciones?\n self.verificaciones.collect { |i|\n i if i['cancelado'] == 'NO'\n }.compact\n end",
"def ==(*several_variants)\n #This is a stub, used for indexing\n end",
"def <=(other_list)\n return false if other_list.list.empty?\n return true if self.list.empty?\n\n return (\n self.max_item[1] <= other_list.max_item[1] &&\n self.min_item[1] <= other_list.min_item[1]\n )\n end",
"def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left != right, message)\n end",
"def all_equal?\n a = self.first\n all? { |b| a == b }\n end",
"def verificaciones_approved\n return false unless self.verificaciones_valid?\n self.verificaciones_valid.collect { |i|\n i if i['resultado'] != 'RECHAZO'\n }.compact \n end",
"def valida_conta?(lista)\n valida = true\n\n for x in [lista[0], lista[2], lista[3], lista[4]]\n valida = false if x.class != Fixnum\n end\n\n if valida\n valida = false if lista[1].class != Float\n valida = false if lista[5].class != String\n valida = false if lista[6].class != String\n end\n return valida\n end",
"def include?(list,tst)\n list.each {|itm| return true if itm == tst}\n false\nend",
"def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} does not have the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left == right, message)\n end",
"def eql?(other)\n items == other.items\n end",
"def include?(value)\n each do |index, list_value|\n return true if list_value == value\n end\n return false\n end",
"def same_ids?(item_ids)\n all_item_ids.sort == item_ids.sort\n end",
"def all_same?\n self.all? { |element| element == self[0] }\n end",
"def all_same?\n self.all? { |element| element == self[0] }\n end",
"def valid?\n if value.is_a?(Array)\n (value - self.class.list).none?\n else\n self.class.list.include?(value)\n end\n end",
"def all_votes_specified?\n # if at least one value is nil, return false\n return false if (pro.nil? or pro == \"\") or\n (con.nil? or con == \"\") or\n (abs.nil? or abs == \"\")\n # otherwise return true\n return true\n end",
"def all_votes_specified?\n # if at least one value is nil, return false\n return false if (pro.nil? or pro == \"\") or\n (con.nil? or con == \"\") or\n (abs.nil? or abs == \"\")\n # otherwise return true\n return true\n end",
"def comp_2(array1, array2)\n array1.nil? || array2.nil? ? false : array1.sort.map { |e| e * e } == array2.sort\nend",
"def all_same?(first_operand, arglist)\n if arglist.empty?\n boolean(true)\n else\n first_value = first_operand.value\n all_equal = arglist.all? { |elem| first_value == elem.value }\n boolean(all_equal)\n end\n end",
"def test\n\t\t@a+@b > @c && @a+@c > @b && @b+@c > @a\n\tend",
"def item_in_list(check, list)\n list.each do |item|\n if check == item\n return true\n end\n end\nend",
"def comp(array1, array2)\n return false if array1.nil? || array2.nil? || array1.length != array2.length\n a = array1.sort\n b = array2.sort\n b.each_with_index do |value, i|\n if a[i]*a[i] != value\n return false\n end\n end\n return true\nend",
"def sort_cards_by_value_bis!()\r\n\t\taucun_echange=false\r\n\t\twhile aucun_echange==false\r\n\t\t\taucun_echange=true\r\n\t\t\tlen=@list.length-2\r\n\t\t\tfor i in 0..len\r\n\t\t\t\tif !@list[i].nil? and !@list[i+1].nil?\r\n\t\t\t\t\tif @list[i].get_value_bis<@list[i+1].get_value_bis\r\n\t\t\t\t\t\ttemp=@list[i]\r\n\t\t\t\t\t\t@list[i]=@list[i+1]\r\n\t\t\t\t\t\t@list[i+1]=temp\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telsif @list[i].get_value_bis == @list[i+1].get_value_bis\r\n\t\t\t\t\t\t@list.delete_at(i)\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def sort_cards_by_value!()\r\n\t\taucun_echange=false\r\n\t\twhile aucun_echange==false\r\n\t\t\taucun_echange=true\r\n\t\t\tlen=@list.length-2\r\n\t\t\tfor i in 0..len\r\n\t\t\t\tif !@list[i].nil? and !@list[i+1].nil?\r\n\t\t\t\t\tif @list[i].get_value<@list[i+1].get_value\r\n\t\t\t\t\t\ttemp=@list[i]\r\n\t\t\t\t\t\t@list[i]=@list[i+1]\r\n\t\t\t\t\t\t@list[i+1]=temp\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telsif @list[i].get_value == @list[i+1].get_value\r\n\t\t\t\t\t\t@list.delete_at(i)\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def test_compare\r\n assert_equal(-1, @lucas<=>@uwe)\r\n assert_equal(-1, @lucas<=>@person1)\r\n assert_equal(-1, @person1<=>@person2)\r\n assert_equal(1, @person2<=>@person3)\r\n\r\n assert_equal(0, @lucas<=>@lucas2)\r\n\r\n assert_equal(1,@lucas.<=>(@uwe,2))\r\n end",
"def eql_one? values\n\t\tif values.class == Array\n\t\t\treturn false if values.empty?\n\t\t\tvalues.each do |value|\n\t\t\t\treturn true if value.eql? self\n\t\t\tend\n\t\t\treturn false\n\t\telse\n\t\t\treturn to_check == values\n\t\tend\n\tend",
"def trio?\n @valores.to_h.select{|k, v| (3..3).cover?(v)}.size == 1\n end",
"def comp(array1, array2)\n p array1\n p array2\n if array1.nil? || array2.nil?\n return false\n else\n array2 = array2.map { |num| Math.sqrt(num) }\n p array1.sort\n p array2.sort\n array1.sort == array2.sort\n end\nend",
"def compare(obj_ser, obj_deser)\n assert_equal obj_ser.list1, obj_deser.list1\n end",
"def comp(array1, array2)\n return false if array1.nil? || array2.nil?\n\n array1.sort.map { |e| e * e } == array2.sort\nend",
"def compare_list(attrs={})\n match = true\n # assume linux\n md5sum = \"md5sum\"\n md5sum = \"md5\" if node.platform == \"freebsd\"\n\n attrs['compare_list'].each do |src_file, dst_file|\n src = `#{md5sum} #{Chef::Config[:file_cache_path]}/#{attrs['src_dir']}/#{src_file}`.split(/\\s+/)\n dst = `#{md5sum} #{attrs['prefix']}/#{dst_file}`.split(/\\s+/)\n if (src[0] != dst[0]) || src[0].nil? || dst[0].nil?\n p \"#{src_file} #{attrs['prefix']}/#{dst_file}\"\n p \"#{src[0]} #{dst[0]}\"\n match = false\n end\n end\n return match\nend",
"def ==(other_list)\n return false if !other_list.is_a?(InkList)\n return false if other_list.list.size != self.list.size\n\n return self.list.all?{|item, int_value| other_list.list.has_key?(item) }\n end",
"def check_empty_order(items)\r\n flag = items.item.length\r\n items.item.each do |h|\r\n (flag -= 1) if h[:num] == 0\r\n end\r\n return true if flag == 0\r\n return false\r\nend",
"def ==(other)\n @element_list == other.element_list\n end",
"def on(numbers)\n sorted_numbers = numbers.sort\n\n sorted_numbers.each_with_index do |number, index|\n return true if number == sorted_numbers[index + 1]\n end\n\n false\n end",
"def matches?(other)\n operable_values == other.operable_values\n end",
"def valid?(list)\n l = zip(list).map {|a,i| a.optional? ? nil : i }\n l.flatten.compact.size >= min && possible?(list)\n end",
"def sim_list_compare(other)\n return os_name.to_s <=> other.os_name.to_s unless os_name == other.os_name\n return other.os_version <=> os_version unless os_version == other.os_version\n device1, model1 = device_and_model\n device2, model2 = other.device_and_model\n return device_compare(device1, device2) unless device1 == device2\n return model1 <=> model2 unless model1.nil? || model2.nil?\n model2.nil? ? 1 : -1\n end",
"def eql?(other)\n @element_list.each do |element|\n return false unless other.element_list.include? element\n end\n other.element_list.each do |element|\n return false unless @element_list.include? element\n end\n true\n end",
"def ordenar(*valores)\r\n valores.sort\r\nend",
"def testLigneContient(a,a2)\n\t\t0.upto(a.size-1) do |x|\n\t\t\tif a[x].couleur != a2[x].couleur && a2[x].couleur != Tuile.getCouleurVide \n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\n\tend",
"def is_equal?(old_values,new_values,multivalued_field=false)\n new_values_split = (multivalued_field && new_values.class != Array && !new_values.blank?) ? new_values.to_s.split(\"|\") : new_values # if the user has indicated the first value is coming a special multivalued field entered as a single value, let's split along the delimiter\n compare_values1=self.to_array(old_values).collect{|val| val.to_s.strip.gsub(/\\r\\n?/, \"\\n\")}.delete_if(&:blank?).sort\n compare_values2=self.to_array(new_values_split).collect{|val| val.to_s.strip.gsub(/\\r\\n?/, \"\\n\")}.delete_if(&:blank?).sort\n compare_values1 == compare_values2\n end",
"def valid?(side1, side2, side3)\n return false if (side1 <= 0) || (side2 <= 0) || (side3 <= 0)\n tmp = [side1, side2, side3]\n tmp.sort!\n tmp[0..1].sum > tmp[-1]\nend",
"def areSimilar(a, b)\n count = 0\n \n for i in 0..(a.count-1)\n if a[i] != b[i]\n count += 1\n end\n end\n \n if count < 3\n if a.sort == b.sort\n return true\n end\n end\n \n false\nend",
"def all_eql?(arr)\n arr.each_cons(2).all? { |x, y| x == y }\n end",
"def validate_items\n not(empty_item_list? or has_invalid_items? ||\n has_different_point_values?) ? true : false\n end",
"def true_comparitons\n ['be','is','are','were','=','>','>=','==','<=','<','=<','gt','lt','eq','bigger','greater','equals','identical to',\n 'smaller','less','equal to','more','less','the same as','same as','similar']\n end",
"def check_for_equal_item(name, price, description, item_not_to_compare = nil)\r\n index = items.index {|x| x.name.eql?(name) and x.price.eql?(price) and x.description.eql?(description) and x != item_not_to_compare}\r\n return items[index] unless index == nil\r\n end",
"def values_equal?(bav, pav)\n values_sndiff_equal?(bav, pav) || array_value_diff_ignored? && pav.is_a?(Array) && pav.size == 1 && values_sndiff_equal?(bav, pav[0])\n end",
"def comparable? = super && index.comparable?",
"def test_check_valid\n assert_equal check_valid([2, '1', '5']), [0, 2, 1, 5]\n end",
"def areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight)\n [yourLeft,yourRight].sort == [friendsLeft,friendsRight].sort\nend",
"def check_list(array)\n min = array.first\n i = 0\n while i < array.length\n j = i + 1\n while j < array.length\n min = array[i] if array[i] < array[j] && array[i] < min\n j += 1\n end\n i += 1\n end\n min\n end",
"def compare_equal?(item, line_item)\n ![\n :ax_account_number,\n :ax_account_id,\n :ax_order_number,\n :ax_order_id,\n :email_address,\n :first_name,\n :last_name,\n :serial_number,\n :purch_order_form_num\n ].detect { |attr| item.send(attr) != line_item.send(attr) }\n end",
"def valid?(v)\n values.include?(normalize(v))\n end",
"def comp(array1, array2)\n return false if (array1+array2).any? {|x| x == nil }\n array1.delete(nil)\n squares = array1.map { |num| num*num }\n squares.uniq.sort == array2.uniq.sort\nend",
"def among_validate_in_values?\n vs = @cfg.valid_values\n !vs || vs.include?(@value)\n end",
"def same_as?(l2)\r\n\t\tself.product.id == l2.product.id && self.option_values == l2.option_values\r\n\tend",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n id_conta == o.id_conta &&\n id_pessoa == o.id_pessoa &&\n id_cartao == o.id_cartao &&\n id_bandeira == o.id_bandeira &&\n id_tipo_cartao == o.id_tipo_cartao &&\n numero_cartao == o.numero_cartao &&\n nome_plastico == o.nome_plastico &&\n cvv2 == o.cvv2 &&\n data_geracao == o.data_geracao &&\n data_validade == o.data_validade &&\n cpf == o.cpf &&\n tipo_portador == o.tipo_portador &&\n trilha1 == o.trilha1 &&\n trilha2 == o.trilha2 &&\n trilha_cvv1 == o.trilha_cvv1 &&\n trilha_cvv2 == o.trilha_cvv2 &&\n flag_virtual == o.flag_virtual &&\n nome_bandeira == o.nome_bandeira &&\n flag_titular == o.flag_titular &&\n sequencial_cartao == o.sequencial_cartao &&\n id_status == o.id_status &&\n descricao_status_cartao == o.descricao_status_cartao &&\n data_status == o.data_status &&\n id_estagio == o.id_estagio &&\n descricao_estagio == o.descricao_estagio &&\n data_estagio == o.data_estagio &&\n numero_bin == o.numero_bin &&\n id_produto == o.id_produto &&\n descricao_produto == o.descricao_produto &&\n id_status_conta == o.id_status_conta &&\n descricao_status_conta == o.descricao_status_conta &&\n data_embossing == o.data_embossing &&\n codigo_desbloqueio == o.codigo_desbloqueio &&\n nome_pessoa == o.nome_pessoa &&\n tipo_pessoa == o.tipo_pessoa &&\n data_nascimento == o.data_nascimento &&\n id_endereco == o.id_endereco &&\n id_tipo_endereco == o.id_tipo_endereco &&\n descricao_tipo_endereco == o.descricao_tipo_endereco &&\n cep == o.cep &&\n logradouro == o.logradouro &&\n numero_endereco == o.numero_endereco &&\n complemento_endereco == o.complemento_endereco &&\n bairro == o.bairro &&\n cidade == o.cidade &&\n uf == o.uf &&\n pais == o.pais &&\n senha_criptografada == o.senha_criptografada &&\n icvv == o.icvv &&\n id_status_impressao == o.id_status_impressao\n end",
"def sorted?\n if first_item.nil?\n return 1\n end\n if first_item == first_item.next_list_item\n return 1\n end\n # puts \"\\n 100 first_item.payload = #{first_item.payload} \\nfirst_item.next_list_item.payload = #{first_item.next_list_item.payload} \"\n if first_item.payload != first_item.next_list_item.payload\n # puts \"\\n first_item.payload = #{first_item.payload} \\nfirst_item.next_list_item.payload = #{first_item.next_list_item.payload} \"\n return 1\n else\n # puts \"\\n -1 yo\"\n return -1\n end\n # if first_item.payload != first_item.next_list_item.payload\n # if first_item.payload > first_item.next_list_item.payload\n # return true\n # else\n # return false\n # end\n # end\n end",
"def all_same?\n\t\t\tself.all? { |element| (element == self[0]) && (element != nil) }\n\t\tend",
"def all_items(item)\r\n result = false\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.get_name == item.get_name )\r\n return true\r\n else\r\n result = false\r\n end\r\n }\r\n else\r\n result = false\r\n end\r\n\r\n return result\r\n end",
"def include?(ary, value)\r\n ary.select{ |obj| obj == value } != []\r\nend",
"def indexes_exist?(vegie_arr, choice_arr)\n vegie_index = []\n vegie_arr.each_index {|index| vegie_index << index}\n if choice_arr.length > vegie_arr.length\n return false\n else\n choice_arr.each do |value|\n return false if !vegie_index.include?(value - 1)\n end\n end\n true\n end",
"def combicheck(ref_arr, result)\r\n found_combi = []\r\n not_found_combi = []\r\n ref_arr.each do |item|\r\n #p item\r\n if combifind_in(item, result)\r\n found_combi << item\r\n else\r\n not_found_combi << item\r\n end\r\n end\r\n if found_combi.size == ref_arr.size\r\n log \"Combicheck is ok\"\r\n return true\r\n else\r\n log \"Combicheck failed, NOT found #{not_found_combi.size}/#{ref_arr.size} combi, they are:\"\r\n not_found_combi.each{|e| puts e.join(\",\") }\r\n end\r\n return false\r\n end",
"def set_complete?(eqps = [])\n itms = items\n !itms.empty? && ((itms & eqps).size == itms.size)\n end",
"def all_different?\n a = self.to_a.drop(1)\n self.each do |e|\n return false if a.include?(e)\n a.shift\n end\n return true\n end",
"def ==(val)\n a1 = val\n a2 = @vtag[0].dup\n a1.sort!\n a2.sort!\n\n # for each word in a1 make sure *any* word minimally matches in a2\n a1.each do |word|\n i = 0\n found = false\n loop do\n return false if !a2[i]\n if a2[i].start_with?(word) # if this is a match we need to make sure that array position id deleted. It can't be used again to match\n found = true\n a2.delete_at(i) # delete this position\n break\n end\n i += 1\n end\n return false if !found # if this match didn't pass return false.\n end\n return true\n end",
"def isSame(tab)\n for x in 0..3\n for y in 0..3\n return(false) if (self.val(x,y) != tab.val(x,y)) ;\n end\n end\n return true ;\n end",
"def in_order?(arr)\r\n # your code goes here\r\n\r\n arr == arr.sort\r\nend",
"def campare_values(a, b)\n\t\tif a == b\n\t\t\t#puts\"#{a} and #{b}\"\n\t\t\tputs \"Item count is same as before\"\n\t\telsif a > b\n\t\t\tputs \"Item is removed from the basket\"\n\n\t\telse\n\t\t\tputs \"Item is added into basket\"\n\t\tend\n\n\tend",
"def validate_comb(board_view, comb)\n comb.each_with_index do |value, idx|\n return false unless board_view[idx].include?(value)\n end\n true\nend",
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n id_transferencia == o.id_transferencia &&\n valor_cet == o.valor_cet &&\n id_autorizacao == o.id_autorizacao &&\n codigo_autorizacao == o.codigo_autorizacao &&\n nsu_origem == o.nsu_origem &&\n id_conta == o.id_conta &&\n id_cartao == o.id_cartao &&\n id_operacao == o.id_operacao &&\n valor_compra == o.valor_compra &&\n valor_parcela == o.valor_parcela &&\n valor_contrato == o.valor_contrato &&\n numero_parcelas == o.numero_parcelas &&\n valor_iof == o.valor_iof &&\n valor_tac == o.valor_tac &&\n valor_taxa_saque == o.valor_taxa_saque &&\n taxa_juros == o.taxa_juros &&\n data_compra == o.data_compra &&\n data_movimento == o.data_movimento &&\n data_vencimento_real == o.data_vencimento_real &&\n data_vencimento_padrao == o.data_vencimento_padrao &&\n data_autorizacao == o.data_autorizacao &&\n banco == o.banco &&\n numero_agencia == o.numero_agencia &&\n digito_agencia == o.digito_agencia &&\n numero_conta == o.numero_conta &&\n digito_conta == o.digito_conta &&\n flag_conta_poupanca == o.flag_conta_poupanca &&\n documento_favorecido == o.documento_favorecido &&\n nome_favorecido == o.nome_favorecido &&\n status == o.status &&\n status_processamento == o.status_processamento\n end",
"def assert_facets_have_values(facets)\n facets.size.should > 1\n # should have at least one value for each facet\n facets.each do |facet|\n facet.items.size.should >= 1\n end\nend"
] |
[
"0.598365",
"0.5930304",
"0.5918263",
"0.5692191",
"0.55947196",
"0.5529169",
"0.5526782",
"0.55149204",
"0.5504688",
"0.5460339",
"0.5427653",
"0.5420974",
"0.5414546",
"0.54072195",
"0.5378469",
"0.53717905",
"0.5363165",
"0.5352386",
"0.5349939",
"0.5338657",
"0.53374577",
"0.5333521",
"0.53227496",
"0.53145266",
"0.5308637",
"0.5307428",
"0.5281023",
"0.5277003",
"0.52702665",
"0.5263539",
"0.5251872",
"0.52368873",
"0.5220092",
"0.5212828",
"0.52059066",
"0.5203524",
"0.5202149",
"0.5200778",
"0.52007675",
"0.5190055",
"0.5190055",
"0.51886314",
"0.5175444",
"0.5175444",
"0.5173706",
"0.517104",
"0.51675916",
"0.5166027",
"0.51603633",
"0.5159906",
"0.5159359",
"0.51566964",
"0.5154298",
"0.5146544",
"0.51455414",
"0.5144808",
"0.51427317",
"0.5141168",
"0.5140294",
"0.5132804",
"0.51316154",
"0.5119929",
"0.51173335",
"0.51169807",
"0.51158816",
"0.5103624",
"0.510127",
"0.50920904",
"0.50883436",
"0.5084898",
"0.5084491",
"0.5079287",
"0.50777924",
"0.5076202",
"0.50652814",
"0.50588465",
"0.5054203",
"0.50529873",
"0.50515795",
"0.504727",
"0.5035548",
"0.5033767",
"0.50308543",
"0.50278324",
"0.5026062",
"0.5020818",
"0.50195324",
"0.5010889",
"0.50104636",
"0.5008651",
"0.5007678",
"0.49985057",
"0.49918583",
"0.49907708",
"0.49889842",
"0.4987792",
"0.49831733",
"0.49815932",
"0.49652553",
"0.49611884",
"0.49593267"
] |
0.0
|
-1
|
Mostrar los valores de la cabeza de la lista
|
def to_s
"#{@head.value}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def listar_arreglo(arreglo)\n cadena = '| '\n # puts 'el indice: #{index} y el valor: #{value}'\n arreglo.each { |value| cadena += \" #{value} | \" }\n puts cadena\nend",
"def print_items\n return values\n end",
"def lista(contatos)\n\tfor i in 0..contatos.size-1\n\t\tputs (\"#{i+1}. #{contatos[i].nome}\")\n\t\ti = i + 1\n\tend\nend",
"def mostrar_resultados\n calcular\n s=\"Resultados\\n\"\n for j in 0..@resultados.length-1\n s << @resultados[j].to_s\n end\n s\n end",
"def display_values\n options.each do |option|\n update_ui option, read(option)\n end\n end",
"def ar_show_data \n result= []\n \n controller.ardata.fields.for_show.each do |column, title|\n label= ar_get_index_label(title)\n if label && !label.empty?\n result << content_tag(:dt, label)\n result << content_tag(:dd, ar_get_resource_value(@resource, column))\n end\n end\n \n content_tag :dl, result.join(\"\\n\")\n end",
"def show_all_values my_array\n puts \"\\nAll Values: \"\n puts \"-----------\"\n my_array.each do |value| \n puts \"Name: \" + value.get_name.to_s\n puts \" Area: \" + value.get_area.to_s\n puts \" Temperature: \" + value.get_temperature.to_s\n puts \"Radiator: \" + value.get_num_radiator.to_s\n puts \" Ground: \" + value.get_num_ground.to_s\n puts \" Num: \" + value.get_num.to_s + \"\\n\\n\"\n end \n end",
"def print_all_value_from_list_elements(objects)\n puts \"Total count of the length is: #{objects.length}\"\n objects.each do |item|\n puts \"Item text == >>> #{item.text.upcase}\"\n end\n end",
"def print_item\n return values\n end",
"def show_list\n\t\tclear\n\t\tputs \"= LISTE DES INSTANCES #{name} =\".bleu\n\t\tputs \"\\n\\n\"\n\t\tlen_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80\n\t\tdelim = (\"-\"*len_delim).bleu\n\t\tif defined?(LIST_ENTETE)\n\t\t\tputs delim\n\t\t\tputs LIST_ENTETE \n\t\tend\n\t\tputs delim\n\t\tall.each do |inst|\n\t\t\tputs \" #{inst.to_console}\"\n\t\tend\n\t\tputs delim\n\t\tputs \"\\n\\n\"\n\tend",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def mostrar_dados\n puts \"Partido: #{@nome} - Votos: #{@votos}\" \n end",
"def mostrar_actual\n \"#{@actual[:value]}\\n\\n\"\n end",
"def mostrar_fin\n \"#{@fin[:value]}\\n\\n\"\n end",
"def afficher_liste_cours()\n LISTE_COURS.each do |cours_temp|\n puts \"---\"\n puts \"Nom du cours : \"+cours_temp[\"nom\"]\n puts \"Effectif : \"+cours_temp[\"effectif\"].to_s+\"/\"+cours_temp[\"effectif_limite\"].to_s\n puts \"Enseignant : \"+cours_temp[\"enseignant_nom\"]\n end\nend",
"def show\n @categorias = @livro.assunto.split(',')\n end",
"def each\n\t\t@nombre\n\tend",
"def print_info\n self.values.each do |value|\n puts value\n end\n end",
"def listinfo\n puts \"排名:#{@no}\"\n puts \"月份:#{@month}\" if @month\n puts \"标签: #{@subtag}\" if @subtag\n puts \"标题:#{@title}\"\n puts \"集数:#{@episode}\" if @episode\n puts \"链接:#{@link}\"\n puts \"<bilibili独家哟!>\" if @bilibilionly_flag\n puts \"--------------------\"\n end",
"def list \n @@Ordenadores\n end",
"def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo.push(@emisiones_diarias)\n formateo.push(@metros_terreno)\n\n formateo\n end",
"def liste()\n puts(\"LISTE DES ORDRES\\n\");\n printf(\"%8s %8s %5s %10s\\n\",\n \"ID\", \"DEBUT\", \"DUREE\", \"PRIX\")\n printf(\"%8s %8s %5s %10s\\n\",\n \"--------\", \"-------\", \"-----\", \"----------\")\n @listOrdre = @listOrdre.sort{ |a,b| a.debut <=> b.debut } \n @listOrdre.each { |ordre| afficherOrdre(ordre) }\n printf(\"%8s %8s %5s %10s\\n\",\n \"--------\", \"-------\", \"-----\", \"----------\");\n end",
"def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo\n end",
"def atributos\n p \"El Modelo del carro es: #{@modelo}, la Marca es: #{@marca} y el Color es: #{@color}\"\n end",
"def values\n end",
"def show\n combo_producto\n combo_platillo\n end",
"def print_values(list)\n if !list\n print \"nil\\n\"\n else\n print \"#{list.value} -> \"\n print_values(list.next_node)\n end\n end",
"def print_parameters()\n @h.each do |clave, valor|\n \n $LOG.debug \"The Parameter #{clave} have the value \" +valor.to_s\n end\n end",
"def mostrar_datos\n\tputs \"Los datos de #{@nombre} son: \" <<\n\t\"\\nY: \" << get_Y.to_s <<\n\t\"\\nK: \" << get_K.to_s << \"\\n---------------------\\n\"\n\n\tend",
"def show\n @ciudadDomicilio = @ciudadesColombia.select{|h| h.id == @persona.pers_ciudadDomicilio}.map{|j| j.enter_nombreCorto}.pop\n end",
"def titulares_serial\n Representante.find(self.titular_ids_serial).map(&:nombre)\n end",
"def display\n\t\tcurrent_node = @head\n\t\tlinked_list_array = []\n\t\twhile current_node != nil\n\t\t\t\n\t\t\tlinked_list_array << current_node.value\n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tlinked_list_array\n\tend",
"def to_s\n\t \tputs \"#{@autor}, #{@numero_paginas}, #{@isbn}, #{@valor}, #{@categoria}\"\n\t end",
"def mostrar_palabras_clave_grupos \n \n puts \"Esta operación puede tardar un poco, le rogamos tenga paciencia por favor.\"\n puts\n puts\n coleccion = @hemeroteca.palabras_clave_grupos \n coleccion.each_index do |i|\n puts \"Grupo #{i+1}:\" \n puts \"---------\"\n puts coleccion[i].join(\", \")\n puts \n puts \n end\n if coleccion.empty? then\n puts \"Lo sentimos, no se han encontrado noticias.\" \n puts\n puts\n end \n \n end",
"def to_s\n output = @name\n output << \"\\n#{'=' * @name.size}\\n\"\n output << \"Platos: #{@platos.join(', ')}\\n\"\n output << \"Precio total del menu: #{@precios.reduce(:+)}\\n\"\n output << \"\\nValor calorico total del menu: #{@valor_energetico.reduce(:+).round(1)}\"\n output << \"\\nValor de las emisiones de CO2 del menu: #{@valor_ambiental.reduce(:+).round(1)} \\n\"\n\n end",
"def display (list)\n\tputs list\nend",
"def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a = t.adicional\n\n tipo_region = params[:tipo_region] == \"anp\" ? \"ANP \" : \"Municipio de \"\n \n if a.nombre_comun_principal.present?\n titulo[0] = \"Guía de #{a.nombre_comun_principal}\"\n else\n titulo[0] = \"Guía de #{t.nombre_cientifico}\"\n end\n\n titulo[1] = tipo_region + params[:nombre_region]\n titulo\n end",
"def showlist\n\t\t@people_list.each do |x|\n\t\t\tputs \"* #{capitalize(x.type)}, #{capitalize(x.name)}, #{capitalize(x.party)}\"\n\t\tend\n\tend",
"def show_options \n \n @consequences.each do | index, value |\n puts \"#{index}. #{value.keys.join}\"\n end\n end",
"def values() end",
"def display\n return \"#{@type} (CHOOSE ONE: #{@items.join(', ')})\"\n end",
"def values\n end",
"def lister( les_cours )\n \n recup = recuperer_option \n format = recup[0]\n sep = recup[2]\n if !recup[1].nil?\n cours = les_cours.sort_by(&:sigle)\n end\n \n cours ||= les_cours.select{|c| c.actif?}\n sep ||= CoursTexte::SEPARATEUR_PREALABLES\n cours =cours.sort_by(&:sigle)\n cours.each { |e| puts e.to_s(format, sep) }\n \n return [les_cours, nil]\n \nend",
"def display_list(teampaks)\n i = -1\n @data.list = list = teampaks.map do |mem|\n i += 1\n creator = mem.creator.contact\n { \n \"mem_id\" => mem.mem_id,\n \"full_passport\" => mem.full_passport,\n \"mem_name\" => mem.mem_name,\n \"mem_schoolname\" => mem.mem_schoolname,\n \"coordinator\" => creator.con_name,\n \"con_city\" => creator.mail.add_city,\n \"con_zip\" => creator.mail.add_zip,\n \"reg_#{i}\" => mem.mem_region,\n \"i\" => i,\n }\n end\n\n common_display(list, false)\n end",
"def print_values(list_node)\n\t\t\tif list_node\n\t\t\t\tprint \"#{list_node.value} --> \"\n\t\t\t\tprint_values(list_node.next_node)\n\t\t\telse\n\t\t\t\tprint \"nil\\n\"\n\t\t\t\treturn\n\t\t\tend\n\t\tend",
"def to_s\n\t\t@platos.each do |alimento|\n\t\t\tputs alimento.nombre\n\t\tend\n\tend",
"def set_listas\n #@locais = Local.all.map{|l| [l.nome,l.id]}\n @locais = Local.all\n @periodos = ['Manhã','Tarde','Noite']\n @publicos = ['Infantil','Adulto']\n end",
"def all\n s = []\n unless @list.empty?\n s << \"Auto-display expressions now in effect:\nNum Enb Expression\"\n @list.each do |display|\n s << display.format\n end\n end\n s\n end",
"def to_s\n\t\tstring = @nombre + \" ,Ingredientes: \"\n\t\t@lista.zip(@listagr).each do |normal, gr|\n string += normal.nombre + \" \" \n\t\t\tstring += gr.to_s + \" gr \"\n end\n\t\tstring\n\tend",
"def mostrar_candidatos\n \n puts \" \"\n puts \"Quantidade de votos por candidato\"\n #Buca o candidato em seu array\n for candidato in @candidato\n candidato.mostrar_dados \n end \n end",
"def show_possible_values(options={})\n\t\t@operator.choose do |menu|\n\t\t\toptions.each do |key, value|\n\t\t\t\tmenu.choice(key) { value }\n\t\t\tend\n\t\tend\n\tend",
"def index\n @valor_arriendos = ValorArriendo.all\n end",
"def get_txt_panneau\n\t\treturn [mdl_par.panneaux[0].to_s,mdl_par.panneaux[1].to_s]\n\tend",
"def to_s() # :nodoc:\n mano_seleccionada = super.to_s # Hago un llamado al metodo to_s de mi padre que maneja\n # la impresion de la mano seleccionada\n if not @estrategias.nil?\n return \"Las estrategias suministradas son \" + @estrategias.to_s + \" \" + mano_seleccionada\n end\n return \"La lista de estrategias provista no es valida\"\n end",
"def list_items\n @items.each do |type,list|\n puts \"#{type}\"\n puts \"--------------------\"\n list.each {|item, key| puts \"#{item} #{key}\"}\n puts \"\"\n end\n end",
"def telefones\n self.contato_telefones.map{|a| \"(#{a.ddd}) #{a.numero}\"}\n end",
"def show\n @array = []\n @array << { y: '03/2016', a: 100, i: 300}\n\n @horario = @empleado.horarios.last\n end",
"def lister( les_emprunts )\n liste_emprunts = les_emprunts.select{|e| OPTIONS[:inclure_perdus] ? true : not(e.perdu?) }\n liste_emprunts = liste_emprunts.map{|e| e.to_s(OPTIONS[:format])}\n\n [les_emprunts, liste_emprunts.join(\"\\n\")]\nend",
"def to_s\n i = 0\n temp = \"\"\n for pk in @pl\n i += 1\n temp += i.to_s + \". \" + pk.nombre + \"\\n\"\n end\n temp\n end",
"def display_list(list)\n\t\tsanitize(list.empty? ? \"None\" : list.map(&:display).join(', '))\n\tend",
"def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end",
"def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end",
"def decir_adios\n if @nombres.nil?\n puts \"...\" \n elsif @nombres.respond_to?(\"join\")\n # junta los elementos de la lista usando la coma como separador\n puts \"Adiós #{@nombres.join(\", \")}. Vuelvan pronto.\"\n else\n puts \"Adiós #{@nombres}. Vuelve pronto.\"\n end\n end",
"def decir_adios\n\t\tif @nombres.nil?\n\t\t\tputs \"...\"\n\t\telsif @nombres.respond_to?(\"join\")\n\t\t\t\tputs \"Adios #{@nombres.join(\", \")}. Vuelvan pronto\"\n\t\telse\n\t\t\t\tputs \"Adios #{@nombres}. Vuelve pronto\"\n\t\tend\n\t\tend",
"def prints\n tiros = @tiros\n tiros.each do |tiro_puntaje|\n puts \"Puntaje por tiro: #{tiro_puntaje}\"\n end\n end",
"def print_autor\n count = 0\n lista = \"\"\n autores.each do |autor|\n count += 1\n lista += get_autores_apellidos(autor)\n lista += \" & \" if count != autores.size\n end\n lista\n end",
"def info_conta\n # CAMPO TAMANHO\n # agencia 3\n # conta corrente 7\n \"#{agencia}#{conta_corrente}\"\n end",
"def show_values\n puts \"Name: \" + @heating_name\n puts \" Area: \" + @heating_area.to_s\n puts \" Temperature: \" + @heating_temperature.to_s\n puts \"Radiator: \" + @num_radiator.to_s\n puts \" Ground: \" + @num_ground.to_s\n puts \" Num: \" + @num.to_s\n end",
"def show_data(param)\n\tparam.each do |k,v|\n\t\tputs \"#{k} : #{v}\"\n\tend\nend",
"def setResult(divisores)\t\t\n\t\tcadena=\"\"\n\t\tdivisores.each do |num|\t\t\n\t\t\tcase num\n\t\t\t\twhen 3\n\t\t\t\t cadena = cadena.concat(\"Pling\")\n\t\t\t\twhen 5\n\t\t\t\t cadena = cadena.concat(\"Plang\")\n\t\t\t\twhen 7 \t\n\t\t\t\tcadena = cadena.concat(\"Plong\")\t\t\t\t\n\t\t\tend\t\t\t\t\n\t\tend\n\t\treturn cadena\n\tend",
"def show_mano\n @mi_mano.sort_by{|k, v| v[:valor]}.to_h.map {|k, v| {k => {v[:numero] => v[:pinta]}} }\n end",
"def to_s\n\ts = \"\\nLista de Individuos y sus alimentos\\n\"\n for j in 0..@individuos.length-1\n s << @individuos[j].to_s + \"\\n\"\n end\n s\n end",
"def clasificar_por_sal (lista)\n \n sal_recomendada = Lista.new()\n sal_excesiva = Lista.new()\n \n nodo = lista.extract\n \n while !(nodo.nil?)\n \n if nodo.value.sal > 6\n sal_excesiva.insert(nodo.value.sal)\n else\n sal_recomendada.insert(nodo.value.sal)\n end\n nodo = lista.extract\n end\n \n \"Los productos con una cantidad de sal menor o igual a la recomendada son #{sal_recomendada.to_s} y los que tienen una sal excesiva son #{sal_excesiva.to_s}\"\n \nend",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def to_s()\n [@nombre, @gei, @terreno, @proteinas, @lipidos, @glucidos]\n end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def to_s\n\t\t\t \"( Nombre:#{@nombre}, Conjunto Alimentos: #{@la} ,Conjunto Gramos: #{@lg} ,Proteinas :#{@proteinas},Carbo :#{@carbohidratos},Lipidos :#{@lipidos},VCT :#{@vct} )\"\n\n\t\tend",
"def show\n @mia_tabella = Search.mia_tabella(@search.tabella)\n @mio_campo = Search.mio_campo(@search.campo)\n @mio_tipo = Search.mio_tipo(@search.tipo)\n #\n @descrizione = @search.descrivi()\n end",
"def diz_adeus\n\t\tif @nomes.nil?\n\t\t\tputs \"...\"\n\t\telsif @nome.respond_to?(\"join\")\n\t\t\t#juntar os elemenos à lista\n\t\t\t#juntando a virgula como separador\n\t\t\tputs \"Adeus #{@nomes.join(\", \")}. Voltem em breve.\"\n\t\telse\n\t\t\tputs \"Adeus #{@nomes}. Volta em breve.\"\n\t\tend\n\tend",
"def show\n @objetivos = Objetivo.select(\"id\", \"nombre\",\"descripcion\").where(:mision_id => params[:id])\n @estrellas = Estrella.select(\"idobjetivo_id\", \"idusuario_id\", \"est1\", \"est2\", \"est3\").where(idusuario_id: current_usuario.id)\n #Para optimizar se deberá agregar un campo de idmision y requerirlo en la misma consulta de la línea anterior, para disminuir el tamaño del array\n end",
"def all\n \"#{name}| #{code}| #{cargo}| #{area}| #{mundo}\"\n end",
"def to_s\n\t\tputs \"{#{@nombre} => Proteínas: #{@proteinas} Carbohidratos: #{@carbohidratos} Lípidos: #{@lipidos} GEI: #{@gei} Terreno usado: #{@terrenousado}}\"\n\tend",
"def show\n ##puts Transacao.find(2).cliente.nome\n ##puts Imposto.find(18).tabela_de_limites.limite_inferior\n end",
"def list_chairs\r\n puts \"Choose a product to see information\"\r\n @chairs.each.with_index(1) do |chair, index|\r\n puts \"#{index}. #{chair.name}\"\r\n end\r\n puts \"**************************************\"\r\n puts \"Type the number of the chair that you wish you see.\"\r\n end",
"def to_s()\n puts \"Nume: \"+@nume+\" Prenume: \"+@prenume\n end",
"def show\n @tareapositivas = Tarea.where(listo: true)\n @tareas = Tarea.all\n end",
"def show\n @cautelas = Cautela.find(params[:id])\n @cautelaacessorios = Cautelaacessorio.where(cautela_id: params[:id]).all\n @cautelamunicaos = Cautelamunicao.where(cautela_id: params[:id]).all\n @cautelaarmamentos = Cautelaarmamento.where(cautela_id: params[:id]).all\n end",
"def show_all()\n if @items.length == 0\n puts \"Shopping list is empty...\"\n else\n @items.each_index{\n |i|\n puts \"#{i+1} - #{@items[i].to_s}\"\n }\n end\n end",
"def to_s\n\t\ti=0\n\t\tcadena = \"\"\n\t\twhile i<@lista_alimentos.size do\n\t\t\tcadena += \"#{@lista_alimentos[i].nombre} -> #{@lista_cantidades[i]} \"\n\t\t\ti += 1\n\t\t\n\t\tend\n\t\n\t\treturn cadena\n\tend",
"def show!\n puts 'Current Hosts:'\n @plataforms.each do |key, plataform|\n puts plataform.toString\n end\n end",
"def show\n # Se ordenaran alfabeticamente por orden de unidad\n # @secuencia = GranUnidad.select(:id, :region_militar_id).order(:region_militar_id).ids\n @array = ActiveRecord::Base.connection.execute(\"SELECT gu.id FROM gran_unidad gu INNER JOIN region_militar rm ON gu.region_militar_id = rm.id ORDER BY rm.nombre\")\n @secuencia = []\n @array.each do |item|\n @secuencia << item[\"id\"]\n end\n @gran_unidad = GranUnidad.find(params[:id])\n @breadcrumb.push << {nombre: @gran_unidad.nombre, url: @gran_unidad}\n @unidades = @gran_unidad.unidad\n end",
"def values_to_s\n end",
"def to_s\n \"#{@numero}, #{pinta}\"\n end",
"def mostrar_partidos\n \n puts \" \"\n puts \"Quantidade de votos por partido\"\n \n for partido in @partido\n partido.mostrar_dados \n end\n end"
] |
[
"0.64224577",
"0.63708043",
"0.63429993",
"0.63303196",
"0.63251066",
"0.63100123",
"0.62320286",
"0.6219579",
"0.6181895",
"0.61796343",
"0.6150321",
"0.6150321",
"0.6100619",
"0.6048726",
"0.60370904",
"0.6022908",
"0.6021368",
"0.6000858",
"0.59981227",
"0.5987866",
"0.59802955",
"0.5966915",
"0.59648675",
"0.5946894",
"0.5892682",
"0.5879238",
"0.5876847",
"0.5871192",
"0.58427083",
"0.5828783",
"0.5822998",
"0.58124787",
"0.5783686",
"0.5781537",
"0.5780013",
"0.5778409",
"0.5753385",
"0.5733132",
"0.5730234",
"0.5722474",
"0.57145673",
"0.57130665",
"0.57095003",
"0.57074577",
"0.56962824",
"0.5696269",
"0.56950855",
"0.5691102",
"0.56761765",
"0.56744426",
"0.56709975",
"0.56694305",
"0.56619436",
"0.5661197",
"0.5652281",
"0.5650034",
"0.56494033",
"0.5641406",
"0.56332654",
"0.5633131",
"0.5628493",
"0.56283516",
"0.56283516",
"0.56280935",
"0.5614511",
"0.5613266",
"0.5601804",
"0.5597008",
"0.55832446",
"0.55731964",
"0.5567642",
"0.5564168",
"0.5561538",
"0.5557473",
"0.5549165",
"0.5548207",
"0.55451405",
"0.55451405",
"0.55451405",
"0.55451405",
"0.55451405",
"0.55451405",
"0.55451405",
"0.55300087",
"0.55287945",
"0.5528413",
"0.5528303",
"0.5523604",
"0.55202276",
"0.55151826",
"0.55116224",
"0.5510109",
"0.5498299",
"0.54982823",
"0.54965025",
"0.54960155",
"0.54958534",
"0.5494818",
"0.54941976",
"0.5484799",
"0.54836726"
] |
0.0
|
-1
|
Sirve para recorrer la lista, enumerable
|
def each(&block)
node = @Node.new(nil,nil,nil)
node = @head
while !(node.nil?)
yield node.value
node = node.next
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list\n return @enumerable\n end",
"def list(*) end",
"def items\n items, iter = [], @obj.items\n while (i = iter.next) do\n items << i\n end\n items\n end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def map(collection)\n result = []\n collection.each { |el| result << yield(el)}\n result\nend",
"def each()\n self.to_a.each { |elt| yield elt }\n end",
"def to_a; @list; end",
"def set(enumerable); end",
"def list\n raise NotImplementedError\n end",
"def items\n items = []\n iter = @obj.items\n\n while (i = iter.next)\n items << i\n end\n\n items\n end",
"def list\n @list\n end",
"def get_items\r\n @list\r\n end",
"def get_iterator\n\t\tend",
"def get_list\n \t@items\n end",
"def get_items\n\t\treturn @list\n\tend",
"def each\n self.to_a.each do |el|\n yield(el)\n end\n end",
"def list\n return @list\n end",
"def each\n return enum_for(:each) unless block_given?\n @list.each do |item|\n yield item\n end\n end",
"def enumerator ; end",
"def enumerator ; end",
"def each(&blk)\r\n to_a.each(&blk)\r\n end",
"def each(&block)\n @@list.each(&block)\n end",
"def list\n return @lists\n end",
"def each(&blk)\n to_a.each(&blk)\n end",
"def each_set\n \n end",
"def each(&block)\n to_a.each(&block)\n end",
"def items\n @lists.collect(&:items).flatten\n end",
"def my_select(coll)\n # your code here!\n mod_coll = []\n i=0\n while i < coll.length\n if (yield(coll[i]))\n mod_coll.push(coll[i])\n end\n i = i+1\n end\n mod_coll\nend",
"def enumerator; end",
"def collection\n iterator.next\n end",
"def list\n only.to_a\n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block)\n to_a.each(&block)\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def list\n end",
"def list\n end",
"def list\n end",
"def all\n @list\n end",
"def list\n @@list\n end",
"def through; end",
"def list\n @list.dup\n end",
"def each\n items.each { |itm| yield itm }\n end",
"def ordered_list; end",
"def all\n @list.values\n end",
"def to_a\n a = []\n while (item = self.next)\n a << item.item\n end\n a\n end",
"def my_map\n array = []\n self.my_each do |item|\n array << (yield item)\n end\n array\n end",
"def to_a(enumerable = [])\n call(enumerable).to_a\n end",
"def list\n\n end",
"def all\n @list || []\n end",
"def list(*key)\n objects(*key).to_a\n end",
"def each(&block)\n @list.each(&block)\n end",
"def map &block\n self.class.from_a enumerable_map(&block)\n end",
"def my_select(list)\n result = []\n list.each do |n|\n result << n if yield(n)\n end\n result\nend",
"def items\n (rest.elements || []).inject([first]) { |list, el| list << el.item }\n end",
"def to_a\n @list\n end",
"def list\n call! :list\n end",
"def each\n # Include every to be inside enumerable:\n yield \"pizza\"\n yield \"spaghetti\"\n yield \"salad\"\n yield \"water\"\n yield \"bread\"\n end",
"def items\n result = []\n each_item { |item| result.push(item) }\n result\n end",
"def list\n Enumerator.new do |y|\n @cache.each_value do |re|\n y << [re['address'], re['name']]\n end\n end\n end",
"def each\n \n nodo = @head\n while nodo != nil\n \n yield nodo.value\n nodo = nodo.next\n \n end\n \n end",
"def list\n get()\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def each(&block)\n to_a.each(&block)\n end",
"def iterator()\n raise NotImplementedError\n end",
"def map\n # make a copy of List\n mapped = SinglyLinkedList.new\n self.each do |n|\n mapped.append n.value\n end\n # now map\n mapped.each do |n|\n n.value = yield n.value\n end\n mapped\n end",
"def each(&block)\n list.each &block\n end",
"def each()\n yield izq\n yield der\n end",
"def list\n @List\n end",
"def elements\n # execute query\n ordered_objects.compact.uniq\n end",
"def each\n\n\t\t@a.each do |x|\n\t\t\tyield x\n\t\tend\n\tend",
"def each\n enum = @head\n while (enum != nil) \n yield enum.value\n enum = enum.next\n end\n end",
"def collections; end",
"def each\n return [].to_enum if predicate.nil?\n\n if block_given?\n objects do |object|\n converted_object = convert_object(object)\n yield converted_object unless converted_object.nil?\n end\n end\n\n to_enum\n end",
"def each\n @items.each {|x| yield x}\n end",
"def each(*) end",
"def all_items\n all_items = []\n collections.each do |c|\n c.items.each do |i|\n all_items.push i\n end\n end\n all_items\n end",
"def entries\n @list\n end",
"def each\n return to_enum unless block_given?\n list = self\n until list.empty?\n yield(list.head)\n list = list.tail\n end\n end",
"def list\n @in\n end",
"def collect; end",
"def initialize(enumerable)\n @enumerable = enumerable\n end",
"def each\n for each element\n yield(element)\n end\nend",
"def obtener_lista\n\t\tsendM(\"obtener_lista\")\n\tend",
"def each\n all.each do |el|\n yield el\n end\n end",
"def each(&blk); each_value(&blk) ; end",
"def each(&block)\n @list.each_value &block\n end",
"def each\n #if head is not nil we have a list and can interate.\n #simply iterate and yield data from each node\n if !@head.nil?\n current = @head\n while current.next_node != nil\n yield current.data\n current = current.next_node\n end\n yield current.data\n\n end\n end"
] |
[
"0.7011855",
"0.6359514",
"0.6310448",
"0.6287517",
"0.6287517",
"0.6287517",
"0.6287517",
"0.6287517",
"0.6275133",
"0.6275133",
"0.6275133",
"0.62693816",
"0.6236609",
"0.62325674",
"0.61988324",
"0.6150444",
"0.6061723",
"0.604379",
"0.6032112",
"0.6030455",
"0.60212445",
"0.6007131",
"0.5997238",
"0.5950486",
"0.5947601",
"0.5939033",
"0.5939033",
"0.5901559",
"0.5891332",
"0.5875239",
"0.585891",
"0.5833372",
"0.5829615",
"0.5818016",
"0.5813473",
"0.58051217",
"0.5803928",
"0.57974434",
"0.5787916",
"0.5787916",
"0.5787916",
"0.5787916",
"0.5787916",
"0.5787916",
"0.5783937",
"0.5782509",
"0.5782509",
"0.5782509",
"0.577843",
"0.577843",
"0.577843",
"0.57705736",
"0.57680553",
"0.5767105",
"0.5755933",
"0.57396907",
"0.5737833",
"0.5735406",
"0.5721238",
"0.5718322",
"0.570045",
"0.56984824",
"0.56923443",
"0.5680571",
"0.5679387",
"0.5676746",
"0.5672553",
"0.56721574",
"0.5670377",
"0.5669867",
"0.56691545",
"0.5668653",
"0.5664218",
"0.5661986",
"0.56458825",
"0.5642266",
"0.5642266",
"0.56413424",
"0.56391394",
"0.5630762",
"0.5625119",
"0.562352",
"0.5623097",
"0.56198657",
"0.56115794",
"0.56086874",
"0.56060773",
"0.56003916",
"0.5600079",
"0.5596785",
"0.559653",
"0.5587266",
"0.5585717",
"0.5576703",
"0.55761606",
"0.5565701",
"0.55481505",
"0.5543621",
"0.5540253",
"0.55388165",
"0.55290854"
] |
0.0
|
-1
|
Insertar al final de la lista un objeto
|
def insert_by_end(value)
if @head.nil?
@head = @Node.new(value, nil, nil)
@tail = @head
else
@tail[:next] = @Node.new(value, nil, @tail)
@tail = @tail[:next]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insertar(texto,timestamp,usuario,fotousuario)\n\t\n\t\tlistaobjeto=[texto,timestamp,usuario,fotousuario]\n\t\t@Lista+=[listaobjeto]\n\tend",
"def insertar_lista_final(referencia)\n if @final != nil\n @final = Nodo.new(referencia, nil, @final)\n n = @final.anterior\n n.siguiente = @final\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def save()\n @@list.push(self)\n end",
"def insert(item)\n\n\n\n\n end",
"def insert(index,object)\n\nend",
"def insertar_lista_principio(referencia)\n if @principio != nil && @principio.siguiente != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n elsif @principio != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n @final = n\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insertar_elemento(nodo)\n \n @nodo = Nodo_.new(nil, nodo, nil)\n \n if @tail == nil\n @head = @nodo\n @tail = @nodo\n #@nodo\n else\n @nodo.next = @head\n @head.prev = @nodo\n @head = @nodo\n #@nodo\n end\n \n end",
"def insert_tail(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n @tail.next = nodo\n nodo.prev = @tail\n nodo.next = nil\n @nodos = @nodos +1\n @tail = nodo\n end",
"def insert_final(*val)\n \n val.each do |nuevo_nodo|\n \n if @tail != nil\n @tail.next = nuevo_nodo\n nuevo_nodo.previous = @tail\n @tail = nuevo_nodo\n else\n @head = @tail = nuevo_nodo\n end\n @num_nodos += 1\n end\n end",
"def insert(etiqueta)\n nodo = Node.new(etiqueta, nil, nil)\n\n if self.empty\n nodo.next=nodo\n nodo.prev=nodo\n @head=nodo\n @tail=nodo\n\n else\n nodo.prev = @tail\n nodo.next = nil\n @tail.next = nodo\n @tail = nodo\n end\n end",
"def insert()\n\n end",
"def insert_last(value)\n \n end",
"def insert_object g\n @objects.add g\n end",
"def insert_takoble\n\t\tsql = \"insert into TAKO_List values (?, ?)\"\n\t\treturn sql\n\tend",
"def push_back(*preguntas)\n preguntas.each do |p|\n if (@total == 0)\n @cabeza = Nodo.new(p, nil, nil)\n @cola = @cabeza\n else\n @cola.next = Nodo.new(p, nil, @cola)\n @cola = @cola.next\n end\n @total += 1\n end\n preguntas\n end",
"def insert(value) \n self.head.nil? ? insert_empty_list(value) : insert_on_end(value)\n\n print \"=> Result insertion: \"\n print_simple_list(self.last)\n end",
"def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end",
"def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end",
"def insertar_elemento(nodo)\n \n if @elemento != nil\n \n nodo.next = @elemento\n @elemento = nodo\n end\n end",
"def insert(v)\n \n end",
"def insert(value)\n #YOUR WORK HERE\n end",
"def insert(value)\n # YOUR WORK HERE\n end",
"def save\r\n @@items.push self\r\n end",
"def add_to_list\n\n # Keep a copy of position to set after the change detail is saved, \n # because the entry will be put at the end of the list.\n position = self.position\n self.save\n\n if self.errors.empty?\n change_details = self.change_item.change_details.find(:all)\n position = 1 if !position\n change_details.last.insert_at(position)\n end\n end",
"def insertar_varios(nodos)\n \n nodos.each do |nodoo|\n \n insertar(nodoo)\n \n end\n \n end",
"def insert(**opts)\n add(**opts)\n save!\n end",
"def insert(index,element)\n return nil if index < 0 || index > @size\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n @map.keys.sort.reverse.each do |key|\n if key >= index\n value = @map.delete(key)\n @map[key+1] = value\n end\n end\n @map[index] = @added.size\n @added << pair\n #@commands << [:insert,pair]\n @size += 1\n self\n end",
"def insertar(x)\n nodo = Nodo.new(x, nil, nil) \n if @head == nil && @tail==nil\n nodo.next=@head\n nodo.prev=@tail\n @head=nodo\n @tail=nodo\n else\n nodo.prev=@head\n nodo.next=nil\n @head.next=nodo\n @head=nodo\n end\n \n end",
"def insertarTail(value)\n nodo = Node.new(value)\n if @head == nil and @tail == nil\n @head = nodo\n @tail = nodo\n else\n @tail.prev = nodo\n nodo.next = @tail\n @tail = nodo\n end\n @size+=1\n end",
"def save\n @@userList.push self\n self\n end",
"def insert(obj)\n obj.og_insert(self)\n end",
"def inserta\n\t\tnum_pago = 1\n\t\tmonto = divide_pagos()\n\t\tfecha_pago = suma_dias()\n\t\tpago_total = calcula_pago_total()\n\n\t\t\tpagos = Payment.new(num_pago: num_pago, monto: pago_total, fecha_pago: fecha_pago, registro: \"\", client_id: self.id)\n\t\t pagos.save!\n\n\tend",
"def <<(p)\n raise TypeError, \"Esperada pregunta para inserción\" unless p.is_a? (Pregunta)\n if (@total == 0)\n @cabeza = Nodo.new(p, nil, nil)\n @cola = @cabeza\n else\n @cola.next = Nodo.new(p, nil, @cola)\n @cola = @cola.next\n @cola.value\n end\n @total += 1\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def insert(loc, data)\n insert_array = data.split.reverse\n insert_array.each do |item|\n if list.allowed(item)\n @list.insert(loc, item)\n else\n 0\n end\n end\n end",
"def insert_obj(obj) # :nodoc:\n chk_conn\n tx = @hibernate_session.begin_transaction\n @hibernate_session.save(obj)\n tx.commit\n obj\n end",
"def insert()\n\t\t@db.execute(\"insert into ausgaben (jahr, monat, name, betrag, gemeinsam, tags) values(:jahr, :monat, :name, :betrag, :gemeinsam, :tags)\", @options)\n\tend",
"def insert_in_database\n Fetch.new(insertion_query).array\n end",
"def save_list_tb\n @saved_list_tb = @list\n end",
"def insert(*objects)\n objects = objects.first if objects.size == 1 && objects.first.is_a?(Array)\n res = @db.insert_into_db(@name, objects)\n res.size > 1 ? res : res.first\n end",
"def insert_all(iter)\n iter.each {|v|\n insert v\n }\n nil\n end",
"def insert()\n\n # Kräver att det finns ett \"set_table(\"Table\")\" i klassen\n @insertable_vars_full = self.instance_variables # Ta med namnen user.username osv\n @insertable_vars_full.shift(1) # Kinda frisky\n @insertable_vars = []\n @insertable_values = []\n @insertable_vars_full.each do |var|\n @insertable_vars << var[1..-1]\n @insertable_values << self.instance_variable_get(var)\n end\n\n\n @insertable_vars_str = @insertable_vars.join(\", \")\n\n @question_marks = \"\"\n @insertable_vars.each do |key|\n @question_marks.concat(\"?,\")\n end\n @question_marks = @question_marks[0..-2]\n\n DB.execute(\"INSERT INTO #{@table} (#{@insertable_vars_str})\n VALUES (#{@question_marks})\", @insertable_values)\n\n end",
"def insert(object, table)\n sql = object.to_sql(table)\n execute(sql)\n end",
"def insert(nodos)\n for i in (0.. nodos.size-1)\n insert_tail(nodos[i])\n end\n end",
"def insert_tail(*objects)\n objects.each{ |x|\n if(self.empty)\n aux = Node.new(x, @tail, nil)\n @tail = aux\n @head = aux\n else\n aux = Node.new(x, @tail, nil)\n @tail[:prev] = aux\n @tail = aux\n end\n }\n end",
"def insert_after(item, object)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def inserir_item(item)\n # Insere um item no inicio do buffer\n BUFFER.unshift item\n end",
"def add element\n add_last(element)\n end",
"def add element\n add_last(element)\n end",
"def insert_author_affiliation(affi_object, cd_affi_ids)\n # insert the object\n # get the id of the inserted object\n # update all cr_affiliations with the author_affiliation_id\n sql_statement = \\\n \"SELECT id, name FROM cr_affiliations WHERE article_author_id = \" + affi_object.article_author_id.to_s + \";\"\n db = get_db()\n #stm = db.prepare sql_statement\n #rs = stm.execute\n\n db.execute(\"INSERT INTO Author_Affiliations VALUES (?,?,?,?,?,?,?,?,?,?,?,?)\", 1, affi_object.article_author_id, affi_object.name, affi_object.short_name,\n affi_object.add_01, affi_object.add_02, affi_object.add_03,affi_object.add_04, affi_object.add_05, affi_object.country,'2020-09-27','2020-09-27')\nend",
"def insertar_por_cola(value)\n\t\tnodo=Node.new(value,nil,nil)\n if(@tail==nil)\n @tail=nodo\n @head=nodo\n else\n nodo.prev=@tail\n @tail.nest=nodo\n @tail=nodo\n\t\t\tnodo.nest=nil\n end\n\n\tend",
"def delete_last()\n \n end",
"def save\n result = nil\n # iterate over each instance variable and insert create row to table\n\t\t\t\t obj = self.inst_strip_braces(self.object)\n self.instance_variables.each do |method|\n method = method.to_s.gsub(/@/,\"\")\n # Don't save objects with braces to database\n val = self.send(method.to_sym)\n # add rows excluding object, source_id and update_type\n unless self.method_name_reserved?(method) or val.nil?\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"attrib\"=>method,\n \"value\"=>val,\n \"update_type\"=>'create'})\n end\n end\n # Create a temporary query record to display in the list\n Rho::RhoConfig::sources[self.class.name.to_s]['attribs'].each do |attrib|\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"attrib\"=>attrib['attrib'],\n \"value\"=>self.send(attrib['attrib'].to_sym),\n \"update_type\"=>'query'})\n end\n result\n end",
"def insert_after(pivot, item)\n conn.linsert key, :after, pivot, item\n end",
"def insert_tail (value) # Insertar desde la cola ( este es el que usaremos para practica 7)\n\tnodo=Node.new(value,nil,nil)\n nodo.prev = @tail\n @tail = nodo\n if (@head == nil)\n @head = nodo\n end\n nodo.nest = nil\n if (nodo.prev != nil)\n nodo.prev.nest = nodo\n end\n end",
"def insert_head(nodo)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la lista debe contener nodos\" unless ( nodo.instance_of? Nodo )\n nodo.next = @head\n @head.prev = nodo\n nodo.prev = nil\n @nodos = @nodos +1\n @head = nodo\n end",
"def save\n # Insert object values into DB\n # DB.execute(\"INSERT INTO .....\")\n # @id = DB.last_insert_row_id\n end",
"def insert(index, object)\n # raises IndexOutOfBoundsException if index is out of bounds [0, @length)\n # TODO\n end",
"def insert(item)\n @info << item\n changed\n notify_observers(self, :insert, item)\n self\n end",
"def agregar_compra(producto, unidades = 1)\n DB.execute(\"insert into compras values ( ?, ?)\", producto, unidades)\nend",
"def insert_id!(arr, insertable)\n arr << insertable\n insertable\nend",
"def insertion(val, rel, recursive = T.unsafe(nil), list = T.unsafe(nil)); end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insertAll \n \n # begin\n\n # tengo romper la abstraccion porque quiero que empiece el id siempre desde 1\n # si no bastaría con hacer Cine.delete_all\n #ActiveRecord::Base.connection.execute(\"truncate table #{'cines'}\") # no funciono en postgres\n Cine.delete_all\n Horario.delete_all\n \n doc = Nokogiri::HTML(open(\"http://www.bases123.com.ar/eldia/cines/index.php\"))\n \n doc.xpath('//select[@id=\"cine\"]/option').map do |info|\n Cine.create(:nombre => info.text, :external_id => info.xpath('@value').text)\n end \n \n # borro el primer registro porque dice simplemente \"+ Cines\"\n Cine.find(:first).destroy\n\n # Para cada cine que cree actualizo su información\n @cines = Cine.all \n @cines.each do |cine|\n\n # obtengo los datos del cine\n doc = Nokogiri::HTML(open(\"http://www.bases123.com.ar/eldia/cines/cine.php?id=\" + cine.external_id.to_s))\n\n doc.xpath('/html/body/div/p[1]').map do |info|\n data_cine = info.text.lines\n dir = data_cine.to_a[2].gsub(/\\n/,'')\n loc = data_cine.to_a[3].gsub(/\\n/,'')\n c = Cine.find(cine.id)\n c.attributes = \n {\n :direccion => dir, \n :localidad => loc,\n :address => dir + ', ' + loc.gsub(/\\|/,', '), \n }\n c.save\n end\n \n # obtengo las peliculas que se proyectan en el cine y sus horario\n # nota: el 1 misterioso que se agrega es porque los ids del sitio terra son los mismos que infojet pero con la diferencia \n # que llevan conctenado un 1 al final\n doc = Nokogiri::HTML(open(\"http://cartelera.terra.com.ar/carteleracine/sala/\" + cine.external_id.to_s + \"1\") )\n\n #@horarios = doc.xpath(\"//a[starts-with(@href,'pelicula.php')]/@href\").map do |info|\n doc.xpath(\"//div[@id='filmyhorarios']/ul/li\").map do |info|\n \n horarios = info.xpath(\"div[@class='horario fleft']\").text.gsub(/\\t|\\n/, '')\n pelicula_link = info.xpath(\"div[@class='film fleft']/h3/a/@href\").text.split('/').to_a\n # saco el 1 misterioso, para que el id vuelva a la normalidad\n pelicula_id = pelicula_link[pelicula_link.count - 1].chop \n @p = Pelicula.where(:external_id => pelicula_id).first\n logger.debug \"Peli: \" + @p.class.to_s\n if (@p != nil)\n Horario.create(:cine_id => cine.id, :pelicula_id => @p.id, :horas => horarios )\n end\n\n \n end \n \n end \n\n \n @mensaje = \"Los cines fueron creados y actualizados con éxito!\"\n\n\n \n\n# rescue Exception => exc\n# logger.error(\"Message for the log file #{exc.message}\")\n# @mensaje = \"Algo malo pasó :(\"\n# end \n render :text => @mensaje\n \n end",
"def insert_tail(value)\n if @head.nil?\n @head = Nodo.new(value, nil, nil)\n @tail = @head\n else\n @tail[:next] = Nodo.new(value, nil, @tail)\n @tail = @tail[:next]\n end\n end",
"def save_save_list\n save_list.each do |obj|\n obj.save!\n end\n end",
"def insert_first(new)\n insert_after(nil, new)\n end",
"def insert(clave, valor)\r\n @grafo[clave] = valor\r\n end",
"def addTelefone(contato)\n\tputs(\"\\n\\nDigite o novo numero:\")\n\ttel = Telefone.new\n\ttel.numero = Validacao.validaTelefone(gets.chomp)\n\ttel.id_contato = contato.id\n\tcontato.telefones.push(tel)\n\tContatoDAO.new.addTelefone(tel)\nend",
"def salvar\n i = 0\n if @data.present?\n @data.each do |detalle|\n @detalle = Detail.new(producto: detalle[\"nombre\"], cantidad: detalle[\"cantidad\"] , precio: detalle[\"costo\"], precioventa: detalle[\"precio\"], total: detalle[\"total\"] , descuento: detalle[\"descuento\"], descuentoproveedor: detalle[\"descuentodistribuidor\"], ventum_id: @ventum.id )\n @detalle.save\n i = i + 1\n end\n end\n if @tiempo_instalar.present?\n @detalle = Detail.new(producto: @activacion, cantidad: @tiempo_instalar , precio: @precioinstalar, precioventa: @precioinstalar, total: @costo_instalar, descuento:@descuentoinstalar , venta_id: @ventum.id )\n @detalle.save\n end\n end",
"def crear_en_bloque\r\n if current_user.nil?\r\n redirect_to(log_in_path) and return\r\n end\r\n\r\n ActiveRecord::Base.transaction do\r\n params[:alumno_id].each do |alumno|\r\n @asistencia_alumno_persona_vinculada = Asistencia.new(\r\n :anio_alumno_id => AnioAlumno.find_by_anio_escolar_id_and_alumno_id(anio_escolar.id, alumno).id,\r\n :fecha_hora => Time.now,\r\n :persona_vinculada_id => params[:persona_vinculada_id],\r\n :usuario => current_user.usuario,\r\n :tipo_movimiento => 2\r\n )\r\n\r\n if !@asistencia_alumno_persona_vinculada.save\r\n flash[:notice] = 'Ocurrio un error al registrar la salida'\r\n format.html { render action: \"consultar\" }\r\n else\r\n if @guardados.nil?\r\n @guardados = [@asistencia_alumno_persona_vinculada.id]\r\n else\r\n @guardados.push(@asistencia_alumno_persona_vinculada)\r\n end\r\n \r\n @notificar = AlumnoPersonaVinculada.notificar_salida(alumno)\r\n if !@notificar.empty?\r\n @notificar.each do |alumnopersona|\r\n if alumnopersona.persona_vinculada_id != params[:persona_vinculada_id]\r\n @persona = PersonaVinculada.find(alumnopersona.persona_vinculada_id)\r\n @alumno = Alumno.find(alumno)\r\n AsistenciaMailer.delay.notificar_asistencia(2, @alumno, @asistencia_alumno_persona_vinculada, @persona) ## Asincrono\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end\r\n\r\n tipo = PersonaVinculada.find(params[:persona_vinculada_id]).tipo_documento\r\n numero = PersonaVinculada.find(params[:persona_vinculada_id]).numero_documento\r\n redirect_to :controller => 'alumnos_personas_vinculadas', :action => 'consultar',\r\n :tipo_documento => tipo, :numero_documento => numero\r\n end",
"def add obj\n\t\t\t@objs2 += [obj] \n\t\tend",
"def insert(todo)\n todo = Rutodo::Database::Todo.new(\n title: todo.title,\n description: todo.description,\n done: todo.status == :finished\n )\n\n todo.save\n\n todo.as_entity\n end",
"def insert_sorted(obj)\n raise IndexError, <<-msg.squish if include? obj\n Tried to insert #{obj.inspect} into #{self.inspect},\n which is a duplicate of #{self[name_of(obj)].inspect}.\n msg\n\n name = name_of(obj)\n inserted = false\n list.each_with_index do |e, i|\n if name_of(e) > name\n list.insert i, obj\n inserted = true\n break\n end\n end\n\n list << obj unless inserted\n\n list\n end",
"def insert(nodo, pos)\n if (nodo.instance_of? Nodo) == false\n nodo = Nodo.new(nodo,nil,nil)\n end\n raise \"Error la posicion la debe indicar un entero\" unless ( pos.instance_of? Integer)\n raise \"Error posicion inadecuada\" unless ( pos <= @nodos )\n if pos == 0\n insert_head(nodo)\n elsif pos == @nodos\n insert_tail(nodo)\n else\n i = 1\n a = @head\n while i != pos\n i = i+1\n a = a.next\n end\n b = a.next\n nodo.prev = a\n nodo.next = b\n a.next = nodo\n b.prev = nodo\n @nodos = @nodos +1\n nodo\n end\n end",
"def save\n # Insert OR Update object values into DB\n # DB.execute(\"INSERT INTO .....\")\n # @id = DB.last_insert_row_id # get the last id from the DB\n # OR\n # DB.execute(\"UPDATE .....\")\n end",
"def add_to_list(database, item, quantity, store_name, purchased)\n $database.execute(\"INSERT INTO shopping (item, quantity, store_name, purchased) VALUES (?, ?, ?, ?)\", [item, quantity, store_name, purchased])\nend",
"def insert_at!(data, position)\n node, head, tail = set_insert_vars(data, position)\n\n # before: head -> position -> tail\n # after: head -> node -> tail\n head.tail = node if head\n node.tail = tail\n tail.head = node if tail\n node.head = head\n\n # set @tail for list or it will use old tail\n if position.tail?\n @tail = node\n end\n\n # orphan the old node\n position.head = nil\n position.tail = nil\n end",
"def insert_at(position = acts_as_list_top)\n insert_at_position(position)\n end",
"def extraer_lista_final\n ref = @final\n @final = ref.anterior\n if @final != nil\n @final.siguiente = nil\n else\n @principio = @final\n end\n ref\n end",
"def void_last_transaction\n#save add item to last transaction\n#take total and items list, and remove last transaction\n self.total -= self.last_transaction\n @title.pop\n end",
"def insertar_por_cabeza(value)\n\t\tnodo=Node.new(value,nil,nil)\n\t\tif(@head==nil)\n\t\t\t@tail=nodo\n\t\t\t@head=nodo\n\t\telse\n\t\t\tnodo.nest=@head\n\t\t\t@head.prev=nodo\n\t\t\t@head=nodo\n\t\t\tnodo.prev=nil\n\t\tend\n\n\tend",
"def insert\n @companies = Company.all\n @placement_news = PlacementNews.all\n end",
"def despachar\n self.estado_id = 2 # en ruta\n self.buzon_id = self.destinatario_id\n self.add_traza(current_user.id ,1, current_user.puesto.buzon_id)\n self.recepcion = Time.now\n self.save!\n end",
"def add(o); addObject o end",
"def persist_delayed(objs, inserts)\n unless objs.empty?\n # collection.insert(inserts)\n inserts.each do |insert|\n insert.save\n end\n objs.each do |obj|\n # obj.save\n # obj.post_persist\n end\n end\n end",
"def insert_last(element)\n if @first_node == nil\n insert_first(element)\n else\n old_last_node = find_last_node\n old_last_node.insert_after(element)\n @size += 1\n end\n end",
"def _bulkinsert (data,first)\n @length = 0\n cur = first\n while cur\n k = data[cur]\n # FIXME: Check for `Deleted`?\n if k\n if not_deleted?(k)\n # FIXME: Doing k == Deleted or k != Deleted here fails.\n # FIXME: Combining these on one line triggers bug.\n v = data[cur + 1]\n self[k] = v\n end\n end\n cur = data[cur + 2]\n end\n nil\n end",
"def add_in_logdb(date, adresse, utilisateur_id, description)\n limite = 100\n db_size = Log.order(:id).count\n if db_size > limite\n (db_size-limite).times do |i|\n Log.first.delete\n end\n end\n log = Log.new\n log = Log.create(date: date, adresse: adresse, utilisateur_id: utilisateur_id, description: description)\n if log.save\n # ok\n else\n flash[:alert] = I18n.t(\"logs.index.problem_to_save_logs_in_db\")\n end\n end",
"def insert(node)\n\t\t#this is how you link the nodes together\n\t\t@tail.pointer = node\n\t\t#the tail is now equal to the last node that was entered into the linked list\n\t\t@tail = @tail.pointer\n\tend",
"def insert( list_name, owner, author, text, full_message, submitted )\n # TODO Checking friendship existance requires oauth\n # if owner != author and not base.friendship_exists?(owner, author)\n # puts(owner + \" does not follow \" + author + \". Not adding list.\")\n # else\n # puts (owner + \" \" + author + \" are friends, adding to list.\")\n # end\n \n @list = List.find( :first, \n :conditions => { :name => list_name,\n :owner => owner } )\n \n if not @list\n \n #Don't allow creating a list for someone else.\n if owner != author\n puts (owner + \" \" + author + \" \" + list_name + \" doesn't exist, not creating.\")\n return false\n end\n \n @list = List.new({ \"owner\" => owner,\n \"name\" => list_name,\n \"permission\" => \"public\" } )\n @list.save #TODO error handling here like in list create method\n end\n \n #Created a list but no more items\n if text == \"\"\n return false\n end\n \n #Check if the item exists, since we assume the messages\n #come in chronological order, we can just break when\n #we find something.\n @item = Item.find( :first,\n :conditions => { :author => author,\n :text => text,\n :submitted => submitted } ) \n #Clean up this search by using the submit time and the list name or ID TODO\n #TODO really need to check submit time to make sure it's the same message\n if @item\n puts(\"Already saw this element before\")\n return true\n end\n \n @item = @list.items.build( { :author => author,\n :text => text,\n :fullMessage => full_message,\n :submitted => submitted } )\n @item.save #TODO error handling\n print \"item saved\"\n \n return false\n end",
"def insert(item)\n\t\t\n\t\tif self.size == @capacity\n\t\t\t@a.pop\n\t\tend\n\t\t@a.push item\n\tend",
"def insert(nodo)\n\t\t\n\t\tif(@head == nil)\n\t\t\t@head=nodo\n\t\t\t@tail=nodo\n\t\telsif (@head == @tail)\n\t\t\t@head=nodo\n\t\t\t@head.prev=@tail\n\t\t\t@tail.next=@head\n\t\telse\n\t\t\t@head.next=nodo\n\t\t\tnodo.prev=@head\n\t\t\t@head=nodo\n\t\tend\n\t\treturn true\n\tend",
"def insert(value, index)\n end",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def save\r\n\t\tBlog_post.add_to_array(self)\r\n\tend",
"def push!(obj)\n @objs << obj\n end"
] |
[
"0.6997016",
"0.6977173",
"0.6171723",
"0.6167173",
"0.608169",
"0.60140973",
"0.5989488",
"0.59858423",
"0.59395766",
"0.591478",
"0.5836549",
"0.57913935",
"0.5784744",
"0.57830185",
"0.5753295",
"0.5701729",
"0.56861204",
"0.5683191",
"0.5590882",
"0.55694574",
"0.5565263",
"0.5550072",
"0.55462253",
"0.55293494",
"0.5522235",
"0.5516105",
"0.5493023",
"0.54847276",
"0.5473098",
"0.5472054",
"0.5443399",
"0.5433218",
"0.5429578",
"0.5426159",
"0.5426159",
"0.5426159",
"0.54253423",
"0.5422393",
"0.53917587",
"0.5375146",
"0.5367224",
"0.5353405",
"0.5349396",
"0.5330173",
"0.5329442",
"0.5318941",
"0.53097963",
"0.5297947",
"0.5287027",
"0.52833533",
"0.52833533",
"0.5281775",
"0.5278207",
"0.52766603",
"0.5275694",
"0.5272025",
"0.52643794",
"0.5258125",
"0.5256888",
"0.5251978",
"0.52457577",
"0.5245477",
"0.5240349",
"0.52354324",
"0.5222787",
"0.5222787",
"0.5191489",
"0.5187974",
"0.5186692",
"0.5184948",
"0.5179607",
"0.5171768",
"0.51610297",
"0.515561",
"0.51552546",
"0.51524",
"0.5144651",
"0.51396936",
"0.5139624",
"0.5129892",
"0.5129819",
"0.512711",
"0.51218057",
"0.51213336",
"0.51190495",
"0.5118411",
"0.5111176",
"0.5110403",
"0.5108921",
"0.51035714",
"0.50941867",
"0.50923127",
"0.5091389",
"0.50816226",
"0.5080578",
"0.50743985",
"0.50726223",
"0.50723463",
"0.50723463",
"0.50653785",
"0.5064568"
] |
0.0
|
-1
|
Insertar al comienzo de la lista
|
def insert_by_begin(value)
if @head.nil?
@head = @Node.new(value, nil, nil)
@tail = @head
else
@head[:prev] = @Node.new(value, @head, nil)
@head = @head[:prev]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insertar(texto,timestamp,usuario,fotousuario)\n\t\n\t\tlistaobjeto=[texto,timestamp,usuario,fotousuario]\n\t\t@Lista+=[listaobjeto]\n\tend",
"def insert_takoble\n\t\tsql = \"insert into TAKO_List values (?, ?)\"\n\t\treturn sql\n\tend",
"def agregar_compra(producto, unidades = 1)\n DB.execute(\"insert into compras values ( ?, ?)\", producto, unidades)\nend",
"def insert(item)\n\n\n\n\n end",
"def insert()\n\t\t@db.execute(\"insert into ausgaben (jahr, monat, name, betrag, gemeinsam, tags) values(:jahr, :monat, :name, :betrag, :gemeinsam, :tags)\", @options)\n\tend",
"def insert_in_database\n Fetch.new(insertion_query).array\n end",
"def insert()\n\n end",
"def insertar_varios(nodos)\n \n nodos.each do |nodoo|\n \n insertar(nodoo)\n \n end\n \n end",
"def add_chores(db, name, complete_by_day)\r\n\tdb.execute(\"INSERT INTO chores (name, complete_by_day, family_id) VALUES (?, ?, 0)\", [name, complete_by_day])\r\nend",
"def insert(loc, data)\n insert_array = data.split.reverse\n insert_array.each do |item|\n if list.allowed(item)\n @list.insert(loc, item)\n else\n 0\n end\n end\n end",
"def add_to_list(database, item, quantity, store_name, purchased)\n $database.execute(\"INSERT INTO shopping (item, quantity, store_name, purchased) VALUES (?, ?, ?, ?)\", [item, quantity, store_name, purchased])\nend",
"def insert\n values = params[:workshop_ids]\n conn = ActiveRecord::Base.connection\n id = cookies.signed[:id]\n workshop_list = \"\"\n count = 0\n values.each do |v|\n workshop_list += v.to_s\n if count < values.size - 1\n workshop_list += \",\"\n end\n count += 1\n end\n \n conn.execute(\"select update_worker_workshops(\" + \n id.to_s + \",'\" + workshop_list+ \"')\")\n redirect_to :action=>\"success\", :controller=>\"workshops\"\n end",
"def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end",
"def insertAll \n \n # begin\n\n # tengo romper la abstraccion porque quiero que empiece el id siempre desde 1\n # si no bastaría con hacer Cine.delete_all\n #ActiveRecord::Base.connection.execute(\"truncate table #{'cines'}\") # no funciono en postgres\n Cine.delete_all\n Horario.delete_all\n \n doc = Nokogiri::HTML(open(\"http://www.bases123.com.ar/eldia/cines/index.php\"))\n \n doc.xpath('//select[@id=\"cine\"]/option').map do |info|\n Cine.create(:nombre => info.text, :external_id => info.xpath('@value').text)\n end \n \n # borro el primer registro porque dice simplemente \"+ Cines\"\n Cine.find(:first).destroy\n\n # Para cada cine que cree actualizo su información\n @cines = Cine.all \n @cines.each do |cine|\n\n # obtengo los datos del cine\n doc = Nokogiri::HTML(open(\"http://www.bases123.com.ar/eldia/cines/cine.php?id=\" + cine.external_id.to_s))\n\n doc.xpath('/html/body/div/p[1]').map do |info|\n data_cine = info.text.lines\n dir = data_cine.to_a[2].gsub(/\\n/,'')\n loc = data_cine.to_a[3].gsub(/\\n/,'')\n c = Cine.find(cine.id)\n c.attributes = \n {\n :direccion => dir, \n :localidad => loc,\n :address => dir + ', ' + loc.gsub(/\\|/,', '), \n }\n c.save\n end\n \n # obtengo las peliculas que se proyectan en el cine y sus horario\n # nota: el 1 misterioso que se agrega es porque los ids del sitio terra son los mismos que infojet pero con la diferencia \n # que llevan conctenado un 1 al final\n doc = Nokogiri::HTML(open(\"http://cartelera.terra.com.ar/carteleracine/sala/\" + cine.external_id.to_s + \"1\") )\n\n #@horarios = doc.xpath(\"//a[starts-with(@href,'pelicula.php')]/@href\").map do |info|\n doc.xpath(\"//div[@id='filmyhorarios']/ul/li\").map do |info|\n \n horarios = info.xpath(\"div[@class='horario fleft']\").text.gsub(/\\t|\\n/, '')\n pelicula_link = info.xpath(\"div[@class='film fleft']/h3/a/@href\").text.split('/').to_a\n # saco el 1 misterioso, para que el id vuelva a la normalidad\n pelicula_id = pelicula_link[pelicula_link.count - 1].chop \n @p = Pelicula.where(:external_id => pelicula_id).first\n logger.debug \"Peli: \" + @p.class.to_s\n if (@p != nil)\n Horario.create(:cine_id => cine.id, :pelicula_id => @p.id, :horas => horarios )\n end\n\n \n end \n \n end \n\n \n @mensaje = \"Los cines fueron creados y actualizados con éxito!\"\n\n\n \n\n# rescue Exception => exc\n# logger.error(\"Message for the log file #{exc.message}\")\n# @mensaje = \"Algo malo pasó :(\"\n# end \n render :text => @mensaje\n \n end",
"def insert(value)\n # YOUR WORK HERE\n end",
"def insert(value)\n #YOUR WORK HERE\n end",
"def insert(params)\n params[:real_at] ||= AtStructure.new(params[:at])\n\n if ['_space_', '_return_'].include?(params[:content])\n params.merge!(is_balise: true)\n end\n\n params.merge!(operation: 'insert') unless params.key?(:operation)\n # On ajoute si nécessaire le text-item de référence, qui permettra,\n # notamment, de renseigner les messages, de récupérer le file_id si c'est\n # un projet Scrivener, pour l'affecter aux nouveaux text-items et\n # d'enregistrer les messages d'opération.\n params.merge!(titem_ref: params[:real_at].first_titem) unless params.key?(:titem_ref)\n # Sauf si c'est une balise (*), on crée la simulation pour voir si on va vraiment faire\n # cete opération.\n # (*) Car on ne peut pas occasionner de proximités quand c'est une balise.\n unless params[:is_balise]\n new_titems = simulation(params.merge(debug: debug_insert?)) || return\n end\n\n if params[:operation] == 'insert'\n msg = \"Insertion de “#{params[:content]}” à l’index #{params[:real_at].abs(:at)} (avant “#{extrait_titems[params[:real_at].at].content}”)\"\n log(msg, true)\n end\n\n # :is_balise est true quand on donne '_space_' ou '_return_' comme texte\n unless params[:is_balise]\n # Si c'est une pure insertion, il faut ajouter une espace soit avant\n # soit après les nouveaux items. On l'ajoute après si le titem d'après\n # est un mot (.mot?) et on l'ajoute avant si le titem avant est un mot.\n if params[:operation] == 'insert'\n next_titem = extrait_titems[params[:real_at].at]\n prev_titem = extrait_titems[params[:real_at].first - 1]\n if next_titem && next_titem.mot? && new_titems.last.mot?\n # Dans le cas où l'item suivant existe, que c'est un mot, et que\n # le dernier titem à insérer est aussi un mot, il faut ajouter\n # une espace à la fin des nouveaux items.\n new_titems << NonMot.new(SPACE, type: 'space')\n elsif prev_titem && prev_titem.mot? && new_titems.first.mot?\n # Sinon, dans le cas où l'item précédent existe, que c'est un mot\n # et que le premier item à insérer est aussi un mot, il faut ajouter\n # une espace au début des nouveaux items\n new_titems.unshift(NonMot.new(SPACE, type:'space'))\n end\n end\n else\n new_item = case params[:content]\n when '_space_' then NonMot.new(SPACE, type:'space')\n when '_return_' then NonMot.new(RC, type:'paragraphe')\n end\n new_titems = [new_item]\n end\n # log(\"Nouveaux items ajoutés (#{new_titems.count}) : \")\n # log(new_titems.inspect)\n\n # Si c'est un projet Scrivener, il faut ajouter le file_id de l'item\n # de référence aux nouveaux items\n if itexte.projet_scrivener?\n new_titems.each {|titem| titem.file_id = params[:titem_ref].file_id}\n end\n\n # Insertion des nouveaux titems dans l'extrait\n extrait_titems.insert(params[:real_at].at, *new_titems)\n # Insertion des nouveaux titems dans la base de données\n start_abs_index = params[:real_at].abs(:at)\n new_titems.each_with_index { |i, idx| i.index = idx + start_abs_index }\n itexte.db.insert_text_items(new_titems)\n\n # Pour l'annulation (sauf si c'est justement une annulation)\n if params.key?(:cancellor)\n idx = params[:real_at].abs(:at)\n new_titems.each do |titem|\n content = titem.space? ? '_space_' : titem.content\n params[:cancellor] << {operation: :remove, index:idx, content:content}\n # Note : le content, ci-dessus, ne servira que pour la vérification\n end\n end\n\n # Si c'est vraiment une opération d'insertion, on l'enregistre\n # en tant qu'opération.\n # Noter qu'il faut le faire avant l'update suivant, sinon tous les\n # index et indices seront recalculés et donc faux.\n if params[:operation] == 'insert'\n itexte.operator.add_text_operation(params)\n end\n\n unless params[:noupdate]\n update\n end\nend",
"def inserta\n\t\tnum_pago = 1\n\t\tmonto = divide_pagos()\n\t\tfecha_pago = suma_dias()\n\t\tpago_total = calcula_pago_total()\n\n\t\t\tpagos = Payment.new(num_pago: num_pago, monto: pago_total, fecha_pago: fecha_pago, registro: \"\", client_id: self.id)\n\t\t pagos.save!\n\n\tend",
"def insertar_lista_final(referencia)\n if @final != nil\n @final = Nodo.new(referencia, nil, @final)\n n = @final.anterior\n n.siguiente = @final\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert(**opts)\n add(**opts)\n save!\n end",
"def insert()\n\n # Kräver att det finns ett \"set_table(\"Table\")\" i klassen\n @insertable_vars_full = self.instance_variables # Ta med namnen user.username osv\n @insertable_vars_full.shift(1) # Kinda frisky\n @insertable_vars = []\n @insertable_values = []\n @insertable_vars_full.each do |var|\n @insertable_vars << var[1..-1]\n @insertable_values << self.instance_variable_get(var)\n end\n\n\n @insertable_vars_str = @insertable_vars.join(\", \")\n\n @question_marks = \"\"\n @insertable_vars.each do |key|\n @question_marks.concat(\"?,\")\n end\n @question_marks = @question_marks[0..-2]\n\n DB.execute(\"INSERT INTO #{@table} (#{@insertable_vars_str})\n VALUES (#{@question_marks})\", @insertable_values)\n\n end",
"def insert(index,object)\n\nend",
"def insert(v)\n \n end",
"def insert_id!(arr, insertable)\n arr << insertable\n insertable\nend",
"def insert_all(iter)\n iter.each {|v|\n insert v\n }\n nil\n end",
"def insert(value) \n self.head.nil? ? insert_empty_list(value) : insert_on_end(value)\n\n print \"=> Result insertion: \"\n print_simple_list(self.last)\n end",
"def add_task(db, task, date_needed, notes)\n db.execute(\"INSERT INTO list (task, date_needed, notes) VALUES (?, ?, ?)\", [task, date_needed, notes])\nend",
"def insertar_lista_principio(referencia)\n if @principio != nil && @principio.siguiente != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n elsif @principio != nil\n n = @principio\n @principio = Nodo.new(referencia, n, nil)\n n.anterior = @principio\n @final = n\n else\n @principio = Nodo.new(referencia, nil, nil)\n @final = @principio\n end\n end",
"def insert(clave, valor)\r\n @grafo[clave] = valor\r\n end",
"def insertar (id_usu_den,id_tip_doc,num_doc_den,fec_exp_doc_den,fec_nac_den,pri_nom_den,seg_nom_den,pri_ape_den,seg_ape_den,tel_den,dir_den,push_den,ema_den)\n \tputs \"insertar: \"\n \tprint \"INSERT INTO public.denunciante(\n id_usu_den, id_tip_doc, num_doc_den, fec_exp_doc_den, fec_nac_den, \n pri_nom_den, seg_nom_den, pri_ape_den, seg_ape_den, tel_den, \n dir_den, push_den, ema_den)\n VALUES (?, ?, ?, ?, ?, \n ?, ?, ?, ?, ?, \n ?, ?, ?);\"\n\n end",
"def crear_en_bloque\r\n if current_user.nil?\r\n redirect_to(log_in_path) and return\r\n end\r\n\r\n ActiveRecord::Base.transaction do\r\n params[:alumno_id].each do |alumno|\r\n @asistencia_alumno_persona_vinculada = Asistencia.new(\r\n :anio_alumno_id => AnioAlumno.find_by_anio_escolar_id_and_alumno_id(anio_escolar.id, alumno).id,\r\n :fecha_hora => Time.now,\r\n :persona_vinculada_id => params[:persona_vinculada_id],\r\n :usuario => current_user.usuario,\r\n :tipo_movimiento => 2\r\n )\r\n\r\n if !@asistencia_alumno_persona_vinculada.save\r\n flash[:notice] = 'Ocurrio un error al registrar la salida'\r\n format.html { render action: \"consultar\" }\r\n else\r\n if @guardados.nil?\r\n @guardados = [@asistencia_alumno_persona_vinculada.id]\r\n else\r\n @guardados.push(@asistencia_alumno_persona_vinculada)\r\n end\r\n \r\n @notificar = AlumnoPersonaVinculada.notificar_salida(alumno)\r\n if !@notificar.empty?\r\n @notificar.each do |alumnopersona|\r\n if alumnopersona.persona_vinculada_id != params[:persona_vinculada_id]\r\n @persona = PersonaVinculada.find(alumnopersona.persona_vinculada_id)\r\n @alumno = Alumno.find(alumno)\r\n AsistenciaMailer.delay.notificar_asistencia(2, @alumno, @asistencia_alumno_persona_vinculada, @persona) ## Asincrono\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end\r\n\r\n tipo = PersonaVinculada.find(params[:persona_vinculada_id]).tipo_documento\r\n numero = PersonaVinculada.find(params[:persona_vinculada_id]).numero_documento\r\n redirect_to :controller => 'alumnos_personas_vinculadas', :action => 'consultar',\r\n :tipo_documento => tipo, :numero_documento => numero\r\n end",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert(cartridge)\n end",
"def insertion_query\n [\"INSERT IGNORE INTO collectif SET collectif_nom = '#{@name}'\",\n \"collectif_client = '#{@provider}'\",\n \"collectif_annee = #{@year}\",\n \"collectif_facture = '#{@billing}'\",\n \"collectif_revues = '#{@journal_ids.join(',')}'\"\n ].join(', ')\n end",
"def insert_into(table, data)\n\t\tkeys = \"(#{data.keys.join(', ')})\"\n\t\tvalues = \"(#{data.values.map{ |value| \"'#{value}'\" }.join(', ')})\"\n\t\texecute_with_retry \"INSERT INTO #{table} #{keys} VALUES #{values}; \"\n\tend",
"def add_contact(list)\n\n puts \"Please enter new contact name:\"\n add_name = gets.chomp.downcase\n\n puts \"Please enter new contact phone number:\"\n add_phone = gets.chomp.downcase\n\n puts \"please enter new contact email address:\"\n add_email = gets.chomp.downcase\n\n puts \"please enter new contact occupation:\"\n add_occupation = gets.chomp.downcase\n\n puts \"please enter how you know new contact:\"\n add_group = gets.chomp.downcase\n\n list.execute(\"INSERT INTO contacts(name, occupation, association, phone_number, email) VALUES ('#{add_name}', '#{add_occupation}','#{add_group}', '#{add_email}', '#{add_phone}') \")\nend",
"def batch_insert(data)\n hash = Hash[data.collect { |v| [v, '1'] }]\n @redis.write_multi(hash)\n end",
"def insert_author_affiliation(affi_object, cd_affi_ids)\n # insert the object\n # get the id of the inserted object\n # update all cr_affiliations with the author_affiliation_id\n sql_statement = \\\n \"SELECT id, name FROM cr_affiliations WHERE article_author_id = \" + affi_object.article_author_id.to_s + \";\"\n db = get_db()\n #stm = db.prepare sql_statement\n #rs = stm.execute\n\n db.execute(\"INSERT INTO Author_Affiliations VALUES (?,?,?,?,?,?,?,?,?,?,?,?)\", 1, affi_object.article_author_id, affi_object.name, affi_object.short_name,\n affi_object.add_01, affi_object.add_02, affi_object.add_03,affi_object.add_04, affi_object.add_05, affi_object.country,'2020-09-27','2020-09-27')\nend",
"def insert(*objects)\n objects = objects.first if objects.size == 1 && objects.first.is_a?(Array)\n res = @db.insert_into_db(@name, objects)\n res.size > 1 ? res : res.first\n end",
"def insert_article_list(res, id, title, link)\n if res['exists(select 1 from article_lists where article_url=?)'] == 0\n stmt = @sql.prepare \"insert into article_lists (site_list_id, title, article_url) values(?,?,?)\"\n stmt.execute(id, title, link)\n id_res = @sql.query 'select last_insert_id() from article_lists'\n roles = @sql.query \"select role from site_roles where deleted_at is null and site_list_id=#{id} order by priority desc\"\n r = @http.get(link, :follow_redirect => true)\n id_res.each_with_index {|nowid, i| extract_html(r.body, roles, nowid['last_insert_id()']) if r.status == 200 && i == 0}\n end\n end",
"def insert(tuples)\n pks = tuples.map { |tuple| relation.insert(tuple) }\n relation.where(relation.primary_key => pks).to_a\n end",
"def create\n @lista = Lista.new(lista_params)\n @lista.usuario_id = current_usuario.id\n @lista.columnas=params[:columnas].join(',')\n\n respond_to do |format|\n if @lista.save\n format.html { redirect_to @lista, notice: 'La lista fue creada satisfactoriamente.' }\n format.json { render action: 'show', status: :created, location: @lista }\n else\n format.html { render action: 'new' }\n format.json { render json: @lista.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insert\n @companies = Company.all\n @placement_news = PlacementNews.all\n end",
"def insertConUser(idUser,idChannel)\n \n begin\n query = \"INSERT INTO `#{DB_NAME}`.`#{USER_LIST_IN_CHAN_TABBLE}` (`user_id_user`, `channel_id_channel`) \n VALUES (?, ?)\"\n \n self.connect unless self.connected? # => connect to the DB server if not connected\n \n sth = @dbh.prepare(query)\n\n sth.execute(idUser,idChannel)\n sth.finish\n rescue DBI::DatabaseError => e\n puts \"An error occurred\"\n puts \"Error code: #{e.err}\"\n puts \"Error message: #{e.errstr}\"\n @dbh.rollback\n rescue Exception => e \n puts \"error!!! -> : #{e.to_s}\"\n \n ensure\n # disconnect from server\n @dbh.disconnect if @connected\n @connected=false\n end\n end",
"def insert task\n now = Time.now.to_i\n tasks = @db[:tasks]\n tasks.insert :title => task.title,\n :status => task.getStatus,\n :created => now,\n :wake => now,\n :changed => 0,\n :path => task.getPath,\n :data => Marshal::dump(task)\n end",
"def insert\n attributes = []\n instance_variables.each { |i|\n attributes << i.to_s.delete(\"@\")\n }\n\n query_components_array = []\n attributes.each { |x|\n value = self.send(x)\n\n if value.is_a?(Integer)\n query_components_array << \"#{value}\"\n else\n query_components_array << \"'#{value}'\"\n end\n }\n\n query_string = query_components_array.join(\", \")\n puts query_string\n\n DATABASE.execute(\"INSERT INTO items (name, category, location, quantity, cost, description) VALUES (#{query_string})\")\n\n puts \"Inserted successfully!\"\n end",
"def cargos_solicitud(presupuesto)\n delete = \"Delete FROM public.sep_solicitudcargos where numsol='#{self.numsol}';\" \n cargo = \"\"\" INSERT INTO public.sep_solicitudcargos (codemp, numsol, codcar, codestpro1, codestpro2, codestpro3, codestpro4, codestpro5, spg_cuenta, cod_pro, ced_bene, sc_cuenta, formula) \n SELECT distinct '0001' as codemp,A.numsol,A.codcar,\n '#{presupuesto[:codestpro1]}' as codestpro1,'#{presupuesto[:codestpro2]}' as codestpro2,\n '#{presupuesto[:codestpro3]}' as codestpro3,'#{presupuesto[:codestpro4]}' as codestpro4,\n '#{presupuesto[:codestpro5]}' as codestpro5,trim(spg_cuenta),'----------' as cod_pro,'----------' as ced_bene, \n '11212000spg_ep30001 ' as sc_cuenta, A.formula \n FROM public.sep_dta_cargos A JOIN public.sigesp_cargos using (codemp, codcar) \n WHERE A.numsol = '#{self.numsol}' \n UNION ALL\n SELECT distinct '0001' as codemp,A.numsol,A.codcar,\n '#{presupuesto[:codestpro1]}' as codestpro1,'#{presupuesto[:codestpro2]}' as codestpro2,\n '#{presupuesto[:codestpro3]}' as codestpro3,'#{presupuesto[:codestpro4]}' as codestpro4,\n '#{presupuesto[:codestpro5]}' as codestpro5, trim(spg_cuenta),'----------' as cod_pro,'----------' as ced_bene,\n '11212000spg_ep30001 ' as sc_cuenta, A.formula \n FROM public.sep_dts_cargos A JOIN public.sigesp_cargos using (codemp, codcar) \n WHERE A.numsol = '#{self.numsol}'; \"\"\"\n Sigesp::Solicitud.connection.execute(delete)\n Sigesp::Solicitud.connection.execute(cargo)\n end",
"def insert(name)\n CONN.execute(\"INSERT INTO artits(name) VALUES(?)\", name)\nend",
"def insert_into_shop(name, id) # need to insert the actual stores and ids now into the shop\n shop = \"INSERT INTO shops (name, id) VALUES ($1, $2)\"\n\n result = shop.exec_params(shop, [name, id])\n result.entries\nend",
"def ajouter_cours(effectif_param, effectif_limite_param, nom_param, enseignant_nom_param)\n cours = {\n \"effectif\" => effectif_param,\n \"effectif_limite\" => effectif_limite_param,\n \"nom\" => nom_param,\n \"enseignant_nom\" => enseignant_nom_param\n }\n \n LISTE_COURS.push(cours)\nend",
"def insert(value, index)\n end",
"def add_to_list\n\n # Keep a copy of position to set after the change detail is saved, \n # because the entry will be put at the end of the list.\n position = self.position\n self.save\n\n if self.errors.empty?\n change_details = self.change_item.change_details.find(:all)\n position = 1 if !position\n change_details.last.insert_at(position)\n end\n end",
"def add_item(db, new_item, new_date)\n db.execute(\"INSERT INTO todolist (item, date, done) VALUES (?, ?, ?)\", [new_item, new_date, \"false\"])\nend",
"def insertRemanescentes(conn,id)\n\tputs \" insert Subpopulacao_Remanescente\"\n\tt_init = Time.new\n\tgid_subpop = getSubpopById(conn,id)\n\tfor x in (0..gid_subpop.count-1)\n\t\t#puts \"Subpopulacao #{x+1} de #{gid_subpop.count}\"\n\t\tconn.exec(\"SELECT distinct(gid) as gid_rem from geo.remanescentes where st_intersects(geom,(select geom from geo.subpopulacoes where gid = #{gid_subpop[x]} and id = #{id})) and (geom && (select geom from geo.subpopulacoes where gid = #{gid_subpop[x]} and id = #{id})) and legenda = 'Mata';\").each do |row|\n\t\t\tif (row['gid_rem']) then\n\t\t\t\tconn.exec(\"insert into geo.subpopulacao_remanescente(gid_subpop, gid_remanescente, id) values (#{gid_subpop[x]}, #{row['gid_rem']}, #{id});\")\n\t\t\tend\n\t\tend\n\tend\n\tt = (Time.new - t_init)\n\tconn.exec(\"update geo.tempos set t_subpop_rem = #{t} where id = #{id}\")\nend",
"def db_insert a, b, c\n if a == \"\" or b == \"\" \n return 'blank'\n end\n $db.execute \"INSERT INTO produtos (cod, prod, prec) VALUES(?, ?, ?)\", a, b, c\nend",
"def insert_select(params = {})\n db_str = GenInsert.insert_select(params)\n #@log.debug db_str\n @client.run db_str\n\n return true\n end",
"def insertar_elemento(nodo)\n \n @nodo = Nodo_.new(nil, nodo, nil)\n \n if @tail == nil\n @head = @nodo\n @tail = @nodo\n #@nodo\n else\n @nodo.next = @head\n @head.prev = @nodo\n @head = @nodo\n #@nodo\n end\n \n end",
"def insert(template, *data) # :nodoc:\n chk_conn\n conn = @hibernate_session.connection\n stmt = conn.prepare_statement(template)\n data.each do |d|\n d.each_with_index do |item, index|\n if item.kind_of?(Array)\n set_prepared_statement(stmt, item[0], index+1, item[1])\n else\n set_prepared_statement(stmt, item, index+1, nil)\n end\n end\n stmt.execute_update\n end\n conn.commit\n ensure\n stmt.close rescue nil\n end",
"def insert_statement(statement)\n self.inserts << statement\n end",
"def insert_statement(statement)\n self.inserts << statement\n end",
"def addTelefone(contato)\n\tputs(\"\\n\\nDigite o novo numero:\")\n\ttel = Telefone.new\n\ttel.numero = Validacao.validaTelefone(gets.chomp)\n\ttel.id_contato = contato.id\n\tcontato.telefones.push(tel)\n\tContatoDAO.new.addTelefone(tel)\nend",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def inserir_item(item)\n # Insere um item no inicio do buffer\n BUFFER.unshift item\n end",
"def insert(index,element)\n return nil if index < 0 || index > @size\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n @map.keys.sort.reverse.each do |key|\n if key >= index\n value = @map.delete(key)\n @map[key+1] = value\n end\n end\n @map[index] = @added.size\n @added << pair\n #@commands << [:insert,pair]\n @size += 1\n self\n end",
"def insertar(identificador, tipo, tamanio, asignacion, modificable = true)\n\t\t@tabla.store(identificador.valor.str, tipo)\n\n\t\tif tamanio != nil then\n\t\t\t@tamanio.store(identificador.valor.str, tamanio)\n\t\tend\n\n\t\tif asignacion != nil then\n\t\t\t@asignacion.store(identificador.valor.str, asignacion)\n\n\t\telse\n\n\t\t\tif tipo.str == \"int\" then\n\t\t\t\t# token = Token.new(\"0\", -1, -1)\n\t\t\t\t# nodo = NodoInt.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, 0)\n\n\t\t\telsif tipo.str == \"bool\" then\n\t\t\t\t# token = Token.new(\"false\", -1, -1)\n\t\t\t\t# nodo = NodoBool.new(token)\n\t\t\t\t@asignacion.store(identificador.valor.str, false)\n\n\t\t\telsif tipo.str == \"bits\" && (tamanio.is_a?(Integer) || tamanio.is_a?(String)) then\n\n\t\t\t\ti = 0\n\t\t\t\tvalor = \"0b\"\n\t\t\t\twhile (i<Integer(tamanio))\n\t\t\t\t\tvalor += \"0\"\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\n\t\t\t\t@asignacion.store(identificador.valor.str, valor)\n\n\t\t\tend\n\n\t\tend\n\n\t\t@modificable.store(identificador.valor.str, modificable)\n\n\tend",
"def insert(*values)\n execute_dui(insert_sql(*values)){|c| return c.last_id}\n end",
"def insert(sql, name = nil, pk = nil, id_value = nil) end",
"def insert \n \n DATABASE.execute(\"INSERT INTO categories (genre) VALUES ('#{@genre}')\")\n @id = DATABASE.last_insert_row_id # will return the value of the row id\n end",
"def insert \n \n DATABASE.execute(\"INSERT INTO categories (genre) VALUES ('#{@genre}')\")\n @id = DATABASE.last_insert_row_id # will return the value of the row id\n end",
"def add_item(db, item, location)\n db.execute(\"INSERT INTO keys (item, location) VALUES (?, ?)\", [item, location])\nend",
"def aniade_taxones_seleccionados\n notice = if params[:especies].present?\n @listas.each do |lista|\n lista = Lista.find(lista)\n lista.cadena_especies.present? ? lista.cadena_especies+= ',' + params[:especies].join(',') :\n lista.cadena_especies = params[:especies].join(',')\n lista.save\n end\n 'Taxones incluidos correctamente.'\n else\n 'Debes seleccionar por lo menos una lista y un taxon para poder incluirlo.'\n end\n\n redirect_to :back, :notice => notice\n end",
"def visit_Arel_Nodes_InsertStatement o, *a\n [\n \"INSERT INTO #{visit(o.relation).gsub(/\"/, '')}\",\n \"(#{o.columns.map { |x| x.name }.join ', '})\",\n \" VALUES (#{o.values.left.map { |value| value }.join ', '})\"\n ].compact.join ' '\n end",
"def insert \n DATABASE.execute(\"INSERT INTO contents (slide_order, title, body) \n VALUES (#{@slide_order}, '#{@title}', '#{@body}')\")\n @id = DATABASE.last_insert_row_id\n end",
"def insert( list_name, owner, author, text, full_message, submitted )\n # TODO Checking friendship existance requires oauth\n # if owner != author and not base.friendship_exists?(owner, author)\n # puts(owner + \" does not follow \" + author + \". Not adding list.\")\n # else\n # puts (owner + \" \" + author + \" are friends, adding to list.\")\n # end\n \n @list = List.find( :first, \n :conditions => { :name => list_name,\n :owner => owner } )\n \n if not @list\n \n #Don't allow creating a list for someone else.\n if owner != author\n puts (owner + \" \" + author + \" \" + list_name + \" doesn't exist, not creating.\")\n return false\n end\n \n @list = List.new({ \"owner\" => owner,\n \"name\" => list_name,\n \"permission\" => \"public\" } )\n @list.save #TODO error handling here like in list create method\n end\n \n #Created a list but no more items\n if text == \"\"\n return false\n end\n \n #Check if the item exists, since we assume the messages\n #come in chronological order, we can just break when\n #we find something.\n @item = Item.find( :first,\n :conditions => { :author => author,\n :text => text,\n :submitted => submitted } ) \n #Clean up this search by using the submit time and the list name or ID TODO\n #TODO really need to check submit time to make sure it's the same message\n if @item\n puts(\"Already saw this element before\")\n return true\n end\n \n @item = @list.items.build( { :author => author,\n :text => text,\n :fullMessage => full_message,\n :submitted => submitted } )\n @item.save #TODO error handling\n print \"item saved\"\n \n return false\n end",
"def insert\n DATABASE.execute(\"INSERT INTO boards (title,description) VALUES ('#{@title}', '#{@description}')\")\n @id = DATABASE.last_insert_row_id\n end",
"def insert_task(task, tasklist)\n result = @client.execute(\n api_method: @api.tasks.insert,\n body_object: task,\n parameters: {tasklist: tasklist[\"id\"]}\n )\n #get_tasks(tasklist)\n end",
"def create_new_list(list_name) \n sql = \"INSERT INTO lists (name) VALUES ($1)\"\n result = query(sql, list_name)\n end",
"def _bulkinsert (data,first)\n @length = 0\n cur = first\n while cur\n k = data[cur]\n # FIXME: Check for `Deleted`?\n if k\n if not_deleted?(k)\n # FIXME: Doing k == Deleted or k != Deleted here fails.\n # FIXME: Combining these on one line triggers bug.\n v = data[cur + 1]\n self[k] = v\n end\n end\n cur = data[cur + 2]\n end\n nil\n end",
"def insert_by_data data, table\n sql = \"insert into #{table} \"\n case data\n when Array\n data.each do |d|\n insert_by_data(d, table)\n end\n when Hash\n columns = data.keys.to_s.gsub('[','(').gsub(']',')').gsub('\"','')\n values = data.values.to_s.gsub('[','(').gsub(']',')').gsub('nil','NULL')\n sql = sql + columns + \" values \" + values\n query(sql)\n end\n end",
"def insert_words(words)\n words.each do |word|\n insert(word)\n end\n end",
"def insert\n \n attributes = []\n instance_variables.each do |i|\n attributes << i.to_s.delete(\"@\") if (i != :@id && i != :@table)\n end\n \n values = []\n attributes.each do |a|\n value = self.send(a)\n \n if value.is_a?(Integer)\n values << \"#{value}\"\n else values << \"'#{value}'\"\n end\n end\n \n DATABASE.execute(\"INSERT INTO students (#{attributes.join(\", \")}) \n VALUES (#{values.join(\", \")})\")\n @id = DATABASE.last_insert_row_id\n\n end",
"def exec_insert(sql, name = nil, binds = []) #:nodoc:\r\n log(sql, \"insert\", binds) { query(sql, binds) }\r\n end",
"def insert(key)\n end",
"def using_insert(list_of_programming_languages, another_language)\n list_of_programming_languages = [\"Ruby\", \"JavaScript\", \"Java\", \"C#\", \"Objective C\", \"C++\", \"PHP\"]\n another_language = \"Python\"\n new_array = list_of_programming_languages.insert(4, another_language)\nend",
"def add_listing(db, seller, make_id, model, year, price)\n db.execute(\"INSERT INTO cars (seller, make_id, model, year, price) VALUES (?, ?, ?, ?, ?)\", [seller, make_id, model, year, price])\nend",
"def create_new_todo(list_id, todo_name)\n sql = \"INSERT INTO todos (name, list_id) VALUES ($1, $2)\"\n query(sql, todo_name, list_id)\n end",
"def insert(nodos)\n for i in (0.. nodos.size-1)\n insert_tail(nodos[i])\n end\n end",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def dbinsert(table, variables, variable_names)\n i = 1\n marks = \"?\"\n while i < variables.length\n marks += \",?\"\n i += 1\n end\n\n v = \"\"\n i = 0\n while i < variables.length\n v += variables[i].to_s \n i += 1\n if i < variables.length\n v += \", \"\n end\n end\n\n return db.execute(\"INSERT INTO #{table}(#{v}) VALUES (#{marks})\", variable_names)\nend",
"def save_endereco(log, numero, comp) \n e = Endereco.where(logradouro: log, numero: numero, complemento: comp).first\n if e == nil\n puts \"Criando novo endereco...\"\n e = Endereco.create!(logradouro: log, numero: numero, complemento: comp)\n puts e\n else\n puts \">>> Endereco ja cadastrado #{log.cep} #{numero}\"\n end\n e\n end",
"def insert(index, string)\n execute_only(:insert, index, string)\n end",
"def insertar_por_cabeza(value)\n\t\tnodo=Node.new(value,nil,nil)\n\t\tif(@head==nil)\n\t\t\t@tail=nodo\n\t\t\t@head=nodo\n\t\telse\n\t\t\tnodo.nest=@head\n\t\t\t@head.prev=nodo\n\t\t\t@head=nodo\n\t\t\tnodo.prev=nil\n\t\tend\n\n\tend",
"def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)\n exec_query(sql, name, binds)\n end",
"def multi_insert(tuples)\n pks = relation.multi_insert(tuples, return: :primary_key)\n relation.where(relation.primary_key => pks).to_a\n end",
"def insert(todo)\n todo = Rutodo::Database::Todo.new(\n title: todo.title,\n description: todo.description,\n done: todo.status == :finished\n )\n\n todo.save\n\n todo.as_entity\n end"
] |
[
"0.71916693",
"0.6845767",
"0.6710367",
"0.6560496",
"0.64945215",
"0.62143415",
"0.6160945",
"0.6136621",
"0.61317945",
"0.60741496",
"0.6067267",
"0.60642874",
"0.605406",
"0.6039778",
"0.6017522",
"0.6006295",
"0.6000629",
"0.5986575",
"0.5940899",
"0.59371734",
"0.58709484",
"0.58505005",
"0.5841813",
"0.58383304",
"0.58372796",
"0.5830545",
"0.5796467",
"0.5794402",
"0.5790425",
"0.57853884",
"0.5756205",
"0.5754439",
"0.5754439",
"0.5752514",
"0.5752514",
"0.5752514",
"0.5748702",
"0.5748702",
"0.5743055",
"0.5712318",
"0.5686805",
"0.5682412",
"0.568092",
"0.5680916",
"0.56752884",
"0.5663091",
"0.56624556",
"0.563126",
"0.56288886",
"0.56248957",
"0.5621051",
"0.5619128",
"0.5609466",
"0.5607735",
"0.56058806",
"0.56036645",
"0.56002194",
"0.5599144",
"0.5589035",
"0.55640036",
"0.55565774",
"0.55520016",
"0.555006",
"0.55461067",
"0.5524512",
"0.5524512",
"0.55242825",
"0.5518693",
"0.5516172",
"0.55134606",
"0.55071855",
"0.5499285",
"0.5498835",
"0.54957956",
"0.5495443",
"0.54912466",
"0.54892266",
"0.548848",
"0.54869705",
"0.548432",
"0.5480823",
"0.54697394",
"0.5468333",
"0.54553616",
"0.54433024",
"0.54393184",
"0.543562",
"0.5428949",
"0.5422294",
"0.5400094",
"0.5399353",
"0.5396192",
"0.5384905",
"0.5383194",
"0.5379935",
"0.5376446",
"0.5369443",
"0.5359704",
"0.5357312",
"0.53498167",
"0.53477556"
] |
0.0
|
-1
|
Extraer al comienzo de la lista
|
def extract_by_begin()
if @head == @tail
@head, @tail = nil
else
@head = @head[:next]
@tail = @tail[:prev]
@tail[:next] = nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def liste()\n puts(\"LISTE DES ORDRES\\n\");\n printf(\"%8s %8s %5s %10s\\n\",\n \"ID\", \"DEBUT\", \"DUREE\", \"PRIX\")\n printf(\"%8s %8s %5s %10s\\n\",\n \"--------\", \"-------\", \"-----\", \"----------\")\n @listOrdre = @listOrdre.sort{ |a,b| a.debut <=> b.debut } \n @listOrdre.each { |ordre| afficherOrdre(ordre) }\n printf(\"%8s %8s %5s %10s\\n\",\n \"--------\", \"-------\", \"-----\", \"----------\");\n end",
"def set_listas\n #@locais = Local.all.map{|l| [l.nome,l.id]}\n @locais = Local.all\n @periodos = ['Manhã','Tarde','Noite']\n @publicos = ['Infantil','Adulto']\n end",
"def clasificar_por_imc (lista)\n \n imc_bajo = Lista.new()\n imc_normal = Lista.new()\n imc_excesivo = Lista.new()\n\n nodo = lista.extract\n \n while !(nodo.nil?)\n\n if nodo.value.datos_ant.indice_masa_corporal >= 30\n imc_excesivo.insert(nodo.value.datos_ant.indice_masa_corporal)\n elsif nodo.value.datos_ant.indice_masa_corporal >=18.5\n imc_normal.insert(nodo.value.datos_ant.indice_masa_corporal)\n else\n imc_bajo.insert(nodo.value.datos_ant.indice_masa_corporal)\n end\n nodo = lista.extract\n end\n\n \"Los IMC por debajo de lo normal son #{imc_bajo.to_s}, los IMC dentro de lo normal son #{imc_normal.to_s} y los que tienen un IMC excesivo son #{imc_excesivo.to_s}\"\n\nend",
"def initialize\n @lista_contas = []\n end",
"def lista(contatos)\n\tfor i in 0..contatos.size-1\n\t\tputs (\"#{i+1}. #{contatos[i].nome}\")\n\t\ti = i + 1\n\tend\nend",
"def ordenar_for\n\t @lista = self.map{ |a| a }\n\t \tfor i in (0..@lista.count-1)\n\t\t\tfor j in (0..@lista.count-1)\n\t\t\t\tif j+1 != @lista.count\n if @lista[j+1] < @lista[j]\n\t\t\t\t\t\t@lista[j],@lista[j+1] = @lista[j+1],@lista[j]\n \t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@lista\n end",
"def get_metodos_que_empiecen(letras,lista)\n #lista = get_all_methods\n lista.select{|metodo| metodo[0..letras.size].include? letras}\n end",
"def metodos_con(letras,*clase) # puede ser metodos de una clase, una lista de clases, o una lista de metodos\n if not clase.none? # si no hay parametros busca en los metodos_observados\n self.get_metodos_de(clase) # aca los setea en @metodos_observados\n end\n @metodos_observados.select{|metodo| metodo[0..letras.size].include? letras}\n end",
"def listado\n #@lista = Asignacion.listado_array\n @lista = Campo.find(:all, :include => [:area => [:contrato => [:empresa]]], :conditions => {:codigo => \"\"}) #\n end",
"def filtrarObstaculos(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"O\")\n aux.push(stringObstaculos(elemento))\n end\n end\n return aux #[[\"O\",3,2],......]\nend",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def obtener_lista\n\t\tsendM(\"obtener_lista\")\n\tend",
"def dodaj_do_listy(*jid)\n\tkontakty(*jid) do |kontakt|\n\t\tnext if subskryp?(kontakt)\n\t\tkontakt.autoryzacja\n\tend\n end",
"def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end",
"def listamarcarubro\n respond_to do |format|\n # format.xml { render :xml => @marcarubro }\n @marcarubro = Listaprecio.agrupamiento\n marcarubro.each do |mc|\n @articulospormarcayrubro = Listaprecio.find.articulosmarcarubro( mc.marca_id, mc.rubro_id )\n end\n end\n @tablalistaprecio = @marcarubro.map { | marcarubro.marca_id, marcarubro.rubro_id | Listaprecio.find.articulosmacarubro( m , r) }\n end",
"def lister( les_cours )\n \n recup = recuperer_option \n format = recup[0]\n sep = recup[2]\n if !recup[1].nil?\n cours = les_cours.sort_by(&:sigle)\n end\n \n cours ||= les_cours.select{|c| c.actif?}\n sep ||= CoursTexte::SEPARATEUR_PREALABLES\n cours =cours.sort_by(&:sigle)\n cours.each { |e| puts e.to_s(format, sep) }\n \n return [les_cours, nil]\n \nend",
"def clasificar_por_sal (lista)\n \n sal_recomendada = Lista.new()\n sal_excesiva = Lista.new()\n \n nodo = lista.extract\n \n while !(nodo.nil?)\n \n if nodo.value.sal > 6\n sal_excesiva.insert(nodo.value.sal)\n else\n sal_recomendada.insert(nodo.value.sal)\n end\n nodo = lista.extract\n end\n \n \"Los productos con una cantidad de sal menor o igual a la recomendada son #{sal_recomendada.to_s} y los que tienen una sal excesiva son #{sal_excesiva.to_s}\"\n \nend",
"def copy_list \n\n\tend",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def list; end",
"def aniade_taxones_seleccionados\n notice = if params[:especies].present?\n @listas.each do |lista|\n lista = Lista.find(lista)\n lista.cadena_especies.present? ? lista.cadena_especies+= ',' + params[:especies].join(',') :\n lista.cadena_especies = params[:especies].join(',')\n lista.save\n end\n 'Taxones incluidos correctamente.'\n else\n 'Debes seleccionar por lo menos una lista y un taxon para poder incluirlo.'\n end\n\n redirect_to :back, :notice => notice\n end",
"def listar\n @todos_los_tipos = TipoComida.all.order(id: :asc)\n @titulo_link = \"Registrar nuevo tipo de comida\"\n end",
"def lister( les_emprunts )\n liste_emprunts = les_emprunts.select{|e| OPTIONS[:inclure_perdus] ? true : not(e.perdu?) }\n liste_emprunts = liste_emprunts.map{|e| e.to_s(OPTIONS[:format])}\n\n [les_emprunts, liste_emprunts.join(\"\\n\")]\nend",
"def ordered_list; end",
"def filtrarPuentes(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"P\")\n aux.push(convertPuente(elemento))\n end\n end\n return aux # [P,[3,1],[3,5]]\nend",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list\n super\n end",
"def list \n @@Ordenadores\n end",
"def list(*) end",
"def seleccionarCromosomas()\n #p \"--- Empieza el torneo:\"\n seleccion = []\n @tamMatingPool.times do\n competidor1 = @poblacion[Random.rand(@tamPoblacion)]\n competidor2 = @poblacion[Random.rand(@tamPoblacion)]\n evaluarCromosoma(competidor1)\n evaluarCromosoma(competidor2)\n ganador = competidor1.aptitud > competidor2.aptitud ? \n competidor1 : competidor2\n #p \"--- Ganador: #{ganador.genes}\"\n seleccion.push(ganador)\n end\n return seleccion\n end",
"def tecnicos_postulados\n coleccion = []\n self.request.each do |request|\n info = {}\n info[:id] = request.id\n info[:article] = request.article\n info[:servicio] = request.service.description\n info[:tecnicos] = request.proposal\n coleccion.append(info)\n end\n coleccion\n end",
"def extraer_por_cabeza\n\t\tif(@head==nil)\n\t\t\tputs \"No hay nada que extraer (lista vacia)\"\n\t\telse\n\t\t\taux=@head\n\t\t\t@head=@head.nest\n\t\t\tif(head!=nil)\n\t\t\t\t@head.prev=nil\n\t\t\tend\n\t\t\taux.nest=nil\n\t\t\tif(@head==nil)\n\t\t\t\t@tail=nil\n\t\t\tend\n\t\tend\t\t\t\n\n\t\treturn aux\n\n end",
"def list\n MENU.select do |item|\n your_list = []\n your_list << item[:what] + \" \" + item[:type]\n your_list\n end\n end",
"def agregarMetodos unaClase\n self.metodos.each do |metodo|\n self.agregar_metodo(unaClase,metodo[0],&metodo[1])\n end\n end",
"def cargar_comandos_jugadas_repetir_otro_sorteo(ticket, sorteo_origen , sorteo_destino)\n #Buscar todos los comandos de todas las jugadaslots de ese ticket con ese sorteo de origen.\n @array_jugadas_de_ese_sorteo_en_ese_ticket = Jugadalot.where(:ticket_id => ticket, :sorteot => Sorteot.where(:sigla => sorteo_origen.to_s).first.id)\n \n @comando_jugadas =[] # Defino el array que trenda todos los comando de las jugadas de este sorteo de ese ticket\n\n @array_jugadas_de_ese_sorteo_en_ese_ticket.each do |jugadalot|\n @comando_jugadas << jugadalot.comandojugada\n end\n \n #Hacer un solo string con todos los comando_jugadas.join(\"*\") unidos por caracter especial \"*\" ok. ted.\n @comando_jugadas = @comando_jugadas.join(\"*\")\n\n #Hacer un string.replace pattern .01 a .02 (sorteo_origen, sorteo_destino)\n sorteo_origen = \".\" + sorteo_origen\n sorteo_destino = \".\" + sorteo_destino\n\n @comando_jugadas.gsub(sorteo_origen, sorteo_destino)\n #dejar que siga evaluando hacia abajo... ok ted. Bloque de codigo guardar jugadas.\n \n end",
"def mostrar_candidatos\n \n puts \" \"\n puts \"Quantidade de votos por candidato\"\n #Buca o candidato em seu array\n for candidato in @candidato\n candidato.mostrar_dados \n end \n end",
"def extraer_detras\n if(@tam == 0)\n puts \"La Lista está vacía\"\n else\n aux = @cola\n @cola = @cola[:prev]\n @cola[:Next_] = nil\n @tam = @tam - 1\n return aux[:value]\n end\n end",
"def index\n @anios = Ordenanza.select(:anio).uniq.map do | ord | ord.anio end\n\n @temas = Ordenanza.select(:tema).uniq.map do | ord | ord.tema end\n\n #TODO: Borrar\n @ordenanzas = Ordenanza.limit(10)\n end",
"def listar_arreglo(arreglo)\n cadena = '| '\n # puts 'el indice: #{index} y el valor: #{value}'\n arreglo.each { |value| cadena += \" #{value} | \" }\n puts cadena\nend",
"def list\n order_items\n end",
"def list\n end",
"def list\n end",
"def list\n end",
"def busca_receitas_por_nome(nome_busca)\n nome_busca = nome_busca.upcase\n receitas_encontradas = []\n\n receitas_encontradas = $receitas.select do |receita|\n receita.nome.upcase.include? nome_busca \n end\n\n receitas_encontradas\nend",
"def select_list; end",
"def get_list_data\n\t\tlist_data = Array.new\n\t\tlist = get_list\n\t\tlist.each do |item|\n\t\t\tvoc = Voc.find(item)\n\t\t\tvoc.wylie = Functions.disparse_a(voc.wylie)\t\n\t\t\tlist_data.push( voc )\n\t\tend\n\t\treturn list_data\n\tend",
"def list\n\n end",
"def eliminar_duplicados(lista)\n if lista.instance_of?(Array)\n return lista.uniq\n end\n end",
"def initialize(nome, comentario)\n @nome = nome\n @comentario = comentario\n @estrelando = []\n end",
"def list_of_pvas\n super\n end",
"def lista\n @kontrahenci = Kontrahenci.find(params[:id])\n @faktury = Faktury.where(:kontrahenci_id => @kontrahenci.id)\n if @faktury.nil? then\n @faktury = []\n end\n @obroty = Obroty.where(:kontrahenci_id => @kontrahenci.id).last(6)\n if @obroty.nil? then\n @obroty = []\n end\n @osoby = OsobaKont.where(:kontrahenci_id => @kontrahenci.id)\n if @osoby.nil? then\n @osoby = []\n end\n \n @inf_dodatka_kontr = InfDodatkaKontr.where(:kontrahenci_id => @kontrahenci.id)\n if @inf_dodatka_kontr.nil? then\n @inf_dodatka_kontr = []\n end\n \n @odmowa_mark = OdmowaMark.where(:kontrahenci_id => @kontrahenci.id)\n if @odmowa_mark.nil? then\n @odmowa_mark = []\n end\n \n ktory= @kontrahenci.id\n m1=1.month.ago.month\n y1=1.month.ago.year\n m2=2.month.ago.month\n y2=2.month.ago.year\n m3=3.month.ago.month\n y3=3.month.ago.year\n \n @saldo1= Obroty.where({ kontrahenci_id: ktory, rok: y1, miesiac: m1 }).take\n @saldo2= Obroty.where({ kontrahenci_id: ktory, rok: y2, miesiac: m2 }).take\n @saldo3= Obroty.where({ kontrahenci_id: ktory, rok: y3, miesiac: m3 }).take\n \n \n if @saldo1.nil?\n @suma1=0\n else \n @suma1=@saldo1['kwota'].to_f\n end\n if @saldo2.nil?\n @suma2=0\n else\n @suma2 = @saldo2['kwota'].to_f\n end\n if @saldo2.nil?\n @suma3=0\n else\n @suma3= @saldo3['kwota'].to_f\n end\n @suma= @suma1 + @suma2 + @suma3\n end",
"def get_list\n \t@items\n end",
"def listarContatos\n\t\t\n\tescolha = 1\n\tcontatos = []\n\tloop do\n\t\tcontatos = ContatoDAO.new.listar\n\t\tputs(\"--------------------------------\\nContatos:\\n--------------------------------\")\n\n\t\tif contatos.size == 0\n\t\t\tputs(\"\\nVocê nao possui contatos!\\n\\n\")\n\t\t\tbreak\n\t\telse\n\n\t\t\tlista(contatos)\n\n\t\t\tputs(\"\\n\\n#{contatos.size+1}. Pesquisar contatos:\\n#{contatos.size+2}. Exportar contatos para arquivo HTML\\n#{contatos.size+3}. Sair\")\n\n\n\t\t\tputs(\"\\nDigite o numero do contato que deseja ver:\")\n\t\t\tescolha = Validacao.numopcoes(gets.to_i, contatos.size+3)\n\n\t\t\tif (escolha >= 1 && escolha <= contatos.size)\n\t\t\t\tabrirContato(contatos[escolha-1])\n\t\t\telsif (escolha == contatos.size+1)\n\t\t\t\tpesquisa\n\t\t\telsif (escolha == contatos.size+2)\n\t\t\t\ttoHTML(contatos)\n\t\t\tend\n\t\tend\n\tbreak if escolha == contatos.size+3\n\tend\nend",
"def index\n # On récupère la liste des utilisateurs avec une requête sur la base, de sorte à ce qu'il\n # n'y ait rien d'affiché au chargement. Cela permet un chargement très rapide de la page.\n @utilisateurs = Utilisateur.requete_id(params[:requete]) + Utilisateur.requete_nom(params[:requete]) + Utilisateur.requete_prenom(params[:requete])\n end",
"def lancamentos_para_efetivar\n\t\t@entries = []\n\t\tself.categories.each do |c|\n\t\t\tc.lancamentos_ate_mes(Date.today).each do |e|\n\t\t\t\tif(e.mes_nao_efetivado(Date.today))\n\t\t\t\t\t@entries << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@entries\n\tend",
"def resultados\n if params[:checklist] == '1'\n self.taxones = taxones.datos_arbol_con_filtros\n checklist\n else\n self.taxones = taxones.select_basico.order(:nombre_cientifico)\n return if formato == 'xlsx'\n\n self.taxones = taxones.offset(offset).limit(por_pagina)\n\n # Si solo escribio un nombre\n if params[:id].blank? && params[:nombre].present?\n taxones.each do |t|\n t.cual_nombre_comun_coincidio(params[:nombre])\n end\n end\n end # End checklist\n end",
"def make_item_list\n end",
"def nombres_comunes\n datos = eval(naturalista_info.decodifica64)\n datos = datos.first if datos.is_a?(Array)\n return [] unless datos['taxon_names'].present?\n nombres_comunes_faltan = []\n\n # Nombres comunes de la base de catalogos\n nom_comunes = especie.nombres_comunes\n nom_comunes = nom_comunes.map(&:nombre_comun).map{ |nom| I18n.transliterate(nom).downcase }.sort if nom_comunes\n\n datos['taxon_names'].each do |datos_nombres|\n next unless datos_nombres['is_valid']\n next if datos_nombres['lexicon'] == 'Scientific Names'\n\n # Nombre comun de NaturaLista\n nombre = I18n.transliterate(datos_nombres['name']).downcase\n lengua = datos_nombres['lexicon']\n\n if nom_comunes.present?\n next if nom_comunes.include?(nombre)\n end\n nombres_comunes_faltan << \"#{especie.catalogo_id},\\\"#{datos_nombres['name']}\\\",#{lengua},#{especie.nombre_cientifico},#{especie.categoria_taxonomica.nombre_categoria_taxonomica},http://naturalista.conabio.gob.mx/taxa/#{naturalista_id}\"\n end\n\n nombres_comunes_faltan\n end",
"def proximos\n @lista = Array.new\n estabelecimentos = Estabelecimento.all\n if (params[:token] != nil)\n user = Usuario.find_by_token(params[:token])\n @favoritos = Favorito.find_all_by_usuario_id(user.id)\n estabelecimentos.each do |estab|\n estab.favorito = false\n @favoritos.each do |fav|\n if (fav.estabelecimento_id == estab.id)\n estab.favorito = true\n break\n end\n end \n end\n end\n \n raio = params[:raio]\n if (raio == nil)\n raio = 1000\n end\n estabelecimentos.each do |estab|\n dist = distancia(params[:latitude].to_f, params[:longitude].to_f,estab.latitude, estab.longitude)\n if (dist.to_f <= raio.to_f && dist.to_f != 0.0)\n if (estab.favorito == nil)\n estab.favorito = false\n end\n @lista.push(estab)\n end\n end\n \n respond_to do |format|\n format.html # proximos.html.erb\n format.json { render :json => @lista, :include => {:precos =>{:only => :valor, :include =>:produto } , \n :caracteristicas => {:only => [:nome, :id]} } }\n end\n \n end",
"def datos(opc={})\n return [] unless cadena_especies.present?\n\n # Por default muestra todos\n Especie.caso_rango_valores('especies.id',cadena_especies).order('nombre_cientifico ASC').limit(opc[:limit] ||= 300000).each do |taxon|\n self.taxon = taxon\n asigna_datos\n self.taxones << taxon\n end\n end",
"def usun_z_listy(*jid)\n\tkontakty(*jid) do |usun|\n\t\tusun.usun_subskrypcje\n\t\treq=Iq.new_rosterset\n\t\treq.query.add(Roster::RosterItem.new(usun.jid,nil,:remove))\n\t\twyslij(req)\n\tend\n end",
"def set_lista\n @lista = Lista.find(params[:id])\n end",
"def listarAjudas(numAjuda = 0)\n\n ajd = []\n index = 0\n numAjuda.times do\n ajd << @plvAjudas[index]\n index += 1\n end\n return ajd\n end"
] |
[
"0.64497757",
"0.64112437",
"0.63231516",
"0.6316969",
"0.63040507",
"0.6236165",
"0.62184566",
"0.61983",
"0.61309683",
"0.60884625",
"0.6030821",
"0.6030821",
"0.6030821",
"0.59506583",
"0.58929974",
"0.58924073",
"0.5884651",
"0.5873622",
"0.58721846",
"0.5828492",
"0.5827676",
"0.5827676",
"0.5827676",
"0.5827676",
"0.5827676",
"0.58053046",
"0.5804744",
"0.57847524",
"0.57726324",
"0.5724062",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.56983423",
"0.5687021",
"0.56838787",
"0.566976",
"0.5663547",
"0.56474",
"0.5644976",
"0.5606791",
"0.55982417",
"0.5587401",
"0.55781794",
"0.55687284",
"0.5529524",
"0.55212414",
"0.5515416",
"0.5515416",
"0.5515416",
"0.55099463",
"0.5500726",
"0.54905957",
"0.5489796",
"0.54894763",
"0.54887784",
"0.5484902",
"0.5472369",
"0.54721045",
"0.5469403",
"0.5465277",
"0.54623944",
"0.5460417",
"0.5460173",
"0.54498917",
"0.54479027",
"0.54446214",
"0.54212594",
"0.54090744",
"0.5401542"
] |
0.0
|
-1
|
Time this data was processed
|
def processed_at
@data.has_key?('processed_at') ? Time.parse(data['processed_at']) : nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def processed_date_time\n return @processed_date_time\n end",
"def processed_date_time\n return @processed_date_time\n end",
"def time\n return @time\n end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time\n @time\n end",
"def time\n Time.at(data[\"time_ms\"].to_f/1000)\n end",
"def time\n end",
"def elapsed_time\n @internal_data.elapsed_time\n end",
"def cstime(*) end",
"def cstime=(*) end",
"def time\n @time ||= Time.at( timestamp / 1_000_000.0 )\n end",
"def processed_date_time=(value)\n @processed_date_time = value\n end",
"def processed_date_time=(value)\n @processed_date_time = value\n end",
"def start_time\n data.start_time\n end",
"def start_time\n data.start_time\n end",
"def start_time\n @internal_data.start_time\n end",
"def execute_time\n @next_time\n end",
"def time\n Time.at(messaging['time'] / 1000)\n end",
"def total_time; end",
"def time\n reply.documents[0][TIME]\n end",
"def time\n\n end",
"def load_time\n @time_counter = Time.new.to_i\n end",
"def total_time=(_arg0); end",
"def time\n Time.now.to_f\n end",
"def time_request\n\t\tstarttimes = Process.times\n\t\tyield\n\tensure\n\t\truntimes = Process.times\n\t\t@run_count += 1\n\t\t@total_utime += utime = (runtimes.utime - starttimes.utime)\n\t\t@total_stime += stime = (runtimes.stime - starttimes.stime)\n\t\tself.log.info \\\n\t\t\t\"[PID %d] Runcount: %d, User: %0.2f/%0.2f, System: %0.2f/%0.2f\" %\n\t\t\t[ Process.pid, @run_count, utime, @total_utime, stime, @total_stime ]\n\tend",
"def time\n on_each_node :time\n end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def execution_time\n @process.instance_variable_get(:@execution_time).total\n end",
"def time\n @values['time']\n end",
"def time\n request :public, :get, :time\n end",
"def time\n super\n end",
"def start_time; end",
"def time\n params['time']\n end",
"def time=(_arg0); end",
"def time=(_arg0); end",
"def time=(_arg0); end",
"def time=(_arg0); end",
"def time=(_arg0); end",
"def time=(_arg0); end",
"def time\n #Parse the raw time into a binary time structure...\n time = send_request(Packets::RequestTime.new)\n\n #And convert that to a ruby time.\n time.to_time()\n end",
"def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end",
"def report_time time\n end",
"def start_time\n @start_time\n end",
"def response_time\n @response_time\n end",
"def building_time\n @process.instance_variable_get(:@building_time).total\n end",
"def time\n started_at = Time.now.to_f\n yield()\n ensure\n update((Time.now.to_f - started_at.to_f) * 1000)\n end",
"def time\n set_function_and_argument(:time, nil)\n end",
"def ctime\n end",
"def time\n @robot.time\n end",
"def start_time\n return @start_time\n end",
"def progress_observation_date_time\n return @progress_observation_date_time\n end",
"def launch_time\n data[:launch_time]\n end",
"def time\r\n\t\t@usr_time\r\n\tend",
"def start_time=(_arg0); end",
"def time\n end_time - start_time\n end",
"def start_time\n if ev = start_event.last\n ev.time\n end\n end",
"def start_time\n if ev = start_event.last\n ev.time\n end\n end",
"def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end",
"def time\n beg_time = Time.now\n yield\n end_time = Time.now\n end_time - beg_time\n end",
"def end_time\n data.end_time\n end",
"def usage_operation_update_time\n data[:usage_operation_update_time]\n end",
"def start_time\n start\n end",
"def time\n @ole.Time\n end",
"def time\n @ole.Time\n end",
"def time\n @ole.Time\n end",
"def ctime() end",
"def ctime() end",
"def ctime() end",
"def update\n\t\t\t@last_run = Time.new\n\t\tend",
"def processed_at\n @processed_at ||= begin\n groups = *mapping_for(:processed_at).match(/(\\d{2})\\/(\\d{2})\\/(\\d{4}) ([\\d:]+)/sm)\n Time.parse(\"#{groups[3]}-#{groups[2]}-#{groups[1]} #{groups[4]}\")\n end\n end",
"def run_date_time\n return @run_date_time\n end",
"def process_creation_date_time\n return @process_creation_date_time\n end",
"def server_timing; end",
"def request_time\n @request_time ||= Time.now.utc\n end",
"def time_elapsed\n Time.now - @start_time\n end",
"def get_completion_time()\n return process_stamp(@end_time)\n end",
"def time\n each_item.reduce(0) { |a, e| a + e.duration }\n end",
"def total_time\n Time.now - @now\n end",
"def time\n building_time + execution_time\n end",
"def runtime_latency\n (finished_at || Time.current) - performed_at if performed_at\n end",
"def process_duration\n t1 = Process.times.utime\n Process.times.utime - t1\nend",
"def get_time\n Process.clock_gettime(Process::CLOCK_MONOTONIC)\n end",
"def time_elapsed\n\t\treturn Time.now - self.start_time\n\tend",
"def time\n send_message!(Protocol::Device::GetTime.new, wait_for: Protocol::Device::StateTime) do |payload|\n Time.at(payload.time.to_f / NSEC_IN_SEC)\n end\n end",
"def utime(*) end",
"def time\n Time.now.localtime + self.time_offset\n end",
"def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end"
] |
[
"0.7575571",
"0.7575571",
"0.7322301",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.72568333",
"0.7240576",
"0.71006215",
"0.7082745",
"0.705201",
"0.69457346",
"0.69243026",
"0.68922687",
"0.68641275",
"0.68641275",
"0.6843688",
"0.6843688",
"0.6837375",
"0.6831766",
"0.6818337",
"0.68079174",
"0.6796913",
"0.6783786",
"0.6778955",
"0.67582375",
"0.67448753",
"0.67210406",
"0.67008626",
"0.668614",
"0.668614",
"0.668614",
"0.668614",
"0.668614",
"0.668614",
"0.6685046",
"0.6658998",
"0.6639387",
"0.6623037",
"0.6597642",
"0.65755504",
"0.65673125",
"0.65673125",
"0.65673125",
"0.65673125",
"0.65673125",
"0.65673125",
"0.65535617",
"0.65165216",
"0.6499323",
"0.6488805",
"0.648875",
"0.64820224",
"0.6463405",
"0.64421934",
"0.64337796",
"0.64316934",
"0.64218694",
"0.64132273",
"0.6413139",
"0.64070165",
"0.6403193",
"0.6401466",
"0.6400504",
"0.6400504",
"0.6395189",
"0.63950306",
"0.63822234",
"0.63658684",
"0.6357879",
"0.6354932",
"0.6354932",
"0.6354932",
"0.63432294",
"0.6342525",
"0.6342525",
"0.63269323",
"0.6321417",
"0.6319004",
"0.63081926",
"0.62931216",
"0.6290062",
"0.62882566",
"0.6286397",
"0.6285957",
"0.6282314",
"0.6263239",
"0.62616426",
"0.626012",
"0.6257316",
"0.6255917",
"0.62377053",
"0.62315613",
"0.62304926",
"0.6225665"
] |
0.68988043
|
18
|
a single dash before and after each odd digit. There is one exception: don't start or end the string with a dash. You may wish to use the `%` modulo operation; you can see if a number is even if it has zero remainder when divided by two. Difficulty: medium.
|
def dasherize_number(num)
i=1
num = num.to_s
new_str = num[0]
while (i>0 && i<num.length)
if (num[i].to_i%2==1 || num[i-1].to_i%2==1)
new_str = new_str + "-" + num[i].to_s
else
new_str = new_str + num[i].to_s
end
i+=1
end
return new_str
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dasherize_number(num)\n\n index = 0\n \n num_string = num.to_s\n new_string = ''\n \n while index < num_string.length\n # Simplify your checks for odd and evenness here. \n # You are checking for so many things which makes the code messy.\n # Just divide the number using modulo you don't need to check for index\n \n if num_string[index].to_i.even? \n new_string += num_string[index].to_s \n elsif num_string[index].to_i.odd? \n new_string = \"-\" + num_string[index].to_s + \"-\"\n end\n \n index = index + 1\n end\n puts new_string\nend",
"def dasherize_number(num)\n\tnum_string = num.to_s\n\tidx = 0\n\n\twhile idx < num_string.length-1\n\t\tif num_string[idx].to_i % 2 != 0\n\t\t\tnum_string.insert(idx+1, \"-\")\n\t\tend\n\t\tidx += 1\n\tend\n\n\twhile num_string[idx] != \"-\"\n\t\tif num_string[idx2].to_i % 2 == 0 && num_string[idx2+1] != \"-\"\n\t\t\tputs \"#{num_string[idx2]} qualifies\"\n\t\tend\n\t\tidx2 += 1\n\tend\n\treturn num_string\nend",
"def dasherizer(integer)\n array = integer.to_s.chars.map(&:to_i)\n new_string = \"\"\n size = array.size - 1\n\n array.each_with_index do |int, index|\n if index == size\n new_string << int.to_s\n elsif int.odd? && array[index + 1].odd?\n new_string << int.to_s + \"-\"\n else\n new_string << int.to_s\n end\n end\n\n new_string\nend",
"def dasherize_number(num)\n num = num.to_s\n result = ''\n\n idx = 0\n while idx < num.length\n # No dash to be added: all even digits\n if num[idx].to_i % 2 == 0\n result += num[idx]\n \n # Is first\n elsif idx == 0\n result += num[idx] + '-'\n\n # Is last\n elsif idx == num.length-1\n result += '-' unless result[-1] == '-'\n result += num[idx] \n \n # All others\n else\n result += '-' unless result[-1] == '-'\n result += num[idx] \n result += '-'\n end \n\n #puts result #debug\n idx += 1\n end\n\n #puts result #debug\n return result\nend",
"def dasherize_number(num)\n arr = num.to_s.split(\"\")\n idx = 0\n while idx < arr.length\n if arr[idx].to_i % 2 == 0\n idx += 1\n elsif idx == 0 && arr[idx].to_i % 2 != 0\n arr[idx] = \"#{arr[idx]}-\"\n elsif arr[idx].to_i % 2 != 0 && arr[idx - 1].length > 1\n arr[idx] = \"#{arr[idx]}-\"\n else\n arr[idx] = \"-#{arr[idx]}-\"\n end\n idx += 1\n end\n return final = arr.join(\"\").split(\"\")\n if final[-1] == \"-\"\n final.pop\n end\n return final.join(\"\")\nend",
"def dasherize_number(num)\n\n arr = num.to_s.split(\"\")\n arr.each do |x|\n if x[0].to_i.odd?\n puts x[0] + \"-\"\n end\nend\n\n # if arr[0].to_i.odd?\n # puts arr[0] + \"-\"\n # elsif arr[arr.length-1].to_i.odd?\n # puts \"-\" + arr[arr.length-1]\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[arr.length-1]\n # # puts \"-\" + x\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[0]\n # # puts x + \"-\"\n # # else\n # # return nil\n # # end\n # end\n # end\nend",
"def dasherize_number(num)\n str = \"\"\n arr = num.to_s.split('')\n i = 0\n while i<arr.count\n if is_odd?(arr[i].to_f)\n if i>0 && !(str[-1]=='-')\n str += '-'\n end\n str += arr[i]\n if i<arr.count-1\n str += '-'\n end\n else\n str += arr[i]\n end\n i+=1 \n end\n return str\nend",
"def dasherize_number(num)\n\tstr_num = num.to_s\n\tnew_str = \"\"\n\ti = 0\n\twhile i < str_num.length\n\t\tif (str_num[i].to_i % 2 == 1) || (str_num[i - 1].to_i % 2 == 1)\n\t\t\tnew_str += '-'\n\t\tend\n\t\tnew_str += str_num[i]\n\t\ti += 1\n\tend\n\n\tif(new_str[0] =='-')\n\t\tnew_str[0] = ''\n\tend\n\t\n\t#if(new_str[(new_str.length - 1)] == '-')\n\t#\tnew_str[(new_str.length - 1)] = ''\n\t#end\n\t\n\tputs new_str\n\tnew_str\nend",
"def dasherize_number(num)\n number_string = num.to_s\n i = 0\n result = []\n while i < number_string.length\n if number_string[i].to_i % 2 == 1 && number_string[i + 1].to_i % 2 == 1\n letter = \"-\" + number_string[i]\n else\n leter = number_string[i]\n end\n result.push(letter)\n i += 1\n end\n result.join(\"\")\nend",
"def dasherize_number(num)\n i = 1\n answer = [num[0]]\n while i < num.to_s.length\n if num[i].to_i % 2 == 1 || num[i-1].to_i % 2 == 1\n answer << \"-\"\n end\n answer << num\n i += 1\n end\n return answer.join(\"\")\nend",
"def dasherize_number(num)\n \n idx = 0\n string = num.to_s.split(\"\")\n arr = \"\"\n \n while idx < string.length\n \n if string[idx].to_i % 2 != 0 \n string[idx] = \"-\" , \"#{string[idx]}\" , \"-\"\n end\n \n idx += 1\n \n end\n\t\n arr = string.join.to_s\n\tarr.split(\"\")\n\t\n\tif arr[-1] == \"-\"\n\t\tarr[-1] = \"\"\n\tend\n\t\n\tif arr[0] == \"-\"\n\t\tarr[0] = \"\"\n\tend\n\t\n\tarr.gsub! \"--\", \"-\"\n\treturn arr\n \nend",
"def insert_dash(num)\n string_split = num.to_s.split(\"\")\n \n string_split.each_with_index do |num, i|\n if string_split[i].to_i.odd? == true && string_split[i+1].to_i.odd? == true\n string_split.insert(i+1, \"-\")\n i+=2\n end \n end\n return string_split.join\n \nend",
"def DashInsert(str)\n \n i = 0\n while i < str.length - 1\n if str[i].to_i % 2 != 0 && str[i+1].to_i % 2 != 0 && str[i].to_i != 0 \n \t str[i] = str[i] + \"-\"\n end\n i += 1\n end\n \n str\n \nend",
"def dasherize_number(num)\n #split number into an array\n array = num.to_s.chars.map(&:to_i)\n i = 0\n #iterate over array to find odd numbers\n while i < array.length\n if !(array[i] % 2 == 0)\n #if it is the first number, only put a dash on the right side\n if i == 0\n array[0] = [array[i], \"-\"].join\n puts \"first number: #{array[0]}\"\n #if it is the last number, only put a dash on the left side\n elsif i == array.length-1\n array[array.length-1] = [\"-\", array[array.length-1]].join\n puts \"last number: #{array[array.length-1]}\"\n #else put a dash on both sides\n else\n if (i-1 == 0 && i+1 == array.length-1)\n array[i] = array[i]\n elsif i-1 == 0\n array[i] = [array[i], \"-\"].join\n elsif i+1 == array.length-1\n array[i] = [\"-\", array[i]].join\n else\n array[i] = [\"-\", array[i], \"-\"].join\n end \n end \n end \n i += 1\n end \n #return dashedString\n array = array.join\n puts array\n return array\nend",
"def dasherize_number(num)\n#my counter variable\n i = 1\n# Convert numbers to a string \n number_string = num.to_s\n# Create result variable to add in the numbers after they've been 'dashed'\n result= \"#{number_string[0]}\"\n\n while i < number_string.length\n #need to convert number_string to variables because \"1\" != 1\n current_num = number_string[i].to_i\n # if there isnt a remainder after i divide by two add current_num to result \n if(current_num % 2 == 0) \n result += \"#{current_num.to_s}\"\n #if there is a remainder after i divide by 2 add current_num to result with a dash in front of current_num\n elsif (current_num % 2 == 1) \n result += \"-#{current_num.to_s}\"\n end\n i += 1\n end\n puts result\n return result\nend",
"def dasherize_number(num)\n num = num.to_s\n new = []\n \n if num[0].to_i % 2 == 1\n new.push(num[0])\n new.push('-')\n else\n new.push(num[0])\n end\n \n i = 1\n while i < num.size - 1\n if num[i].to_i% 2 == 1\n if (new[new.length-1] != '-')\n new.push(\"-\")\n end\n new.push(num[i])\n new.push(\"-\")\n else \n new.push(num[i])\n end\n i += 1\n end\n if num[num.size-1].to_i % 2 ==1 && new[new.length-1] != '-'\n new.push('-')\n end\n new.push(num[num.length-1])\n print new.join\n return new.join\n \nend",
"def dashing_odds(num)\n\n # convert integer to string\n int_to_string = num.to_s()\n\n\n # checking the type of int_string\n #\n #\n\n # p num.instance_of? Integer # Fixnum is deprecated and replaced by Integer\n # p int_to_string.instance_of? String\n #\n # puts int_to_string.respond_to?(:to_s)\n\n # all 3 prints true !\n #\n # end of checking type of int_string\n # https://stackoverflow.com/questions/15769739/determining-type-of-an-object-in-ruby\n\n\n i = 0\n\n dashified = \"\"\n\n # treat string as an array\n while( int_to_string.length() > i )\n\n # p \"int_to_string[i].to_i #{int_to_string[i].to_i} % 2 = #{int_to_string[i].to_i % 2}\"\n\n # checks if number is odd\n if( int_to_string[i].to_i % 2 == 0 )\n\n if( int_to_string[i-1].to_i % 2 == 1 )\n\n dashified += \"-\"\n end\n\n dashified += int_to_string[i]\n\n\n else\n\n dashified += \"-\"\n dashified += int_to_string[i]\n # dashified += \"-\"\n\n end # if\n\n i += 1\n end # while\n\n # p dashified\n\n # remove leading dashes\n # treating string as array\n # p \"dashified[0] #{dashified[0]}\"\n\n if( dashified[0] == \"-\" )\n\n dashified = dashified.slice( 1, dashified.length() )\n\n end # if\n\n # remove trailing dashes\n # treating string as array\n\n # p dashified\n\n # p \"dashified[ dashified.length() - 1 ] #{dashified[ dashified.length() - 1 ]}\"\n\n if( dashified[ dashified.length() - 1 ] == \"-\" )\n\n dashified = dashified.slice( 0, dashified.length() - 1 )\n\n end # if\n\n p dashified\n\n\n # IMPROVEMENT !!!! \n #\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n # maybe best to have own method !\n\n # End of:\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n\n p dashified\n return dashified\n\nend",
"def dasherize_number(num)\n number = num.to_s\n dashed = \"\"\n\n dashed = number[0]\n if number[0].to_i % 2 == 1\n dashed += \"-\"\n end\n\n number[1..-1].each_char do |n|\n\n if n.to_i % 2 == 1\n if dashed[-1] != \"-\"\n dashed = dashed + \"-\" + n + \"-\"\n else\n dashed += n\n end\n else\n dashed += n\n end\n end\n\n if dashed[-1] == \"-\"\n return dashed[0...-1]\n end\n\n dashed\nend",
"def dasherize_num(num)\n\n num_s = num.to_s\n\n result = \"\"\n\n i = 0\n\n while num_s.length > i\n\n digit = num_s[i].to_i\n\n if (i > 0) # only if the it's not the leading digit\n\n prev_digit = num_s[i - 1].to_i\n\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n\n end\n\n end\n\n result += num_s[i]\n\n i += 1\n end\n\n return result\nend",
"def dash_insert_ii(str)\n result = ''\n str.each_char.with_index do |char, idx|\n result << char\n next if char == '0' || idx >= str.size - 1 || str[idx + 1] == '0'\n if char.to_i.even? && str[idx + 1].to_i.even?\n result << '*'\n elsif char.to_i.odd? && str[idx + 1].to_i.odd?\n result << '-'\n end\n end\n result\nend",
"def dasherize_number(num)\n num_s = num.to_s\n\n result = \"\"\n\n idx = 0\n while idx < num_s.length\n digit = num_s[idx].to_i\n\n if (idx > 0)\n prev_digit = num_s[idx - 1].to_i\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n end\n end\n result += num_s[idx]\n\n idx += 1\n end\n\n return result\nend",
"def dasherize_number(num)\r\n nums = num.to_s.split('') #turns argument into a string and splits it into an array of single numbers. NOTE: '2' != 2\r\n nums.map! do |i| #Loop through nums .map! so you can change the orginal array\r\n if i.to_i.odd? == true # convert each iteration from string to integer, if its odd...\r\n i = \"-\"+ i # add a \"-\" before the number\r\n end\r\n i.to_s #leave it alone if its not odd and convert it back a string\r\n end#^^^\r\n\r\n if nums[0].to_i.odd? #this is to compensate for odd numbers at the beginning. \r\n nums[0].reverse! #example: [\"-3\",\"0\", \"-3\"] >> [\"3-\",\"0\", \"-3\"] \r\n end\r\n\r\nnums = nums.join('').split('') #converts [\"-3\",\"0\", \"-3\"] >> [\"3\", \"-\", \"0\", \"-\", \"3\"].\r\nnums.map! do |k| #loop through nums\r\n index = nums.index(k) #set index\r\n if nums[index] == \"-\" && nums[index+1] == \"-\" # checks to see if a dash is next to a dash\r\n nums.delete_at(index) #if so, delete it\r\n end\r\n k = k # otherwise leave k alone\r\n end\r\nreturn nums.join('') #return as a single string\r\nend",
"def DashInsert(str)\n str = str.split(\"\")\n odd = \"13579\"\n i = 0\n new = \"\"\n\n while i < str.length\n new += str[i]\n if odd.index(str[i]) && str[i+1] && odd.index(str[i + 1])\n new += \"-\"\n end\ni+= 1\n end\n # code goes here\n return new\n\nend",
"def dasherize_number(num)\n\tanswer = ''\n\tnum.to_s.each_char do |x|\n\t\tif x.to_i.odd? \n\t\t\tif answer.match(/-$/)\n\t\t\t\tanswer += x + '-' \n\t\t\telse\n\t\t\t\tanswer += '-' + x + '-'\n\t\t\tend\n\t\telse\n\t\t\tanswer += x\n\t\tend\n\n\tend\n\tanswer.reverse.chomp('-').reverse.chomp('-')\nend",
"def dasherize_number(num)\n\t num_s = num.to_s\n\t\n\tresult = \"\"\n\t\n\ti = 0\n\twhile i < num_s.length\n\tdigit = num_s[i].to_i\n\t\n\tif (i > 0)\n\tprev_digit = num_s[i - 1].to_i\n\tif (prev_digit % 2 == 1) || (digit % 2 == 1)\n\tresult += \"-\"\n\tend\n\tend\n\tresult += num_s[i]\n\t\n\ti += 1\n\tend\n\t\n\treturn result\nend",
"def dasherize_number(num)\n result = String.new \n \n while num > 0 do\n digit = num % 10\n if digit % 2 != 0\n result = \"-\" + digit.to_s + \"-\" + result\n else\n result = digit.to_s + result\n end\n num = num / 10\n end\n # puts result\n result = result.gsub(\"--\", \"-\")\n# puts result\n \n \n \n if result[0] == \"-\" || result[len-1] == \"-\"\n len = result.length\n if result[0] == \"-\" \n result = result[1..len-1]\n end\n len = result.length\n if result[len-1] == \"-\"\n result = result[0..len-2]\n end\n end\n # puts result\n return result \nend",
"def DashInsert(num)\n\n # step1: convert the integer to a string\n # step2: determine whether a number is odd or not and grab index \n # step3: insert a dash after it \n\n num.scan(/[13597]{2}|.+/).join(\"-\")\n # num_arr = num.to_s\n # num_arr.each_char do |n|\n # \tif n % 3 = 0 \n # \t\tstr.insert(i+1, '-')\n # \tend\n # end\n # code goes here \n \nend",
"def dasherize_number(num)\n\nnumx = num.to_s\nlength = numx.length\n\nidx = 0\n\nif numx[1] == nil\n\treturn numx[0]\nend\n\n\nwhile idx < length\nstring = ''\n\tif numx[idx] == 0\n\t\tstring = string + 0\n\t\tidx += 1\n\telsif num[idx] == nil\n\t\treturn string\t\n\telsif (numx[0] % 2) == 0\n\t\tstring = string + numx[0]\n\t\tidx += 1\n\telsif (numx[0] % 2 != 0)\n\t\tstring = string + numx[0] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + '-' + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = string + '-' + numx[idx]\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = '-' + numx[idx] + '-'\n\t\tidx += 1\n\telse\n\t\tstring = string + numx[idx]\n\t\tidx += 1\n\tend\t\nend\n\nreturn string\n\nend",
"def dasherize_number(num)\n\tnum_arr = []\n\toutput_arr = []\n\tevens = ''\n\twhile num > 0\n\t\tnum_arr.unshift(num % 10)\n\t\tnum /= 10\n\tend\n\ti = 0\n\twhile i < num_arr.size\n\t\tif num_arr[i] % 2 != 0\n\t\t\toutput_arr.push(evens) if evens != ''\n\t\t\tevens = ''\n\t\t\toutput_arr.push(num_arr[i].to_s)\n\t\telse\n\t\t\tevens += num_arr[i].to_s\n\t\tend\n\t\ti += 1\n\tend\n\toutput_arr.join('-')\n\nend",
"def DashInsert(str)\n str.chars\n .each_cons(2)\n .map { |i,j| (i.to_i.odd? && j.to_i.odd?) ? i+'-' : i }\n .join + str[-1]\nend",
"def dashatize(n)\n n ? n.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def dashatize(num)\n return 'nil' if num == nil\n str = num.to_s.each_char.map do |char|\n char.to_i.odd? ? char = \"-#{char}-\" : char\n end\n\n str = str.join.squeeze('-')\n str.slice!(0,1) if str[0] == '-'\n str.slice!(-1,1) if str[-1] == '-'\n str\nend",
"def dashatize(num)\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def dasherize_number(num)\n arr = num.to_s.chars\n arr.each { |char| char.gsub!(char, \"-#{char}-\") if char.to_i.odd? }\n string = arr.join\n string.chop! if string[-1] == '-'\n string[0] = '' if string[0] == '-'\n string.squeeze('-')\nend",
"def dashatize(num)\n return \"nil\" if num.nil?\n s = ''\n num = num.abs\n num.digits.reverse.each_with_index do |digit,index|\n if digit.odd?\n s += \"-#{digit}-\"\n else\n s += \"#{digit}\"\n end\n end\n s = s.gsub(\"--\",\"-\")\n if s[0] == \"-\"\n s = s.reverse.chop.reverse\n end\n if s[-1] == \"-\"\n s.chop!\n end\n return s\nend",
"def dasherize(str)\n (str.length > 1 ? \"--\" : \"-\") + str\n end",
"def insert_dash(num)\n num.to_s.gsub(/(?<=[13579])([13579])/, '-\\1')\nend",
"def DashInsertII(num)\n\n # code goes here\n str = num.to_s.chars.to_a\n str.each_index do |i|\n next if i == 0\n if str[i] && str[i-1] =~ /\\d+/\n if str[i-1].to_i.even? && str[i].to_i.even?\n str.insert(i,'*')\n elsif str[i-1].to_i.odd? && str[i].to_i.odd?\n str.insert(i,'-')\n end\n end\n end\n return str.join\n \nend",
"def DashInsert(num)\n\n num.to_s.gsub(/[13579]{2,}/){|x| x.split('').join(\"-\")}\n \nend",
"def dashatize(num)\n # scan(pattern) -> [String] | [[String]]\n # self に対して pattern を繰り返しマッチし、 マッチした部分文字列の配列を返します。\n # pattern が正規表現で括弧を含む場合は、 括弧で括られたパターンにマッチした部分文字列の配列の配列を返します。\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def seperation\n puts \"-\" * 10\n end",
"def fix_dash_dash(text); end",
"def DashInsert(str)\n str.to_s.gsub(/([13579])(?=[13579])/, '\\1-')\nend",
"def num_to_dashes(num)\n\treturn '-'*num\nend",
"def stringy_hightech(num, zero_start=1)\n half, remainder = num.divmod 2\n\n case zero_start\n when 0 then '01' * half + '0' * remainder\n when 1 then '10' * half + '1' * remainder\n end\nend",
"def dasherize(word)\n word.gsub(/_/,'-')\nend",
"def _n(str)\n str.gsub(/(-)(.*)/, '\\2')\n end",
"def divider(char=\"-\")\n char * 80\nend",
"def odd(str)\n result = ''\n is_odd_idx = false\n space_just_added = false\n last_letter_idx = nil\n last_space_idx = nil\n str.each_char do |char|\n if char == ' '\n next if space_just_added\n result << ' '\n space_just_added = true\n last_space_idx = result.size\n is_odd_idx = !is_odd_idx\n elsif char.match?(/[a-z]/i)\n is_odd_idx ? result.insert(last_space_idx, char) : result << char\n last_letter_idx = result.size - 1\n raise ArgumentError if last_letter_idx - last_space_idx.to_i >= 20\n space_just_added = false\n elsif char == '.'\n break\n else\n raise ArgumentError, 'invalid input'\n end\n end\n last_letter_idx ? result[0..last_letter_idx] + '.' : result\nend",
"def odds_and_evens(string, return_odds)\n newstring = \"\"\n n = 1 if return_odds\n n = 0 if !return_odds\n # n = return_odds ? 1 : 0\n\n for index in 0..(string.length-1)\n if index % 2 == n\n newstring = newstring + string[index]\n end\n end\n return newstring\nend",
"def odds_and_evens(string, return_odds)\nif return_odds == false\n return string.gsub(/(.)./, '\\1')\n\nelse return_odds == true\n if string.length.odd?\n return string.gsub(/.(.)/, '\\1')[0...-1]\n else \n return string.gsub(/.(.)/, '\\1')\n end\nend\nend",
"def odds_and_evens(string, return_odds)\n new_string = ''\n\n if return_odds\n string.length.times {|num| new_string << string[num] if num.odd?}\n\n elsif\n string.length.times {|num| new_string << string[num] if num.even?}\n\n end\n\n new_string\n\nend",
"def odds_and_evens(string, return_odds)\n return_odds ? odd_string = '' : even_string = ''\n if return_odds\n string.chars.each_with_index {|char, index| odd_string += char if index.odd?}\n odd_string\n\t else\n\t\t string.chars.each_with_index {|char, index| even_string += char if index.even?}\n even_string\n\t end\n\nend",
"def reverse_odds(string)\n result = arr = string.chars\n arr.each_with_index do |letter, i|\n if i.odd?\n result[i] = arr[- 1 - i]\n result[-1 - i] = letter\n else\n letter\n end\n return result.join('') if i >= (arr.length / 2)\n end\nend",
"def stringy(int)\n (int/2).times { print 10 }\n 1 if int.odd?\nend",
"def dasherize\n\t\treturn self.split.join('-')\n\tend",
"def to_dash(s)\n s.gsub(/\\.|\\_/, '--')\n end",
"def odds_and_evens(string, return_odds)\n stringy = \"\"\n string.chars.each_with_index do |char, i|\n stringy += char if i.odd? == return_odds\n end\n stringy\nend",
"def as(besar)\n\tbesar = besar.to_i\n\tstr = \"\"\n\tcount = 1\n\t# besar.odd? ? mid = besar + 1 : mid = besar\n\tbesar.odd? ? mid = besar - 1 : mid = besar\n\tx = (mid/2).ceil + 1\n\n\tfor i in 1..mid do\n \n\t\tfor j in i...mid do\n\t\t\tstr += \"-\"\n\t\tend\n\n\t\tif i != x\n\t\t\tfor j in 1..count do\n\t\t\t j > 1 && j < count ?\tstr += \"-\" : str += \"A\"\n\t\t\tend\n\t\telse\n\t\t\tfor j in 1..count\n\t\t\t\tj.odd? ? str += \"A\" : str += \"-\"\n\t\t\tend\n\t\tend\n\n\t\tstr += \"\\n\"\n\t\tcount += 2\n\tend\n\n\tprint str\nend",
"def alternate string, num\n range = ('a'..'z').to_a.rotate(num)\n working = string.split(//)\n working.map! do |x|\n x = range[('a'..'z').to_a.index(x)]\n end.join\n \n \n\nend",
"def evenator(s)\n s.delete(\".,?!_\").split(\" \").map do |word|\n word.length % 2 == 1? word << word[-1] : word\n end.join(\" \")\nend",
"def even_or_odd(number)\n if number % 2 == 0\n \"Even\"\n else\n \"Odd\"\n end\n end",
"def stringy(int)\n new_string = \"\"\n (int / 2).times { new_string << \"10\" }\n new_string << \"1\" if int.odd? \n new_string\nend",
"def oddness(count)\n count.odd? ? \"odd\" : \"even\"\n end",
"def all_digits_odd?\n self.to_s.split('').inject(0) { |memo, s| memo + ( s.to_i%2==0 ? 1 : 0 ) } == 0\n end",
"def odds_and_evens(string, return_odds)\n\nindex = 1\n\n (string.length/2).times do\n string.slice(index)\n index += 1\n string\n end\n\n\n#return string.chars.select.each_with_index{|x, y| y.odd?}.join if return_odds == true\n#return string.chars.select.each_with_index{|x, y| y.even?}.join if return_odds == false\n\nend",
"def dashify\n strip.gsub(/[ \\/_~]/, '-').squeeze('-')\n end",
"def add_dashes(uuid)\n return uuid if uuid =~ /\\-/\n [uuid[0..7], uuid[8..11], uuid[12..15], uuid[16..19], uuid[20..-1]].join(\"-\")\n end",
"def stringy(num, start=1)\n string = '10' * (num/2)\n if start == 1\n num.even? ? string : string + '1'\n else\n num.even? ? string.reverse : string.reverse + '0'\n end\nend",
"def twice(num)\n number = num.to_s\n length = number.length\n\n case\n when length.odd?\n return num * 2\n when length.even?\n left = number.slice(0, number.length / 2)\n right = number.slice((number.length / 2)..-1)\n left == right ? num : num * 2\n end\nend",
"def dash_separator\n 60.times { @results += '-' }\n newline\n end",
"def undasherize(str)\n str.sub(/^-{1,2}/, '')\n end",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '': string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def twice(number)\n string_number = number.to_s\n center = string_number.size / 2\n left_side = center.zero? ? '' : string_number[0..center - 1]\n right_side = string_number[center..-1]\n\n return number if left_side == right_side\n return number * 2\nend",
"def odds_and_evens(string, return_odds)\n chars = string.chars\n for i in 0..(chars.length-1)\n (chars[i] = '') if (return_odds ? i.even? : i.odd?)\n end\n chars.join\nend",
"def stringy(number)\n digits = []\n counter = 0\n while counter < number do\n digits[counter] = counter.odd? ? 0 : 1\n counter += 1\n end\n digits.join\nend",
"def staircase(n)\r\n # Write your code here\r\n empty = \" \"\r\n value = \"#\"\r\n n.times do |num|\r\n \tnumber = num + 1\r\n first = empty*(n-number).abs\r\n second = value*number\r\n puts first+second\r\n end\r\nend",
"def is_odd?\n return TRUE if get_dash_version.match(/^\\d+\\.(\\d+)\\.\\d+/)[1].to_i.odd?\n return FALSE\n end",
"def stringy(int)\n str = ''\n int.times { |i| str += ((i + 1) % 2).to_s }\n str\nend",
"def odds_and_evens(string, return_odds)\n range = 0..string.length-1\n new_string = String.new\n range.step(2) {|x| string[x+1] && new_string << string[x+1]} if return_odds\n range.step(2) {|x| new_string << string[x]} if !return_odds\n new_string\nend",
"def odd_or_even (number)\n if number % 2 == 0\n \"even\"\n elsif number % 2 == 1\n \"odd\"\n end\nend",
"def hide_last_four(string)\n string.gsub!(/-\\d{4}/,\"-****\")\nend",
"def dasherize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"-\").downcase)\n end",
"def is_odd?(integer)\r\n !(integer.abs.remainder(2) == 0)\r\nend",
"def oddify(string)\n words = string.split(/[ .]+/)\n\n words.map.with_index do |word, idx|\n idx.odd? ? word.reverse : word\n end.join(' ') << '.'\nend",
"def odds_and_evens(string, return_odds)\n\n even = []\n odd = []\n arr = string.each_char.to_a\n arr.each_index{|index| index % 2 == 0 ? even << arr[index] : odd << arr[index]}\n if return_odds == true\n return odd.join('')\n else\n return even.join('')\n end\n\n\n\n\nend",
"def show_game_title(title)\n formatted_title = '| ' + title + ' |'\n dashes = '-' * formatted_title.length\n puts dashes\n puts formatted_title\n puts dashes\nend",
"def show_game_title(title)\n formatted_title = '| ' + title + ' |'\n dashes = '-' * formatted_title.length\n puts dashes\n puts formatted_title\n puts dashes\nend",
"def all_digits_odd?(number)\n number.to_s.split(//).each_with_index do |digit,index|\n if index == 0 && digit.to_i == 2\n #Don't return false if first digit is 2\n elsif digit.to_i%2==0\n return false\n end\n end\n return true\nend",
"def twice(number)\n num_length = number.to_s.length\n num_is_odd = (num_length % 2 == 0) ? false : true \n return (number * 2) if num_is_odd\n \n first_half = number.to_s.slice(0, num_length / 2)\n second_half = number.to_s.slice(num_length / 2, num_length)\n first_half == second_half ? number : number * 2\nend",
"def odds_and_evens(string, return_odds)\n result = \"\"\n string.length.times do |index|\n next if\n return_odds == true && index.even?\n next if\n return_odds == false && index.odd?\n result << string[index]\n end\nresult\nend",
"def hideWord (word)\n\tnumDashes = word.length\n\tdisplayDash = Array.new(numDashes) { |i| \n\ti = \"_\" }\n\n\treturn displayDash.join(\" \")\nend",
"def is_odd?(integer)\n integer.abs.remainder\nend",
"def staircase(n)\n i = 1\n while i <= n\n puts \" \" * (n - i) + \"#\" * i\n i += 1 \n end\nend",
"def odds_and_evens(string, return_odds)\n odds = \"\"\n evens = \"\"\n string.each_char.with_index { |char, i|\n if i.odd?\n odds << char\n else\n evens << char\n end }\n if return_odds == true\n return odds\n else\n return evens\n end\nend",
"def stringy(num)\n string = '10' * (num/2)\n num.even? ? string : string + '1'\nend",
"def hide_last_four(string)\n\treturn string.gsub(/(\\d{2})-(\\d{2})-\\d{4}/, '\\1-\\2-****')\nend",
"def odd_number_check_two(number)\r\n number % 2 == 1 || number % 2 == -1 \r\nend",
"def two_digit(number)\n dizaine = (number/10) * 10\n unit = (number % 10)\n if unit == 0\n return specific_word(dizaine)\n else\n return specific_word(dizaine) + \" \" + specific_word(unit)\n end\nend",
"def stringy(int, first_num = 1)\n first_num == 0 ? second_num = 1 : second_num = 0\n\n arr = Array(1..int)\n arr.map! { |n| n.odd? ? first_num : second_num }\n arr.join\nend"
] |
[
"0.83188766",
"0.7967828",
"0.792637",
"0.792181",
"0.79200864",
"0.7898977",
"0.78481513",
"0.777453",
"0.7764941",
"0.7703267",
"0.7702926",
"0.76862717",
"0.7661154",
"0.7652543",
"0.765168",
"0.76323277",
"0.7630894",
"0.7611904",
"0.7605826",
"0.7599978",
"0.7582187",
"0.75653964",
"0.7565243",
"0.74797",
"0.7475456",
"0.74658966",
"0.7445171",
"0.7442508",
"0.74094695",
"0.7372702",
"0.7255191",
"0.7238888",
"0.7167964",
"0.7074289",
"0.70381063",
"0.69975203",
"0.6965532",
"0.69227606",
"0.6886961",
"0.68248653",
"0.6756104",
"0.65873045",
"0.6567514",
"0.6529328",
"0.64770037",
"0.64768136",
"0.6454439",
"0.6421039",
"0.6365254",
"0.63491684",
"0.6343509",
"0.63049686",
"0.627315",
"0.6266576",
"0.6263736",
"0.62633383",
"0.6250945",
"0.6225782",
"0.6212383",
"0.62030184",
"0.6200372",
"0.6198742",
"0.61941576",
"0.618632",
"0.61825055",
"0.617735",
"0.6168787",
"0.6150646",
"0.6148665",
"0.6142781",
"0.6134546",
"0.61167556",
"0.6113731",
"0.61129564",
"0.61106867",
"0.6106817",
"0.6097374",
"0.60775185",
"0.60647357",
"0.6055872",
"0.60485154",
"0.604672",
"0.6034225",
"0.6031914",
"0.60316",
"0.6026746",
"0.6023889",
"0.6023889",
"0.60164547",
"0.6010506",
"0.6009455",
"0.6006461",
"0.5999437",
"0.5994554",
"0.59945035",
"0.5990026",
"0.5988141",
"0.5981409",
"0.5979441",
"0.59730625"
] |
0.79424214
|
2
|
Read in AH data from CSV file
|
def read_file(fname=nil)
return if fname.nil?
# Array we use to store entries
lines = Array.new
ah_data = Array.new
# Deal with DOS line endings by reading in file, then manually splitting on DOS line ending
File.open(fname).each_line do |line|
lines = line.split(/\r\n?/).map(&:chomp)
end
return lines
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def read_in_csv_data(csv_file_name)\n begin\n CSV.foreach(csv_file_name, headers: true) do |row|\n @songs << Song.new(row['name'], row['location'])\n end\n rescue Exception\n @songs = nil\n end\n @songs\n end",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @data << Employee.new(row)\n end\n end",
"def load_data\n @data ||= CSV.read(@file)\n end",
"def get_csv_data(csv_data)\r\n csv_file = nil\r\n\r\n #Get the path and name of the CSV file\r\n if csv_data.to_s.include? '.csv'\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}\")\r\n elsif (\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}.csv\")\r\n )\r\n end\r\n\r\n csv_arr = CSV.read( csv_file, {:headers => true, :header_converters => :symbol, :encoding => 'UTF-8'} )\r\n keys = csv_arr.headers.to_a\r\n # read attribute example => csv[index][:column1]\r\n return csv_arr.to_a.map {|row| Hash[ keys.zip(row) ] }\r\nend",
"def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end",
"def import(filename = 'yhd.csv')\n # Load CSV rows\n puts 'Attempting to load CSV...'\n data = CsvLoader.load_csv filename\n\n # Error if no data\n unless data\n puts 'ERROR: unable to load data from CSV. Terminating.'\n return\n end\n\n # Extract headers (first row)\n headers = data[0]\n\n puts 'Normalising header names...'\n norm_headers = normalise_headers headers\n\n # Define data rows as the rest of the CSV\n row_range = 1..data.size\n\n # Get data from each row (process it line at a time)\n puts 'Loading data...'\n load_data_from_rows(norm_headers, data[row_range])\n\n puts 'Creating relationships between definitions...'\n create_definition_associations\n\n puts 'Done!'\n\n @error_reporter.print\n end",
"def load_data(filename)\n return CSV.read(filename, headers: true).map { |line| line.to_h }\nend",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def load_data(filename)\n data = CSV.open(filename, 'r', headers: true).map do |line|\n line.to_h\n end\n return data\nend",
"def load_data(filename)\n athlete_array = []\n CSV.read(filename, headers: true).each do |athlete|\n athlete_array << athlete.to_h\n end\n return athlete_array\nend",
"def read_csv(csv_file, data)\n logger.info \"Reading #{data.type} data from '#{csv_file} date column = #{@date_column} data starts at col #{@data_start_column} skipping #{@header_rows} header rows\"\n lines = File.readlines(csv_file)\n (@header_rows...lines.length).each do |i|\n reading = lines[i].split(',')\n begin\n date = Date.parse(reading[@date_column])\n rowdata = reading[@data_start_column, @data_start_column + 47].map(&:to_f)\n data.add(date, rowdata)\n rescue StandardError => e\n logger.warn e.message\n logger.warn e.backtrace.join(\"\\n\")\n logger.warn \"Unable to read data on line #{i} of file #{csv_file} date value #{reading[@date_column]}\"\n end\n end\n logger.info \"Read hash #{data.length} rows\"\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def read_csv_file(csv_table_path)\r\n \r\n table_dimensions = detect_state_table_dim(csv_table_path)\r\n \r\n if table_dimensions==:one_d\r\n return read_1d_csv_file(csv_table_path)\r\n elsif table_dimensions==:two_d\r\n return read_2d_csv_file(csv_table_path)\r\n else\r\n raise \"Error: CSV File dimensions: #{table_dimensions}\"\r\n end # end if else \r\n \r\n end",
"def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend",
"def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @meals << Meal.new(row)\n end\n end",
"def import_csv_full\n \n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def load_data(filename)\n data = CSV.read(filename, headers: true).map(&:to_h)\n return data\nend",
"def load_file full_name\n file = FasterCSV.open( full_name , { :col_sep => \"\\t\"} ) \n @header = file.shift\n @data = file.readlines\n #puts @header\n @header.each do |col|\n #puts \"col=#{col}= mapped to =#{@mapping[col]}=\"\n end\n index = 0\n while index < @data.length\n row = @data[index]\n #puts \"row is \" + row.join(\"--\")\n @mapping.each do |key,val|\n #puts \"Row:#{val} at #{@mapping.index(val)} is --#{@header.index(@mapping.index(val))}--value---\"\n #puts \"--#{at_in(val,row)}--\" if @header.index(@mapping.index(val))\n end\n prod = get_product(row)\n set_attributes_and_image( prod , row )\n set_taxon(prod , row)\n #puts \"saving -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n prod.save!\n throw \"no master for #{prod.name}\" if prod.master == nil \n# pr = get_product( row )\n# puts \"TAXONs #{pr.taxons}\"\n \n puts \"saved -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n index = slurp_variants(prod , index + 1) #read variants if there are, returning the last read line\n end\n\n end",
"def csvReader(file, headers)\n begin\n csvTable = CSV.read(file, {col_sep:\"\\t\", quote_char:\"\\0\", headers:headers})\n rescue ArgumentError\n puts \"Error: Unsupported encoding, tabulated/CSV file must be in UTF-8 format.\"\n abort\n end\n parsedObj = OpenStruct.new()\n parsedObj.rowArray = []\n parsedObj.belArray = []\n csvTable.each do |row|\n unless row.length == 0\n current = OpenStruct.new()\n current.bel_id = row[0]\n current.bel_id.slice! \"BEL:\"\n current.bel = row[1]\n current.sentence = row[2]\n current.sentence_id = row[3]\n current.sentence_id.slice! \"SEN:\"\n current.pmid = row[4]\n parsedObj.rowArray << current\n parsedObj.belArray << row[1]\n end\n end\n parsedObj.linecount = csvTable.length\n return parsedObj\nend",
"def open_data_for_read\n @data_file = CSV.open(data_file_full_path,\"r\", @data_lib.csv_opt)\n @data_stream = @data_file\n end",
"def load_csv\n options = { headers: :first_row, header_converters: :symbol }\n\n CSV.foreach(@csv_path, options) do |row|\n row[:id] = row[:id].to_i\n row[:price] = row[:price].to_i\n @elements << Meal.new(row)\n end\n @next_id = @elements.empty? ? 1 : @elements.last.id + 1\n end",
"def import_csv_smart\n \n end",
"def loadStructure(file)\n csv_text = File.read(file)\n return CSV.parse(csv_text, :headers => true)\n \nend",
"def datat_read\n \n #Read in the csv file\n @@datat_array = CSV.read(@@datat_path_specific)\n \n #Delete the row which contains the database title.\n @@datat_array.delete_at(0)\n \n ######################################\n #puts @@datat_array[2]\n #Verify the conversion has taken place\n #puts @database + \" CSV file converted\"\n ######################################\n \n end",
"def load\n csv = csv_data\n @data = TableFu.new(csv_data, @table_opts[:column_options] || {})\n if @table_opts[:faceting]\n @data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]\n @facets = @data.faceted_by @table_opts[:faceting][:facet_by]\n end\n @data.delete_rows! @table_opts[:dead_rows] if @table_opts[:dead_rows]\n end",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def load(path)\n if File.exists?(path)\n @data = CSV.read(path)\n @data.shift(1)\n else\n log.warning \"No data file found at #{path}\"\n @data = []\n end\n @data\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows. Then create a has for each row.\n # Convert each row_hash to an entry by using add_entry method.\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def csv(handle, path = nil)\n @dsd = DataSourceDownload.get(handle)\n raise \"handle '#{handle}' does not exist\" if @dsd.nil? and handle != \"manual\"\n path = (handle == \"manual\") ? DataSourceDownload.flex(path) : @dsd.save_path_flex \n @handle = handle\n @csv ||= {}\n if @csv[path].nil? \n download_handle unless @dsd.nil?\n #puts path\n begin\n @csv[path] = CSV.read(path)\n @new_data = true\n rescue\n #resolve one ugly known file formatting problem with faster csv\n alternate_csv_load = alternate_fastercsv_read(path) #rescue condition if this fails\n #return \"READ_ERROR:CSV FORMAT OR FILE PROBLEM\" if alternate_csv_load.nil? \n @csv[path] = alternate_csv_load\n @new_data = true\n end\n end\n @csv[path]\n end",
"def import_from_csv(file_name)\n # implementation\n csv_text = File.read(file_name)\n # the variable 'csv' is a table type object\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n \n # \n csv.each do |row|\n # create a hash type variable 'row_hash'\n row_hash = row.to_hash\n # use 'add_entry' to change 'row_hash' into 'Entry', also add the new Entry into AddressBook's entries\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def load_from_csv(row)\n payload = {\n emails: [{ email: row['email'] }],\n firstname: row['first_name'],\n lastname: row['last_name'],\n external_ids: { controlshift: row['id'] },\n updated_at: row['updated_at']\n }\n UpsertMember.call(payload)\n end",
"def load_csv(csv_path)\n raise Error::InvalidCSV unless File.exist? csv_path\n begin\n vals = CSV.read(csv_path)\n rescue CSV::MalformedCSVError\n raise Error::InvalidCSV\n end \n\n raise Error::BlankCSV if vals.length == 0\n raise Error::InvalidCSV if vals[0].length != 3\n\n # remove optional header\n vals.shift if vals[0][0] == HEADER_VAL\n\n @data = vals.collect do |data|\n {\n \"image_path\" => data[0],\n \"id\" => data[1],\n \"label\" => data[2]\n }\n end\n end",
"def parse_csv(file_path)\n record_list = []\n header = []\n is_header = true\n \n CSV.foreach(file_path) do |row|\n if (is_header)\n\theader = row\n\tis_header = false\n else\n\trecord = Record.new\n\trecord.create(header, row)\n\trecord_list.push(record)\n end\n end\n return record_list\n end",
"def read_data\n\t\t@testers_data = CSV.read(\"data/testers.csv\")\n\n\t\t@testers_device_data = CSV.read(\"data/tester_device.csv\")\n\n\t\t@devices_data = CSV.read(\"data/devices.csv\")\n\n\t\t@bugs_data = CSV.read(\"data/bugs.csv\")\n\tend",
"def read_csv_data file\n rows = []\n readerIn = CSV.open(file, 'r')\n row = readerIn.shift\n while row!= nil && !row.empty?\n rows << row\n row = readerIn.shift\n end\n readerIn.close\n \n return rows\nend",
"def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true)\n # Iterate over the table object's rows\n csv.each do |row|\n # Create a hash for each row\n row_hash = row.to_hash\n # Convert each row_hash to an Entry by using add_entry method\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n\n # Get the number of items parsed by calling the count method\n return csv.count\n end",
"def import_from_csv(file)\n entries = Keybox::Convert::CSV.from_file(file)\n entries.each do |entry|\n @db << entry\n end\n hsay \"Imported #{entries.size} records from #{file}.\", :information\n end",
"def parse_csv(filename)\n @file=CSV.read(filename)\n # Read order of headers\n headers = @file.shift\n @file.each do |line|\n next if line.length==0 || (line.length==1 && line[0]==nil)\n # Read fields from line based on headers\n value=ReturnValue.new( line[headers.index('label')],\n line[headers.index('name') || headers.index('label')],\n line[headers.index('type')],\n line[headers.index('unit')],\n line[headers.index('per_unit')],\n line[headers.index('default')] )\n @values.push value\n end\n validate\n end",
"def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end",
"def read_scores_from\n teams_data = []\n\n CSV.foreach('scores.csv', headers: true, header_converters: :symbol) do |row|\n teams_data << row.to_hash\n end\n teams_data\nend",
"def load()\n\tFile.open(\"instructors.csv\", \"r\") { |f|\n\t\tdata = f.read()\n\t\treturn data\n\t}\nend",
"def set_data_from_csv_file(csv_file)\n begin\n start_time = 0,\n end_time = 0,\n sum = 0, temp_sum = 0, index = 1,\n data = [],\n first_row = true\n \n if csv_file\n csv_data = FasterCSV.parse(csv_file)\n length = csv_data.length\n interval = 1\n until length/interval < 10000\n interval+=1\n end\n csv_data.each do |time,power_data|\n start_time = time if first_row\n end_time = time\n temp_sum = temp_sum + power_data.to_f\n \n if(index % interval == 0 )\n data << (temp_sum/interval).to_f.round(2)\n temp_sum = 0\n end\n sum = sum + power_data.to_f\n first_row = false\n index+=1\n end\n @analysis_data.csv_data = data.to_json()\n @analysis_data.test_duration = end_time.to_i - start_time.to_i\n @analysis_data.energy_consumed = sum/3600\n end\n rescue FasterCSV::MalformedCSVError\n @analysis.errors.add_to_base(INVALID_CSV_FILE_ERROR)\n @invalid_csv = true\n end\n end",
"def loadCSVFile(filePath)\n data = []\n CSV.foreach(filePath, :headers => true) do |row|\n row = row.to_h\n row.each do |k, v|\n v = v.to_s\n row[k] = v\n end\n data << row\n end\n data\n end",
"def import_csv(csv_file)\n data, header = parse_csv(csv_file)\n validate_header(header)\n return if @rollback\n process_data(data, header)\n end",
"def initialize(csv_file_path)\n # take recipe from csv file\n @csv_file_path = csv_file_path\n @recipes = []\n parse\n end",
"def parse(file_path)\n begin\n rows = CSV.read(file_path, headers: true, header_converters: :symbol, converters: [:all, :blank_to_nil])\n rescue CSV::MalformedCSVError => e\n raise \"Could not parse CSV file. Original error: #{e.message}\"\n rescue StandardError => e\n raise \"Could not load CSV file. Make sure the file has CSV headers. Original error: #{e.message}\"\n end\n @contracts = rows.collect {|row| row.to_hash }\n end",
"def parse_csv(csv_file)\n\n # Loop through all entries in CSV file\n CSV.foreach(csv_file, :quote_char => \"\\\"\") do |row|\n next if row[0] == \"From\" && row[1] == \"To\"\n next if row[0].nil?\n\n # [0, 1] refers to the 2 addresses in the csv file\n [0, 1].each do |i|\n add_location(row[i])\n end\n\n add_journey(row)\n end\nend",
"def read_1d_csv_file(state_table_path) \r\n rows_read=0\r\n\t\tstate_transition_list= Array.new\r\n\t\tignore_first_row = true\r\n\r\n\t\tCSV::Reader.parse(File.open(state_table_path, 'r').read.gsub(/\\r/,\"\\n\")) do |row_array|\r\n\t\t\t# First row should be the header\r\n\t\t\tif ignore_first_row\r\n\t\t\t\tignore_first_row=false\r\n\t\t\telse\r\n\t\t\t\ttransition = TransitionHolder.new(row_array[STATE1].to_s,row_array[ACTION].to_s,row_array[STATE2].to_s)\r\n\t\t\t\tputs_debug \"Read in transitions: #{transition}\"\r\n\t\t\t\tstate_transition_list.push transition \r\n\t\t\tend # if first row\r\n\t\t\trows_read +=1\r\n\t\tend # end csv block\r\n\r\n raise \"CSV File Empty\" if rows_read==0\r\n raise \"Missing Data in CSV File\" if rows_read==1\r\n \r\n\t\t# return state table, its a raw list of transition objects\r\n\t\treturn state_transition_list\r\n\r\n\tend",
"def initMetaDataFromCSV(csvfile)\n\t\tif not File.exist?(csvfile)\n\t\t\traise StandardError \"file not exist!\"\n\t\tend\n\t\tbasename = File.basename(csvfile, \".csv\")\n\t\tcase basename\n\t\t#处理角色名,用来随机用\n\t\twhen 'JiaoSeMing'\n\t\t\tinitPlayerNameMetaData(csvfile)\n\t\t#英雄配表\n\t\twhen 'WuJiang'\n\t\t\t@heroMetaMap = {}\n\t\t\tinitMetaData(csvfile,@heroMetaMap,\"generalID\")\n\t\t\t#自有兵法列表\n\t\t\t@selfBookList = []\n\t\t\t@heroMetaMap.each_value do |hero| \n\t\t\t\tselfBook = hero.gInitialWarcraft.to_i\n\t\t\t\tif selfBook > 0 and not @selfBookList.include?(selfBook)\n\t\t\t\t\t@selfBookList << selfBook\n\t\t\t\tend\n\t\t\tend #generalID \n\t\t#招募配表\n\t\twhen 'ZhaoMu'\n\t\t\t@recuriteMetaMap = {}\n\t\t\tinitMetaData(csvfile,@recuriteMetaMap,\"recruitName\")\n\t\t#情义(命运)\n\t\twhen 'MingYun'\n\t\t\t@fateMetaMap = {}\n\t\t\tinitMetaData(csvfile,@fateMetaMap,\"fateID\")\n\t\t#角色级别与经验值\n\t\twhen 'JiaoSeShengJiJingY'\n\t\t\t@playerLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @playerLevelMetaMap ,\"characterLevel\")\n\t\t#英雄级别与经验值配表\n\t\twhen 'WuJiangDengJi'\n\t\t\t@heroLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroLevelMetaMap ,\"levelGeneral\")\n\t\t#英雄进阶\n\t\twhen 'WuJiangJinJie'\n\t\t\t@heroAdancedLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroAdancedLevelMetaMap ,\"advancedTime\")\n\t\t#装备-武器防具坐骑\n\t\twhen 'ZhuangBei'\n\t\t\t@equipmentMap = {}\n\t\t\tinitMetaData(csvfile, @equipmentMap ,\"equipmentID\")\n\t\t#兵法\n\t\twhen 'BingFa'\n\t\t\t@bookMap = {}\n\t\t\tinitMetaData(csvfile,@bookMap,\"bookID\")\n\t\t#宝物\n\t\twhen 'DaoJu'\t\n\t\t\t@propMap = {}\n\t\t\tinitMetaData(csvfile,@propMap,\"propID\")\n\t\twhen 'PeiYang'\n\t\t\tinitHeroBringupMetaData(csvfile)\n\t\t#VIP表\n\t\twhen 'Vip'\n\t\t\t@vipMap = {}\n\t\t\tinitMetaData(csvfile,@vipMap,\"vipLevel\")\n\t\t#强化表\n\t\twhen 'ZhuangBeiQiangHua'\n\t\t\t@strengthenMap = {}\n\t\t\tinitStrengthenMapMetaData(csvfile,@strengthenMap)\n\t\t#进阶表\n\t\twhen 'BingFaJinJie'\n\t\t\t@bookAdvancedMap = {}\n\t\t\tinitBookAdvancedMapMetaData(csvfile,@bookAdvancedMap)\n\t\t#兵法碎片\n\t\twhen 'BingFaSuiPian'\n\t\t\t@bookFragment = {}\n\t\t\tinitMetaData(csvfile,@bookFragment,\"fragmentID\")\n\t\t#flag , 游戏配置,标记 等表\n\t\twhen 'Flag'\n\t\t\t@flagMap = {}\n\t\t\tinitMetaData(csvfile,@flagMap,\"name\")\n\t\twhen 'ZhanYi'\n\t\t\tinitBattle(csvfile)\n\t\twhen 'NPC'\n\t\t\t@npcMetaMap = {}\n\t\t\tinitMetaData(csvfile, @npcMetaMap, \"npcID\")\n\t\twhen 'ChengZhangRenWu'\n\t\t\tinitTaskMetaData(csvfile)\n\t\telse\n\t\tend\n\tend",
"def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end",
"def parsed_data\n @parsed_data ||= begin\n CSV.read(full_filename, col_sep: col_sep, quote_char: quote_char, encoding: encoding)\n rescue => e #CSV::MalformedCSVError => er\n @parse_error = e.to_s\n rows = []\n #one more attempt. If BOM is present in the file.\n begin\n f = File.open(full_filename, \"rb:bom|utf-8\")\n rows = CSV.parse(f.read.force_encoding(\"ISO-8859-1\"))\n ensure\n return rows\n end\n end\n end",
"def initialize(csv_in_filename, era_year_handle, rmid_from_era_year_handles_string)\n @in_file = csv_in_filename\n verify_in_file\n\n @db_conn = PG::Connection.connect(DB_CONNECT_INFO)\t# Connect to the DB\n @era_year_handle = era_year_handle\n verify_era_year_handle\n\n @rmid_from_era_year_handles_string = rmid_from_era_year_handles_string\n if @rmid_from_era_year_handles_string == 'any'\n @rmid_from_era_year_handles = nil\n @rmid_from_era_year_handles_regex = nil\n else\n @rmid_from_era_year_handles = rmid_from_era_year_handles_string.split(',')\n @rmid_from_era_year_handles_regex = \"^(#{@rmid_from_era_year_handles.join('|')})$\"\n end\n verify_rmid_from_era_year_handles\n\n @csv_out_headers = nil\n @csv_out_data = nil\n @handles_by_prefix = {}\t\t# Cache for collection-handles\n convert\n @db_conn.close if @db_conn\n end",
"def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end",
"def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend",
"def read_parameters_from_csv(csv)\r\n\t\tbegin\r\n\t\t\ttemp = CSV.read(csv)\r\n\t\trescue Exception\r\n\t\t\traise ArgumentError, \"It wasn't possible to read from #{csv} file.\"\r\n\t\tend\r\n\t\ttemp.each_with_index do |row,index|\r\n\t\t\t@actual_parameters[index] = row[0].split(';')\r\n\t\tend\r\n\tend",
"def\tparse_file\n CSV.foreach(@file) do |row|\n begin\n rid, price, item = row[0].strip.to_i, row[1].strip.to_f, row[2..-1].map(&:strip).join('-').downcase\n validate(rid, price, item) ? load(rid, price, item) : puts(\"Escaping invalid row: #{row}\")\n rescue StandardError \n puts \"Escaping incorrect row: #{row}\"\n end\n end\n end",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def read_in_ownership(csv_file_name, temp_hash = Hash.new)\n\t CSV.foreach(csv_file_name, :headers => true) do |row|\n\t\t song_id, owner_data = row[0], row[1]\n\t \t unless (song_id =~ /#/)\n\t \t \t temp_hash[song_id] = owner_data\n\t \t end\n end\n temp_hash\n\tend",
"def csv(csv_file)\n Slacker.get_csv(csv_file)\n end",
"def convert_csv_file_to_object\n begin\n CSV.foreach(@file_name) do |row|\n @csv_object.push(row)\n end \n rescue => exception\n raise FileReadError, exception\n end\n end",
"def parse_csv(csv_name, schema)\n CSV.read(csv_name).map {|row| map_row_to_entity(row, schema) }\nend",
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def load_csv(csv_file_or_object, table_name, log_name = nil)\n log_name ||= \"load_csv '#{csv_file_or_object.kind_of?(CSV::Table) ? 'CSV Object' : csv_file_or_object }', 'table_name'\"\n csv_object = case csv_file_or_object\n when String then Slacker.get_csv(csv_file_or_object)\n when CSV::Table then csv_file_or_object\n when Array then Slacker.hash_array_to_csv(csv_file_or_object)\n end\n\n Slacker.load_csv(example, csv_object, table_name, log_name)\n end",
"def create_people_raw\n @@people_raw = CsvMapper.import('test_ward.csv') do\n read_attributes_from_file\n end\nend",
"def get_metadata(csv_url, id)\n begin\n open(csv_url) do |u|\n csv_file_name = File.basename(csv_url)\n csv_file_path = \"#{@config.output_dir}/#{csv_file_name}\"\n unless File.exists?(csv_file_path)\n File.open(csv_file_path, 'wb') { |f| f.write(u.read) }\n end\n CSV.read(csv_file_path, 'r:bom|utf-8', headers: true).each do |row|\n if row.header?(\"Identifier\")\n if row.field(\"Identifier\") == id\n return row.field(\"Title\"), row.field(\"Description\")\n end\n else\n puts \"No Identifier header found\"\n return\n end\n end\n puts \"No matching Identifier found\"\n end\n rescue\n puts \"No CSV file found\"\n end\nend",
"def get\n arr = []\n\n process(csv_file).each do |record|\n arr << SOA_CSV_RECORD.new(*record.fields)\n end\n\n arr\n end",
"def parse_csv\n CSV.parse(File.read(\"DeleteMe.csv\")) do |row|\n puts row.class\n #project = @rally.find(RallyAPI::RallyQuery.new({:type => :project, :query_string => \"(Name = #{row[\"Name\"]})\"}))\n project = @rally.find(RallyAPI::RallyQuery.new({:type => :project, :query_string => \"(Name = \\\"#{row.first}\\\")\"}))\n puts project\n project = project.first\n fields = {}\n fields[:state] = 'Closed'\n fields[:notes] = close_reason(project)\n project.update(fields)\n end\n # File.open(\"DeleteMe.csv\", \"r\") do |f|\n # f.each_line do |line|\n # puts line\n # end\n # end\n end",
"def read_csv(file_path)\n CSV.parse(File.read(file_path), headers: true)\nend",
"def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end",
"def load_students\n puts \"Loading file\"\n # Open the file with \"read\" privilages\n file = File.open(\"students.csv\", \"r\")\n # Go through each line of the file\n file.readlines.each do |line|\n # .. picking out the name and cohort columns\n name, cohort = line.chomp.split(',')\n # Add them to the student variable as a hash\n @students << {name: name, cohort: cohort.to_sym}\n end\n # Close the file\n file.close\nend",
"def read_data\n\t\tindex = 0\n\t\torders = []\n\t\tCSV.parse(@data_file.read()) do |row|\n\t\t\tif index == 0\n\t\t\t\t#header row\n\t\t\t\t@columns = parse_columns(row[0])\n\t\t\t\t# p @columns\n\t\t\telse\n\t\t\t\t# p row[0]\n \t\t\tdata = row[0].split(\"\\t\")\n \t\t\torders << parse_order(data) \n\t\t\tend\n \t\tindex += 1\n\t\tend\n\t\treturn orders\n\tend",
"def read_csv_data_from_file(full_file_path)\n data = []\n CSV.open(full_file_path, \"r\") do |csv|\n data = csv.readlines\n end\n data\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows, create a string for each row, and convert each row to a Client by using the create_client method.\n csv.each do |row|\n name, facebook_id, twitter_handle = row.to_s.split(\",\").map(&:chomp)\n create_client(name, facebook_id, twitter_handle)\n end\n end",
"def load_data(file_name)\n\t\tindata = []\n\t\t#csv reader as shown in class; typecasted because I ran into some weird bugs\n\t\tCSV.foreach(\"#{file_name}\", col_sep: \"\\t\") do |row| \n\t\t\tindata.push({\"user_id\"=>row[0].to_i, \"movie_id\"=>row[1].to_i, \"rating\" => row[2].to_i, \"timestamp\" => row[3].to_i})\n\t\tend\n\t\treturn indata\n\tend",
"def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend",
"def import\n CSV.new(open(uri), headers: :first_row).each_with_index do |csv_row, i|\n begin\n create_departure(csv_row: csv_row)\n rescue => e\n # this is a catch all for all the types of parsing errors that could\n # occur above\n csv_logger.info(\n I18n.t('import_exception', scope: LOCALE, row_number: i)\n )\n csv_logger.error(e)\n end\n end\n end",
"def csv_import(the_file)\n import_list = []\n CSV.foreach(the_file, headers: true) do |row|\n import_list << row.to_hash\n end\n import_list\n end",
"def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n #value_filter is for single value\n values = args[:values_filter].call(row, i) if args[:values_filter]\n if values\n if args[:value_filter]\n j = -1\n values = row.map do |value|\n j += 1\n args[:value_filter].call(value,i,j)\n end\n end\n yield values if values\n end\n i += 1\n end\n end",
"def parse_file\n if @csv_source == \"siteimprove\"\n column_seperator = \"\\t\" \n # If using CharlockHolmes Encoding Detector, uncomment this\n #detection = CharlockHolmes::EncodingDetector.detect(contents)\n #@csv_encoding = detection[:encoding]\n @csv_encoding = \"UTF-16LE\"\n elsif @csv_source == \"google\" \n column_seperator = \",\"\n # If using CharlockHolmes Encoding Detector, uncomment this \n #detection = CharlockHolmes::EncodingDetector.detect(contents)\n #@csv_encoding = detection[:encoding]\n @csv_encoding = \"ISO-8859-1\"\n end\n contents = File.read(@csv_filename)\n output_encoding = @csv_encoding + \":UTF-8\"\n arr_csv_contents = CSV.read(@csv_filename, { :encoding => output_encoding, :headers => true, :col_sep => column_seperator, :skip_blanks => true })\n if @csv_source == \"siteimprove\"\n @site_name = \"Graduate Research\"\n @site_addr = \"http://gradresearch.unimelb.edu.au\"\n arr_csv_contents.each { |row| \n @arr_of_titles << row[0]\n @arr_of_urls << row[1]\n } \n # delete the first two rows of the array\n @arr_of_titles = @arr_of_titles.drop(2)\n @arr_of_urls = @arr_of_urls.drop(2) \n elsif @csv_source == \"google\" \n #@site_name = \"Grainger Museum\"\n @site_name = \"Varied-Sample\"\n @site_addr = \"http://www.unimelb.edu.au/\"\n arr_csv_contents.each { |row| \n @arr_of_titles << row[0]\n @arr_of_urls << row[7] #1 for grainger\n } \n end\n end",
"def load_data(csv)\n @hash.each do |sentence, count|\n csv << [sentence, count]\n end\n end",
"def parseCSV(csvfile)\n begin\n if csvfile != nil\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def csv_read(filename)\n return CSV.read(filename)\nend",
"def import_from_csv\n puts 'Which file would you like to import?'\n file_path = gets.chomp\n CsvImporter.new(@database, file_path).import\n puts 'Import complete.'\n rescue FileNotFoundError\n puts 'The specified file was not found.'\n rescue CsvInvalidError => e\n puts e.message\n end",
"def open_csv(file_name)\n CSV.foreach(file_name,\n :headers => true,\n :converters => :all,\n :header_converters => :symbol\n ) do |row|\n hash_row = row.to_hash # Make CSV data as hash\n # Get rid of blank cells - Putting all data into @content\n if hash_row[:product_links] != nil || hash_row[:cta_link] != nil\n @content << hash_row\n end\n end\n end",
"def from_csv(filename)\n @successes = []\n @problems = []\n @unfound_vita_partners = []\n\n @headers = CSV.foreach(filename).first\n return unless headers_aligned? == true\n\n data = CSV.read(filename, headers: true)\n\n state_routing_pairs = generate_state_routing_pairs(data)\n\n create_records_for_state_routing_pairs(state_routing_pairs)\n\n print_script_messages\n true\n end",
"def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend",
"def parseCSV(csvfile)\n begin\n if csvfile != nil && csvfile != \"\"\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end",
"def parse\n\t\tresults = []\n\t\tif !self.csv_file_file_name.blank? &&\n\t\t\t\tFile.exists?(self.csv_file.path)\n\t\t\t(f=FasterCSV.open( self.csv_file.path, 'rb',{\n\t\t\t\t:headers => true })).each do |line|\n\n#\t\"Masterid\",\"Motherid\",\"Record_Owner\",\"Datereceived\",\"Lastatt\",\"Lastdisp\",\"Currphone\",\"Vacauthrecd\",\"Recollect\",\"Needpreincentive\",\"Active_Phone\",\"Recordsentformatching\",\"Recordreceivedfrommatching\",\"Sentpreincentive\",\"Releasedtocati\",\"Confirmedcaticontact\",\"Refused\",\"Deceasednotification\",\"Eligible\",\"Confirmationpacketsent\",\"Catiprotocolexhausted\",\"Newphonenumreleasedtocati\",\"Pleanotificationsent\",\"Casereturnedtoberkeleyfornewinf\",\"Casereturnedfromberkeley\",\"Caticomplete\",\"Kitmothersent\",\"Kitinfantsent\",\"Kitchildsent\",\"Kitadolescentsent\",\"Kitmotherrefusedcode\",\"Kitchildrefusedcode\",\"Noresponsetoplea\",\"Responsereceivedfromplea\",\"Senttoinpersonfollowup\",\"Kitmotherrecd\",\"Kitchildrecvd\",\"Thankyousent\",\"Physrequestsent\",\"Physresponsereceived\"\n\n#\n#\tThe IcfMasterTracker will include an after_save or something that will\n#\tdetermine what has changed and update appropriately. It may also\n#\tcreate OperationalEvents to document the data changes. As it is\n#\ttheoretically possible that the Masterid does not exist in the identifiers\n#\ttable, perhaps add a successfully_updated_models flag which could\n#\tbe used?\n#\n\t\t\t\ticf_master_tracker = IcfMasterTracker.find_or_create_by_Masterid(line['Masterid'])\n\t\t\t\t#\tNO BANG. Don't want to raise any errors.\n\t\t\t\tsuccessfully_updated = icf_master_tracker.update_attributes(line.to_hash)\n#\n#\terrors = icf_master_tracker.errors.full_messages.to_sentence\n#\tThese won't be validation errors as there shouldn't be any.\n#\tPerhaps \"no column by that name\" errors if csv file changes?\n#\n#\tAdd successfully_updated value?\n#\t\ticf_master_tracker.update_attribute(:sucessfully_updated, successfully_updated)\n#\twill the above include the line's attributes?\n#\n#\tAdd update_errors column?\n#\t\ticf_master_tracker.update_attribute(:update_errors, errors)\n#\n\n\t\t\t\tresults.push(icf_master_tracker)\n\n\t\t\tend\t#\t(f=FasterCSV.open( self.csv_file.path, 'rb',{ :headers => true })).each\n\t\tend\t#\tif !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path)\n\t\tresults\t#\tTODO why am I returning anything? will I use this later?\n\tend",
"def process_data(data, header)\n i = 2\n if data.present?\n data.each do |row|\n obj = Transport.new(:academic_year_id => academic_year_id)\n header.each do |name|\n method_n = header_to_method(name)\n send(method_n, obj, row[name].try(:strip)) if row[name].present? or method_n == \"fare\"\n end\n val = obj.save\n log_error(i, obj.errors.full_messages) unless val\n i += 1\n end\n else\n import_failed(1, t(:no_data_present_in_csv))\n end\n end",
"def load_csv(csv_filepath)\n gifts = []\n CSV.foreach(csv_filepath) do |row|\n gifts << row[0] # Nosso csv só tem uma coluna\n end\n return gifts\nend",
"def parse\n\t\tresults = []\n\t\tif !self.csv_file_file_name.blank? &&\n\t\t\t\tFile.exists?(self.csv_file.path)\n\t\t\t(f=CSV.open( self.csv_file.path, 'rb',{\n\t\t\t\t:headers => true })).each do |line|\n\n\t\t\t\ticf_master_tracker = IcfMasterTracker.find_or_create_by_master_id(\n\t\t\t\t\tline['master_id'],\n\t\t\t\t\t:master_tracker_date => self.master_tracker_date )\n\n\t\t\t\tsuccessfully_updated = icf_master_tracker.update_attributes!(\n\t\t\t\t\tline.to_hash.delete_keys!(\n\t\t\t\t\t\t'master_id').merge(\n\t\t\t\t\t\t:master_tracker_date => self.master_tracker_date) )\n\n\t\t\t\tresults.push(icf_master_tracker)\n\t\t\tend\t#\t(f=CSV.open( self.csv_file.path, 'rb',{ :headers => true })).each\n\t\tend\t#\tif !self.csv_file_file_name.blank? && File.exists?(self.csv_file.path)\n\t\tresults\t#\tTODO why am I returning anything? will I use this later?\n\tend",
"def initMetaData(csvfile,metamap,keyfield)\n\t\tallRows = CSV.read(csvfile,{:col_sep=>\";\"})\n\t\tif allRows and not allRows.empty?\n\t\t\ttitle = allRows[1]\n\t\t\tallRows.each_with_index do |row,i|\n\t\t\t\tif i > 1\n\t\t\t\t\tmetaData = Model::MetaData.new(title,row)\n\t\t\t\t\tkey = metaData.send(keyfield)\n\t\t\t\t\tmetamap[key] = metaData\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def import\n CSV.foreach(@file.path, :converters => :all, :return_headers => false, :headers => :first_row) do |row|\n source, first_name, last_name, _, company, phone, *address = *row.to_hash.values\n\n street, city, state, zip, _ = *address\n address = Address.new(:street1 => street, :city => city, :state => state, :zipcode => zip)\n\n lead = Lead.new(:source => source, :first_name => first_name, :last_name => last_name,\n :company => company, :phone => phone)\n\n lead.first_name = \"FILL ME\" if lead.first_name.blank?\n lead.last_name = \"FILL ME\" if lead.last_name.blank?\n lead.access = \"Private\"\n lead.addresses << address\n\n lead.assignee = @assigned if @assigned.present?\n\n lead.save!\n end\n end",
"def load_athletes(file = 'athletes_london2012.csv')\n puts \"Clearing out old athletes ..\"\n Athlete.destroy_all\n puts \"Importing athletes ..\"\n CSV.read(file, headers: true).each do |row|\n Athlete.create({\n name: row[\"Name\"],\n country: row[\"Country\"],\n age: row[\"Age\"],\n height: row[\"Height, cm\"],\n weight: row[\"Weight\"],\n sex: row[\"Sex\"],\n dob: extract_date(row[\"Date of birth\"]),\n gold: row[\"Gold\"],\n silver: row[\"Silver\"],\n bronze: row[\"Bronze\"],\n sport: row[\"Sport\"],\n events: row[\"Event\"].split(\", \")\n })\n end\n puts \"Done! You have #{Athlete.count} athletes in your database.\"\nend",
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end",
"def read_from_roster(csv)\n players = []\n CSV.foreach(csv, headers: true, header_converters: :symbol) do |player|\n players << player.to_hash\n end\n players\nend",
"def csvAccountDataParsing\n\taccounts = {}\n\n\tCSV.foreach(\"accounts.csv\", {headers: true, return_headers: false}) do |row|\n\t\taccountName = row[\"Account\"].chomp.capitalize\n\t\taccounts = set_initial_values(accounts, accountName, row)\n\t\taccounts[accountName].addData(row)\n\tend\n\n\taccounts.each_value do |value|\n\t\tvalue.calculateFinalAmounts\n\tend\n\n\treturn accounts\nend",
"def row_from_csv(csv, line:)\n row_args = %i[timestamp speaker settings content].each_with_object({}) do |key, args|\n args[key] = csv[@key_map[key]]\n args\n end\n\n Row.new(line_number: line, **row_args)\n end"
] |
[
"0.6840709",
"0.6812845",
"0.6753627",
"0.67416865",
"0.66207886",
"0.6611238",
"0.6594113",
"0.65697026",
"0.65382767",
"0.6517975",
"0.651279",
"0.64944214",
"0.6486111",
"0.6482863",
"0.6425298",
"0.63752025",
"0.63615036",
"0.6338695",
"0.632677",
"0.630831",
"0.6298699",
"0.628233",
"0.6258771",
"0.6258762",
"0.62503624",
"0.6236246",
"0.6225081",
"0.6220405",
"0.6216409",
"0.6210903",
"0.620675",
"0.6205287",
"0.6182075",
"0.6165944",
"0.6163909",
"0.6163757",
"0.61501265",
"0.61460316",
"0.61347485",
"0.61343616",
"0.61244464",
"0.6121121",
"0.61080885",
"0.6105297",
"0.6104458",
"0.6103256",
"0.6098909",
"0.6079357",
"0.6069959",
"0.60653263",
"0.6045569",
"0.6044608",
"0.6039348",
"0.6039103",
"0.60379875",
"0.6018625",
"0.6017299",
"0.60135275",
"0.60101306",
"0.6009532",
"0.6008387",
"0.59986466",
"0.5998497",
"0.59945124",
"0.59928465",
"0.59917074",
"0.59477776",
"0.5944204",
"0.5919313",
"0.5916227",
"0.5912791",
"0.59104425",
"0.590566",
"0.5895559",
"0.58803",
"0.587431",
"0.5873208",
"0.5866898",
"0.5863698",
"0.58616376",
"0.58482003",
"0.5843443",
"0.5837806",
"0.58364224",
"0.58359367",
"0.5829453",
"0.5829171",
"0.5823687",
"0.5821553",
"0.5821245",
"0.5819868",
"0.5819512",
"0.581931",
"0.58115613",
"0.5810845",
"0.5806482",
"0.58032376",
"0.57995343",
"0.5793775",
"0.578216",
"0.5782119"
] |
0.0
|
-1
|
Merges given configuration parameters with defined during initialization and returns the result.
|
def configure(settings = {})
abstract_method
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def merge_config!(config = {})\n self.config.url = config[:url] if config.key?(:url)\n self.config.opts = config[:opts] if config.key?(:opts)\n self.config.db = config[:db] if config.key?(:db)\n end",
"def config_merge(config)\n @config.merge!(config)\n end",
"def initial_config\n default_config.deep_merge(@passed_config)\n end",
"def merge_configs\n # Apply config file settings on top of mixlib-cli defaults\n combined_config = default_config.merge(config_file_settings)\n # Apply user-supplied options on top of the above combination\n combined_config = combined_config.merge(config)\n # replace the config hash from mixlib-cli with our own.\n # Need to use the mutate-in-place #replace method instead of assigning to\n # the instance variable because other code may have a reference to the\n # original config hash object.\n config.replace(combined_config)\n end",
"def configure(c)\n c.merge!(@passed_config)\n end",
"def merge!(config)\n self.compiled = false\n self.resource_class ||= config.resource_class\n transforms_from.merge! config.transforms_from\n transforms_to.merge! config.transforms_to\n custom_serializers.merge! config.custom_serializers\n namespaces.merge! config.namespaces\n facets.merge! config.facets #TODO --jdc change to a deep_merge!\n extensions.merge! config.extensions\n\n self\n end",
"def merge_configs\n # Update our original_config - if someone has created a knife command\n # instance directly, they are likely ot have set cmd.config values directly\n # as well, at which point our saved original config is no longer up to date.\n @original_config = config.dup\n # other code may have a handle to the config object, so use Hash#replace to deliberately\n # update-in-place.\n config.replace(config_file_defaults.merge(default_config).merge(config_file_settings).merge(config))\n end",
"def independent_config\n initial_config.deep_merge(persistent_config_hash)\n end",
"def configure(c)\n # passed config\n c.merge!(@passed_config)\n end",
"def merge_config_layers(*config_data)\n config_data.inject({}) do |acc, config|\n acc.merge(config) do |key, val1, val2|\n case key\n # Shallow merge config for each plugin\n when 'plugins'\n val1.merge(val2) { |_, v1, v2| v1.merge(v2) }\n # Transports are deep merged\n when *TRANSPORT_CONFIG.keys\n Bolt::Util.deep_merge(val1, val2)\n # Hash values are shallow merged\n when 'apply-settings', 'log', 'plugin-hooks', 'puppetdb', 'puppetdb-instances'\n val1.merge(val2)\n # Disabled warnings are concatenated\n when 'disable-warnings'\n val1.concat(val2)\n when 'analytics'\n val1 && val2\n # All other values are overwritten\n else\n val2\n end\n end\n end\n end",
"def _compile(config)\n default_configuration.deep_merge(config).deep_merge(overlay_configuration)\n end",
"def get_config\n {}.update(local_config)\nend",
"def configure opts\n configuration.merge!(opts)\n end",
"def merge_configurations cfg,cfg2\n cfg['prefix']||=cfg2['prefix']\n raise \"Attempting to merge configurations with differing prefixes: '#{cfg['prefix']}' vs. '#{cfg2['prefix']}' \" if cfg['prefix']!=cfg2['prefix']\n cfg['include']||=[]\n cfg['depend']||=[]\n cfg['interface']||=[]\n cfg['include']+=cfg2['include'] if cfg2['include']\n cfg['depend']+=cfg2['depend'] if cfg2['depend']\n cfg['interface']+=cfg2['interface'] if cfg2['interface']\n return cfg\nend",
"def merge_with_default(config, config_file, unset_nil:); end",
"def compile\n @config_list.inject({}) do |config, hash_or_proc|\n case hash_or_proc\n when Hash\n config.deep_merge hash_or_proc\n when Proc\n instance or raise InstanceNotBoundError\n c = instance.instance_eval(&hash_or_proc)\n c.is_a?(Hash) || c == nil or raise InvalidBlockReturnValue\n c ? config.deep_merge(c) : config\n end\n end\n end",
"def load_config\n if params[:config].given?\n @config = File.open(File.expand_path(params[:config].value)) { |f| JSON.load(f) }\n\n @config.each do |key, value|\n if params.has_key?(key) and params[key].values == params[key].defaults\n params[key].values = [*value]\n params[key].given = true\n end\n end\n\n end\n end",
"def merge(config_hash)\n config_hash.each_pair { |option, value| set_option(option, value) }\n self\n end",
"def configure_with(params)\r\n\r\n\t\tend",
"def merge_with_default(config, config_file, unset_nil:)\n default_configuration = ConfigLoader.default_configuration\n\n disabled_by_default = config.for_all_cops['DisabledByDefault']\n enabled_by_default = config.for_all_cops['EnabledByDefault']\n\n if disabled_by_default || enabled_by_default\n default_configuration = transform(default_configuration) do |params|\n params.merge('Enabled' => !disabled_by_default)\n end\n end\n\n config = handle_disabled_by_default(config, default_configuration) if disabled_by_default\n\n opts = { inherit_mode: config['inherit_mode'] || {},\n unset_nil: unset_nil }\n Config.new(merge(default_configuration, config, **opts), config_file)\n end",
"def config_params\n app_props.merge(idp_props).merge(custom_props)\n end",
"def configure(config={})\n config.each do |(key, val)|\n self.config[key] = val\n end\n end",
"def get_config(*arguments)\n \t\targs = arguments.clone\n \t\t@config ||= {}\n \t\topt = args.rfm_extract_options!\n \t\tstrings = opt[:strings].rfm_force_array || []\n \t\tsymbols = opt[:use].rfm_force_array || []\n \t\tobjects = opt[:objects].rfm_force_array || []\n \t\targs.each do |arg|\n \t\t\tcase true\n \t\t\twhen arg.is_a?(String) ; strings << arg\n \t\t\twhen arg.is_a?(Symbol) ; symbols << arg\n \t\t\telse objects.unshift arg\n \t\t\tend\n \t\tend\n\n\t\t\trslt = config_merge_with_parent(symbols).merge(opt)\n\t\t\t#using = rslt[:using].rfm_force_array\n\t\t\tsanitize_config(rslt, CONFIG_DONT_STORE, false)\n\t\t\trslt[:using].delete \"\"\n\t\t\trslt[:parents].delete \"\"\n\t\t\trslt.merge(:strings=>strings, :objects=>objects)\n \tend",
"def merge_config!(data, conf)\n # Catch edge-cases\n return if data.nil? || conf.nil?\n # Step through all conf items and create combined return value\n data.merge!(conf) do |_, v1, v2|\n if v1.is_a?(Array) && v2.is_a?(Array)\n # If both the data field and the conf field are arrays, then combine them\n v1 + v2\n elsif v1.is_a?(Hash) && v2.is_a?(Hash)\n # If both the data field and the conf field are maps, then deep merge them\n merge_config!(v1, v2)\n else\n # All other cases, just use the new value (regular merge behavior)\n v2\n end\n end\n end",
"def load_config!\n if options[:config]\n config_inst = Config.new(options[:config])\n elsif self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES)\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = Config.new(path) if path\n end\n if config_inst\n options.delete(:config)\n defaults_inst = Smash[\n config_class.new(\n defaults.to_smash\n ).to_smash.find_all do |key, value|\n defaults.key?(key)\n end\n ]\n config_data = config_inst.data\n config_inst = Smash[\n config_inst.to_smash.find_all do |key, value|\n config_data.key?(key)\n end\n ]\n options_inst = Smash[\n config_class.new(\n options.to_smash\n ).to_smash.find_all do |key, value|\n options.key?(key)\n end\n ]\n @options = config_class.new(\n defaults_inst.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options_inst.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end",
"def setup()\n @configuration = {}\n @configuration.merge!(defaults)\n @configuration\n end",
"def merge_config_data(config_data)\n config_data.inject({}) do |acc, config|\n acc.merge(config[:data]) do |key, val1, val2|\n case key\n # Plugin config is shallow merged for each plugin\n when 'plugins'\n val1.merge(val2) { |_, v1, v2| v1.merge(v2) }\n # Transports are deep merged\n when *TRANSPORTS.keys.map(&:to_s)\n Bolt::Util.deep_merge(val1, val2)\n # Hash values are shallow mergeed\n when 'puppetdb', 'plugin_hooks', 'apply_settings', 'log'\n val1.merge(val2)\n # All other values are overwritten\n else\n val2\n end\n end\n end\n end",
"def populate_defaults(config)\n new_config = DEFAULT_CEEDLING_CONFIG.deep_clone\n new_config.deep_merge!(config)\n config.replace(new_config)\n\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST )\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST_PREPROCESSORS ) if (config[:project][:use_test_preprocessor])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST_DEPENDENCIES ) if (config[:project][:use_deep_dependencies])\n\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE ) if (config[:project][:release_build])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE_ASSEMBLER ) if (config[:project][:release_build] and config[:release_build][:use_assembly])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE_DEPENDENCIES ) if (config[:project][:release_build] and config[:project][:use_deep_dependencies])\n end",
"def merged_config_for_generator\n return {}\n end",
"def update_config(current, new)\n current.merge! new\n end",
"def initialize_config(overrides={})\n @config = ConfigHash.new(self, overrides, false)\n \n # cache as configs (equivalent to self.class.configurations)\n # as an optimization\n configs = @config.configs\n \n # hash overrides by delegate so they may be set\n # in the correct order below\n initial_values = {}\n overrides.each_key do |key|\n if config = configs[key]\n \n # check that the config may be initialized\n unless config.init?\n key = configs.keys.find {|k| configs[k] == config }\n raise \"initialization values are not allowed for: #{key.inspect}\"\n end\n \n # check that multiple overrides are not specified for a\n # single config, as may happen with indifferent access\n # (ex 'key' and :key)\n if initial_values.has_key?(config)\n key = configs.keys.find {|k| configs[k] == config }\n raise \"multiple values map to config: #{key.inspect}\"\n end\n \n # since overrides are used as the ConfigHash store,\n # the overriding values must be removed, not read\n initial_values[config] = overrides.delete(key)\n end\n end\n \n # now initialize configs in order\n configs.each_pair do |key, config|\n next unless config.init?\n\n if initial_values.has_key?(config)\n config.set(self, initial_values[config])\n else\n config.init(self)\n end\n end\n end",
"def load_config!\n if(options[:config])\n config_inst = config_class.new(options[:config])\n elsif(self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES))\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = config_class.new(path) if path\n end\n if(config_inst)\n options.delete(:config)\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end",
"def configure(options={})\n @parameters = default_parameters.merge options\n end",
"def merge_configurations( list, options = {}, &block )\n invoke_merge = merge_configuration_method( options )\n \n list.inject( format_hash_keys({}) ) do |config, c|\n second = format_hash_keys( block_given? ? yield( c ) : c )\n config.send( invoke_merge, second ) if second\n config\n end\n end",
"def merge_values!(values)\n # STUB: should make recorsive calls if need\n global_config[target] ||= {}\n global_config[target].merge!(values)\n end",
"def update_configs!(config_params)\n config_params.each do |config|\n value = config[1].to_s\n #find the config\n configuration = UniversalAr::Configuration.find(config[0])\n if !configuration.nil?\n configuration.create_or_update_config(self, config[1])\n end\n end\n end",
"def configuration\n @configuration ||= deep_merge(default_configuration, @factory_config)\n end",
"def merge!(other)\n other.config.each do |key, value|\n case key\n when 'clusters', 'contexts', 'users'\n value.each do |other_value|\n own_value = config[key].find { |c| c['name'] == other_value['name'] }\n config[key].delete(own_value) if own_value\n config[key] << other_value\n end\n when 'current-context', 'preferences'\n config[key] = value\n else\n config[key] ||= value\n end\n end\n\n self\n end",
"def config\n independent_config.deep_merge(strong_parent_config).deep_merge(strong_session_config)\n end",
"def config\n @config ||= multi_config || single_config\n end",
"def merge( params )\n\t\tcopy = self.dup\n\t\tcopy.merge!( params )\n\t\treturn copy\n\tend",
"def initialize\n @config = DEFAULT_CONFIG.deep_dup\n end",
"def merge_with_default(config, config_file, unset_nil: true)\n resolver.merge_with_default(config, config_file, unset_nil: unset_nil)\n end",
"def merge!(hash)\n hash.each do |key, value|\n if config_contexts.key?(key)\n # Grab the config context and let internal_get cache it if so desired\n config_contexts[key].restore(value)\n else\n configuration[key] = value\n end\n end\n self\n end",
"def load_config\n # Nothing in base class. This should be used to load the configuration from\n # disk if saved to a file.\n configuration || {}\n end",
"def merge_with_default(config, config_file, unset_nil: T.unsafe(nil)); end",
"def build_configuration_from_parameters(parameters)\n configuration = {}\n parameters.each do |parameter|\n parameter_parts = parameter.name[@prefix.length..-1].split(PATH_SEPARATOR).map(&:to_sym)\n param_container = parameter_parts[0..-2].reduce(configuration) do |container, part|\n container[part] ||= {}\n end\n param_container[parameter_parts[-1]] = parameter.value\n end\n\n configuration\n end",
"def init(config)\n config.each{|k, v|\n @config[k] = v\n }\n end",
"def merge_set_up_params(params)\n if (!@oauth_token.nil? && !@version.nil?)\n params.merge!(:oauth_token => @oauth_token)\n params.merge(:v => @version)\n end\n return params\n end",
"def configuration\n @configuration ||= begin\n ConfigFile.new(GLOBAL_CONFIG).merge_file(LOCAL_CONFIG)\n rescue TypeError\n raise AssistedWorkflow::Error, \"Error on loading .awconfig files. Please check the content format.\"\n end\n end",
"def import(another)\n merge! configs.import(another)\n end",
"def +(other_config)\n result = self.copy\n Config.variables.each { |v|\n other_value = other_config.send(v.to_s)\n next unless other_value != nil and other_value != Config.variable_default(v)\n result.send(v.to_s + \"=\", other_value)\n }\n result\n end",
"def setup(config={})\n if block_given?\n yield(self.config.dup)\n end\n # merge new settings\n self.configure(config)\n end",
"def deep_merge!(hash_or_config)\n return self if hash_or_config.nil?\n other_config = convert hash_or_config\n other_config.each do |key, other_value|\n value = has_key?(key) && self[key]\n self[key] = if ConfigNode === value && ConfigNode === other_value\n value.deep_merge!(other_value)\n elsif ConfigNode === value && other_value.nil?\n self[key]\n else\n other_value\n end\n end\n self\n end",
"def config(opts=nil)\n if opts\n @config = @config.merge(get_subhash(opts, DEFAULTS.keys))\n else\n @config\n end\n end",
"def config=(*args); end",
"def config=(*args); end",
"def configuration\n config = {}\n tag_configuration_plugins.each do |p|\n # the first submodule listed is the one which accepts the configuration\n key = p.plugin.modules.first.submodule_name\n config[key] = p.parameters;\n end\n config\n end",
"def build_config(dir_or_config_hash)\n if dir_or_config_hash.is_a? String\n # Read config from config.yaml in given dir\n config_path = File.join(dir_or_config_hash, 'config.yaml')\n @config = DEFAULT_CONFIG.merge(YAML.load_file(config_path).symbolize_keys)\n @config[:data_sources].map! { |ds| ds.symbolize_keys }\n @config_mtime = File.stat(config_path).mtime\n else\n # Use passed config hash\n @config = DEFAULT_CONFIG.merge(dir_or_config_hash)\n @config_mtime = nil\n end\n\n # Merge data sources with default data source config\n @config[:data_sources].map! { |ds| DEFAULT_DATA_SOURCE_CONFIG.merge(ds) }\n end",
"def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end",
"def setup_config(config=nil, &block)\n @config = config || ConfigStruct.block_to_hash(block)\n end",
"def config\n filter_config(static.merge(dynamic))\n end",
"def smash_configs\n # private overrides public general config\n a = remove_environments(@general_config_pub)\n b = remove_environments(@general_config_priv)\n general = a.merge(b)\n\n # private overrides public collection config\n c = remove_environments(@collection_config_pub)\n d = remove_environments(@collection_config_priv)\n collection = c.merge(d)\n\n # collection overrides general config\n return general.merge(collection)\n end",
"def configure\n load_all_configs \n end",
"def config\n config = {}\n config['recipes'] = []\n config['recipes'] |= hash_path(@default_config, 'recipes', 'global') || []\n config['recipes'] |= hash_path(@default_config, 'recipes', @platform) || []\n @group_configs.each do |group_name, group_config|\n config['recipes'] |= hash_path(group_config, 'recipes', 'global') || []\n config['recipes'] |= hash_path(group_config, 'recipes', @platform) || []\n end\n people_recipes = @people_config['recipes'] || {}\n config['recipes'] |= people_recipes['global'] || []\n config['recipes'] |= people_recipes[@platform] || []\n config['attributes'] = {}\n config['attributes'].deep_merge!(@default_config['attributes'] || {}) { |key, old, new| Array.wrap(old) + Array.wrap(new) }\n @group_configs.each do |group_name, group_config|\n config['attributes'].deep_merge!(group_config['attributes']) { |key, old, new| Array.wrap(old) + Array.wrap(new) } unless group_config['attributes'].nil?\n end\n people_attributes = @people_config['attributes'] || {}\n config['attributes'].deep_merge!(people_attributes) { |key, old, new| Array.wrap(old) + Array.wrap(new) }\n config\n end",
"def merge(cfg_file)\n cfg = read_configuration(cfg_file)\n list_keys, = *keys\n cfg.each_key do |k|\n if @config.keys.include?(k) && list_keys.include?(k)\n @config[k] += cfg[k]\n else\n # last one wins\n @config[k] = cfg[k]\n end\n end\n @configuration_files << cfg_file\n end",
"def merge(other)\n result = self.class.new\n\n # Set all of our instance variables on the new class\n [self, other].each do |obj|\n obj.instance_variables.each do |key|\n # Ignore keys that start with a double underscore. This allows\n # configuration classes to still hold around internal state\n # that isn't propagated.\n if !key.to_s.start_with?(\"@__\")\n result.instance_variable_set(key, obj.instance_variable_get(key))\n end\n end\n end\n\n result\n end",
"def configure(root_config)\n end",
"def configure(root_config)\n end",
"def initialize\n credentials = self.rails_credentials\n\n CONFIG_PARAMS.each do |param, config|\n value = (\n config[:sources]&.map { |s| credentials[s] }&.compact&.first ||\n config[:env_vars]&.map { |v| ENV[v] }&.compact&.first\n )\n\n if (value)\n if (config[:parse])\n instance_variable_set(config[:ivar], config[:parse].call(value))\n else\n instance_variable_set(config[:ivar], value)\n end\n else\n case (config[:default])\n when Proc\n instance_variable_set(config[:ivar], config[:default].call)\n else\n instance_variable_set(config[:ivar], config[:default])\n end\n end\n end\n end",
"def config\n options.to_smash.deep_merge(opts.to_smash)\n end",
"def config\n options.to_smash.deep_merge(opts.to_smash)\n end",
"def merge(options)\n unless options\n return CallSettings.new(timeout: @timeout,\n retry_options: @retry_options,\n page_descriptor: @page_descriptor,\n page_token: @page_token,\n bundler: @bundler,\n bundle_descriptor: @bundle_descriptor,\n metadata: @metadata,\n errors: @errors)\n end\n\n timeout = if options.timeout == :OPTION_INHERIT\n @timeout\n else\n options.timeout\n end\n retry_options = if options.retry_options == :OPTION_INHERIT\n @retry_options\n else\n options.retry_options\n end\n page_token = if options.page_token == :OPTION_INHERIT\n @page_token\n else\n options.page_token\n end\n\n metadata = @metadata || {}\n metadata = metadata.dup\n metadata.update(options.metadata) if options.metadata != :OPTION_INHERIT\n\n CallSettings.new(timeout: timeout,\n retry_options: retry_options,\n page_descriptor: @page_descriptor,\n page_token: page_token,\n bundler: @bundler,\n bundle_descriptor: @bundle_descriptor,\n metadata: metadata,\n errors: @errors)\n end",
"def merge!(another)\n configs = self.configs\n another.each_pair do |key, value|\n if config = configs[key]\n config.set(receiver, value)\n else\n store[key] = value\n end\n end\n self\n end",
"def merge(opts); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def config_merge_with_parent(filters=nil)\n remote = if (self != Rfm::Config) \n \teval(@config[:parent] || 'Rfm::Config').config_merge_with_parent rescue {}\n else\n \tget_config_file.merge((defined?(RFM_CONFIG) and RFM_CONFIG.is_a?(Hash)) ? RFM_CONFIG : {})\n end.clone\n \n remote[:using] ||= []\n remote[:parents] ||= ['file', 'RFM_CONFIG']\n\n\t\t\tfilters = (@config[:use].rfm_force_array | filters.rfm_force_array).compact\n\t\t\trslt = config_filter(remote, filters).merge(config_filter(@config, filters))\n\t\t\t\n\t\t\trslt[:using].concat((@config[:use].rfm_force_array | filters).compact.flatten) #.join\n\t\t\trslt[:parents] << @config[:parent].to_s\n\t\t\t\n\t\t\trslt.delete :parent\n\t\t\t\n\t\t\trslt\n end",
"def resolve_config(**attrs)\n config = config_defaults.merge(attrs.transform_keys(&:to_s))\n file_path = File.join(config['root'], config['config_path'])\n file_config = config_from_file(file_path, mode: config['mode'])\n new DEFAULT_CONFIG.merge(file_config).merge(config_from_env).merge(config)\n end",
"def configuration\n\t\t\t\tconfiguration = Configuration.new\n\t\t\t\t\n\t\t\t\tself.resolved_paths.each do |path|\n\t\t\t\t\tpath = File.expand_path(path)\n\t\t\t\t\t\n\t\t\t\t\tconfiguration.load_file(path)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn configuration\n\t\t\tend",
"def apply_configuration_data!(vars)\n if merge_vars = vars[\"merge\"]\n append(merge_vars)\n end\n if append_vars = vars[\"append\"]\n merge_flags(append_vars)\n end\n if parse_vars = vars[\"parse\"]\n parse_vars.each do |parse_string|\n parse_flags!(parse_string)\n end\n end\n end",
"def load_config **kwargs\n project_id = kwargs[:project] || kwargs[:project_id]\n configuration.project_id = project_id unless project_id.nil?\n\n creds = kwargs[:credentials] || kwargs[:keyfile]\n configuration.credentials = creds unless creds.nil?\n\n service_name = kwargs[:service_name]\n configuration.service_name = service_name unless service_name.nil?\n\n service_vers = kwargs[:service_version]\n configuration.service_version = service_vers unless service_vers.nil?\n\n ignores = kwargs[:ignore_classes]\n configuration.ignore_classes = ignores unless ignores.nil?\n\n init_default_config\n end",
"def load_config **kwargs\n project_id = kwargs[:project] || kwargs[:project_id]\n configuration.project_id = project_id unless project_id.nil?\n\n creds = kwargs[:credentials] || kwargs[:keyfile]\n configuration.credentials = creds unless creds.nil?\n\n service_name = kwargs[:service_name]\n configuration.service_name = service_name unless service_name.nil?\n\n service_vers = kwargs[:service_version]\n configuration.service_version = service_vers unless service_vers.nil?\n\n init_default_config\n end",
"def configuration_with_overrides(options, preloaded = nil)\n return preloaded.merge!(options) if preloaded.is_a?(Bridgetown::Configuration)\n\n Bridgetown.configuration(options)\n end",
"def config_load(config); end",
"def merge_params(opts = {})\n parse_params(opts)\n end",
"def merge_params(opts = {})\n parse_params(opts)\n end",
"def reconfigure(overrides={})\n config.merge!(overrides)\n self\n end",
"def config_for(config_name, mode_name=nil)\n mode_name = :all if mode_name.nil? || mode_name.to_s.size == 0\n config_name = :all if config_name.nil? || config_name.to_s.size == 0\n\n # collect the hashes\n all_configs = configs[:all]\n cur_configs = configs[mode_name]\n ret = ::SC::Buildfile::Config.new\n\n # now merge em! -- note that this assumes the merge method will handle\n # self.merge(self) & self.merge(nil) gracefully\n ret.merge!(all_configs[:all]) if all_configs\n ret.merge!(cur_configs[:all]) if cur_configs\n ret.merge!(all_configs[config_name.to_sym]) if all_configs\n ret.merge!(cur_configs[config_name.to_sym]) if cur_configs\n\n # Done -- return result\n return ret\n end",
"def build_config(config, allow_missing=false)\n all_definitions = config_meta.map {|p, l| l }.flatten\n Config.new(all_definitions, config, allow_missing)\n end",
"def set_config(parameters)\n parameters.each do |k,v|\n self.instance_variable_set(\"@#{k}\".to_sym, v)\n end\n end",
"def initialize\n super\n Souffle::Config.merge!(config)\n end",
"def config=(config); end",
"def extend_configs(configs_to_extend, config)\n configs_to_extend[1..-1].inject(configs_to_extend.first) do |merged, config_to_extend|\n merged.merge(config_to_extend)\n end.merge(config)\n end",
"def load_configuration!\n unless @configured\n load Rails.root.join( *Parametrization::Config::DEFAULT_CONFIG_PATH )\n end\n end",
"def config\n Config.new(@sources, @deployments)\n end",
"def load_overrides\n if ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''\n if File.readable?(ENV['PARAMS_FILE'])\n project_root = self.instance_variable_get(\"@project_root\")\n packaging_root = self.instance_variable_get(\"@packaging_root\")\n self.config_from_yaml(ENV['PARAMS_FILE'])\n self.instance_variable_set(\"@project_root\", project_root) if project_root\n self.instance_variable_set(\"@packaging_root\", packaging_root) if packaging_root\n else\n fail \"PARAMS_FILE was set, but not to the path to a readable file.\"\n end\n end\n end",
"def build_config\n file = [options[:config_file], DEFAULT_CONFIG_FILE_LOCATION].\n compact.find {|f| File.exists?(f) }\n\n hash =\n if file\n YAML.load_file(file).each do |key, value|\n stderr.puts(\"Warn: Unknown key in config file: #{key}\") unless\n self.class.configs.find {|opt| opt.first.to_s == key.to_s }\n end\n else\n {}\n end\n\n options[:config_option].map {|str| str.split('=') }.\n inject(hash) {|m, (k,v)| m.merge(k.to_sym => v) }\n end"
] |
[
"0.7071678",
"0.69807863",
"0.67086303",
"0.6531987",
"0.6501963",
"0.645218",
"0.6424541",
"0.64244926",
"0.6417341",
"0.63183165",
"0.6314637",
"0.6313858",
"0.62458676",
"0.6232559",
"0.62201583",
"0.61650246",
"0.61438435",
"0.6096816",
"0.60810095",
"0.60730255",
"0.6051133",
"0.60298836",
"0.59840965",
"0.5965587",
"0.59535486",
"0.59490836",
"0.5942681",
"0.5927358",
"0.59188575",
"0.5916479",
"0.5903565",
"0.59024924",
"0.5894524",
"0.5875029",
"0.5874587",
"0.58414245",
"0.5833446",
"0.5826238",
"0.5816386",
"0.57913524",
"0.5777524",
"0.57724345",
"0.5760078",
"0.57504123",
"0.5747119",
"0.5745378",
"0.5745206",
"0.5728314",
"0.57247627",
"0.57140493",
"0.57054436",
"0.56944656",
"0.5689982",
"0.5676787",
"0.56679034",
"0.56665075",
"0.56665075",
"0.56642103",
"0.56513524",
"0.56351197",
"0.562883",
"0.5617211",
"0.55850166",
"0.55787724",
"0.55744815",
"0.5571875",
"0.55710214",
"0.5569434",
"0.5569434",
"0.5565503",
"0.5564505",
"0.5564505",
"0.5563579",
"0.55608857",
"0.55507416",
"0.55503756",
"0.55503756",
"0.55503756",
"0.55503756",
"0.55503756",
"0.55482274",
"0.5537346",
"0.55366457",
"0.5530995",
"0.5524905",
"0.5522877",
"0.5518179",
"0.5515214",
"0.55127287",
"0.55127287",
"0.5511395",
"0.5502312",
"0.5498653",
"0.5493245",
"0.5491841",
"0.54823744",
"0.5482246",
"0.5480958",
"0.5469039",
"0.5468148",
"0.54659337"
] |
0.0
|
-1
|
Method for defining other methods as abstract.
|
def abstract_method
method_not_implemented
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def abstract!; end",
"def abstract?; end",
"def abstract!\n @abstract = true\n end",
"def abstract!\n @abstract = true\n end",
"def abstract!\n @abstract = true\n end",
"def abstract?; @abstract; end",
"def abstract\n @abstract = true\n end",
"def abstract(*methods)\n methods.each do |method|\n define_method(method) do |*|\n raise NotImplementedError, \"#{self.class}##{method} must be defined\"\n end\n end\n end",
"def abstract_method()\n\t\t# Determine the short class name of self\n\t\tclassName = self.class.name.split(/::/).last\n\t\t\n\t\t# Retrieve the top text line of the call stack\n\t\ttop_line = caller.first\n\t\t\n\t\t# Extract the calling method name\n\t\tcallerNameInQuotes = top_line.scan(/`.+?$/).first\n\t\tcallerName = callerNameInQuotes.gsub(/`|'/, '')\t# Remove enclosing quotes\n\t\t\n\t\t# Build the error message\n\t\terror_message = \"The method #{className}##{callerName} is abstract. It should be implemented in subclasses of #{className}.\"\n\t\traise NotImplementedError, error_message\n\tend",
"def special\n override\n end",
"def abstract_method(*methods)\n @abstract_class = self\n\n methods.each do |method|\n define_method method do\n raise NotImplementedError, \"You must implement #{self.class}##{__method__}.\"\n end\n end\n end",
"def implementation; end",
"def implementation; end",
"def abstract_class=(_arg0); end",
"def abstract_class=(_arg0); end",
"def abstract!(abstract = true)\n current_target_definition.abstract = abstract\n end",
"def create_abstract_instance_method(name); end",
"def create_abstract_instance_method(name)\n define_method(name) do |*|\n fail NotImplementedError, \"#{self.class}##{name} is not implemented\"\n end\n end",
"def create_new_method(abstract_class); end",
"def overrides; end",
"def base_operation1\n puts 'AbstractClass says: I am doing the bulk of the work'\n end",
"def text\n raise 'Abstract Method'\n end",
"def nome \n raise NoMethodError(\"AbstractClassError: Override this implementation\")\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def certain?\n fail NotImplementedError\n end",
"def create_abstract_instance_method(name)\n class_eval <<-RUBY, __FILE__, __LINE__ + 1\n def #{name}(*) # def name(*)\n raise NotImplementedError, \"\\#{self.class.inspect}##{name} is not implemented\" # raise NotImplementedError, \"\\#{self.class.inspect}#name is not implemented\"\n end # end\n RUBY\n end",
"def dispatch\n raise NotImplementedError\n end",
"def wellformed?(signature)\n fail 'abstract method'\n end",
"def custom; end",
"def custom; end",
"def abstract?\n @abstract\n end",
"def generate_abstract_strategy_method\n implemented_strategy.strategy_methods.each do |method|\n # TODO : in case of inherited strategy. Do not override the method\n # TODO : Must be tested\n unless self.respond_to?(method)\n self.send(:define_method, method) do |*args|\n raise NotImplementedError.new(\"Abstract method #{method} not implemented, or unsupported operation\")\n end\n end\n end\n end",
"def realize_self\n raise NotImplementedError\n end",
"def abstract_id=(_); end",
"def abstract_method(*names)\n names.each { |name| create_abstract_instance_method(name) }\n self\n end",
"def abstract?\n !base_class.operation(base_class.name,false)\n end",
"def implementation\n fail 'Subclasses must implement implementation()!'\n end",
"def commence\n raise NotImplementedError\n end",
"def abstract?\n !!@abstract\n end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def functions(name = nil)\n raise \"Internal Error: Connection adapter did not override abstract function\"\n end",
"def internal; end",
"def to_risc\n raise \"abstract in #{self.class}\"\n end",
"def extended(*) end",
"def x(y)\n raise NotImplementedError, \"Define #{__method__}() in the inherited class.\"\n end",
"def execute\n raise ArgumentError, 'Abstract Method'\n end",
"def methods() end",
"def to_qres()\n raise AbstractMethodException.new(\"Abstract method\")\n end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def my_fare\n\traise NotImplementedError,\n\t \"This class #{self.class.to_s} can not respond to the method::: #{__method__.to_s}\"\n end",
"def run(*)\n raise NotImplementedError, \"Expected #{self.class} to implement ##{__method__}\"\n end",
"def doManipulation(contents); raise \"Abstract Exception: doManipulation must be extended\"; end",
"def function_definition(function_name, params, name = nil)\n raise \"Internal Error: Connection adapter did not override abstract function\"\n end",
"def to_qres()\n raise AbstractMethodExcepion.new(\"Abstract method\")\n end",
"def run; raise NotImplementedError; end",
"def run; raise NotImplementedError; end",
"def superclass() end",
"def specialty; end",
"def virtual; end",
"def resolves?; @abstract; end",
"def beginning\n abstract!\n end",
"def process_result(_result)\n raise NotImplementedError, new(\"#{self.class.name} is an abstract class.\")\n end",
"def dispatch\n raise(NotImplemetedError, \"subclass responsability\")\n end",
"def perform\n raise Errors::AbstractMethod\n end",
"def super_method; end",
"def internal_methods; end",
"def abstract?\n @modifiers.include? :abstract\n end",
"def errors\n raise 'Method should implemented in inherit class'\n end",
"def about\n raise NotImplementedError, 'this should be overridden by concrete sub-class'\n end",
"def definition\n super\n end",
"def definition\n super\n end",
"def equation\n raise NotImplementedError, \"Define #{__method__}() in the inherited class.\"\n end",
"def fit\n #raise NotImplementedError, \"Define fit() in the inherited class.\"\n raise NotImplementedError, \"Define #{__method__}() in the inherited class.\"\n end",
"def tag; raise 'Override this method'; end",
"def inherited(base); end",
"def __getobj__\n raise \"Abstract class requires implementation\"\n end",
"def call\n raise NotImplementedError\n end",
"def call\n raise NotImplementedError\n end",
"def commands\n abstract!\n end",
"def all_child_text\n abstract_method\n end",
"def instructions; raise NotImplementedError\n end",
"def visit_offerwall\n raise NotImplementedError\n end",
"def exchange\n raise \"This is an abstract class. Override exchange method in descendant class\"\n end",
"def call\n raise NotImplementedError,\n \"Override #call and implement your application logic.\"\n end"
] |
[
"0.84944344",
"0.8262082",
"0.81707656",
"0.8026988",
"0.79551786",
"0.78130686",
"0.78109115",
"0.70584995",
"0.6977021",
"0.68376577",
"0.682224",
"0.68141264",
"0.68141264",
"0.67399716",
"0.67399716",
"0.6660936",
"0.662506",
"0.66215926",
"0.654345",
"0.65226305",
"0.64904433",
"0.64219534",
"0.6377928",
"0.6374338",
"0.6374338",
"0.6374338",
"0.6374338",
"0.63689137",
"0.6358661",
"0.63561475",
"0.6347854",
"0.6343279",
"0.6343279",
"0.6334933",
"0.6331409",
"0.6328623",
"0.63183784",
"0.6299566",
"0.6292577",
"0.629146",
"0.6290025",
"0.62872475",
"0.62480336",
"0.62480336",
"0.62480336",
"0.62464935",
"0.62259924",
"0.6218372",
"0.62145096",
"0.6184658",
"0.6176455",
"0.61487997",
"0.6144686",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.6139549",
"0.61377215",
"0.6132145",
"0.61247355",
"0.6111008",
"0.6096038",
"0.6041159",
"0.6041159",
"0.6039609",
"0.60384965",
"0.6033384",
"0.6033059",
"0.6021784",
"0.6020628",
"0.6015987",
"0.60107195",
"0.60092807",
"0.6000956",
"0.5994587",
"0.5967972",
"0.5962515",
"0.59570765",
"0.59570765",
"0.59524107",
"0.59354144",
"0.59260166",
"0.5925771",
"0.5924511",
"0.59069717",
"0.59069717",
"0.59048027",
"0.5897789",
"0.58732015",
"0.587319",
"0.58713454",
"0.5870471"
] |
0.73208475
|
7
|
As a user I should be able to list meals As a user I should be able to create a meal
|
def list
display_meals
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_meal\n @meal = current_user.meals.find(params[:id])\n end",
"def meals\n get(\"/user/#{@user_id}/meals.json\")\n end",
"def set_meal\n @meal = Meal.available.exclusive(current_user).find(params[:id])\n end",
"def set_meal\n @meal = Meal.find_by(user_id: current_user.id)\n end",
"def add\n meal_name = @view.ask_name\n meal_price = @view.ask_price.to_i\n new_meal = Meal.new({name: meal_name, price: meal_price})\n @meals_repository.add(new_meal)\n end",
"def invite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n User.find_by(name: params[:user_name])\n end\n @meal.invite_user @user\n redirect_to @meal\n end",
"def like(meal)\n self.customer_meals.create!(meal_id: meal.id)\n end",
"def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repository\n @meals_repository.add(Meal.new(attributes))\n end",
"def set_user_meal\n @user_meal = UserMeal.find(params[:id])\n end",
"def create\n @meal = Meal.create(user_id: current_user.id)\n @meal.update(meal_params)\n if @meal.save\n flash[:notice] = \"Meal was successfully created\"\n redirect_to user_meal_path(current_user, @meal)\n else\n flash[:error] = \"Please update complete the form\"\n redirect_to controller: \"meals\", action: \"new\"\n end\n\n end",
"def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repo\n @meals_repo.add(Meal.new(attributes))\n end",
"def create\n @user_meal = UserMeal.new(user_meal_params)\n\n respond_to do |format|\n if @user_meal.save\n format.html { redirect_to @user_meal, notice: 'User meal was successfully created.' }\n format.json { render :show, status: :created, location: @user_meal }\n else\n format.html { render :new }\n format.json { render json: @user_meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add\n # 1. Ask the user for the meal name and store in var\n name = @meal_view.ask_name\n # 2. Ask the user for the meal price and store in var\n price = @meal_view.ask_price\n # 3. Create a new meal instance with those values\n meal = Meal.new(name: name, price: price)\n # 4. Add to repository using #create\n @meal_repo.create(meal)\n end",
"def index\n # get meals from the user\n @meals = @user.meals\n # create a new meal for the ajax form to use\n @meal = Meal.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meals }\n end\n end",
"def index\n @meals = current_user.meals\n end",
"def index\n @meals = current_user.meals\n end",
"def index\n @meals = current_user.meals.all\n end",
"def set_meal\n @meal = Meal.find_by(id: params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def set_meal\n @meal = Meal.find(params[:id])\n end",
"def meal_params\n params.require(:meal).permit(:date, :meal, :ingredients, :nutrition, :notes, :target, :user_id)\n end",
"def meal_params\n params.require(:meal).permit(:title, :food_name, :sick, :sick_type, :comments, :user_id)\n end",
"def meal_params\n properties = [:title, :calories, :date, :time]\n properties << :user_id if current_user.admin?\n params.require(:meal).permit(*properties)\n end",
"def create\n @meal = current_user.meals.build(meal_params)\n @meal.ip_address = request.location.ip\n @meal.expires_at = DateTime.now + 1.hour\n\n respond_to do |format|\n if @meal.save\n format.html { redirect_to @meal, notice: 'Meal was successfully created.' }\n format.json { render :show, status: :created, location: @meal }\n else\n format.html { render :new }\n format.json { render json: @meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @user_meals = UserMeal.all\n end",
"def check_meal_info\n if params[:tenant][:meal] == \"true\" && (tenant_params[:tenant_details_attributes][\"0\"][:meal_time] == \"\" || tenant_params[:tenant_details_attributes][\"0\"][:meal_plan] == \"\" || tenant_params[:tenant_details_attributes][\"0\"][:order] == \"\" || tenant_params[:tenant_details_attributes][\"0\"][:quantity] == \"\" || tenant_params[:tenant_details_attributes][\"0\"][:food_category_id] == \"\") \n redirect_to :action => \"new\", notice: 'Tenant was not created. Please fill the meal_info'\n end\n end",
"def addMeal(meal)\n @meals[meal.name] = meal\n @meals[\"other\"].remove_qty(meal.quantity)\n end",
"def new_meal(customer, total, tip=0)\n Meal.new(self, customer, total, tip)\nend",
"def meal_params\n params.require(:meal).permit(:meal_type, :id)\n end",
"def meal_params\n params.require(:meal).permit(\n :name, :time, :notes\n )\n end",
"def create\n @meal = Meal.new(meal_params)\n\n respond_to do |format|\n if @meal.save\n format.html { redirect_to @meal, notice: 'Meal was successfully created.' }\n format.json { render json: @meal, status: :created, location: @meal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @meal = Meal.find(params[:id])\n end",
"def show\n @meal = Meal.find(params[:id])\n end",
"def show\n @meal = Meal.find(params[:id])\n end",
"def meal_params\n params.require(:meal).permit(:name, :description, :location, :image, :expires_at)\n end",
"def like?(meal)\n self.customer_meals.find_by_meal_id(meal.id)\n end",
"def show\n @user = User.find(@meal_posting.user_id)\n @usermeals = @user.meal_postings\n @reservation = Reservation.new\n @other_meal_ids = MealPosting.where(\"user_id = ? AND id != ?\", @meal_posting.user_id, @meal_posting.id).ids\n @ordered_meal_ids = @other_meal_ids.unshift(@meal_posting.id)\n end",
"def show \n @meal = Meal.where(id: params[:id])\n end",
"def menu\n foods = current_user.restaurant.meals.where(meal_type: 0)\n drinks = current_user.restaurant.meals.where(meal_type: 1)\n render json: {foods: foods, drinks: drinks, is_success: true}, status: :ok\n end",
"def meet\n # Envia pedido de que quer conhecer o animal. \n # Isto mandaria uma proposta para o dono do shelter.\n\n # TODO: É preciso criar uma tabela associativa para saber quem já mandou proposta para o animal.\n # Assim evitaria mandar proposta múltiplas vezes.\n if params[:user_id]\n # friendly_user = User.find(params[:user_id])\n friendly_user = current_user\n AnimalMailer.meet_up_proposal(@animal, friendly_user).deliver\n end\n end",
"def index\n @meals = Meal.all\n end",
"def new_meal(waiter, total, tip=0)\r\n Meal.new(waiter,self, total, tip)\r\n end",
"def new\n @meal = Meal.new\n @meal.food_items.build()\n end",
"def user_meal_params\n params.fetch(:user_meal, {})\n end",
"def whole_meal?\n @whole_meal\n end",
"def index?\n order && MealPolicy.new(user, order.meal).show?\n end",
"def add_food(food)\n food_meals.create(food_id: food.id)\n end",
"def private_goal(user)\n create_goal(\"Learn to paint\", \"true\")\n create_goal(\"Play the piano\")\n click_link 'Sign Out'\n other_user(user)\n click_link 'Wilbur'\n end",
"def meal_params\n params.require(:meal).permit(:day_id, :time, :portions, :name, :favorite, :notes, :meal_type)\n end",
"def create\n @group_meal = GroupMeal.new(params[:group_meal])\n\n respond_to do |format|\n if @group_meal.save\n format.html { redirect_to @group_meal, notice: 'Group meal was successfully created.' }\n format.json { render json: @group_meal, status: :created, location: @group_meal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_meal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_meal(waiter, total, tip=0)\n Meal.new(waiter, self, total, tip)\n end",
"def new_meal(waiter, total, tip=0)\n Meal.new(waiter, self, total, tip)\n end",
"def new_meal(waiter, total, tip=0)\n Meal.new(waiter, self, total, tip)\n end",
"def list\n # 1. Ask the repo to bring all meals #all\n meals = @meal_repo.all\n # 2. Pass the meals to the view to display them\n @meal_view.display_all(meals)\n end",
"def create\n @meal = Meal.new(params[:meal])\n respond_to do |format|\n if @meal.save\n recipeid = @meal.recipe_id\n flash[:notice] = 'Meal was successfully created.'\n #format.html { redirect_to(recipe_url(recipeid), :layout => false) }\n format.xml { render :xml => @meal, :status => :created, :meal => @meal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @meals = Menu.meals\n @locations = Menu.locations\n @menu = Menu.where(id: params[:id]).first\n @selected_meal = @menu.meal\n @selected_location = @menu.location\n if current_user\n @items = @menu.items.sort_by{ |obj| obj.updated_at }.partition{ |item| item.users.include? (current_user)}.flatten\n else\n @items = @menu.items.sort_by{ |obj| obj.updated_at }\n end\n end",
"def meal\n @meals = Meal.all\n\n respond_to do |format|\n #format.html # index.html.erb\n format.json { render json: @meals, :only => [:id, :name, :price], :include => { :items => {:only => [:id, :name, :description, :price, :time], :include => {:product_type => { :only => [:id, :name]}}}} }\n end\n end",
"def list\n meals = @meals_repository.all\n @view.list(meals)\n end",
"def index\n @meal_records = current_user.meal_records.all\n end",
"def random_meal\n # API EXAMPLE: https://www.themealdb.com/api/json/v1/1/random.php\n content = api_call('random.php')\n validate(content)\n content\n end",
"def current_meal\n Meal.find(session[:meal_id])\n rescue ActiveRecord::RecordNotFound\n meal = Meal.create\n session[:meal_id] = meal.id\n meal\n end",
"def requested\n @requested_meals = Meal.where(type: \"requested\")\n end",
"def meal_params\n params.require(:meal).permit(:name, :calories, :meal_time_text,\n :meal_date_text, :meal_time, :meal_date)\n end",
"def show\n @group_meal = GroupMeal.find(params[:id])\n if(current_user.alert==true)\n \t\tcurrent_user.alert=false\n\t\tcurrent_user.save\n\tend\n\tif(current_user.alert_location= @group_meal.id)\n\t\tcurrent_user.alert_location=nil\n\t\tcurrent_user.save\n\tend\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_meal }\n end\n end",
"def set_meal_record\n @meal_record = MealRecord.find(params[:id])\n end",
"def show_meals(userObj)\n table = TTY::Table.new [\"#{userObj.user_name}'s meals!\", \"Calories\", \"Foods\"], userObj.meal_arrays\n puts table.render(:ascii)\n end",
"def new_meal(waiter, total, tip=0)\n Meal.new(waiter, self, total, tip)\n end",
"def set_meal\n\t\t@meal = Meal.find(session[:meal_id])\n\trescue ActiveRecord::RecordNotFound \n\t\t@meal = Meal.create \n\t\tsession[:meal_id] = @meal.id\n\tend",
"def enable\n meal = current_user.restaurant.meals.find(params[:id])\n meal.update(available: true)\n render json: {is_success: true}\n end",
"def meal_params\n params.require(:meal).permit(:result_no, :generate_no, :e_no, :last_result_no, :last_generate_no, :i_no, :name, :recovery, :effect_1_id, :effect_1_value, :effect_2_id, :effect_2_value, :effect_3_id, :effect_3_value)\n end",
"def get_married \n create_inhabitant('Female', 'lastname','Female')\n create_inhabitant('Male', 'lastname1','Male')\n page.find('a', text: 'Go to church').click\n page.should have_content('lastname')\n page.should have_content('lastname1')\n page.find('a', text: 'Get married').click\n page.should have_content('New marriage')\n page.select('Female lastname', :from => 'wedding_first_spouse_id')\n page.select('Male lastname1', :from => 'wedding_second_spouse_id')\n page.click_button('Get Married')\n end",
"def index\n @meals = Menu.meals\n @locations = Menu.locations\n @menus = Menu.all\n params[:meal] ? @selected_meal = params[:meal] : @selected_meal = session[:selected_meal]\n params[:location] ? @selected_location = params[:location] : @selected_location = session[:selected_location]\n @current_items = []\n if current_user\n @menus.each do |menu|\n @current_items.push(menu.items.select{ |item| item.users.include? (current_user)}.flatten)\n end\n end\n if params[:meal] and params[:location]\n session[:selected_meal] = params[:meal]\n session[:selected_location] = params[:location]\n menu = Menu.where(:meal => params[:meal], :location => params[:location]).first\n if not menu.nil?\n redirect_to menu_path(menu.id) and return\n end\n end\n end",
"def create\n @meal_posting = MealPosting.new(meal_posting_params)\n @meal_posting.user = current_user\n\n respond_to do |format|\n if @meal_posting.save\n format.html { redirect_to @meal_posting }#, notice: 'Meal posting was successfully created.' }\n format.json { render :show, status: :created, location: @meal_posting }\n else\n format.html { render :new }\n format.json { render json: @meal_posting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if session[:meal_id].nil?\n redirect_to meals_path\n else\n @meal = Meal.find(session[:meal_id]) \n @meal_dishes = @meal.meal_dishes\n end \n end",
"def set_indication_for_meal\n @indication_for_meal = IndicationForMeal.find(params[:id])\n end",
"def meals\r\n Meal.all.select do |meal|\r\n meal.customer == self\r\n end\r\n end",
"def show\n @meals = Menu.meals\n @locations = Menu.locations\n @menu = Menu.where(id: params[:id]).first\n @items = @menu.items.sort_by{ |obj| obj.updated_at }\n #we have access to meal\n end",
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meal }\n end\n end",
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meal }\n end\n end",
"def create\n @meal = Meal.new(params[:meal])\n\n @meal.test_subject = @test_subject\n\n respond_to do |format|\n if @meal.save\n flash[:notice] = 'Meal was successfully created.'\n format.html { redirect_to(@test_subject) }\n format.xml { render :xml => @meal, :status => :created, :location => @meal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @meal }\n end\n end",
"def create\n @mealplan = Mealplan.new(mealplan_params.merge(user: current_user))\n\n respond_to do |format|\n if @mealplan.save\n format.html { redirect_to @mealplan, notice: 'Mealplan was successfully created.' }\n format.json { render :show, status: :created, location: @mealplan }\n else\n format.html { render :new }\n format.json { render json: @mealplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def offered\n @offered_meals = Meal.where(type: \"offered\")\n end",
"def my_rentals\n @rentals = Rental.get_all_for_user current_user\n end",
"def set_malice\n @malice = Malice.find(params[:id])\n end",
"def create\n @malice = Malice.new(malice_params)\n\n respond_to do |format|\n if @malice.save\n format.html { redirect_to @malice, notice: 'Malice was successfully created.' }\n format.json { render :show, status: :created, location: @malice }\n else\n format.html { render :new }\n format.json { render json: @malice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def approve_setup_fee_collection( current_user )\n self.is_setup_fee_collection_approved = true \n self.setup_fee_collection_approver_id = current_user.id \n self.save\n \n # create all those payment payable : loan disbursement \n end",
"def meal_params\n switch_to_int\n params.require(:meal).permit(:name, meal_foods_attributes: %i[food_id amount id])\n end",
"def user_editable\n if current_user.admin?\n @deal = Deal.find_by(id: params[:id])\n flash[:danger] = \"No existe ese deal\" if @deal.nil?\n else\n if not @deal = current_user.deals.find_by(id: params[:id]) || current_user.codeals.find_by(id: params[:id])\n if deal = Deal.find_by(id: params[:id])\n redirect_to deal and return\n end\n end\n end\n redirect_to root_url if @deal.nil?\n end",
"def new\n reset_session\n @user = User.new\n @meal_dates = [\"2013-07-08\",\"2013-07-09\",\"2013-07-10\",\"2013-07-11\",\"2013-07-12\",\"2013-07-13\",\"2013-07-14\"]\n @child = @user.children.build\n @meal = @user.meals.build\n @travels = @user.travels.build\n @registration = @user.registrations.build\n @programs = Program.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end"
] |
[
"0.71216446",
"0.7096165",
"0.70177394",
"0.6932517",
"0.6847684",
"0.68153816",
"0.6728353",
"0.6681564",
"0.66689736",
"0.66546756",
"0.66472256",
"0.6592594",
"0.65827924",
"0.6570472",
"0.6569442",
"0.6569442",
"0.65679926",
"0.6458745",
"0.64425606",
"0.64425606",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6433618",
"0.6411202",
"0.6399811",
"0.638499",
"0.6344039",
"0.63274664",
"0.6291207",
"0.6268337",
"0.62542766",
"0.6196251",
"0.6168148",
"0.61505955",
"0.60679966",
"0.6039622",
"0.6033695",
"0.6033695",
"0.6033695",
"0.6021367",
"0.59739786",
"0.5958651",
"0.59561473",
"0.5875362",
"0.5833332",
"0.5821553",
"0.58199024",
"0.5814318",
"0.58099276",
"0.5806838",
"0.5798107",
"0.57980067",
"0.5782473",
"0.576562",
"0.57511955",
"0.57444996",
"0.57444996",
"0.57444996",
"0.57363117",
"0.57333916",
"0.572932",
"0.5729152",
"0.57239795",
"0.5723908",
"0.5719208",
"0.5711673",
"0.5705885",
"0.5699844",
"0.5697296",
"0.56907254",
"0.56868047",
"0.56863135",
"0.5684805",
"0.5676236",
"0.5672011",
"0.5664588",
"0.5632618",
"0.5625135",
"0.5604241",
"0.5602083",
"0.55942994",
"0.558658",
"0.55859596",
"0.55859596",
"0.5540363",
"0.55385274",
"0.55056167",
"0.5496689",
"0.549138",
"0.5487338",
"0.54739916",
"0.54695666",
"0.5459088",
"0.5458583",
"0.5457633"
] |
0.57579494
|
59
|
Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+. source://i18n//lib/i18n/backend/fallbacks.rb17
|
def fallbacks; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fallbacks\n @fallbacks ||= {}\n end",
"def fallback\n @@fallback\n end",
"def ar_fallbacks(force = false)\n return @@ar_fallbacks if @@ar_fallbacks\n return fallbacks unless force\n @@ar_fallbacks = Globalize::Locale::Fallbacks.new\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def languagefallback()\n merge(languagefallback: 'true')\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def fallbacks=(fallbacks); end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def fallbacks?\n return true if options[:fallbacks].nil?\n !!options[:fallbacks]\n end",
"def fallback_url\n return @fallback_url\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def invoke_fallbacks_for(name, base)\n return nil unless base && fallbacks[base.to_sym]\n invoked_fallbacks = []\n\n Array(fallbacks[base.to_sym]).each do |fallback|\n next if invoked_fallbacks.include?(fallback)\n invoked_fallbacks << fallback\n\n klass = find_by_namespace(name, fallback)\n return klass if klass\n end\n\n nil\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def fallback_reviewers\n return @fallback_reviewers\n end",
"def fallback_reviewers\n return @fallback_reviewers\n end",
"def preferred_language_from(locales)\n (accepted_languages & locales).first\n end",
"def ar_fallbacks=(fallbacks)\n @@ar_fallbacks = fallbacks\n end",
"def fallback_escalation_approvers\n return @fallback_escalation_approvers\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def supported_languages\n return self.supported_locales.present? ? self.supported_locales : [\"en\"]\n end",
"def fallback_data\n @fallback_data ||= {}\n end",
"def find_best_locale\n browser_locale =\n http_accept_language.preferred_language_from(\n Rails.application.config.automatic_locales\n )\n return browser_locale if browser_locale.present?\n\n I18n.default_locale\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def compatible_language_from(locales)\n accepted_languages.map do |language| # en-US\n locales.find do |locale| # en\n language == locale || language.split('-', 2).first == locale.split('-', 2).first\n end\n end.compact.first\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def get_locales\n fall_back = [:ru].to_yaml\n locales = CustomSetting.find_or_create_by_name(\"languages\").value || fall_back\n begin\n locales = YAML::load(locales)\n rescue\n locales = YAML::load(fall_back)\n end\n end",
"def register_fallback(*providers)\n @@fallback += providers\n end",
"def available_locales\n []\n end",
"def fallback(&block)\n @fallback = true\n result = block.call\n @fallback = false\n result\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def fallback_url\n case retv = read_attribute(:fallback_url)\n\n # if in the format association#method it will try to call it, this is useful\n # for situations like a blog_post wanting the default url to be the user's\n # avatar\n when /^(spec|owner)#(.*)/\n if association = send($1)\n association.respond_to?($2) && association.send($2)\n end\n\n # when blank it'll try to get the url from the spec\n when /^\\s*$/, nil\n spec != self && spec.try(:fallback_url) || CATCHALL_FALLBACK_URL\n\n # otherwise the assumption is that fallback_url is a hardcoded path\n else\n retv\n end.presence\n end",
"def correct_locale\n (locales.select{|loc|loc.locale == I18n.locale.to_s}.first || locales.first)\n end",
"def fallback_to_default(localization_key, localization)\n localization_key.localizations.where.not(default_value: nil). \\\n where.not(id: localization.id).first&.default_value\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def default_language\n languages.find_by(default: true)\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def preferred_locales\n read_attribute(\"preferred_locales\").map(&:to_sym)\n end",
"def legacy_fallback_urls\n {\n 'Cache' => 'redis://localhost:6380',\n 'Queues' => 'redis://localhost:6381',\n 'SharedState' => 'redis://localhost:6382'\n }\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def available_locales; end",
"def available_locales; end",
"def default_i18n_with_milkshake\n default_i18n = default_i18n_without_milkshake\n default_i18n.load_path.concat(Milkshake.environment.locale_paths)\n default_i18n.load_path.uniq!\n default_i18n\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def preferred_language\n mother_tongues.first || self.last_login_language || Language[I18n.default_locale]\n end",
"def available_languages\n AppConfig.available_languages\n end",
"def fallback_primary_approvers\n return @fallback_primary_approvers\n end",
"def preferred_locales_str\n (preferred_locales || []).join(\",\")\n end",
"def get_fallback_shipping_rates(international_shipment)\n spree_shipping_methods = Spree::ShippingMethod.all\n if international_shipment\n # First filter to international shipping methods then to methods that use\n # preferred packaging, assuming preferred packaging has one word of method's\n # name in it, i.e. \"FedExPak\" contains \"FedEx.\"\n international_methods = spree_shipping_methods.select { |m| m.name.match /international/i }\n packaging_name = Spree::Config.preferred_international_packaging\n methods = international_methods.select { |m| !m.name.split.select { |word| packaging_name.match word }.empty? }\n cost = 25\n else\n methods = spree_shipping_methods.select { |m| !m.name.match /international/i }\n cost = 10\n end\n methods.map { |method| Spree::ShippingRate.new(name: method.name, cost: cost, shipping_method: method) }\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def severity_lookup(severity, fallback = :unknown)\n LOG_LEVELS[severity.to_sym] || LOG_LEVELS[fallback]\n end",
"def locale_backend; end",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def default_language\n @default_language || :en\n end",
"def best_locale_in(locales)\n formatted_sorted_locales(locales).each do |candidate|\n return candidate if not available_locales\n return candidate if available_locales.include?(candidate)\n return candidate[0..1] if available_locales.include?(candidate[0..1])#available locales include a langauge\n end\n return nil#nothing found im sorry :P\n end",
"def available_locales_set; end",
"def infer_languages\n raise \"Not Implemented. Class #{self.class.name} doesn't implement infer_languages\"\n end",
"def get_endpoints\n endpoints = @cache.endpoints || []\n endpoints.empty? ? @fallbacks : endpoints\n end",
"def current\n locale = I18n.locale\n @current ||=\n Rails.cache.fetch(\"languages/current/#{locale}\") do\n l = Language.find_by_group(locale)\n l ||= Language.english\n end\n end",
"def available_locales\n @available_locales ||= self.languages.published\n end",
"def default_lang\n GamePlay::Load::DEFAULT_GAME_LANGUAGE\n end",
"def polling_fallback_message(value)\n @adapter_options[:polling_fallback_message] = value\n self\n end",
"def available_locales_initialized?; end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def fallbacks=(_arg0); end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def fallback_url=(value)\n @fallback_url = value\n end",
"def matching_locales\n @_matching_locales ||= ::I18n.available_locales.select do |locale|\n locale.to_s.split(\"-\")[0] == language_code\n end\n end",
"def parse_lacp_fallback(config)\n mdata = /lacp fallback (static|individual)/.match(config)\n { lacp_fallback: mdata ? mdata[1] : DEFAULT_LACP_FALLBACK }\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def fallback_data; end",
"def fallback_data; end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance_or_fallback(locale)\n end\n end",
"def find_locale\n locale = locales.all.detect(&:default)\n return locale.code if locale\n\n default_locale\n end",
"def layout_file_name_or_fallback\n ActionController::Base.view_paths.each do |path|\n ActionView::Template::Handlers.extensions.each do |engine_suffix|\n format = params[:format].presence || \"html\"\n file_in_path = File.join(\n path.to_s, \"layouts\", \"#{layout_file_name}.#{format}.#{engine_suffix}\"\n )\n return layout_file_name if File.exist?(file_in_path)\n end\n end\n fallback = \"application\"\n if self.class.sinicum_layout_prefix.present?\n fallback = self.class.sinicum_layout_prefix + \"/\" + fallback\n end\n fallback\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def another_locale\n I18n.available_locales.map(&:to_sym).select {|locale| locale != I18n.locale.to_sym }.first\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def fetch(locale, name)\r\n Mongoid::Globalize.fallbacks(locale).each do |fallback|\r\n value = fetch_stash(fallback, name) || fetch_attribute(fallback, name)\r\n return value unless fallbacks_for?(value)\r\n end\r\n return nil\r\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def pbGetLanguage()\n getUserDefaultLangID=Win32API.new(\"kernel32\",\"GetUserDefaultLangID\",\"\",\"i\") rescue nil\n ret=0\n if getUserDefaultLangID\n ret=getUserDefaultLangID.call()&0x3FF\n end\n if ret==0 # Unknown\n ret=MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,\n \"Control Panel\\\\Desktop\\\\ResourceLocale\",\"\",0)\n ret=MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,\n \"Control Panel\\\\International\",\"Locale\",\"0\").to_i(16) if ret==0\n ret=ret&0x3FF\n return 0 if ret==0 # Unknown\n end\n return 1 if ret==0x11 # Japanese\n return 2 if ret==0x09 # English\n return 3 if ret==0x0C # French\n return 4 if ret==0x10 # Italian\n return 5 if ret==0x07 # German\n return 7 if ret==0x0A # Spanish\n return 8 if ret==0x12 # Korean\n return 2 # Use 'English' by default\nend",
"def locales\n EnvironmentLocaleMethodsFactory.new(self)\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def available_locales\n translations = Dir.glob('config/locales/*').map { |locale| locale.split('/').last.split('.').first }\n locales = []\n translations.each do |t|\n value = (t == 'zh' ? 'zh-CN' : t)\n locales << [LanguageList::LanguageInfo.find(t).name, value]\n end\n locales\n end",
"def fallbacks_for?(object)\r\n object.nil? || (fallbacks_for_empty_translations? && object.blank?)\r\n end",
"def default_locale; end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def loaded_languages\n @@languages.keys\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def uds_fallback\n return @uds_fallback if defined?(@uds_fallback)\n\n @uds_fallback =\n if configured_hostname.nil? &&\n configured_port.nil? &&\n deprecated_for_removal_transport_configuration_proc.nil? &&\n File.exist?(Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_PATH)\n\n Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_PATH\n end\n end",
"def system\n locale_from_env || default_locale\n end"
] |
[
"0.7676079",
"0.7343258",
"0.660933",
"0.6498168",
"0.6493042",
"0.6470338",
"0.64479476",
"0.6431005",
"0.6210287",
"0.6094286",
"0.5987497",
"0.5829084",
"0.5816213",
"0.5570987",
"0.5507317",
"0.5507317",
"0.54668903",
"0.54631096",
"0.5412813",
"0.5351174",
"0.5350387",
"0.5335702",
"0.5323094",
"0.52880925",
"0.52719396",
"0.5247355",
"0.5231851",
"0.52250075",
"0.52081597",
"0.51639766",
"0.5153758",
"0.5152745",
"0.51480687",
"0.51078045",
"0.51026803",
"0.50986296",
"0.5096696",
"0.50960284",
"0.5094623",
"0.5093954",
"0.50711703",
"0.5059739",
"0.50594044",
"0.5044883",
"0.5042073",
"0.5042073",
"0.5034597",
"0.50240535",
"0.5022865",
"0.50212234",
"0.50107276",
"0.5009132",
"0.50066173",
"0.49906343",
"0.4988947",
"0.4976478",
"0.4974773",
"0.49712208",
"0.49324414",
"0.4901246",
"0.4880263",
"0.4871734",
"0.48658824",
"0.48639277",
"0.48614737",
"0.48541975",
"0.4847899",
"0.48414782",
"0.4825953",
"0.4814293",
"0.4803662",
"0.4797418",
"0.47917628",
"0.4789508",
"0.47820348",
"0.47687042",
"0.47614044",
"0.47435117",
"0.47435117",
"0.47218356",
"0.47145793",
"0.4699628",
"0.46976894",
"0.4691843",
"0.46907428",
"0.4688811",
"0.46708387",
"0.4662168",
"0.46327925",
"0.46258226",
"0.46233746",
"0.46166995",
"0.46081012",
"0.4605144",
"0.45966694",
"0.45832583",
"0.45745516",
"0.45707694",
"0.45646843"
] |
0.65809137
|
3
|
Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. source://i18n//lib/i18n/backend/fallbacks.rb23
|
def fallbacks=(fallbacks); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fallbacks\n @fallbacks ||= {}\n end",
"def fallback\n @@fallback\n end",
"def languagefallback()\n merge(languagefallback: 'true')\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def ar_fallbacks=(fallbacks)\n @@ar_fallbacks = fallbacks\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def fallbacks; end",
"def fallbacks; end",
"def register_fallback(*providers)\n @@fallback += providers\n end",
"def fallback_url=(value)\n @fallback_url = value\n end",
"def ar_fallbacks(force = false)\n return @@ar_fallbacks if @@ar_fallbacks\n return fallbacks unless force\n @@ar_fallbacks = Globalize::Locale::Fallbacks.new\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def polling_fallback_message(value)\n @adapter_options[:polling_fallback_message] = value\n self\n end",
"def fallbacks?\n return true if options[:fallbacks].nil?\n !!options[:fallbacks]\n end",
"def set_as_fallback\n Account.where(fallback: true).all.each do |acc|\n acc.update_attributes fallback: false\n end\n self.update_attributes fallback: true\n end",
"def fallback(&block)\n @fallback = true\n result = block.call\n @fallback = false\n result\n end",
"def set_fonts\n font_families.update Elegant.configuration.fonts\n fallback_fonts ['Fallback']\n end",
"def fallback_reviewers=(value)\n @fallback_reviewers = value\n end",
"def fallback_reviewers=(value)\n @fallback_reviewers = value\n end",
"def invoke_fallbacks_for(name, base)\n return nil unless base && fallbacks[base.to_sym]\n invoked_fallbacks = []\n\n Array(fallbacks[base.to_sym]).each do |fallback|\n next if invoked_fallbacks.include?(fallback)\n invoked_fallbacks << fallback\n\n klass = find_by_namespace(name, fallback)\n return klass if klass\n end\n\n nil\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def fallback_url\n return @fallback_url\n end",
"def fallback_escalation_approvers=(value)\n @fallback_escalation_approvers = value\n end",
"def fallbacks=(_arg0); end",
"def fallback_method=(fallback_method)\n validator = EnumAttributeValidator.new('String', [\"POST\", \"GET\"])\n unless validator.valid?(fallback_method)\n fail ArgumentError, \"invalid value for \\\"fallback_method\\\", must be one of #{validator.allowable_values}.\"\n end\n @fallback_method = fallback_method\n end",
"def handle_fallback(*args)\n case @fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # Chef::Log.debug \"Caught exception => #{ex}\"\n end\n true\n else\n fail \"Unknown fallback policy #{@fallback_policy}\"\n end\n end",
"def handle_fallback(*args)\n case @fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # let it fail\n log DEBUG, ex\n end\n true\n else\n fail \"Unknown fallback policy #{@fallback_policy}\"\n end\n end",
"def fallback_data\n @fallback_data ||= {}\n end",
"def infer_languages\n raise \"Not Implemented. Class #{self.class.name} doesn't implement infer_languages\"\n end",
"def handle_fallback(*args)\n case fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # let it fail\n log DEBUG, ex\n end\n true\n else\n fail \"Unknown fallback policy #{fallback_policy}\"\n end\n end",
"def enabled_locales=(values)\n languages = values.reject { |x| x.blank? }\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def set_best_locale\n if ( RAILS_ENV == 'test' )\n code = 'en'\n else\n code = Translation.reconcile_user_data_with_http_request_language(\n request,\n logged_in? ? current_user : nil\n )\n end\n\n Translation.set_best_locale( code )\n end",
"def enabled_locales=(values)\n languages = values.reject{|x| x.blank?}\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def meth(fallback: nil)\nend",
"def meth(fallback: nil)\nend",
"def set_fallback_persistence_profile(opts)\n opts = check_params(opts,[:profile_names])\n super(opts)\n end",
"def set_lacp_fallback(name, opts = {})\n commands = command_builder('port-channel lacp fallback', opts)\n configure_interface(name, commands)\n end",
"def locale_backend; end",
"def fallback_primary_approvers=(value)\n @fallback_primary_approvers = value\n end",
"def fallback_data; end",
"def fallback_data; end",
"def set_locale(host, params, default_locale = I18n.default_locale)\r\n case I18n.config.language_detection_method\r\n when I18n::Config::DETECT_LANGUAGE_FROM_URL_PARAM\r\n lang = params[I18n.config.language_url_param.to_sym]\r\n when I18n::Config::DETECT_LANGUAGE_FROM_SUBDOMAIN\r\n @@hosts ||= Hash.new\r\n if @@hosts.has_key?(host)\r\n return @@hosts[host]\r\n end\r\n lang = get_locale(host)\r\n end\r\n if lang.present? && locale_enabled?(lang)\r\n I18n.locale = lang\r\n return true\r\n end\r\n I18n.locale = I18n.default_locale\r\n return (lang.present? && I18n.locale_available?(lang)) ? false : nil\r\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def fallback(error, package, *args, &block)\n puts \"Error Code #{error.status}\" if error.respond_to?(:status)\n Importer.fallback_handlers.each do |handler|\n fallback_importer = handler.call(package, self)\n if fallback_importer.kind_of?(Importer)\n begin\n return fallback_importer.send(*args, &block)\n rescue Exception\n # raise error\n end\n end\n end\n raise error\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_backend(val)\n end",
"def assign_defaults(options)\n # Normalizes languages keys from symbols to strings\n normalize_language_keys(options)\n\n # Build a complete list of the required languages\n enabled_languages = detect_languages(options)\n\n # Get all languages used in existing settings\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n current.each do |language, value|\n enabled_languages << language unless enabled_languages.include?(language)\n end\n end\n\n # Check folder list (an empty folder signifies a language is required)\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n next unless File.directory?(lang_folder) # We don't want to read txt as they are non localised\n language = File.basename(lang_folder)\n enabled_languages << language unless enabled_languages.include?(language)\n end\n\n return unless enabled_languages.include?(\"default\")\n UI.message(\"Detected languages: \" + enabled_languages.to_s)\n\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n default = current[\"default\"]\n next if default.nil?\n\n enabled_languages.each do |language|\n value = current[language]\n next unless value.nil?\n\n current[language] = default\n end\n current.delete(\"default\")\n end\n end",
"def assign_defaults(options)\n # Normalizes languages keys from symbols to strings\n normalize_language_keys(options)\n\n # Build a complete list of the required languages\n enabled_languages = detect_languages(options)\n\n # Get all languages used in existing settings\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n current.each do |language, value|\n enabled_languages << language unless enabled_languages.include?(language)\n end\n end\n\n # Check folder list (an empty folder signifies a language is required)\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n next unless File.directory?(lang_folder) # We don't want to read txt as they are non localised\n language = File.basename(lang_folder)\n enabled_languages << language unless enabled_languages.include?(language)\n end\n\n return unless enabled_languages.include?(\"default\")\n UI.message(\"Detected languages: \" + enabled_languages.to_s)\n\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n default = current[\"default\"]\n next if default.nil?\n\n enabled_languages.each do |language|\n value = current[language]\n next unless value.nil?\n\n current[language] = default\n end\n current.delete(\"default\")\n end\n end",
"def use_i18n=(value); end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def set_locale_to_best_available\n best_locale = params[:locale] # Locale in URL always takes precedent\n best_locale = find_best_locale if best_locale.blank?\n\n # Assigning a value to I18n.locale *looks* like a\n # global variable setting, and setting a global\n # variable would be bad since we're multi-threaded.\n # However, this is *not* setting a global variable, it's setting a\n # per-Thread value (which is safe). Per the i18n guide,\n # \"The locale can be either set pseudo-globally to I18n.locale\n # (which uses Thread.current like, e.g., Time.zone)...\".\n I18n.locale = best_locale.to_sym\n end",
"def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end",
"def fallback_url\n case retv = read_attribute(:fallback_url)\n\n # if in the format association#method it will try to call it, this is useful\n # for situations like a blog_post wanting the default url to be the user's\n # avatar\n when /^(spec|owner)#(.*)/\n if association = send($1)\n association.respond_to?($2) && association.send($2)\n end\n\n # when blank it'll try to get the url from the spec\n when /^\\s*$/, nil\n spec != self && spec.try(:fallback_url) || CATCHALL_FALLBACK_URL\n\n # otherwise the assumption is that fallback_url is a hardcoded path\n else\n retv\n end.presence\n end",
"def legacy_fallback_urls\n {\n 'Cache' => 'redis://localhost:6380',\n 'Queues' => 'redis://localhost:6381',\n 'SharedState' => 'redis://localhost:6382'\n }\n end",
"def fallback_to_default(localization_key, localization)\n localization_key.localizations.where.not(default_value: nil). \\\n where.not(id: localization.id).first&.default_value\n end",
"def default_locale=(locale); end",
"def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end",
"def set_defaults\n \tdefault_language = lexeme.try(:language) || Language.new\n \n \tself.language ||= default_language\n\tend",
"def uds_fallback\n return @uds_fallback if defined?(@uds_fallback)\n\n @uds_fallback =\n if configured_hostname.nil? &&\n configured_port.nil? &&\n deprecated_for_removal_transport_configuration_proc.nil? &&\n File.exist?(Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_PATH)\n\n Datadog::Core::Configuration::Ext::Agent::UnixSocket::DEFAULT_PATH\n end\n end",
"def set_locale_old\n locales = ['en', 'en-AU']\n begin\n # Try to auto-detect it\n if request.headers['Accept-Language']\n browser_language = request.headers['Accept-Language'].split(',')[0]\n browser_language = browser_language.split('-')[0] + '-' + browser_language.split('-')[1].upcase\n session[:locale] = browser_language\n end\n session[:locale] = params[:locale] if params[:locale]\n session[:locale] = 'en-AU' if session[:locale] == 'en-GB'\n I18n.locale = locales.include?(session[:locale]) ? session[:locale] : I18n.default_locale\n rescue\n I18n.locale = I18n.default_locale\n end\n end",
"def alternative_lang_for(is_result)\n if is_result\n alternative_lang + '-result'\n else\n alternative_lang\n end\n end",
"def enforce_available_locales!(locale); end",
"def load_backends(path = MDS::DEFAULT_BACKEND_PATHS)\r\n Dir.glob(File.expand_path(path)) do |path|\r\n begin\r\n require path\r\n rescue LoadError\r\n end\r\n end\r\n end",
"def enable_language_autodetect\n put \"languages/enable_autodetect\", nil\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def apply_overrides\n @overrides.each do |key, override|\n @storage[key] = override.call(@storage)\n end\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def parse_lacp_fallback(config)\n mdata = /lacp fallback (static|individual)/.match(config)\n { lacp_fallback: mdata ? mdata[1] : DEFAULT_LACP_FALLBACK }\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def do_fallback action\n do_redirect fallback_path\n end",
"def set_locale\n end",
"def is_fallback_public_client=(value)\n @is_fallback_public_client = value\n end",
"def fall_back\n say 'Xin lỗi! Chúng tôi không biết lựa chọn của bạn. Xin vui lòng thử lại' unless text_message?\n return false unless !text_message? || stop_word_used?('Stop')\n stop_chuyenkhoan\n puts 'Fallback triggered!'\n true # to trigger return from the caller on 'and return'\n end",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def preferred_culture=(value)\n @children['preferred-culture'][:value] = value\n end",
"def preferred_culture=(value)\n @children['preferred-culture'][:value] = value\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def fallback_reviewers\n return @fallback_reviewers\n end",
"def fallback_reviewers\n return @fallback_reviewers\n end",
"def fallback_persistence_profile\n super\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def try_fallback(append_mode)\n if ogr2ogr.invalid_dates?\n job.log 'Fallback: Autoguessing problem, trying to disable the problematic column'\n @job.fallback_executed = \"date\"\n ogr2ogr.overwrite = true\n ogr2ogr.csv_guessing = true\n ogr2ogr.quoted_fields_guessing = false\n disable_autoguessing_on_wrong_column(ogr2ogr.filepath, ogr2ogr.command_output)\n ogr2ogr.run(append_mode)\n elsif ogr2ogr.encoding_error?\n job.log \"Fallback: There is an encoding problem, trying with ISO-8859-1\"\n @job.fallback_executed = \"encoding\"\n ogr2ogr.overwrite = true\n ogr2ogr.encoding = \"ISO-8859-1\"\n ogr2ogr.run(append_mode)\n elsif ogr2ogr.missing_srs?\n job.log \"Fallback: Source dataset has no coordinate system, forcing -s_srs 4326\"\n @job.fallback_executed = \"srs 4326\"\n ogr2ogr.overwrite = true\n ogr2ogr.shape_coordinate_system = '4326'\n ogr2ogr.run(append_mode)\n end\n ogr2ogr.set_default_properties\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def __auto_detect_adapter\n case\n when defined?(::Patron)\n :patron\n when defined?(::Typhoeus)\n :typhoeus\n when defined?(::HTTPClient)\n :httpclient\n when defined?(::Net::HTTP::Persistent)\n :net_http_persistent\n else\n ::Faraday.default_adapter\n end\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def add_missing_locales\n Locale::Info.three_languages['wee'] = Locale::Info::Language.new('', 'wee', 'I', 'L', 'Lower Sorbian')\n Locale::Info.three_languages['wen'] = Locale::Info::Language.new('', 'wen', 'I', 'L', 'Upper Sorbian')\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def fallback_escalation_approvers\n return @fallback_escalation_approvers\n end",
"def set_default_language\n I18n.locale = :ja\n end",
"def find_template(views, name, engine, &block)\n I18n.fallbacks[I18n.locale].each { |locale|\n super(views, \"#{name}.#{locale}\", engine, &block) }\n super(views, name, engine, &block)\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def fall_back\n say 'You tried to fool me, human! Start over!' unless text_message?\n return false unless !text_message? || stop_word_used?('Stop')\n stop_questionnaire\n puts 'Fallback triggered!'\n true # to trigger return from the caller on 'and return'\n end",
"def initialize\n self.namespace = \"i18n_languages\"\n self.custom = false\n self.available_locales_only = true\n end"
] |
[
"0.6867249",
"0.6768516",
"0.66921115",
"0.6677767",
"0.66431564",
"0.645006",
"0.63633806",
"0.63633806",
"0.63354605",
"0.59322584",
"0.5886629",
"0.5800504",
"0.5763564",
"0.56800824",
"0.5643504",
"0.5621275",
"0.5584741",
"0.5487874",
"0.5421522",
"0.5385849",
"0.5385849",
"0.5348379",
"0.5339871",
"0.5301116",
"0.52762395",
"0.52601683",
"0.52433974",
"0.5241192",
"0.5218758",
"0.5074539",
"0.5022291",
"0.49632925",
"0.49377003",
"0.4933593",
"0.49049994",
"0.49039185",
"0.49013248",
"0.486492",
"0.486492",
"0.48602816",
"0.48049638",
"0.48041058",
"0.47966725",
"0.47931504",
"0.47931504",
"0.4787744",
"0.47518456",
"0.4730146",
"0.4725154",
"0.46836",
"0.4682679",
"0.46819425",
"0.4650845",
"0.46198377",
"0.4611682",
"0.46054062",
"0.46017516",
"0.4579294",
"0.45636117",
"0.4515477",
"0.4507227",
"0.45021775",
"0.44930378",
"0.44889423",
"0.4488674",
"0.4479986",
"0.44773942",
"0.4462486",
"0.44583774",
"0.44452962",
"0.44401616",
"0.4439403",
"0.44343773",
"0.44322065",
"0.44285893",
"0.4426189",
"0.44037232",
"0.43833238",
"0.43826118",
"0.4381551",
"0.4381551",
"0.4378568",
"0.43755865",
"0.43755865",
"0.4373254",
"0.43649048",
"0.43636075",
"0.43607447",
"0.4358462",
"0.43571207",
"0.43512958",
"0.43509424",
"0.43417525",
"0.4334506",
"0.43219936",
"0.43168756",
"0.43120232",
"0.43116692",
"0.43083408",
"0.4301861"
] |
0.7369854
|
0
|
Return String or raises MissingInterpolationArgument exception. Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler.
|
def interpolate(string, values); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def missing_interpolation_argument_handler; end",
"def string_interpolation?(value = @value)\n !value.index(INTERPOLATION).nil?\n end",
"def ignore_interpolation? arg, suspect\n return unless string_interp? arg\n return true unless arg[1].chomp.empty? # plain string before interpolation\n\n first_interp = arg.find_nodes(:evstr).first\n return unless first_interp\n\n first_interp[1].deep_each do |e|\n if suspect == e\n return false\n end\n end\n\n true\n end",
"def method_missing(method, *args)\n \"#{method.to_s} not a valid formatter!\"\n end",
"def greetings_interpolation(name)\n # code goes here\nend",
"def error_message\n \"JPT - #{setting_name} received an invalid argument: #{source}\"\n end",
"def err_missing (message, usage)\n raise \"Missing argument --#{message}\\n#{usage}\"\n end",
"def method_missing(name, *args)\n \"The method #{name} doesn't exist - args: #{args}\"\n end",
"def get_argument_value(arg, required, fallback)\n if @args.has_key?(arg)\n @args[arg]\n else\n raise ArgumentError, \"Required argument #{arg} is blank\" if required\n fallback\n end\nend",
"def render_missing_snip(snip_name)\n \"[snip '#{snip_name}' cannot be found]\"\n end",
"def interpolate_string(string, args={})\n if args.length > 0\n args.each do |arg|\n string = string.gsub(\"{#{arg[0].to_s}}\", arg[1].to_s)\n end\n end\n string\n end",
"def raise_formatter_error(name)\n raise Error, \"Unrecognized formatter name '#{name.inspect}'\"\n end",
"def raise_formatter_error(name)\n raise Error, \"Unrecognized formatter name '#{name.inspect}'\"\n end",
"def interpolate_string(string, scope)\n if string.is_a?(String)\n string.gsub(/%\\{([^\\}]*)\\}/) do\n scope[$1] || raise(Exception, \"Interpolation for #{$1} failed\")\n end\n else\n string\n end\n end",
"def msg_ERROR(source, args)\n return args[0]\n end",
"def interpolation_patterns; end",
"def argue(argument)\n return \"#{argument}\"\nend",
"def missing_translation_placeholder field\n evaluate_localization_option!(:placeholder, field)\n end",
"def respond_with_param_missing(exception = nil)\n msg = exception ? exception.message : \"Parameter missing\"\n render partial: \"api/error\", locals: { message: msg, error_code: \"param_missing\" }, status: 400\n return false\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def contains_interpolation?(string)\n contains_connect_variables?(string) || contains_puppet_variables?(string)\n end",
"def _argument_error(exp, rec, msg)\n exp = exp.join(\" or \") if exp.is_a?(Array)\n raise ArgumentError, sprintf(msg, exp, rec)\n end",
"def param_check_string(_param, _display, _value)\n critical_error('the param_check_string method was not overridden after being included in a database class')\n end",
"def interpolation_statement(prior_segments)\n chunks = prior_segments.collect { |s| s.interpolation_chunk }\n chunks << interpolation_chunk\n \"\\\"#{chunks * ''}\\\"#{all_optionals_available_condition(prior_segments)}\"\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def interpolate(path, template_name = nil)\n path.gsub!('%e', Tiller::config[:environment])\n path.gsub!('%t', template_name) if template_name\n path\n end",
"def translatable_string_init_arg(arg_name)\n if XRC2Ruby.use_gettext\n init_arg(arg_name) { | val | \"_(\" + val.inspect + \")\" }\n else\n init_arg(arg_name) { | val | val.inspect }\n end\n end",
"def interpolate(text, args)\n results = []\n while text.include?('[-]')\n head, text = *text.split('[-]', 2)\n results << head << args.shift\n end\n results << text \n results << args unless args.empty?\n \n return results.compact\n end",
"def render_params_missing_error\n render :json => { error: I18n.t('api.errors.parameters') },\n :status => :bad_request\n end",
"def error_for(name,*args)\n # Make sure the name is a downcased symbol\n name = name.to_s.downcase.to_sym\n\n # Create message template\n message = [:errors,:solutions].map{|x| get_message(x,name) }.compact.join(\"\\n\")\n\n # Params for message template\n params = args.flatten\n\n # Ensure we have the right number of placeholders\n num_placeholders = message.scan(\"%s\").length\n unless num_placeholders == params.length\n warn(\"\\nWARNING: error_for called with wrong number of args from: \\n\\t%s\\n\" % caller[0]) if $debug\n # This will ensure we have the right number of arguments, but should not get here\n params << Array.new(num_placeholders,\"???\")\n end\n\n # Return the message\n message % params.flatten\nend",
"def prepared_arg_placeholder\n PREPARED_ARG_PLACEHOLDER\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def format(arg)\n str = if arg.is_a?(Exception)\n \"#{arg.class}: #{arg.message}\\n\\t\" <<\n arg.backtrace.join(\"\\n\\t\") << \"\\n\"\n elsif arg.respond_to?(:to_str)\n arg.to_str\n else\n arg.inspect\n end\nend",
"def interpolate( dindex )\n return method( self.interpoltype ).call( dindex )\n end",
"def log_interpolate prefix, text, time = timestamp\n message = class_trait[:format].dup\n\n vars = { '%time' => time, '%prefix' => prefix, '%text' => text }\n vars.each{|from, to| message.gsub!(from, to) }\n\n message\n end",
"def interpoltype()\n return :linear\n end",
"def prepared_arg_placeholder\n PREPARED_ARG_PLACEHOLDER\n end",
"def require_arg(args, name)\r\n unless args.key?(name) then\r\n raise ArgumentError.new(\"Missing argument #{name}.\")\r\n end\r\n end",
"def exception_on_syntax_error=(_arg0); end",
"def arguments_errors(argument_or_string)\n 'arguments_errors_' << (argument_or_string.is_a?(String) ? argument_or_string : argument_id(argument_or_string))\n end",
"def arguments_missing\n write 'Invalid arguments'\n do_help(current_command) if docs.include?(current_command)\n end",
"def string_length_interpolater(incoming_string)\n \"The string you just gave me has a length of #{incoming_string.length}\"\nend",
"def unknown_string\n t('Unknown')\n end",
"def accept(evaluator)\n evaluator.string_interpolation(self)\n end",
"def resolve_value arg\n arg = arg.to_s\n arg[0] == '_' ? resolve_partializer(arg) : arg.to_sym\n end",
"def safe_exception_parse(arg, default: :original)\n case (ex = arg.try(:exception))\n when Faraday::Error\n {\n message: ex.message,\n response: ex.response,\n exception: ex.wrapped_exception\n }.compact_blank!\n when Exception\n ex.message\n else\n # noinspection RubyMismatchedReturnType\n (default == :original) ? arg : default\n end\n end",
"def interpolate_strings(string1, string2)\n p \"#{string1} is cooler than #{string2}\"\nend",
"def localized_format(key, translation_table = nil, placeholder_value)\n format_str = localized(key, translation_table)\n puts format_str\n NSString.stringWithFormat(format_str, placeholder_value)\nend",
"def method_missing(name, *args)\n if args.size==1\n args[0]\n elsif args.size==0\n Waw.logger.warn(\"No such resource #{name} on #{@__name}, (#{caller[0]})\")\n nil\n else\n super\n end\n end",
"def record_not_found_message\n resource_name&.present? ? I18n.t(:x_not_found, name: resource_name&.singularize&.titleize) : I18n.t(:not_found)\n end",
"def wrong_args_message(size, min, max)\n e = min == max ? min : \"#{min}..#{max}\"\n \"Wrong number of arguments. Received #{size} instead of #{e}.\"\n end",
"def formatted_exception\n @exception && \"#{@exception.class.name}: #{@exception.message}\"\n end",
"def method_missing(name, *_args)\n fail \"Unknown option #{name.to_s.gsub!('=', '')}\"\n end",
"def format_error_message( msg, count = nil, singular = nil, *rest )\n return super unless msg.is_a?( Symbol ) and r18n\n if limit = count and singular\n limit = t.form_input.units[ singular, count ].to_s\n end\n text = t.form_input.errors[ msg, *limit, self ].to_s\n super( text )\n end",
"def inspect(value)\n value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)\n unquoted_string(value.to_sass)\n end",
"def error_string\n # This method should be overridden\n end",
"def cancel\n raise CancelInterpolation.new\n end",
"def raise_single_quote_error\n raise ArgumentError, \"Single quotes are not allowed in filenames here.\"\nend",
"def error_message\n raise \"calculator is empty\"\n end",
"def t(key, *args)\n key.nil? || (key.is_a?(String) && key.to_s.ends_with?(\".\")) ? \"\" : super\n end",
"def interpolation_options\n { resource_name: @organization.name }\n end",
"def interpolate_slug\n interpolation = self.delivery_options.slugged\n ::Transit::Interpolations.interpolate(interpolation, self)\n end",
"def invalid_args!(message)\n raise InvalidCommandLine, message\n end",
"def parameter\n return nil unless @parser.text_arg?(PARAMETER)\n\n \"#{@parser.args[PARAMETER].strip.tr('*', '%').gsub(/×/, 'x')}%\"\n end",
"def infer_interpolation_key(string, others)\n key = string.downcase\n key.sub!(/\\.html_safe\\z/, '')\n key.gsub!(/[^a-z0-9]/, ' ')\n key.strip!\n key.gsub!(/ +/, '_')\n key.slice!(20)\n i = 0\n base_key = key\n while others.key?(key) && others[key] != string\n key = \"#{base_key}_#{i}\"\n i += 1\n end\n key\n end",
"def interpolation_options\n { resource_name: @term.display_name }\n end",
"def to_interpolate(token, &block)\n Interpolation.to_interpolate(token, &block)\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def throw _args\n \"throw _args;\" \n end",
"def interpolate_slug\n interpolation = self.class.delivery_options_for(:slugability)\n ::Transit::Interpolations.interpolate(interpolation, self)\n end",
"def apphelp_unknown_quantity_warning\n \"<em>#{ apphelp_generic( :unknown ) }</em>\"\n end",
"def exception_renderer=(_arg0); end",
"def interpolate_property(property, context, parameters)\n raise InterpolationError.new(\"Cannot interpolate '#{property}' - it is already being interpolated\") if property.interpolating?\n begin\n property.started_interpolate\n interpolate(property.value, context, parameters)\n ensure\n property.finished_interpolate\n end\n end",
"def method_missing(sym, *args)\n puts \" *** missing #{sym} #{args.map { |x| x.inspect}.join(\", \")}\"\n end",
"def method_missing(sym, *args)\n puts \" *** missing #{sym} #{args.map { |x| x.inspect}.join(\", \")}\"\n end",
"def protect_parameter_missing\n yield\n rescue ActionController::ParameterMissing => e\n render_error(:bad_request, e)\n end",
"def build_paramstring\n raise 'not implemented'\n end",
"def exception\n case word\n when 'y' then ['ˈə'] * 2\n when 'yr' then ['ˈər'] * 2\n when 'til' then ['ˈtɪl'] * 2\n else nil\n end\n end",
"def format_arguments; end",
"def format=(_arg0); end",
"def format=(_arg0); end",
"def format=(_arg0); end",
"def format=(_arg0); end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def argument_not_found\n static_404_page\n end",
"def run_interp(text, environment)\n text.map do |r|\n next r if r.is_a?(String)\n val = r.perform(environment)\n # Interpolated strings should never render with quotes\n next val.value if val.is_a?(Sass::Script::String)\n val.to_s\n end.join.strip\n end",
"def format_arguments=(_arg0); end",
"def debug_exception_response_format=(_arg0); end",
"def debug_exception_response_format=(_arg0); end",
"def method_missing(missing, *args)\n candidates = methods_that_sound_like(missing.to_s)\n\n message = \"You called an undefined method: #{missing}\"\n\n unless candidates.empty?\n message += \"\\nDid you mean #{candidates.join(' or ')}?\"\n end\n\n raise NoMethodError.new(message)\n end",
"def interp_option(type)\n @configure_args << \"--enable-#{type}interp\"\n end",
"def method_missing(meth, *args, &block)\n return 'Unknown config value: ' + meth.to_s\n end",
"def printf_substitutor(config_key, value)\n arg_c = value.join.scan(/%/).length\n lambda do |*args|\n unless args.length == arg_c\n fail ArgumentError,\n \"Given #{args.length} args, but #{config_key} requires #{arg_c}\"\n end\n # Fill in the parameters\n result = value.map do |line|\n sprintf(line, *args.shift(line.scan(/%/).length))\n end\n preprocess_value(result)\n end\n end",
"def invalid_user_shot\n \"Please enter a valid coordinate:\\n> \"\n end",
"def command_missing(command, args)\n write \"No such command '#{command}'\"\n end",
"def raise_template_error_with message\n raise MissingTemplateError.new \"No template #{message} found.\"\n end"
] |
[
"0.6942147",
"0.6067322",
"0.5788349",
"0.5743582",
"0.57110333",
"0.5502603",
"0.53332263",
"0.52484816",
"0.51980627",
"0.51798755",
"0.517934",
"0.5028087",
"0.5028087",
"0.5021697",
"0.5018917",
"0.49953845",
"0.4950353",
"0.48989996",
"0.48874968",
"0.4886459",
"0.48814106",
"0.48614982",
"0.48456568",
"0.48249733",
"0.48244455",
"0.48244455",
"0.48244455",
"0.4819102",
"0.4817258",
"0.47943348",
"0.47905374",
"0.47270986",
"0.4724355",
"0.471411",
"0.47058383",
"0.47056988",
"0.46910435",
"0.46889946",
"0.46831137",
"0.4661321",
"0.46195105",
"0.46129405",
"0.46093264",
"0.4609254",
"0.4605547",
"0.4603751",
"0.46037027",
"0.46030116",
"0.4600478",
"0.45890263",
"0.4587337",
"0.4579916",
"0.45734483",
"0.45670027",
"0.45595327",
"0.45483905",
"0.45476335",
"0.45174837",
"0.44927657",
"0.4491534",
"0.44905224",
"0.44900593",
"0.4486804",
"0.44857642",
"0.44805798",
"0.44717696",
"0.44461185",
"0.4443429",
"0.44242665",
"0.44206533",
"0.44182202",
"0.4416082",
"0.44160593",
"0.4400576",
"0.43996847",
"0.43918163",
"0.43918163",
"0.43779144",
"0.437564",
"0.4372958",
"0.4369303",
"0.43657956",
"0.43657956",
"0.43657956",
"0.43657956",
"0.43620214",
"0.43620214",
"0.43620214",
"0.4353685",
"0.43458876",
"0.43391666",
"0.43319926",
"0.43319926",
"0.4330435",
"0.4322953",
"0.431591",
"0.4310652",
"0.43095785",
"0.43030676",
"0.4300156"
] |
0.51238894
|
11
|
Marks a key as reserved. Reserved keys are used internally, and can't also be used for interpolation. If you are using any extra keys as I18n options, you should call I18n.reserve_key before any I18n.translate (etc) calls are made. source://i18n//lib/i18n.rb45
|
def reserve_key(key); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deprecated_key=(_arg0); end",
"def reserve_for(key)\n reserves.fetch(key)\n end",
"def fill_key_name\n self.key_name = key_name&.parameterize(separator: '_')\n end",
"def ensure_valid_key( key )\n key.to_s.index( /\\./ ) ? key.to_s.gsub( /\\./, '_' ) : key\n end",
"def not_reserved\n errors.add(:name, 'is reserved') if self.name.downcase.in?(self.class.reserved_names)\n end",
"def prohibit(key)\n @status[key] = :prohibited\n end",
"def inc_miss(locale, key, options)\n if @misses[key]\n key_hash=@misses[key]\n else\n key_hash={}\n @misses[key]=key_hash\n end\n if (key_hash[locale])\n key_hash[locale]+=1\n else\n key_hash[locale]=1\n end\n end",
"def inc_miss(locale, key, options)\n if @misses[key]\n key_hash=@misses[key]\n else\n key_hash={}\n @misses[key]=key_hash\n end\n if (key_hash[locale])\n key_hash[locale]+=1\n else\n key_hash[locale]=1\n end\n end",
"def key=(new_key)\n @key = new_key\n end",
"def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end",
"def reserved; end",
"def i18n_set?(key, params = {})\n I18n.t key, params, :raise => true rescue false\n end",
"def require_keys(*p_valid_keys)\n l_missing_keys = []\n p_valid_keys.flatten!\n p_valid_keys.each do |k|\n l_missing_keys << k unless self.has_key?(k)\n end\n\n unless l_missing_keys.empty?\n raise ArgumentError.new(\"Missing required key(s): #{l_missing_keys.map(&:inspect).join(', ')}\")\n end\n\n end",
"def new_key(old_key)\n key_store[old_key] || old_key\n end",
"def clear_key(key)\n key = key.underscore.gsub(' ','_')\n key = key.gsub('%','percent').gsub(/[^a-zA-Z0-9_]/,'')\n end",
"def accept(visitor)\n visitor.visit_unquoted_key(self)\n end",
"def protect(key)\n @_protected << key.to_s\n end",
"def reserved=(_arg0); end",
"def invalid_key(system_key)\n fail InvalidSyntax, \"`#{system_key}` must be a String or a Symbol.\"\n end",
"def normalize_key(k)\n k.to_s.gsub('-', '_').gsub(INVALID_PATTERN, '').to_sym\n end",
"def reserved(words)\n lang_eval { @reserved = words }\n nil\n end",
"def enable(key)\n @status[key] = :prohibited\n end",
"def missing_keys; end",
"def validate_key!(key)\n unless key.is_a?(String) or key.is_a?(Symbol)\n raise SketchUpJSON::JSONEncodeError, \"This hash can not generate valid JSON\"\n end\n end",
"def kms_key= new_kms_key_name\n frozen_check!\n @gapi.kms_key_name = new_kms_key_name\n end",
"def reserve!\n memory_map.transform_values! { |_| RESERVED }\n end",
"def validate_keys(*valid_keys)\n valid_keys.flatten!\n @hash.each_key do |k|\n unless valid_keys.include?(k)\n raise ArgumentError.new(\"Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}\")\n end\n end\n end",
"def key=(key)\n key = key.to_s\n\n if registered?\n bibliography.entries.delete(@key)\n key = register(key)\n end\n\n @key = key\n rescue => e\n raise BibTeXError, \"failed to set key to #{key.inspect}: #{e.message}\"\n end",
"def prepare_key\n return item_in_use.prepare_key\n end",
"def prepare_key\n return item_in_use.prepare_key\n end",
"def handle_key(key); end",
"def missing_hash_key(key:, source_row:, node_id:)\n # nothing\n end",
"def allow(key)\n @status[key] = :allowed\n end",
"def missing_keys(route, parts); end",
"def key=(key); end",
"def localized(key, value = nil)\n self[key] = value if value\n\n case self[key]\n when NilClass then nil\n when Proc then instance_eval(&self[key])\n else _(self[key])\n end\n end",
"def escape_translation_key(key, scope=nil, separator=nil)\n scope ? \"#{scope}#{separator || I18n.default_separator}\\\"#{key}\\\"\" : \"\\\"#{key}\\\"\"\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def deny_encryption_using_incorrect_key_statement(\n bucket_name,\n kms_key_arn\n )\n {\n effect: 'Deny',\n principal: '*',\n action: 's3:PutObject',\n resource: \"arn:aws:s3:::#{bucket_name}/*\",\n condition: {\n 'StringNotEqualsIfExists' => {\n 's3:x-amz-server-side-encryption-aws-kms-key-id' => kms_key_arn\n }\n }\n }\n end",
"def add_key i18n_prj, input, select_from_translations\n v, quote = input.unquote\n\n if select_from_translations\n items = i18n_prj.potential_i18n_keys v\n if items.empty?\n TextMate::UI.tool_tip \"Can not find tranlation key\"\n else\n k = TextMate::UI.request_item \\\n :title => \"Select Translation Key\",\n :prompt => 'Select Translation Key',\n :items => items\n if !k\n TextMate::UI.tool_tip \"Canceled\"\n end\n end\n return input if !k\n else # new translation if needed\n v.gsub! '.', ''\n k = v[0..0].downcase + v[1..-1].underscore\n full_k = \"#{i18n_prj.key_prefix}.#{k}\"\n if i18n_prj.no_translation(full_k)\n new_k = TextMate::UI.request_string \\\n :default => full_k,\n :title => \"New Translation Key\"\n return input if new_k.nil? or new_k.empty?\n if new_k != full_k\n full_k = new_k\n k = new_k\n else\n k = '.' + k\n end\n insert_translation i18n_prj.en_yml_path, full_k, v\n else\n TextMate::UI.tool_tip \"Translation key '#{full_k}' exists\"\n k = '.' + k\n end\n end\n\n # snippet\n file_type = i18n_prj.file_type\n if quote or file_type == 'rb'\n %Q|t(#{k.inspect})|\n else\n case file_type\n when 'slim'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n when 'haml'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n else %Q|<%= t #{k.inspect} %>|\n end\n end\nend",
"def key(symbol, required: true, &block)\n keys << symbol unless @keys.include? symbol\n required_keys << symbol if required\n attr_accessor symbol\n defaults[symbol] = block if block\n end",
"def with_keys_disabled\n disable_keys\n yield\n enable_keys\n end",
"def to_key(key)\n return key if key.is_a? Symbol\n processed_key = nil\n unless key.nil?\n begin\n processed_key = key.to_s.to_sym\n rescue\n nil\n end\n end\n raise Deployment::InvalidArgument.new self, \"The value '#{key}' cannot be used as a concurrency name!\" unless processed_key\n processed_key\n end",
"def possible_keys(key); end",
"def nonheritable!(key)\n formatted_key = format_key(key)\n self.nonheritable_keys << formatted_key unless self.nonheritable_keys.include?(formatted_key)\n end",
"def prohibited?(key)\n @status[key] == :prohibited\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def key_replace\n /[^a-z0-9?]+/\n end",
"def key(arg = nil)\n set_or_return(:key,\n arg,\n kind_of: [String, NilClass],\n default: nil)\n end",
"def sanitize(key)\n # E.g. cur/1263444769.M975543P58179Q11.gnt.local:2,\n unless KEY_VALIDATORS.any?{|validator| key.match(validator) }\n content_type \"text/plain\"\n halt 403, \"Malformed key: #{key}\"\n end\n end",
"def treat_reserved_as_conflict; end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def treat_reserved_as_conflict=(_arg0); end",
"def confirm_newkeys; end",
"def key\n @key or raise MissingKey\n end",
"def with_keys_disabled\n disable_keys\n yield\n enable_keys\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def identifier_valid?(key)\n key = key.to_s\n ForbiddenChars.each_char do |char|\n return false if key.include?(char)\n end\n end",
"def format_key(key)\n key.to_s.gsub(\"-\",\"_\")\n end",
"def rekey_as_needed; end",
"def update_skip_key\n SceneManager.goto(Scene_Title) if Input.trigger?(TH::Splash_Screen_Map::Skip_Button)\n end",
"def encode_parameter(key)\n IGNORED_PARAMETERS.include?(key) ? \"_#{key}\".to_sym : key\n end",
"def create\n respond_with(@i18n_key = Gallifreyian::I18nKey.create(params[:i18n_key]),\n location: i18n_keys_path)\n end",
"def ignore_key?(key, ignore_type, locale = nil)\n key =~ ignore_pattern(ignore_type, locale)\n end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def check_key_valid\n @key_warning = false unless defined?(@key_warning)\n if !configuration.valid_api_key? && !@key_warning\n configuration.warn(\"No valid API key has been set, notifications will not be sent\")\n @key_warning = true\n end\n end",
"def resident_key=(_arg0); end",
"def key=(key)\n if (!key.kind_of?(String))\n raise ArgumentError, \"Expected String, but #{key.class} provided.\"\n end\n @key = key\n end",
"def allow_keys(keys)\n @allow_keys = keys\n end",
"def key=(_); end",
"def key=(_); end",
"def set_key_statement\n super\n end",
"def next_item_key=(next_item_key)\n if !next_item_key.nil? && next_item_key.to_s.length > 24\n fail ArgumentError, 'invalid value for \"next_item_key\", the character length must be smaller than or equal to 24.'\n end\n\n if !next_item_key.nil? && next_item_key.to_s.length < 1\n fail ArgumentError, 'invalid value for \"next_item_key\", the character length must be great than or equal to 1.'\n end\n\n @next_item_key = next_item_key\n end",
"def required key\n if !has?(key)\n $stderr.print self\n raise \"Key #{key} does not exist\"\n end\n self[key]\n end",
"def valid?(key)\n MENUS.keys.map(&:to_sym).include?(key.to_sym)\n end",
"def delete_key(key)\n end",
"def sanitize_key key\n key.gsub! '-', '_'\n key.gsub! ' ', ''\n key.gsub! ',', ''\n key.downcase!\n return key\n end",
"def upcase_keys!\n replace(upcase_keys)\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def set_key\n self.key = SecureRandom.urlsafe_base64(KEY_LENGTH)\n self.set_key if Url.exists?(key: self.key)\n end",
"def add_alias! key, to_key\n key = validate_new_key! key\n to_key = String(to_key).to_sym\n @defaults.delete key\n @validators[key] = to_key\n end",
"def in_key_of(in_key = nil)\n\t\t@key = in_key.instance_of?(String) ? Key[in_key] : in_key\n\t\tself\n\tend",
"def add_key(key)\n keys.add(key)\n end",
"def translate!(key, **options); end",
"def prepare_key(key, options)\n complete_key = key\n\n # if a scope is passed in options then build the full key\n complete_key = options[:scope].present? ? \"#{options[:scope].to_s}.#{complete_key}\" : complete_key\n\n # add the correct count suffix\n if options[:count].present? && options[:count] == 1\n complete_key = \"#{complete_key}.one\"\n elsif options[:count].present? && options[:count] != 1\n complete_key = \"#{complete_key}.other\"\n end\n complete_key\n end",
"def prepare_key(val)\n val.nil? ? val : val.to_s.downcase\n end",
"def transform_to_empty_key(key)\n (key.to_s << '/').to_sym\n end",
"def unprotect(key)\n @_protected.reject! { |e| e == key.to_s }\n end",
"def write_key(key, value)\n raise RuntimeError.new(\"write_key not implemented!\")\n end",
"def deny_keys(*keys)\r\n tmp = self.clone\r\n tmp.delete_if {|k,v| keys.include?(k) }\r\n tmp\r\n end",
"def initialize(opts = {})\n @reserved = opts[:reserved] || RESERVED\n end",
"def fast_assert_valid_keys(valid_keys)\n unknown_keys = keys - valid_keys\n raise(ArgumentError, \"Unknown key(s): #{unknown_keys.join(\", \")}\") unless unknown_keys.empty?\n end",
"def t(key, options = {})\n options[:raise] = true\n translate(key, options)\n end",
"def should_not_contain!(*keys, **options, &block)\n before_validation do\n JSONAPIonify::Continuation.new(**options).check(self) do\n keys += self.keys.select(&block) if block_given?\n invalid_keys = self.keys.map(&:to_sym) & keys.map(&:to_sym)\n if invalid_keys.present?\n invalid_keys.each do |key|\n warnings.add(key, 'is not permitted')\n end\n end\n end\n end\n end",
"def missing_keys_from(required_keys)\n required_keys.select{ |k| self.get(k).to_s.empty? }\n end",
"def request_next_item_key=(request_next_item_key)\n if !request_next_item_key.nil? && request_next_item_key.to_s.length > 24\n fail ArgumentError, 'invalid value for \"request_next_item_key\", the character length must be smaller than or equal to 24.'\n end\n\n if !request_next_item_key.nil? && request_next_item_key.to_s.length < 1\n fail ArgumentError, 'invalid value for \"request_next_item_key\", the character length must be great than or equal to 1.'\n end\n\n @request_next_item_key = request_next_item_key\n end",
"def unavailable!(reason = nil)\n if persisted? && reserved?\n raise Error, \"Cannot make a reserved identifier unavailable.\"\n end\n if unavailable? and reason.nil?\n return\n end\n value = Status::UNAVAILABLE\n if reason\n value += \" | #{reason}\"\n end\n self.status = value\n end",
"def add_key(arg)\n \"key=#{arg.to_json}\"\n end"
] |
[
"0.57092774",
"0.5637886",
"0.5629352",
"0.55948514",
"0.5532422",
"0.5491892",
"0.54411393",
"0.54411393",
"0.54227424",
"0.5416488",
"0.5406671",
"0.5398595",
"0.5373242",
"0.53245187",
"0.5323265",
"0.53149354",
"0.5314035",
"0.5307312",
"0.52914375",
"0.52865493",
"0.5264092",
"0.5241704",
"0.523557",
"0.518526",
"0.5168011",
"0.5134959",
"0.51343894",
"0.50948006",
"0.5084127",
"0.5084127",
"0.5082478",
"0.5080673",
"0.5072524",
"0.50699735",
"0.502848",
"0.5025967",
"0.5020226",
"0.5016068",
"0.5014799",
"0.5010124",
"0.50093085",
"0.50037575",
"0.49999177",
"0.49948892",
"0.49947414",
"0.4991371",
"0.49907225",
"0.49867895",
"0.49867895",
"0.49845752",
"0.49694934",
"0.49686038",
"0.49668503",
"0.49648204",
"0.49529973",
"0.49515158",
"0.49402273",
"0.4935161",
"0.4930295",
"0.49238303",
"0.49106085",
"0.49079636",
"0.48990518",
"0.4897418",
"0.48878092",
"0.48842692",
"0.48812988",
"0.48776734",
"0.48754537",
"0.4873487",
"0.4870385",
"0.48695648",
"0.48695648",
"0.48644572",
"0.48631775",
"0.48608243",
"0.48603094",
"0.48588195",
"0.48500916",
"0.48439297",
"0.48385483",
"0.4837837",
"0.48345843",
"0.483068",
"0.48286527",
"0.48278165",
"0.48271143",
"0.48217002",
"0.48135588",
"0.48128754",
"0.4810828",
"0.48093867",
"0.4808436",
"0.4807011",
"0.48059526",
"0.47893876",
"0.478393",
"0.47802207",
"0.47800407",
"0.47787127"
] |
0.68313456
|
0
|
Accepts a list of paths to translation files. Loads translations from plain Ruby (.rb), YAML files (.yml), or JSON files (.json). See load_rb, load_yml, and load_json for details. source://i18n//lib/i18n/backend/base.rb14
|
def load_translations(*filenames); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_translations_and_collect_file_errors(files); end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_files(*files)\n dsl = DSL.new(self)\n files.each do |file|\n next unless File.file?(file) # TODO: warn ?\n #begin\n dsl.instance_eval(File.read(file), file)\n #rescue => e\n # raise e if $DEBUG\n # warn e.message\n #end\n end\n end",
"def load(files = T.unsafe(nil), reparse = T.unsafe(nil)); end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def load!(files)\n raise NoConfigFiles if !files || files.empty?\n files.each do |path|\n load path if File.readable?(File.expand_path(path))\n end\n end",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load_files(*sources); end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def load(*files)\n files.map { |f|\n evaluate(File.read(f).gsub(/\\A#!.*$/, ''), f, 1)\n }.last\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load_files(*file_paths)\n files = (site_configs + file_paths).map { |f| Pathname.new(f) }\n\n # Keep only files that exist.\n files.select!(&:file?)\n\n # Load the YAML files into Hashes.\n configs = files.map { |file| YAML.safe_load(file.read) }\n\n # Apply configs.\n load(*configs)\n end",
"def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end",
"def load(path); end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_tasks(tasks)\n load File.join(File.dirname(__FILE__), 'tasks', \"#{tasks}.rb\")\nend",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def load(path_or_io)\n case path_or_io\n when String, Pathname\n path = Pathname.new(path_or_io)\n path = path.join('*.{yaml,yml}') if path.directory?\n\n Dir.glob(path).each { |f| load(File.new(f)) }\n else\n update(YAML.load(path_or_io))\n end\n end",
"def load_yml(filename); end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def load_yaml_files(path)\n each_data_file(path).map { |file| YAML.load_file(file) }\n end",
"def load(file_path); end",
"def load(file_path); end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end",
"def import(*files)\r\n require \"models/user_task\"\r\n require \"models/log_record\"\r\n require \"timeout\"\r\n establish! do\r\n unless( files.empty? )\r\n files.each do |file|\r\n puts \"Loading %s\" % file\r\n File.open(file, \"r:utf-8\") do |stream|\r\n import_from stream\r\n end\r\n end\r\n else\r\n begin\r\n require \"stringio\"\r\n str = Timeout::timeout(10) {\r\n $stdin.set_encoding(\"utf-8\")\r\n $stdin.read # read as utf-8, ensured by top of this file comments\r\n }\r\n puts \"Loading from stdin\"\r\n import_from StringIO.new(str,\"r:utf-8\")\r\n rescue Timeout::Error\r\n raise \"You should specify several import file\"\r\n end\r\n end\r\n end\r\n end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\" if Bolt.verbose?\n end\n # puts candidates.inspect\n candidates\n end",
"def add(*files)\n # due to the multi passing of splat args, we can get Array-in-Array situations here\n files.flatten.each do |fn|\n @files.push(fn)\n if ! File.exists?(fn)\n next if self.class.skipmissing\n raise ArgumentError, \"file #{fn} does not exist\"\n end\n begin\n data = YAML.load(File.open(fn))\n if ! data.instance_of?(Hash)\n raise ArgumentError, \"file #{fn} does not contain a Hash\"\n end\n @cfg.deep_merge!(data.deep_symbolize_keys).deep_symbolize_keys\n rescue\n if ! self.class.skipbad\n raise\n end\n end\n end\n\n # resolve templates\n if self.class.templates\n resolve_templates\n end\n end",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\"\n end\n # puts candidates.inspect\n candidates\n end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def run\n @files.each { |filename| load(filename) }\n end",
"def load_yaml_files\n @room_list = YAML.load_file(__dir__ + '/rooms.yml')\n @weapon_list = YAML.load_file(__dir__ + '/weapons.yml')\n @enemy_list = YAML.load_file(__dir__ + '/enemy.yml')\n @high_score_list = YAML.load_file(__dir__ + '/high_score.yml')\n end",
"def load_resources(path, ids)\n ids.map do |id|\n resource = load_resource \"#{path}/#{id}\"\n resource = yield id, resource if block_given?\n resource\n end\n end",
"def load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if !@loaded_paths.include?( expanded_path ) && File.exists?( expanded_path )\n $CLASSPATH << expanded_path\n load_paths << expanded_path\n @loaded_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def load\n @models = []\n\n # \n files = \n if File.directory?(config_path) \n files_in_dir = []\n Dir[config_path + \"/*.yml\"].each do |file|\n files_in_dir << file\n end\n files_in_dir\n elsif File.file?(config_path)\n [config_path]\n else\n nil\n end\n\n return nil if files.nil?\n\n # \n @models = files.inject(@models) do |models, file|\n begin\n yaml = YAML.load_file(file)\n rescue => ex\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n if yaml.nil?\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n models + yaml2models(yaml)\n end.extend(ArrayMethods)\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def loadFiles( reload = false )\n\t\t\t\tfiles().each do |file|\n\t\t\t\t\tfile.load( reload )\n\t\t\t\tend\n\t\t\tend",
"def load(*globs)\n skips = globs.grep(/^-/)\n (globs - skips).each do |glob|\n glob += '.rb' if glob =~ /\\*$/\n Dir.glob(glob).sort.each do |path|\n next unless File.file? path\n next if skips.find {|pat| path =~ /#{pat[1..-1]}$/}\n instance_eval(File.read(path), path)\n end\n end\n end",
"def initialize files=nil\n self.class.load_files files.to_a.concat(DEFAULT_TASK_FILES)\n end",
"def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end",
"def load_resources\n resource_path = File.join(File.dirname(__FILE__), \"resources\")\n Similar.load_all_ruby_files_from_path(resource_path)\n end",
"def load_ruby_files(directory = '.')\n print \"Loading ruby files...\\n\\n\"\n files = `find #{directory} -type f -name '*.rb'`\n files.split(/\\s+/).each do |f|\n begin\n load File.expand_path(f)\n rescue Exception => e\n puts \"failed loading '#{f[/\\b[\\-\\w]+\\/.*rb$/]}': #{e}\"\n end\n end\n puts \"Done\"\nend",
"def load_file(filename); end",
"def load_file(filename); end",
"def load_file(file); end",
"def import\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_import_file_given')) and return unless params[:importfile].present?\n filename = params[:importfile].original_filename\n extension = filename.sub(/.*\\./, '')\n if extension == 'yml'\n hash = YAML.load_file(params[:importfile].tempfile.path) rescue nil\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.cannot_parse_yaml')) and return unless hash\n CouchbaseI18n.traverse_flatten_keys(hash).each do |key, value|\n existing = CouchbaseI18n::Translation.find_by_translation_key(key)\n if existing\n if existing.translation_value != value\n existing.translation_value = value\n existing.translated = true\n existing.save\n end\n else\n CouchbaseI18n::Translation.create :translation_key => key, :translation_value => value\n end\n end \n else\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_proper_import_extension', :extension => extension)) and return \n end\n redirect_to({:action => :index, :offset => params[:offset]}, :notice => I18n.t('couchbase_i18n.translation.file_imported', :filename => filename))\n end",
"def eval_scripts(*files)\n files.flatten.each do |file|\n self.instance_eval File.open(file).read\n end\n end",
"def yaml(*files, **options, &block) = read(*files, parse: :yaml, ext: ['.yml', '.yaml'], **options, &block)",
"def load_strings(strings_filename)\n return [{}, {}]\n end",
"def l(*args); I18n.l(*args) end",
"def parse_strings(toolname=nil, locale=\"en\", dir=nil)\n toolname = \"\" if toolname.nil?\n raise(ArgumentError, \"Argument 'toolname' needs to be a String\") unless toolname.is_a?(String)\n raise(ArgumentError, \"Argument 'locale' needs to be a String\") unless locale.is_a?(String)\n raise(ArgumentError, \"Argument 'dir' needs to be a String\") unless dir.is_a?(String) || dir.nil?\n dir = File.dirname(File.expand_path(__FILE__)) if dir.nil? || !File.exists?(dir.to_s)\n language = locale[/^[^\\-]+/]\n extensions = [\"strings\", \"lingvo\", \"rb\"]\n\n available_files = Dir.entries(dir).find_all{ |f|\n File.basename(f)[/(^|#{toolname}[^a-zA-Z]?)#{locale}\\.(#{extensions.join('|')})/i]\n }.concat(Dir.entries(dir).find_all{|f|\n File.basename(f)[/(^|#{toolname}[^a-zA-Z]?)#{language}(-\\w{2,3})?\\.(#{extensions.join('|')})/i]\n })\n return if available_files.empty?\n path = File.join(dir, available_files.first)\n format = File.extname(path)[/[^\\.]+/]\n strings = {}\n File.open(path, \"r\"){ |file|\n # load .rb format\n if format == \"rb\"\n strings = eval(file.read)\n # parse .strings or .lingvo format\n else\n entry = \"\"\n inComment = false\n file.each{ |line|\n if !line.include?(\"//\")\n if line.include?(\"/*\")\n inComment = true\n end\n if inComment==true\n if line.include?(\"*/\")\n inComment=false\n end\n else\n entry += line\n end\n end\n if format == \"strings\" && entry.include?(\";\") || format == \"lingvo\" && !entry.empty?\n keyvalue = entry.strip.gsub(/^\\s*\\\"|\\\"\\s*;$/, \"\").split(/\\\"\\s*=\\s*\\\"|\\s*<==>\\s*/)\n entry = \"\"\n next unless keyvalue.length == 2\n key = keyvalue[0].gsub(/\\\\\\\"/,'\"').gsub(/\\\\\\\\/, \"\\\\\")\n value = keyvalue[1].gsub(/\\\\\\\"/,'\"').gsub(/\\\\\\\\/, \"\\\\\")\n strings[key] = value\n end\n }\n end # if format\n }\n\n @strings.merge!(strings)\n return (strings.empty?)? false : true\n end",
"def load(file); end",
"def load_library(path)\n data = YAML.load_file(path)\n # maps the data to their proper language despcriptions\n data.map do |key, value|\n data[key] = { english: value[0], japanese: value[1] }\n end\n data\nend",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def read_languages_from_file(data_file)\n File.open(data_file, 'rb') do |fin|\n until fin.eof\n label, outputs = Marshal.load(fin)\n yield label, outputs\n end\n end\nend",
"def import_translations(path, page)\n old_translations = page.translations.pluck(:locale)\n new_translations = []\n\n Dir[\"#{path}content.*.html\"].each do |file_path|\n locale = File.basename(file_path).match(%r{content\\.(\\w+)\\.html})[1]\n new_translations << locale\n\n translation = page.translations.where(locale: locale).first_or_initialize\n\n next unless fresh_seed?(translation, file_path)\n\n # reading file content in, resulting in a hash\n fragments_hash = parse_file_content(file_path)\n\n # parsing attributes section\n attributes_yaml = fragments_hash.delete(\"attributes\")\n attrs = YAML.safe_load(attributes_yaml)\n\n # applying attributes\n layout = site.layouts.find_by(identifier: attrs.delete(\"layout\")) || page.try(:layout)\n translation.attributes = attrs.merge(\n layout: layout\n )\n\n # applying fragments\n old_frag_identifiers = translation.fragments.pluck(:identifier)\n\n new_frag_identifiers, fragments_attributes =\n construct_fragments_attributes(fragments_hash, translation, path)\n translation.fragments_attributes = fragments_attributes\n\n if translation.save\n message = \"[CMS SEEDS] Imported Translation \\t #{locale}\"\n ComfortableMexicanSofa.logger.info(message)\n\n # cleaning up old fragments\n frags_to_remove = old_frag_identifiers - new_frag_identifiers\n translation.fragments.where(identifier: frags_to_remove).destroy_all\n\n else\n message = \"[CMS SEEDS] Failed to import Translation \\n#{locale}\"\n ComfortableMexicanSofa.logger.warn(message)\n end\n end\n\n # Cleaning up removed translations\n translations_to_remove = old_translations - new_translations\n page.translations.where(locale: translations_to_remove).destroy_all\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def load_data_infile_multiple(files, options = {})\n files.each do |file|\n load_data_infile(file, options)\n end\n end",
"def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end",
"def load(filename)\n end",
"def load_from_filesystem(options)\n return if options[:skip_metadata]\n\n # Load localised data\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n language = File.basename(lang_folder)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n path = File.join(lang_folder, \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= {}\n options[key][language] ||= File.read(path)\n end\n end\n\n # Load non localised data\n (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key|\n path = File.join(options[:metadata_path], \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= File.read(path)\n end\n\n # Load trade representative contact information\n options[:trade_representative_contact_information] ||= {}\n TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:trade_representative_contact_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:trade_representative_contact_information][option_name] ||= File.read(path)\n end\n\n # Load review information\n options[:app_review_information] ||= {}\n REVIEW_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:app_review_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:app_review_information][option_name] ||= File.read(path)\n end\n end",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end",
"def load(*args)\n @core.load(*args)\n end",
"def i18n\n %w(en es).each do |locale|\n copy_file \"i18n.#{ locale }.yml\", \"config/locales/seo_landing_pages.#{ locale }.yml\"\n end\n end",
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def initialize(*paths)\n @configuration = {}\n paths.each { |f| load f }\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def require_files\n @load_paths.each do |path|\n Dir[\"#{path}/**/*\"].each do |f|\n require f\n end\n end\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def import\n read_dict_file(:langA)\n write_database(:langA)\n\n read_dict_file(:langB)\n write_database(:langB)\n end",
"def load_files(filename)\n filename_domain = filename.sub('.yai', '.yad')\n\n content = ''\n content << load_file_to_content(filename_domain)\n content << load_file_to_content(filename)\n end",
"def create_locale_files\n @i18n_scope = model.i18n_scope.to_s\n @i18n_key = model.model_name.i18n_key.to_s\n @columns = model.column_names\n\n options[:locales].each do |locale|\n @locale = locale\n locale_file = File.join(\n 'config/locales/models', model_name.underscore, \"#{@locale}.yml\"\n )\n template 'locale.yml', locale_file\n end\n rescue NameError\n puts \"#{model_name} is undefined.\"\n end",
"def load_source\n case File.extname(config[:source])\n when '.json'\n Yajl.load(File.open(config[:source]))\n when '.yml'\n YAML.load(File.open(config[:source]))\n else\n raise 'unknown source file extension'\n end\n end"
] |
[
"0.8155875",
"0.8110001",
"0.7122936",
"0.70008355",
"0.69906133",
"0.6961666",
"0.6930811",
"0.6836793",
"0.6796501",
"0.6796501",
"0.6506182",
"0.6363883",
"0.632046",
"0.6258818",
"0.6198518",
"0.61548525",
"0.6090957",
"0.60649735",
"0.60345614",
"0.5994245",
"0.59636754",
"0.59636754",
"0.5935419",
"0.59318876",
"0.5914708",
"0.5902269",
"0.588048",
"0.5864241",
"0.5849305",
"0.580084",
"0.5780559",
"0.5777729",
"0.5773787",
"0.5765097",
"0.575227",
"0.5740475",
"0.57404023",
"0.5727249",
"0.5716601",
"0.57114935",
"0.5711422",
"0.5696503",
"0.5693791",
"0.5678091",
"0.5678091",
"0.56699425",
"0.563363",
"0.5565801",
"0.5552564",
"0.5538623",
"0.55315495",
"0.5525941",
"0.551355",
"0.5494787",
"0.54925346",
"0.548731",
"0.54784757",
"0.54617405",
"0.5460196",
"0.5456916",
"0.5438881",
"0.54363024",
"0.5429747",
"0.541528",
"0.5413396",
"0.5401799",
"0.5397669",
"0.53954613",
"0.53954613",
"0.5392605",
"0.5369297",
"0.53676105",
"0.53673536",
"0.53563136",
"0.5355949",
"0.5352119",
"0.5335676",
"0.5328276",
"0.5308963",
"0.5299646",
"0.52798647",
"0.5278947",
"0.5275079",
"0.52709174",
"0.5257861",
"0.5246075",
"0.52441376",
"0.5242084",
"0.52370924",
"0.5231115",
"0.52296495",
"0.5229248",
"0.52161944",
"0.521594",
"0.52057093",
"0.52023154",
"0.518727",
"0.5169411",
"0.51639885"
] |
0.8322083
|
1
|
Evaluates defaults. If given subject is an Array, it walks the array and returns the first translation that can be resolved. Otherwise it tries to resolve the translation directly. source://i18n//lib/i18n/backend/base.rb125
|
def default(locale, object, subject, options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\n result = resolve(locale, object, item, options) #and return result\n result = lookup(locale, result, options[:scope], options)\n return result if result.is_a?(String)\n return result = resolve(locale, object, item, options) if item == subject.last\n end and nil\n else\n resolve(locale, object, subject, options)\n end\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def resolve(locale, object, subject, options = T.unsafe(nil)); end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end",
"def extract_value_from_default(default)\n case default\n # Array elements\n when /\\AARRAY\\[(.*)\\]\\z/\n # TODO: Improve this since it's not the most safe approach\n eval(default.gsub(/ARRAY|::\\w+(\\[\\])?/, ''))\n else\n super\n end\n rescue SyntaxError\n # If somethin goes wrong with the eval, just return nil\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def find_first_valid_translation_for_translator(language, translator, token_values)\n translation = find_first_valid_translation(language, token_values)\n return [language, translation] if translation\n \n if translator.fallback_language and not translator.fallback_language.default?\n return find_first_valid_translation_for_language(translator.fallback_language, token_values)\n end\n\n [language, nil]\n end",
"def use_and_copy_default_locale_translations_if_they_exist(locale, key)\n default_locale_entry = lookup(Locale.default_locale, key)\n return unless default_locale_entry\n\n if default_locale_entry.is_a?(Array)\n default_locale_entry.each_with_index do |entry, index|\n locale.create_translation(key, nil, index) if entry\n end\n else\n locale.create_translation(key, nil) \n end\n\n return default_locale_entry\n end",
"def find_first_valid_translation_for_language(language, token_values)\n translation = find_first_valid_translation(language, token_values)\n return [language, translation] if translation\n\n if Tr8n::Config.enable_fallback_languages?\n # recursevily go into the fallback language and look there\n # no need to go to the default language - there obviously won't be any translations for it\n # unless you really won't to keep the keys in the text, and translate the default language\n if language.fallback_language and not language.fallback_language.default?\n return find_first_valid_translation_for_language(language.fallback_language, token_values)\n end\n end \n \n [language, nil]\n end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def pt( *args )\n translation = ft[ name ]\n args.empty? ? translation : translation[ *args, self ]\n end",
"def process_subjects(subjects_arr)\n return_arr = []\n subjects_arr.each do |subject|\n unless subject['_resolved'].blank?\n return_arr.push(subject['_resolved'])\n end\n end\n return_arr\n end",
"def langprop(*values)\n values.inject(self) { |res, val| res._langprop(val) or fail ArgumentError, \"Unknown value for langprop: #{val}\" }\n end",
"def translate(settings); end",
"def translate(klass, key, value)\n if defined?(I18n)\n super\n else\n value ? value.to_s.humanize.downcase : 'nil'\n end\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def human(options = {})\n return @human if i18n_keys.empty? || i18n_scope.empty?\n\n key, *defaults = i18n_keys\n defaults << options[:default] if options[:default]\n defaults << MISSING_TRANSLATION\n\n translation = I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)\n translation = @human if translation == MISSING_TRANSLATION\n translation\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def translate(*args, **opts); end",
"def suitable_locale_text(texts)\n english = texts.select { |t| english_locales.include? t[\"locale\"] }\n (english + texts).first[\"text\"]\n end",
"def lookup_chain = locale(true).lookup",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def deep_compile(locale, subject, options)\n if subject.is_a?(Hash)\n subject.each do |key, object|\n subject[key], _had_to_compile_result = deep_compile(locale, object, options)\n end\n else\n compile(locale, subject, options)\n end\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def translate!(key, **options); end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def subject_for(template, attributes = {})\n subject = EmailTemplate.subject_for(template)\n subject = I18n.t(\"email_templates.#{template}.default_subject\") if subject.nil?\n subject = \"No Subject\" if subject.nil?\n Florrick.convert(subject, add_default_attributes(attributes))\n end",
"def ft( *args )\n fail \"You need to set the locale with R18n.set('en') or similar. No locale, no helper. Sorry.\" unless r18n\n translation = t.forms[ self.class.translation_name ]\n args.empty? ? translation : translation[ *args ]\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.context.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.context || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.context\n valid_translations << {:label => translation.label, :context => translation.context.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.rules_hash.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.rules_hash || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.rules_definitions\n valid_translations << {:label => translation.label, :context => translation.rules_definitions.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def get_attribute(attribute, lang, fallback)\n translation = translations.find {|t| t['locale'] == lang }\n translation = translations.find_by(locale: lang) unless translation\n\n # return previously setted attributes if present\n return translation[attribute] if translation\n return if new_record? || !fallback\n\n # Lookup chain:\n # if translation not present in current locale,\n # use default locale, if present.\n # Otherwise use first translation\n translation = translations.detect { |t| t.locale.to_sym == lang && t[attribute] } ||\n translations.detect { |t| t.locale.to_sym == puret_default_locale && t[attribute] } ||\n translations.first\n\n translation ? translation[attribute] : nil\n end",
"def init_translations; end",
"def translate(message)\n @messages[message] || message\n end",
"def inject_i18n_translations(params, required_params)\n reject_unnecessary_i18n_params!(params, required_params)\n required_params_to_check = required_params\n return unless required_params_to_check\n\n required_params_to_check.each do |required_param|\n if required_param.to_s =~ /i18n_(.+)/\n params[required_param] ||= I18nRoutable.translate_segment($1, params[:locale])\n end\n end\n end",
"def t(*values)\n self.class::translate(self) % values\n end",
"def find_template(subject)\n properties = @graph.properties(subject)\n types = (properties[RDF.type.to_s] || [])\n \n matched_templates = []\n \n (1..types.length).each do |len|\n types.combination(len) do |set|\n templ = @options[:haml] && @options[:haml][set]\n templ ||= haml_template[set]\n if len == 1\n templ ||= @options[:haml] && @options[:haml][set.first]\n templ ||= haml_template[set.first]\n end\n\n add_debug \"find_template: look for #{set.inspect}\"\n add_debug \"find_template: look for #{set.first.inspect}\" if len == 1\n\n # Look for regular expression match\n templ ||= if len == 1\n key = haml_template.keys.detect {|k| k.is_a?(Regexp) && set.first.to_s.match(k)}\n haml_template[key]\n end\n\n next unless templ\n \n matched_templates[len] ||= []\n matched_templates[len] << templ\n end\n end\n\n if matched_templates.empty?\n add_debug \"find_template: no template found for any #{types.inspect}\"\n return nil\n end\n \n list = matched_templates.last\n \n # Order the list of templates by priority\n list = list.sort_by {|templ| templ[:priority] || 99}\n \n # Choose the lowest priority template found\n templ = list.first\n\n add_debug \"find_template: found #{templ[:identifier] || templ.inspect}\"\n\n @options[:matched_templates] << templ[:identifier]\n \n templ\n end",
"def find_template(subject)\n properties = @graph.properties(subject)\n types = (properties[RDF.type.to_s] || [])\n \n matched_templates = []\n \n (1..types.length).each do |len|\n types.combination(len) do |set|\n templ = @options[:haml] && @options[:haml][set]\n templ ||= haml_template[set]\n if len == 1\n templ ||= @options[:haml] && @options[:haml][set.first]\n templ ||= haml_template[set.first]\n end\n\n #log_debug \"find_template: look for #{set.inspect}\"\n\n # Look for regular expression match\n templ ||= if len == 1\n key = haml_template.keys.detect {|k| k.is_a?(Regexp) && set.first.to_s.match(k)}\n haml_template[key]\n end\n\n next unless templ\n \n matched_templates[len] ||= []\n matched_templates[len] << templ\n end\n end\n\n if matched_templates.empty?\n log_debug \"find_template: no template found for any #{types.inspect}\"\n return nil\n end\n \n list = matched_templates.last\n \n # Order the list of templates by priority\n list = list.sort_by {|templ| templ[:priority] || 99}\n \n # Choose the lowest priority template found\n templ = list.first\n\n log_debug \"find_template: found #{templ[:identifier] || templ.inspect}\"\n\n @options[:matched_templates] << templ[:identifier]\n \n templ\n end",
"def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def translate_value(args)\n code = get_field_val(args)\n translate_lang_code(code)\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def messages(message, lang = LANGUAGE)\n MESSAGES[lang][message]\nend",
"def translate_with_namespace(namespace, arg = nil, default = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def handle_subjects(subjects)\n subjects.each do |link|\n subject = link['_resolved']\n term, *terms = subject['terms']\n ind1 = ' '\n code, *ind2 = case term['term_type']\n when 'uniform_title'\n value = term['term'].split(\" \")[0]\n first_indicator = '0'\n if value\n hsh = {}\n hsh['A'] = '2'\n hsh['An'] = '3'\n hsh['The'] = '4'\n articles = []\n articles = hsh.keys\n first_indicator = hsh[value] if articles.include?(value)\n end\n ['630', first_indicator, source_to_code(subject['source'])]\n when 'temporal'\n ['648', source_to_code(subject['source'])]\n when 'topical'\n ['650', source_to_code(subject['source'])]\n when 'geographic', 'cultural_context'\n ['651', source_to_code(subject['source'])]\n when 'genre_form', 'style_period'\n ['655', source_to_code(subject['source'])]\n when 'occupation'\n ['656', '7']\n when 'function'\n ['656', '7']\n else\n ['650', source_to_code(subject['source'])]\n end\n\n sfs = [['a', term['term']]]\n\n terms.each do |t|\n tag = case t['term_type']\n when 'uniform_title'; 't'\n when 'genre_form', 'style_period'; 'v'\n when 'topical', 'cultural_context'; 'x'\n when 'temporal'; 'y'\n when 'geographic'; 'z'\n end\n sfs << [tag, t['term']]\n end\n\n # code borrowed from Yale to export subject authority id\n unless subject['authority_id'].nil?\n sfs << ['0', subject['authority_id']]\n end\n\n \n # N.B. ind2 is an array at this point.\n if ind2[0] == '7'\n sfs << ['2', subject['source']]\n end\n\n # adding this code snippet because I'm making ind2 an array\n # for code 630 if the title begins with an article\n if (ind2.is_a?(Array) && code == '630')\n ind1, ind2 = ind2\n else\n ind2 = ind2[0]\n end\n\n df!(code, ind1, ind2).with_sfs(*sfs)\n end\n end",
"def subject_all_search\n vals = topic_search ? Array.new(topic_search) : []\n vals.concat(geographic_search) if geographic_search\n vals.concat(subject_other_search) if subject_other_search\n vals.concat(subject_other_subvy_search) if subject_other_subvy_search\n vals.empty? ? nil : vals\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def translate!(text, *languages)\n languages = Translations.keys unless languages.any?\n languages = languages.flatten.map!(&:to_sym)\n languages.delete :en # remove :en translation from everywhere\n languages.push :en # to push it as the last one\n languages.each do |lang|\n Translations[lang] && Translations[lang].call(text)\n end\n text\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def translated_msg(translate, message, src_lang, target_lang)\n return message unless translate \n use_src = nil \n if (src_lang.nil? || src_lang.empty?)\n # We don't need to infer again and again\n begin\n @inferred_src_lang ||= infer_languages.first\n rescue StandardError => e \n raise LangDetectionFailureException.new(\"Failed to infer language due to #{e.message}\")\n end\n use_src = @inferred_src_lang\n else\n use_src = src_lang\n end\n return message if use_src.eql?(target_lang)\n @translator.translate(message, use_src, target_lang)\n end",
"def choose_subject(action, params = {})\n scope = [:mailers, mailer_name, action]\n key = :subject\n experiment_name = \"#{mailer_name}_mailer_#{action}_subject\".to_sym\n if experiment_active?(experiment_name)\n scope << key\n key = ab_test(experiment_name)\n end\n params.merge!(scope: scope)\n I18n.t(key, params)\n end",
"def call(*available_langtags)\n available_langtags = drop_unacceptable(*available_langtags)\n\n preferred_langtags.each do |preferred_tag|\n if wildcard?(preferred_tag)\n langtag = any_other_langtag(*available_langtags)\n return langtag unless langtag.nil?\n else\n available_langtags.each do |available_langtag|\n return available_langtag if available_langtag.match?(/\\A#{preferred_tag}/i)\n end\n end\n end\n\n nil\n end",
"def default\n defaults = {}\n @rules.each {|rule| rule.complete_defaults(defaults)}\n defaults\n end",
"def upsert(locale, key, value) # rubocop:disable Metrics/MethodLength\n I18n.with_locale(locale) do\n # when an array has to be inserted with a default value, it needs to\n # be done like:\n # I18n.t('foo', default: [['bar', 'baz']])\n # because without the double array, array items are treated as fallback keys\n # - then, the last array element is the final fallback; so in this case we\n # don't specify fallback keys and only specify the final fallback, which\n # is the array\n val = value.is_a?(Array) ? [value] : value\n I18n.t(key, default: val)\n\n # this indicates that this translation already exists\n existing_translation =\n Lit::Localization.joins(:locale, :localization_key)\n .find_by('localization_key = ? and locale = ?', key, locale)\n\n return unless existing_translation\n\n if @raw\n existing_translation.update(default_value: value)\n else\n existing_translation.update(translated_value: value, is_changed: true)\n lkey = existing_translation.localization_key\n lkey.update(is_deleted: false) if lkey.is_deleted\n end\n end\n end",
"def subjectify(options = {})\n result = []\n all_subjects = []\n sub_array = []\n options[:value].each_with_index do |subject, i|\n spl_sub = subject.split(QUERYSEP)\n sub_array << []\n subject_accum = ''\n spl_sub.each_with_index do |subsubject, j|\n spl_sub[j] = subject_accum + subsubject\n subject_accum = spl_sub[j] + QUERYSEP\n sub_array[i] << spl_sub[j]\n end\n all_subjects[i] = subject.split(QUERYSEP)\n end\n options[:value].each_with_index do |_subject, i|\n lnk = ''\n lnk_accum = ''\n all_subjects[i].each_with_index do |subsubject, j|\n lnk = lnk_accum + link_to(subsubject,\n \"/?f[subject_facet][]=#{CGI.escape sub_array[i][j]}\",\n class: 'search-subject', title: \"Search: #{sub_array[i][j]}\")\n lnk_accum = lnk + content_tag(:span, SEPARATOR, class: 'subject-level')\n end\n result << sanitize(lnk)\n end\n result\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def solrize\n return [rdf_subject.to_s] unless label_present\n [rdf_subject.to_s, { label: \"#{preferred_label}$#{rdf_subject}\" }]\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def resolve_lexically(resolver, val, ctx)\n case val\n when Hash\n new = {}\n\n val.each do |k, v|\n new[k] = resolve_lexically(resolver, v, [val] + ctx)\n end\n\n new\n when Array\n val.collect do |v|\n resolve_lexically(resolver, v, ctx)\n end\n when String\n val.gsub(/\\$\\{([^\\}]+)\\}/) do\n resolve_symbol(resolver, $1, ctx)\n end\n else\n val\n end\n end",
"def select_value_for_compare(entry, condition)\n condition.each_locale_fallback do |cond|\n # The condition's path tells us where to find the value in the JSON object\n val = entry.dig(*cond.path)\n\n # If the object has no value for this locale, try the fallbacks\n next if val.nil?\n\n # The object has a value for this locale, so we must compare against it and not the fallbacks\n return val\n end\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def lang=(_arg0); end",
"def lang=(_arg0); end",
"def subject_string_by_index(index)\n\t\tcase index\n\t\t\twhen 0\n\t\t\t\treturn \"ma\"\n\t\t\twhen 1\n\t\t\t\treturn \"sc\"\n\t\t\twhen 2\n\t\t\t\treturn \"ss\"\n\t\t\twhen 3\n\t\t\t\treturn \"la\"\n\t\t\twhen 4\n\t\t\t\treturn \"fl\"\n\t\t\twhen 5\n\t\t\t\treturn \"mu\"\n\t\t\twhen 6\n\t\t\t\treturn \"pe\"\n\t\t\twhen 7\n\t\t\t\treturn \"he\"\n\t\t\twhen 8\n\t\t\t\treturn \"da\"\n\t\t\twhen 9\n\t\t\t\treturn \"va\"\n\t\t\twhen 10\n\t\t\t\treturn \"se\"\n\t\t\twhen 11\n\t\t\t\treturn \"te\"\n\t\tend\n\t\t#otherwise\n\t\treturn \"Invalid subject index!\"\n\tend",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end",
"def translator_for(t_key, template = nil, parameters = nil)\n o_translator = translators[t_key]\n if template\n translator = Translator.new(template,\n :parameters => parameters)\n if o_translator\n o_translator.flagged.each do |i|\n translator.flag_ref(i)\n end\n end\n translators[t_key] = translator\n o_translator = translator\n else\n unless o_translator\n o_translator = Translator.new({},\n :parameters => {})\n end\n end\n o_translator\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def translate(*args)\n key = args.shift\n if xlated = @map[key]\n if xlated.is_a?(String)\n args.empty? ? xlated : sprintf(xlated, *args)\n else\n xlated.call(*args)\n end\n else\n return key\n end\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def register_default_translators\n [ \"time\",\n \"timestamp\" ].each { |type| add_translator( type ) { |t, v| Time.parse( v ) } }\n\n add_translator( \"date\" ) { |t,v| Date.parse(v) }\n add_translator( \"datetime\" ) { |t,v| DateTime.parse(v) }\n\n [ \"decimal\",\n \"float\",\n \"numeric\",\n \"double\",\n \"real\",\n \"dec\",\n \"fixed\" ].each { |type| add_translator( type ) { |t,v| v.to_f } }\n\n [ \"integer\",\n \"smallint\",\n \"mediumint\",\n \"int\",\n \"bigint\" ].each { |type| add_translator( type ) { |t,v| v.to_i } }\n\n [ \"bit\",\n \"bool\",\n \"boolean\" ].each do |type|\n add_translator( type ) do |t,v|\n !( v.strip.gsub(/00+/,\"0\") == \"0\" ||\n v.downcase == \"false\" ||\n v.downcase == \"f\" ||\n v.downcase == \"no\" ||\n v.downcase == \"n\" )\n end\n end\n\n add_translator( \"tinyint\" ) do |type, value|\n if type =~ /\\(\\s*1\\s*\\)/\n value.to_i == 1\n else\n value.to_i\n end\n end\n end",
"def localized(key, value = nil)\n self[key] = value if value\n\n case self[key]\n when NilClass then nil\n when Proc then instance_eval(&self[key])\n else _(self[key])\n end\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def extract_subjects(subject)\n if subject.is_a?(Hash) && subject.key?(:any)\n subject[:any]\n else\n [subject]\n end\n end"
] |
[
"0.73392236",
"0.5986221",
"0.59776527",
"0.59714496",
"0.5765452",
"0.5482785",
"0.54764575",
"0.53853554",
"0.536861",
"0.5346757",
"0.5334776",
"0.5306782",
"0.5297737",
"0.52549946",
"0.51945865",
"0.5161835",
"0.5151408",
"0.514883",
"0.50704414",
"0.5014808",
"0.49537235",
"0.4953113",
"0.4930449",
"0.49031517",
"0.4896787",
"0.48947352",
"0.48769084",
"0.48761028",
"0.48708817",
"0.48700172",
"0.48316664",
"0.48049",
"0.478822",
"0.47657955",
"0.47486672",
"0.47482455",
"0.47257525",
"0.47121325",
"0.47120532",
"0.47054666",
"0.46955857",
"0.468224",
"0.46537927",
"0.46511796",
"0.46480283",
"0.46480283",
"0.46403095",
"0.46392274",
"0.461331",
"0.45858228",
"0.4580401",
"0.45789137",
"0.45666334",
"0.45511788",
"0.4543474",
"0.45330167",
"0.45317262",
"0.45255607",
"0.45162213",
"0.4508",
"0.45079377",
"0.44741634",
"0.44635612",
"0.44601318",
"0.44566736",
"0.44551364",
"0.44460836",
"0.44401112",
"0.442585",
"0.44194892",
"0.44176966",
"0.44106933",
"0.44059363",
"0.4404709",
"0.44037753",
"0.44010288",
"0.43997842",
"0.43911415",
"0.43897173",
"0.4385015",
"0.43823123",
"0.43816584",
"0.43697846",
"0.4367166",
"0.4365107",
"0.4365107",
"0.43634397",
"0.43631768",
"0.4362838",
"0.4359928",
"0.4358699",
"0.4357216",
"0.4355372",
"0.4354756",
"0.43433776",
"0.43429324",
"0.43420318",
"0.43420318",
"0.43420318",
"0.43374923"
] |
0.5466102
|
7
|
Loads a single translations file by delegating to load_rb or load_yml depending on the file extension and directly merges the data to the existing translations. Raises I18n::UnknownFileType for all other file extensions.
|
def load_file(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load\n if File.file?(@file_name)\n File.open(@file_name, 'r') do |file|\n YAML::load(file)\n end\n else\n default\n end\n end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def import!(file)\n if File.directory?(file)\n # ...\n else\n case File.extname(file)\n when '.yaml', '.yml'\n merge!(YAML.load(File.new(file)))\n else\n text = File.read(file)\n if /\\A---/ =~ text\n name = File.basename(file)\n self[name] = YAML.load(text)\n else\n name = File.basename(file)\n self[name] = text.strip\n end\n end\n end\n end",
"def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end",
"def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end",
"def import\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_import_file_given')) and return unless params[:importfile].present?\n filename = params[:importfile].original_filename\n extension = filename.sub(/.*\\./, '')\n if extension == 'yml'\n hash = YAML.load_file(params[:importfile].tempfile.path) rescue nil\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.cannot_parse_yaml')) and return unless hash\n CouchbaseI18n.traverse_flatten_keys(hash).each do |key, value|\n existing = CouchbaseI18n::Translation.find_by_translation_key(key)\n if existing\n if existing.translation_value != value\n existing.translation_value = value\n existing.translated = true\n existing.save\n end\n else\n CouchbaseI18n::Translation.create :translation_key => key, :translation_value => value\n end\n end \n else\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_proper_import_extension', :extension => extension)) and return \n end\n redirect_to({:action => :index, :offset => params[:offset]}, :notice => I18n.t('couchbase_i18n.translation.file_imported', :filename => filename))\n end",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_file(file); end",
"def load_translations_and_collect_file_errors(files); end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def load(file); end",
"def translate_file(filename)\n f = File.read(filename)\n f = translate_title(f)\n f = translate_body(f)\n f = update_category(f)\n f\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def load_yml(filename); end",
"def load(file_path); end",
"def load(file_path); end",
"def read_file(path)\n raise ArgumentError, \"don't know extension #{ext}, use from [#{extensions.join(', ')}]\" unless understands_ext?(path)\n ext = File.extname(path)\n case ext\n when '.json'\n JSON.parse(File.read(path))\n when '.yaml'\n YAML.load_file(path)\n else\n self.send \"read_#{ext.tr('.','')}\", path\n end\n end",
"def load_source\n case File.extname(config[:source])\n when '.json'\n Yajl.load(File.open(config[:source]))\n when '.yml'\n YAML.load(File.open(config[:source]))\n else\n raise 'unknown source file extension'\n end\n end",
"def load_yaml\n if has_file? \"#{name}.yml\"\n YAML.load_file(path / \"#{name}.yml\").apply_to self\n end\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load_from_file!\n return unless File.exists?(uservoice_configuration_file)\n\n config = ERB.new(IO.read(uservoice_configuration_file)).result\n configuration = YAML::load(config)\n self.merge!(configuration[\"uservoice\"])\n end",
"def load_file(definition)\n paths = definition.file\n\n paths.each do |path|\n ext = file_module.extname(path).strip.downcase[1..-1]\n parse_method = \"parse_#{ext}\"\n unless respond_to?(parse_method)\n fail \"extension (#{ext}), for (#{definition.key}: #{path}) \" +\n \"is not valid, only yaml and json are supported\"\n end\n\n if file_module.exists?(path)\n config = public_send(parse_method, path)\n unless config.is_a?(Hash)\n fail \"[config #{parse_method}] config must be a hash\"\n end\n config.deep_symbolize_keys!\n return config[definition.key]\n end\n end\n\n list = paths.join(',')\n fail \"none of :#{definition.key} config files exist at (#{list})\"\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def load(tag, lang)\n txt = File.open(FOLDER + '/' + lang + '.' + EXTENSION, 'rb') {|f| f.read}\n major = txt[0].unpack('U').first\n minor = txt[1].unpack('U').first\n \n if major > MAJOR || (major >= MAJOR && minor > MINOR)\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: LANG Script version not compatible\"\n return ''\n end\n \n enc = txt[2].unpack('U').first > 0\n txt = txt[3..-1]\n \n txt.split(\"\\n\").each do |t|\n unless t[0] == TAG_BEGIN\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: Invalid language file\"\n return ''\n end\n unless t[1] == TAG_NAME\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: Invalid language file\"\n return ''\n end\n i = t.index(TAG_TEXT)\n unless i\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: Invalid language file\"\n return ''\n end\n name = enc ? decrypt(t[2...i]) : t[2...i].force_encoding('UTF-8')\n next unless name == tag\n text = enc ? decrypt(t[(i+1)...t.size]) : t[(i+1)...t.size].force_encoding('UTF-8')\n begin\n return text.gsub('&line', \"\\n\")\n rescue\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: Invalid language file\"\n return ''\n end\n end\n puts \"Failed to load tag '#{tag}' from file #{FOLDER}/#{lang}.#{EXTENSION}: Could not find tag\"\n return ''\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def load(filename, wrap=false) end",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def load_yml(template, options={})\n case File.extname(template)\n when '.erb'\n parse_erb(template, options)\n else\n YAML.load_file(template)\n end\n end",
"def load(path_or_io)\n case path_or_io\n when String, Pathname\n path = Pathname.new(path_or_io)\n path = path.join('*.{yaml,yml}') if path.directory?\n\n Dir.glob(path).each { |f| load(File.new(f)) }\n else\n update(YAML.load(path_or_io))\n end\n end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end",
"def load\n return unless @file_path && File.exist?(@file_path)\n File.open(@file_path, 'rb') do |file|\n return Marshal.load(file)\n end\n end",
"def load(files = T.unsafe(nil), reparse = T.unsafe(nil)); end",
"def load_file( file, hash = {})\n fail 'given file is nil' unless file\n hash.merge!( YAML.load_file(file) )\n end",
"def translation\n @translation ||= Mongify::Translation.parse(@translation_file)\n end",
"def load(filename)\n end",
"def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end",
"def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end",
"def load_file(path, recurse=false, &block)\n return load_file(path, recurse, &DEFAULT_LOAD) if recurse && !block_given?\n base = File.directory?(path) ? {} : (YAML.load_file(path) || {})\n \n if recurse\n # determine the files/dirs to load recursively\n # and add them to paths by key (ie the base\n # name of the path, minus any extname)\n paths = {}\n files, dirs = Dir.glob(\"#{path.chomp(File.extname(path))}/*\").partition do |sub_path|\n File.file?(sub_path)\n end\n\n # directories are added to paths first so they can be\n # overridden by the files (appropriate since the file\n # will recursively load the directory if it exists)\n dirs.each do |dir|\n paths[File.basename(dir)] = dir\n end\n\n # when adding files, check that no two files map to\n # the same key (ex a.yml, a.yaml).\n files.each do |filepath|\n key = File.basename(filepath).chomp(File.extname(filepath))\n if existing = paths[key]\n if File.file?(existing)\n confict = [File.basename(paths[key]), File.basename(filepath)].sort\n raise \"multiple files load the same key: #{confict.inspect}\"\n end\n end\n\n paths[key] = filepath\n end\n\n # recursively load each file and reverse merge\n # the result into the base\n paths.each_pair do |key, recursive_path|\n value = load_file(recursive_path, true, &block)\n yield(base, key, value)\n end\n end\n\n base\n end",
"def remove_locale_file language\n File.delete yml_path(language) if File.exists?(yml_path language)\n\n new_load_paths = I18n.load_path.map do |path|\n path unless path.include?(\"#{language}.yml\")\n end.compact\n\n I18n.load_path = new_load_paths\n\n I18n.locale = I18n.default_locale\nend",
"def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load(file, wrap = false) # :nodoc:\n Loader.load(file, wrap)\n end",
"def load_from_file(file, options = T.unsafe(nil)); end",
"def load\n @models = []\n\n # \n files = \n if File.directory?(config_path) \n files_in_dir = []\n Dir[config_path + \"/*.yml\"].each do |file|\n files_in_dir << file\n end\n files_in_dir\n elsif File.file?(config_path)\n [config_path]\n else\n nil\n end\n\n return nil if files.nil?\n\n # \n @models = files.inject(@models) do |models, file|\n begin\n yaml = YAML.load_file(file)\n rescue => ex\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n if yaml.nil?\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n models + yaml2models(yaml)\n end.extend(ArrayMethods)\n end",
"def load_file(file)\n File.open(file, \"r\") { |f| load(f) }\n end",
"def loadTemplate\n\t\t@template = File.read(@templateFile)\n\tend",
"def loadTemplate\n\t\t@template = File.read(@templateFile)\n\tend",
"def load_from_file!(file_path)\n raise IOError, \"File #{file_path} not exist\" unless File.exist?(file_path)\n raw_data = IO.read(file_path)\n load_from_json!(raw_data)\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def load\n config_files.each do |file|\n config = YAML::load(File.open(file))\n @config.merge! config\n end\n end",
"def parse_translation_file(pattern, model)\n # check if all languages have an associated column name\n Florensia::Language.all.map(&:name).each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of {model.name} but within Florensia::Language\"\n raise \"Translation/Description Language Error\"\n end\n\n batch(Dir[pattern]) do |f|\n data = open(f).read # reading file\n data.encode!('utf-8', 'utf-16') # fix encoding\n data = data.split(\"\\r\\n\") # split into lines\n data.pop # delete __END\n\n # working on header/languages\n header = data.shift.downcase.split(\"\\t\")\n header.shift # 'Code' an identifier, not a language\n #check if we have all languages in our system\n header.delete(\"name\") # that's not a language but is included in Descriptions\n header.each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of #{model.name}\"\n raise \"Translation/Description Language Error\"\n end\n\n # working on the datasets itself\n data.each do |line|\n line = line.split(\"\\t\")\n code = line.shift #first column is the identifier\n line.shift if model == Florensia::Description #second column is unused 'name' in description files\n line.collect!{|text| text.gsub('\\n', \"\\n\")} #fix line breaks\n t = model.where(code: code).first_or_initialize\n t.update_attributes(Hash[header.zip(line)])\n end\n end\n end",
"def import_translations(path, page)\n old_translations = page.translations.pluck(:locale)\n new_translations = []\n\n Dir[\"#{path}content.*.html\"].each do |file_path|\n locale = File.basename(file_path).match(%r{content\\.(\\w+)\\.html})[1]\n new_translations << locale\n\n translation = page.translations.where(locale: locale).first_or_initialize\n\n next unless fresh_seed?(translation, file_path)\n\n # reading file content in, resulting in a hash\n fragments_hash = parse_file_content(file_path)\n\n # parsing attributes section\n attributes_yaml = fragments_hash.delete(\"attributes\")\n attrs = YAML.safe_load(attributes_yaml)\n\n # applying attributes\n layout = site.layouts.find_by(identifier: attrs.delete(\"layout\")) || page.try(:layout)\n translation.attributes = attrs.merge(\n layout: layout\n )\n\n # applying fragments\n old_frag_identifiers = translation.fragments.pluck(:identifier)\n\n new_frag_identifiers, fragments_attributes =\n construct_fragments_attributes(fragments_hash, translation, path)\n translation.fragments_attributes = fragments_attributes\n\n if translation.save\n message = \"[CMS SEEDS] Imported Translation \\t #{locale}\"\n ComfortableMexicanSofa.logger.info(message)\n\n # cleaning up old fragments\n frags_to_remove = old_frag_identifiers - new_frag_identifiers\n translation.fragments.where(identifier: frags_to_remove).destroy_all\n\n else\n message = \"[CMS SEEDS] Failed to import Translation \\n#{locale}\"\n ComfortableMexicanSofa.logger.warn(message)\n end\n end\n\n # Cleaning up removed translations\n translations_to_remove = old_translations - new_translations\n page.translations.where(locale: translations_to_remove).destroy_all\n end",
"def load(environment=nil)\n load_from_file(file, environment)\n end",
"def load_from_file(filename)\n MIME.deprecated(self, __method__)\n MIME::Types::Loader.load_from_v1(filename)\n end",
"def load_from_filesystem(options)\n return if options[:skip_metadata]\n\n # Load localised data\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n language = File.basename(lang_folder)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n path = File.join(lang_folder, \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= {}\n options[key][language] ||= File.read(path)\n end\n end\n\n # Load non localised data\n (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key|\n path = File.join(options[:metadata_path], \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= File.read(path)\n end\n\n # Load trade representative contact information\n options[:trade_representative_contact_information] ||= {}\n TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:trade_representative_contact_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:trade_representative_contact_information][option_name] ||= File.read(path)\n end\n\n # Load review information\n options[:app_review_information] ||= {}\n REVIEW_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:app_review_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:app_review_information][option_name] ||= File.read(path)\n end\n end",
"def load(file)\n File.open(path(file)).read\n end",
"def load_config_file( file_name, options = {} )\n options.symbolize_keys!\n content = File.read( config_file_name( file_name ) )\n\n format = options[:format] || File.extname( file_name ).gsub('.','')\n require 'erb'\n\n content = case format.to_s\n when '', 'yml', 'yaml' then YAML.load( ERB.new( content ).result )\n when 'js', 'json' then JSON.load( content )\n when 'rb', 'ruby', 'eval' then eval( content )\n else content\n end if content && format && !options[:raw]\n\n if content.is_a?( Hash )\n content = format_hash_keys( content, options[:key_format] || :stringify )\n content = search_key_chain( content, options )\n end\n\n content\n rescue => e\n log( :info, \"Unable to load #{file_name} for #{format}\" )\n raise( e ) if options[:required]\n nil\n end",
"def load\n yaml_filespec = @filespec.ext('.yaml')\n if File.exist?(yaml_filespec) && (File.mtime(yaml_filespec) > File.mtime(@filespec))\n load_from_yaml(yaml_filespec)\n else\n load_from_xml(@filespec)\n end\n end",
"def merge_i18n(barclamp)\n locales = barclamp['locale_additions']\n locales.each do |key, value|\n #translation file (can be multiple)\n f = File.join CROWBAR_PATH, 'config', 'locales', \"#{key}.yml\"\n if File.exist? f\n puts \"merging translation for #{f}\" if DEBUG\n master = YAML.load_file f\n master = merge_tree(key, value, master)\n File.open( f, 'w' ) do |out|\n YAML.dump( master, out )\n end\n else\n puts \"WARNING: Did not attempt tranlation merge for #{f} because file was not found.\"\n end\n end\n end",
"def load_file(path)\n load(path)\n end",
"def load(filename)\n Format.load(filename)\n end",
"def load filepath\n require 'zip'\n\n ::Zip::File.open filepath do |zip|\n entry = zip.entries.first\n entry_path = path entry.name\n entry.extract entry_path\n\n serializer = serializers.resolve entry.name\n serializer.load entry_path\n end\n end",
"def load_file\n raise NotImplementedError, \"loading Ruby source files is not implemented\"\n end",
"def load(path); end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def ensure_source_processed(translated_filename)\n return unless $SOURCE.empty?\n\n source_filename = File.dirname(translated_filename) + '/en.yml'\n source_contents = File.read(source_filename)\n original_source = YAML.safe_load(source_contents)\n convert_source('', original_source['en'])\nend",
"def load_data(filename=nil)\n filename=data_file(filename)\n return unless File.exist?(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n YAML.load(File.open(filename))\n when \".json\"\n JSON.parse(File.read(filename))\n else\n File.read(filename)\n end\n end",
"def load\n reload_rh_texts unless PSDK_CONFIG.release?\n lang = ($pokemon_party ? $pokemon_party.options.language : default_lang)\n unless lang && Available_Langs.include?(lang)\n log_error \"Unsupported language code (#{lang}).\\nSupported language code are : #{Available_Langs.join(', ')}\"\n lang = Available_Langs.first\n log_info \"Fallback language code : #{lang}\"\n end\n @lang = lang\n @dialogs.clear\n end",
"def load(clear=true, filename = @filename)\n @mutex.synchronize{\n @filename = filename\n\n hash = YAML.load_file( filename )\n self.clear if clear\n self.merge!(hash)\n }\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def load_source!\n @source = load_file_contents\n end",
"def load(wrap=false)\n resolve_load_path\n load_file(wrap)\n end",
"def add(*files)\n # due to the multi passing of splat args, we can get Array-in-Array situations here\n files.flatten.each do |fn|\n @files.push(fn)\n if ! File.exists?(fn)\n next if self.class.skipmissing\n raise ArgumentError, \"file #{fn} does not exist\"\n end\n begin\n data = YAML.load(File.open(fn))\n if ! data.instance_of?(Hash)\n raise ArgumentError, \"file #{fn} does not contain a Hash\"\n end\n @cfg.deep_merge!(data.deep_symbolize_keys).deep_symbolize_keys\n rescue\n if ! self.class.skipbad\n raise\n end\n end\n end\n\n # resolve templates\n if self.class.templates\n resolve_templates\n end\n end",
"def fromFile( filename ) \n lines = IO.readlines( filename )\n loadAll( lines )\n end",
"def load(filename)\n update! YAML.load_file(filename)\n end",
"def load!(files)\n raise NoConfigFiles if !files || files.empty?\n files.each do |path|\n load path if File.readable?(File.expand_path(path))\n end\n end",
"def load(filename)\n\t\tend",
"def import\n read_dict_file(:langA)\n write_database(:langA)\n\n read_dict_file(:langB)\n write_database(:langB)\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def load(file = nil)\n @file = file if file\n @cfg = YAML.load_file(@file)\n end",
"def parse_config_file config_path\n File.open(config_path, \"r\") do |file|\n case File.extname(file).delete(\".\")\n when \"json\" then JSON.parse(file.read)\n when \"yml\" then YAML.load_file(file)\n else\n file.close\n raise LoadError, \"Type of file is not supported.\"\n end\n end\n end",
"def load_file(filename)\n File.read File.join(\"plugins\",name,filename)\n end",
"def fill_file_ios(language, translations)\n translations[:filename] = language.to_s.downcase + \".lproj/\" + \"Localizable.strings\"\n file = translations[:file]\n\n # Header\n file.puts \"/*\"\n file.puts \" Localizable.strings\"\n file.puts \" \" + @project.name\n file.puts \"\"\n file.puts \" Created on Translate Community on \" + Time.new.strftime(\"%d.%m.%y\")\n file.puts \"*/\"\n file.puts \"\"\n\n # Content\n translations.each do |key, value|\n unless key == :file or key == :filename\n file.puts \"\\\"\" + key.gsub(/[^\\\\]\"|^\"/) { |s| (s.size > 1 ? s.first : \"\") + \"\\\\\\\"\"} + \"\\\" = \\\"\" + value[:value].gsub(/[^\\\\]\"|^\"/) {|s| (s.size > 1 ? s.first : \"\") + \"\\\\\\\"\"} + \"\\\";\"\n end\n end\n\n file.close\n end"
] |
[
"0.6884348",
"0.6668286",
"0.6668286",
"0.651807",
"0.6482737",
"0.6285057",
"0.6182364",
"0.6182364",
"0.61569136",
"0.6142363",
"0.61227286",
"0.6052862",
"0.60503095",
"0.59643984",
"0.59460646",
"0.5942739",
"0.5933745",
"0.5922498",
"0.5796637",
"0.57852334",
"0.568418",
"0.5678175",
"0.5617893",
"0.5596192",
"0.559261",
"0.5570938",
"0.55254763",
"0.55254763",
"0.5523122",
"0.55075103",
"0.54783887",
"0.54431456",
"0.54119086",
"0.5411575",
"0.5405841",
"0.5401731",
"0.5376194",
"0.53685397",
"0.53506625",
"0.53397745",
"0.53264976",
"0.5318627",
"0.5300025",
"0.5299644",
"0.52855104",
"0.52781206",
"0.525777",
"0.5250926",
"0.5243955",
"0.52397376",
"0.5234936",
"0.52300537",
"0.5218238",
"0.52150446",
"0.5212303",
"0.51998204",
"0.5199174",
"0.51787764",
"0.5169998",
"0.51490194",
"0.51490194",
"0.51486266",
"0.51481974",
"0.5146462",
"0.5132662",
"0.5132001",
"0.5128167",
"0.51140606",
"0.5113994",
"0.5110258",
"0.5097425",
"0.50936925",
"0.50895715",
"0.5086249",
"0.50796545",
"0.5068337",
"0.5047512",
"0.5046415",
"0.5039065",
"0.5031303",
"0.50295043",
"0.5004439",
"0.50032896",
"0.49871597",
"0.4980726",
"0.4979323",
"0.49674368",
"0.4955103",
"0.49476817",
"0.494465",
"0.49406525",
"0.49385586",
"0.49306852",
"0.49272963",
"0.4927238",
"0.49263144",
"0.4918973",
"0.49184462",
"0.4908087"
] |
0.55584794
|
26
|
Loads a JSON translations file. The data must have locales as toplevel keys. source://i18n//lib/i18n/backend/base.rb266
|
def load_json(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def read_json_file(locale)\n\t\tember_json_file_path = File.join(Rails.root, \"frontend\", \"translations\", \"#{locale.to_sym}.json\")\n\t\tfile_exists = File.exist?(ember_json_file_path)\n\t\tif file_exists # Read file contents, if file exists.\n\t\t\tfile_contents = File.read(ember_json_file_path)\n\t\t\tember_json_file_data = JSON.parse(file_contents)\n\t\telse # Create the locale file, if file doesn't exist\n\t\t\tfile_handle = File.new(ember_json_file_path, \"w\")\n\t\t\tember_json_file_data = File.read(file_handle)\n\t\tend\n\t\treturn [ember_json_file_path, ember_json_file_data]\n\tend",
"def import_locale_map\n json = JSON.parse(File.read(path_to_json))\n\n json[\"countries\"].each_pair do |country_code, country_data|\n country_name = country_data[\"name\"]\n languages = country_data[\"locales\"]\n\n associate_country_with_locales(country_name, country_code, languages)\n end\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load(file)\n data = File.read(file)\n JSONL.parse(data)\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def de\n file = File.read(Rails.root.join('client', 'languages', 'deDe.json'))\n data_hash = JSON.parse(file)\n render :json => data_hash\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_data_from_file(default=json_default)\n KiJSONFile.load_json(path, default)\n end",
"def translate_json prefix, src\n json = JSON.parse src\n json.each do |translation_json|\n qualified_key = join_keys prefix, translation_json[\"value\"]\n translations.add locale, qualified_key, translation_json[\"name\"]\n end\n end",
"def load_from_file(path)\n return unless File.exist?(path)\n json_data = File.read(path)\n load_raw_json(json_data)\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def load_data\n data = {}.with_indifferent_access\n\n %w[.json .yaml].each do |ext|\n Dir.glob(\"#{DATA_DIR}/*#{ext}\") do |fname|\n key = File.basename(fname, ext).to_sym\n puts \"Loading data[:#{key}] from #{fname}...\"\n data[key] =\n if ext == '.json'\n JSON.parse(File.read(fname))\n else\n Psych.parse(fname)\n end\n end\n end\n\n data\n end",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def store_translations(locale, data)\n flatten_data(locale => data).each do |key, value|\n self[key] = value\n end\n end",
"def load_json(dir_path, filename)\n file_path = File.join(dir_path, filename)\n JSON.parse(File.read(file_path))\n end",
"def init_translations; end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_json(filename)\n File.open(File.expand_path(\"../support/#{filename}\", __FILE__), \"r\") do |json_file|\n JSON.load(json_file)\n end\nend",
"def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = {}\n \n File.open(file, \"r:UTF-8\").each do |line| \n if line.include? \":\"\n splited_line = line.encode!('UTF-8').strip.split(':')\n @properties[splited_line[0]] = splited_line[1] \n end \n end\n end",
"def load_library(path)\n data = YAML.load_file(path)\n # maps the data to their proper language despcriptions\n data.map do |key, value|\n data[key] = { english: value[0], japanese: value[1] }\n end\n data\nend",
"def store_translations(locale, data)\n data = flatten data\n data.each { |key, data| store_translation(locale, key, data) }\n end",
"def load_from_file!(file_path)\n raise IOError, \"File #{file_path} not exist\" unless File.exist?(file_path)\n raw_data = IO.read(file_path)\n load_from_json!(raw_data)\n end",
"def load_json(file)\n type = File.basename(file, File.extname(file)).to_sym\n JSON.parse(File.read(file)).each do |allocation, settings|\n next if allocation == \"_\"\n\n settings.reject! { |k, _| k.start_with?(\"_\") }\n host = settings.delete(\"host\")\n host = intern_string(host) if host\n options = if settings.empty?\n EMPTY_HASH\n else\n settings.map { |k, v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }.to_h.freeze\n end\n define(type, allocation, host, options)\n end\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def update_translations(locale, data)\n set_translations(locale, application.cache_translations(\n locale,\n key,\n data.is_a?(Hash) ? data['translations'] : data\n ))\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def open_data(file)\n @data = JSON.parse(IO.readlines(file).join)\n end",
"def load_metas_for_locale(locale)\n path = metas_path(locale)\n if File.exists?(path)\n YAML.load(File.open(path))\n else\n logger.error \"[Metaslug] #{path} not found.\"\n {}\n end\n end",
"def readJson(dataFilePath)\n dataFile = File.new(dataFilePath, \"r\");\n data = JSON.load(dataFile);\n dataFile.close();\n data;\nend",
"def store_translations(locale, data, options = {})\n escape = options.fetch(:escape, true)\n flatten_translations(locale, data, escape, @subtrees).each do |key, value|\n key = \"#{locale}.#{key}\"\n\n case value\n when Hash\n if @subtrees && (old_value = @store[key])\n old_value = ActiveSupport::JSON.decode(old_value)\n value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash)\n end\n when Proc\n raise \"Key-value stores cannot handle procs\"\n end\n\n unless value.is_a?(Symbol)\n if value.is_a?(String)\n @store[key] = value.strip.gsub(/\\<script.*?\\>|\\<\\/script\\>/, '') unless value.blank? # don't store the locale if it is empty\n else\n @store[key] = ActiveSupport::JSON.encode(value)\n end\n end\n end\n end",
"def render_json(file_path, local_variables = {})\n object = load file_path, local_variables\n JSON.pretty_generate object\n end",
"def read_and_parse_file(path)\n json = JSON.parse(File.read(path))\n recursive_symbolize_keys!(json)\n end",
"def get_json(serverID,default_language=\"en\")\n data = JSON.load(get_file(default_language))\n file = get(serverID)\n data.deep_merge!(JSON.load(file)) if file\n return data\n end",
"def create_locale_files\n @i18n_scope = model.i18n_scope.to_s\n @i18n_key = model.model_name.i18n_key.to_s\n @columns = model.column_names\n\n options[:locales].each do |locale|\n @locale = locale\n locale_file = File.join(\n 'config/locales/models', model_name.underscore, \"#{@locale}.yml\"\n )\n template 'locale.yml', locale_file\n end\n rescue NameError\n puts \"#{model_name} is undefined.\"\n end",
"def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_transitions(filename)\n file = File.read(filename)\n JSON.parse(file)\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def fetch\n update_attributes(application.api_client.get(\n \"language/#{locale}/definition\", {},\n {\n cache_key: self.class.cache_key(locale)\n }\n ))\n rescue Tml::Exception => ex\n Tml.logger.error(\"Failed to load language: #{ex}\")\n self\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def json_file_fixture(path)\n return JSON.parse(File.read(file_fixture(path)), symbolize_names: true)\n end",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def load_json(filename)\n begin\n File.open(filename, \"r\" ) do |f|\n JSON.load(f)\n end\n rescue Errno::ENOENT, TypeError => e\n puts \"You must supply a valid filename: #{e.message}\"\n exit\n end\nend",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def load\n @cache = JSON.parse(File.read(file))\n rescue\n @cache = {}\n end",
"def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.translations[\"#{locale}\"] = #{translations_for_locale.to_json};\\n);\n end\n end\n end",
"def read\n file = File.read(@filename)\n JSON.parse(file)\n end",
"def load_translations_and_collect_file_errors(files); end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = []\n \n File.open(file, \"r:UTF-8\").each do |line| \n @properties << line \n end\n end",
"def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end",
"def read_from_json\n JSON.parse File.new(@filepath).read\n end",
"def read_JSON_file # called a helper method (is helping you to use less code and dealing with something so that your other methods don't have to)\n @json_data = File.read('./lib/contacts.json')\n @contacts = JSON.parse(@json_data, {:symbolize_names => true})\n end",
"def read\n return nil unless File.file?(\"./#{filename}\")\n JSON.parse(IO.read(filename))\n end",
"def load!\n JSON.load(File.read(@name))\n rescue JSON::ParserError => e\n raise LogFile::LoadError, e.message\n end",
"def translation\n @translation ||= Mongify::Translation.parse(@translation_file)\n end",
"def load_json(path)\n JSON.parse(File.read(File.expand_path(path))).each do |_env, config|\n config.transform_keys!(&SNAKE_CASE) if config.is_a?(Hash)\n end.tap do |config|\n config.transform_keys!(&SNAKE_CASE)\n end\n end",
"def read_unicorns\n JSON.parse(File.read(\"unicorns.json\"))\nend",
"def store_translations(locale, data, options = {})\n locale = locale.to_sym\n translations[locale] ||= {}\n data = data.deep_symbolize_keys\n translations[locale].deep_merge!(data)\n end",
"def read_data_from_file\n file = File.read(\"condensed_capitals.json\")\n @countries_capitals_as_hash = JSON.parse(file)\n end",
"def load_vocab_translations\n pp_nl_serialized = File.read(\"#{$filepath_nl}alle danyvertalingen qff export.json\")\n pp_nl = JSON.parse(pp_nl_serialized)\n\n #orgins of words: passaporte (and chapter) or other\n construct_book_origins(pp_nl[\"folders\"])\n \n #saving the words to the database with reference to passaporte_words\n pp_nl[\"words\"].each do |ppnl_line|\n word_pt_raw = ppnl_line[\"word\"]\n word_pt_split = Translation.split_article_front(word_pt_raw)\n word_pt = word_pt_split[:word]\n genre_pt = word_pt_split[:article]\n # puts \"for word_pt_split: #{word_pt_split}\"\n passaporte_found = passaporte_unit?(word_pt_split)\n # puts \"found?:\"\n # puts passaporte_found\n pt_translation = nil\n if !passaporte_found.nil?\n pt_transl = Translation.find_by word_pt:word_pt_split[:word], genre_pt:word_pt_split[:article]\n # puts pt_transl\n end\n # puts \"pt_transl:\"\n # puts pt_transl\n translation_array = ppnl_line[\"translations\"]\n save_nl_translation(word_pt, pt_transl, genre_pt,translation_array, ppnl_line[\"comments\"])\n end\nend",
"def GetLocales params = {}\n\n params = params.merge(path: 'locales.json')\n APICall(params)\n\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def json_file_fixture(path)\n return JSON.parse(File.read(file_fixture(path)), symbolize_names: true)\nend",
"def translations\n @translations ||= {}\n end",
"def read_json_file(path)\n JSON.parse(File.open(path){ |f| f.read })\nend",
"def load_data(filename=nil)\n filename=data_file(filename)\n return unless File.exist?(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n YAML.load(File.open(filename))\n when \".json\"\n JSON.parse(File.read(filename))\n else\n File.read(filename)\n end\n end",
"def json(*files, **options, &block) = read(*files, parse: :json, ext: '.json', **options, &block)",
"def parse\n file = File.read(@file)\n @data = JSON.parse(file)\n end",
"def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end",
"def load_json( filename, debug = false)\n\traise RuntimeError, \"Missing filename\" if not filename\n\n\tif( File.exists?( filename ) or File.symlink?( filename ) )\t\t\n\t\treturn JSON.load( File.open( filename ) )\n\telse\n\t\traise RuntimeError, \"Could not find \"+filename+\"\\n\"\n\tend\n\nend",
"def translations; end",
"def language_strings(data_version = nil)\n language_string = get(resource_path('language-strings'), @version, version: data_version)\n RiotGamesApi::LOL::Model::StaticData::LanguageString.new language_string\n end",
"def translations_hash; end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load\n sleeper = 0.0\n while File.exist? lock_file\n sleeper += 0.1 if sleeper <= 10.0\n sleep(sleeper.to_i)\n end\n # :symbolize_names does not play nicely with :create_additions\n tmp = JSON.parse(File.read(path),\n {:symbolize_names=>false, :create_additions=>true})\n @data = {}\n tmp.each_pair{ |k,v| self[k] = v }\n end",
"def load_file(file_name)\n File.open(file_name, \"r\") do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def get_po\r\n\r\n send_file(\"#{Rails.root}/po/#{params[:locale]}/#{APP_SID}.po\",\r\n :filename => \"#{APP_SID}.po\",\r\n :type => \"text/x-gettext-translation\")\r\n end",
"def load_file(file_name)\n File.open(file_name, 'r') do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def store_translations(locale, data, options = T.unsafe(nil)); end",
"def dump\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n delete_all unless Interpret.soft\n\n records = []\n files.each do |f|\n ar = YAML.load_file f\n locale = ar.keys.first\n records += parse_hash(ar.first[1], locale)\n end\n\n # TODO: Replace with activerecord-import bulk inserts\n transaction do\n records.each {|x| x.save(:validate => false)}\n end\n end",
"def json(file_path)\n raise(format(ERROR_EXT_NOT_JSON, file_path)) unless json?(file_path)\n\n content = read_file(file_path)\n JSON.parse(content)\n end",
"def read_languages_from_file(data_file)\n File.open(data_file, 'rb') do |fin|\n until fin.eof\n label, outputs = Marshal.load(fin)\n yield label, outputs\n end\n end\nend"
] |
[
"0.7047893",
"0.6657459",
"0.64885545",
"0.6479761",
"0.6408364",
"0.6368965",
"0.62687755",
"0.62687755",
"0.6224206",
"0.6219601",
"0.6200123",
"0.6154813",
"0.6136007",
"0.6136007",
"0.6099765",
"0.6079235",
"0.60539055",
"0.59556514",
"0.58981043",
"0.5855989",
"0.5802763",
"0.5772993",
"0.5772298",
"0.57701683",
"0.57638085",
"0.5758099",
"0.57242125",
"0.5708473",
"0.5693919",
"0.56929606",
"0.5673926",
"0.5671423",
"0.5670648",
"0.5668113",
"0.56308717",
"0.5626245",
"0.56061065",
"0.56005967",
"0.559058",
"0.55716115",
"0.55711025",
"0.5569547",
"0.5555857",
"0.5547067",
"0.55277133",
"0.55275214",
"0.55233973",
"0.5485294",
"0.54826254",
"0.54793596",
"0.54788697",
"0.547734",
"0.5457769",
"0.5449523",
"0.5449462",
"0.54431164",
"0.54395026",
"0.54379964",
"0.54357",
"0.5429496",
"0.54273796",
"0.5421034",
"0.542061",
"0.54126984",
"0.5405679",
"0.5402645",
"0.5399668",
"0.53971",
"0.53801376",
"0.5378256",
"0.5372231",
"0.5348412",
"0.53437674",
"0.5343213",
"0.53427696",
"0.53422636",
"0.5339534",
"0.5326104",
"0.5324897",
"0.53168",
"0.53164613",
"0.530834",
"0.53065646",
"0.52869767",
"0.52758867",
"0.527567",
"0.52738845",
"0.5256256",
"0.5247407",
"0.5237858",
"0.52201694",
"0.52201694",
"0.52176195",
"0.5211194",
"0.52109516",
"0.5210812",
"0.5208966",
"0.52084106",
"0.5205909",
"0.51958627"
] |
0.6439563
|
4
|
Loads a plain Ruby translations file. eval'ing the file must yield a Hash containing translation data with locales as toplevel keys. source://i18n//lib/i18n/backend/base.rb244
|
def load_rb(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def parse_lang_file\n # Open .lang file and parse it, then copy \n # its full grammatical expression.\n File.open(@lang_file, \"r:UTF-8\") do |file|\n lines_count = 1\n current = :none\n\n # Evaluating lines\n while (line = file.gets)\n # Parsing .lang file\n case line\n when /(^\\s*$)|(^\\s*#.*$)/\n # Ignore blank lines or comments\n \n when /^\\s*symbols\\s*for\\s*(\\w*)?\\s*(\\w+)\\s*:\\s*(#.*)?$/\n # Create new symbol set\n captured = line.scan(/\\s*(\\w+)\\s*:/)\n current_binding = captured[0][0]\n @bindings[current_binding] = ConlangWordGenerator::SymbolSet.new\n current = :symbols\n\n when /^\\s*expression\\s*:\\s*(#.*)?$/\n # Start of grammatical expression\n current = :expression\n\n when /^\\s*replacements\\s*:\\s*(#.*)?$/\n # Start of list of replacements\n current = :replacements\n\n when /^\\s*(\\S+)\\s*[:=]\\s*(\\S+)\\s*(#.*)?$/\n # Add bindings\n case current\n when :symbols\n #Add a symbol to the current SymbolSet's binding\n @bindings[current_binding].add_pair($1, $2.to_i)\n when :replacements\n @replacements[$1] = $2\n else\n raise LangSyntaxError, \"Runtime error when evaluating \" +\n \"\\\"#{@lang_file}\\\" at binding line #{lines_count}.\"\n end\n else\n if current == :expression\n # Copying expression\n @full_expression += line.strip\n else\n raise LangSyntaxError, \"Runtime error when evaluating \" +\n \"\\\"#{@lang_file}\\\" at line #{lines_count}.\"\n end\n end\n\n #Counting lines\n lines_count += 1\n end\n end\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end",
"def read_languages_from_file(data_file)\n File.open(data_file, 'rb') do |fin|\n until fin.eof\n label, outputs = Marshal.load(fin)\n yield label, outputs\n end\n end\nend",
"def load_translations_and_collect_file_errors(files); end",
"def load(file); end",
"def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end",
"def load_file(file); end",
"def load\n eval(@data, TOPLEVEL_BINDING, @filename)\n end",
"def load_yml(filename); end",
"def load_from_file(file_path)\n require \"erb\"\n opts = YAML.load(ERB.new(File.read(file_path)).result) || {}\n symbolize_keys(opts)\n end",
"def load_rb( file )\r\n begin\r\n str = IO.read(file)\r\n load_rb_rules_as_string(str)\r\n rescue Exception => e\r\n raise RuleLoadingError, \"loading ruby file\"\r\n end\r\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def load(files = T.unsafe(nil), reparse = T.unsafe(nil)); end",
"def load_templates\n templates = {}\n file = __FILE__\n\n begin\n io = ::IO.respond_to?(:binread) ? ::IO.binread(file) : ::IO.read(file)\n app, data = io.gsub(\"\\r\\n\", \"\\n\").split(/^__END__$/, 2)\n rescue Errno::ENOENT\n app, data = nil\n end\n\n if data\n lines = app.count(\"\\n\") + 1\n template = nil\n data.each_line do |line|\n lines += 1\n if line =~ /^@@\\s*(.*\\S)\\s*$/\n template = ''\n templates[$1.to_sym] = template\n elsif template\n template << line\n end\n end\n end\n\n templates\nend",
"def load_file(filename); end",
"def load_file(filename); end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def parse(filename, custom_path = nil)\n # Find the correct file based on the current locale setting in SketchUp.\n # If no path has been given it'll revert back to the Resource folder in\n # SketchUp, like LanguageHandler does.\n if custom_path\n path = File.expand_path(custom_path)\n full_file_path = File.join(path, Sketchup.get_locale, filename)\n else\n full_file_path = Sketchup.get_resource_path(filename)\n end\n\n # Define returned dictionary. Make a hash that will return the key given\n # if the key doesn't exist. That way, when a translation is missing for\n # a string it will be returned un-translated.\n strings = Hash.new { |hash, key| key }\n\n # Ensure the file is valid.\n if full_file_path.nil? || !File.exist?(full_file_path)\n puts \"Warning! Could not load dictionary: #{full_file_path}\"\n return strings\n end\n\n # Read and process the content.\n state = STATE_SEARCH\n key_buffer = ''\n value_buffer = ''\n state_cache = nil # Used when comments are exited.\n\n # File position statistics.\n last_line_break = nil\n line_pos = 0\n\n if Sketchup.version.split('.')[0].to_i < 14\n read_flags = 'r'\n else\n read_flags = 'r:BOM|UTF-8'\n end\n\n File.open(full_file_path, read_flags) { |file|\n file.lineno = 1 # Line numbers must be manually tracked.\n file.each_byte { |byte|\n # Count line numbers and keep track of line position.\n if byte.chr =~ TOKEN_EOL # (?) Can we avoid regex? Is 10 & 13 enough?\n line_pos = 0\n if last_line_break.nil? || byte == last_line_break\n file.lineno += 1\n last_line_break = byte\n end\n else\n line_pos += 1\n last_line_break = nil\n end\n\n log_state(state, byte)\n\n # Check for UTF-8 BOM at the beginning of the file. (0xEF,0xBB,0xBF)\n # This is done here before the rest of the parsing as these are\n # special bytes that doesn't appear visible in editors.\n if file.lineno == 1\n if line_pos == 1 && byte == 0xEF\n state = STATE_EXPECT_UTF8_BOM\n next\n elsif state == STATE_EXPECT_UTF8_BOM\n if line_pos == 2 && byte == 0xBB\n next\n elsif line_pos == 3 && byte == 0xBF\n # Reset line position tracker as the BOM is not visible in\n # editors and will give misleading references.\n line_pos = 0\n state = STATE_SEARCH\n next\n end\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n end\n\n # Process the current byte.\n # Note that White-space and EOL matches are done with regex and\n # therefore last in evaluation.\n case state\n\n # Neutral state looking for the beginning of a key or comment.\n when STATE_SEARCH\n if byte == TOKEN_QUOTE\n state = STATE_IN_KEY\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # Parser is inside a key string looking for end-quote.\n # All characters that are not the end-quote is considered part of\n # the string and is added to the buffer.\n when STATE_IN_KEY\n if byte == TOKEN_QUOTE\n state = STATE_EXPECT_EQUAL\n else\n key_buffer << byte\n end\n\n # After a key the parser expects to find an equal token or a concat\n # token that will allow a string to be split up. Comments are\n # allowed.\n when STATE_EXPECT_EQUAL\n # Accept: Whitespace, Comment\n # Look for: = /\n if byte == TOKEN_EQUAL\n state = STATE_EXPECT_VALUE\n elsif byte == TOKEN_CONCAT\n state = STATE_SEARCH\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # After a key and equal-token is found the parser expects to find\n # a value string. Comments are allowed.\n when STATE_EXPECT_VALUE\n if byte == TOKEN_QUOTE\n state = STATE_IN_VALUE\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # Parser is inside a value string looking for end-quote.\n # All characters that are not the end-quote is considered part of\n # the string and is added to the buffer.\n when STATE_IN_VALUE\n if byte == TOKEN_QUOTE\n state = STATE_EXPECT_END\n strings[ key_buffer ] = value_buffer\n else\n value_buffer << byte\n end\n\n # After a key and value pair has been found the parser expects to\n # find and end token or end of line. The end token is only required\n # if multiple statements are placed on the same line.\n #\n # A concat token will kick the parser back into looking for a value\n # string.\n #\n # Comments are allowed.\n when STATE_EXPECT_END\n if byte == TOKEN_END || byte.chr =~ TOKEN_EOL\n state = STATE_SEARCH\n key_buffer = ''\n value_buffer = ''\n elsif byte == TOKEN_CONCAT\n state = STATE_EXPECT_VALUE\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # The beginning of a comment is found. The next token is expected to\n # be a token for either singe-line or multi-line comment.\n when STATE_EXPECT_COMMENT\n if byte == TOKEN_COMMENT_MULTI\n state = STATE_IN_COMMENT_MULTI\n elsif byte == TOKEN_COMMENT_SINGLE\n state = STATE_IN_COMMENT_SINGLE\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # The parser is processing a multi-line comment. When it encounter a\n # multi-line token will look for an comment end-token next. All\n # other data is ignored.\n when STATE_IN_COMMENT_MULTI\n if byte == TOKEN_COMMENT_MULTI # Multiline Comment\n state = STATE_EXPECT_COMMENT_END\n end\n\n # The parser is processing a multi-line comment and the last token\n # was an indication for end of comment. If this token is not an\n # end-token it will resume to processing the comment.\n when STATE_EXPECT_COMMENT_END\n if byte == TOKEN_COMMENT_START # End token is the same as start.\n state = state_cache\n elsif byte != TOKEN_COMMENT_MULTI\n state = STATE_IN_COMMENT_MULTI\n end\n\n # The parser is processing a single-line comment. The comment ends\n # at the first end-of-line.\n when STATE_IN_COMMENT_SINGLE\n if byte.chr =~ TOKEN_EOL\n state = state_cache\n end\n end\n } # file.each_byte\n } # File.open\n\n return strings\n end",
"def load(file_path); end",
"def load(file_path); end",
"def load_file(file_path)\n\t\t\tcode = File.open(file_path) { |f| f.read }\n\t\t\t@interpreter.run(code)\n\t\tend",
"def load_template(filename)\n\t\t\t@filename = filename\n\t\t\t@contents = []\n\t\t\t#@valid_keys = []\n\t\t\t#@dirty_mappings = {}\n\t\t\t#@replacements = {}\n\t\t\ti=0\n\t\t\n\t\t\t#If the file name is invalid, exit prematurely\n\t\t\tif filename == nil || filename == \"\" then\n\t\t\t\tputs \"Invalid filename provided.\"\n\t\t\t\treturn 0\n\t\t\tend\n\t\t\n\t\t\tbegin\n\t\t\t\tif File.exists? filename then\n\t\t\t\t\tputs \"Loading Template: \" + filename\n\t\t\t\t\tfile = File.open(filename, \"r\").each_line do |line|\n\t\t\t\t\t\t@contents.push line\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@section_tree = SectionTree.new @contents\n\t\t\t\n\t\t\t\t#size = line_count\n\t\t\t\n\t\t\t\t#Iterates over each line, remembering the line number\n\t\t\t\t#for i in 0..size-1\n\t\t\t\t\t#Extracts the keys from each line\n\t\t\t\t\t#matchdata = get_line_matchdata i\n\t\t\t\t\t#if !matchdata.nil? then\n\t\t\t\t\t\t#Accounts for all keys found in the template file\n\t\t\t\t\t\n\t\t\t\t\t\t#keys = matchdata.captures\n\t\t\t\t\t\t#if !keys.nil? && keys.size > 0 then\n\t\t\t\t\t\t\t#keys.each do |key|\n\t\t\t\t\t\t\t\t#@valid_keys.push(key.strip)\n\t\t\t\t\t\t\t\t#@dirty_mappings[matchdata.to_s] = key.strip\n\t\t\t\t\t\t\t\t#@replacements[key.strip] = matchdata.to_s\n\t\t\t\t\t\t\t#end\n\t\t\t\t\t\t#end\n\t\t\t\t\t#end\n\t\t\t\t#end\n\t\t\tensure\n\t\t\t\tputs \"Closing Template File: \" + filename\n\t\t\t\tfile.close unless file.nil?\n\t\t\tend\n\t\t\n\t\t\tputs ''\n\t\tend",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def load_file\n raise NotImplementedError, \"loading Ruby source files is not implemented\"\n end",
"def load(file_path, local_variables = {})\n yaml = render file_path, local_variables\n YAML.load yaml\n end",
"def load_template!\n feed = self\n eval(File.read(@file))\n end",
"def load_from_file(file, options = T.unsafe(nil)); end",
"def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = {}\n \n File.open(file, \"r:UTF-8\").each do |line| \n if line.include? \":\"\n splited_line = line.encode!('UTF-8').strip.split(':')\n @properties[splited_line[0]] = splited_line[1] \n end \n end\n end",
"def load_file(file_path)\n\t\t\tcode = File.open(file_path) { |f| f.read }\n\t\t\trun(code)\n\t\tend",
"def load(filename)\n end",
"def parse_translation_file(pattern, model)\n # check if all languages have an associated column name\n Florensia::Language.all.map(&:name).each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of {model.name} but within Florensia::Language\"\n raise \"Translation/Description Language Error\"\n end\n\n batch(Dir[pattern]) do |f|\n data = open(f).read # reading file\n data.encode!('utf-8', 'utf-16') # fix encoding\n data = data.split(\"\\r\\n\") # split into lines\n data.pop # delete __END\n\n # working on header/languages\n header = data.shift.downcase.split(\"\\t\")\n header.shift # 'Code' an identifier, not a language\n #check if we have all languages in our system\n header.delete(\"name\") # that's not a language but is included in Descriptions\n header.each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of #{model.name}\"\n raise \"Translation/Description Language Error\"\n end\n\n # working on the datasets itself\n data.each do |line|\n line = line.split(\"\\t\")\n code = line.shift #first column is the identifier\n line.shift if model == Florensia::Description #second column is unused 'name' in description files\n line.collect!{|text| text.gsub('\\n', \"\\n\")} #fix line breaks\n t = model.where(code: code).first_or_initialize\n t.update_attributes(Hash[header.zip(line)])\n end\n end\n end",
"def translate_file(filename)\n f = File.read(filename)\n f = translate_title(f)\n f = translate_body(f)\n f = update_category(f)\n f\n end",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\"\n end\n # puts candidates.inspect\n candidates\n end",
"def translation\n @translation ||= Mongify::Translation.parse(@translation_file)\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def ensure_source_processed(translated_filename)\n return unless $SOURCE.empty?\n\n source_filename = File.dirname(translated_filename) + '/en.yml'\n source_contents = File.read(source_filename)\n original_source = YAML.safe_load(source_contents)\n convert_source('', original_source['en'])\nend",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\" if Bolt.verbose?\n end\n # puts candidates.inspect\n candidates\n end",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def init_translations; end",
"def load_template_io(path)\n File.open(path, \"r\")\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def load(file)\n File.open(path(file)).read\n end",
"def from_file(path)\n\t\t\t\told_eval_path,@current_eval_path = @current_eval_path,path\n\t\t\t\tinstance_eval path.read, path.to_s\n\t\t\tensure\n\t\t\t\t@current_eval_path = old_eval_path\n\t\t\tend",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def load_file(file)\n File.open(file, \"r\") { |f| load(f) }\n end",
"def import\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_import_file_given')) and return unless params[:importfile].present?\n filename = params[:importfile].original_filename\n extension = filename.sub(/.*\\./, '')\n if extension == 'yml'\n hash = YAML.load_file(params[:importfile].tempfile.path) rescue nil\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.cannot_parse_yaml')) and return unless hash\n CouchbaseI18n.traverse_flatten_keys(hash).each do |key, value|\n existing = CouchbaseI18n::Translation.find_by_translation_key(key)\n if existing\n if existing.translation_value != value\n existing.translation_value = value\n existing.translated = true\n existing.save\n end\n else\n CouchbaseI18n::Translation.create :translation_key => key, :translation_value => value\n end\n end \n else\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_proper_import_extension', :extension => extension)) and return \n end\n redirect_to({:action => :index, :offset => params[:offset]}, :notice => I18n.t('couchbase_i18n.translation.file_imported', :filename => filename))\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load_dictionary\n @scrubbed_dict = File.readlines(\"dictionary.txt\")\n puts \"Dictionary loaded\"\n end",
"def load\n if File.exist?(@path) && !self.loaded?\n @source = File.read(@path)\n context = Context.new(self)\n eval @source, context.binding, @path.to_s, 1\n @loaded = true\n end \n end",
"def initialize file\n EasyTranslate.api_key = 'AIzaSyDrbD0AfKHiMZTYoite-ec4byLNlPxoX8k'\n @file = file\n @properties = []\n \n File.open(file, \"r:UTF-8\").each do |line| \n @properties << line \n end\n end",
"def load_file( file )\n log \"Loading file #{file}\"\n\n # Workaround for some odd load behavior when not a regular file.\n IO.read( file )\n\n load( file, true ) #wrap in in anonymous module\n end",
"def load_yaml(filename); end",
"def loadTemplate\n\t\t@template = File.read(@templateFile)\n\tend",
"def loadTemplate\n\t\t@template = File.read(@templateFile)\n\tend",
"def load(path); end",
"def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end",
"def fetch\n update_attributes(application.api_client.get(\n \"language/#{locale}/definition\", {},\n {\n cache_key: self.class.cache_key(locale)\n }\n ))\n rescue Tml::Exception => ex\n Tml.logger.error(\"Failed to load language: #{ex}\")\n self\n end",
"def load_files(*files)\n dsl = DSL.new(self)\n files.each do |file|\n next unless File.file?(file) # TODO: warn ?\n #begin\n dsl.instance_eval(File.read(file), file)\n #rescue => e\n # raise e if $DEBUG\n # warn e.message\n #end\n end\n end",
"def load(filename)\n file_content = File.open(filename).read\n TOMLP::Parser.new(file_content).parse\n end",
"def loadFile _args\n \"loadFile _args;\" \n end",
"def load\n if File.file?(@file_name)\n File.open(@file_name, 'r') do |file|\n YAML::load(file)\n end\n else\n default\n end\n end",
"def load_library(file_path)\n loadme = YAML.load_file(file_path)\n translatorhash = {get_meaning: {}, get_emoticon: {}}\n loadme.each_key do |k|\n translatorhash[:get_meaning][loadme[k][1]] = k\n end\n loadme.each_key do |k|\n translatorhash[:get_emoticon][loadme[k][0]] = loadme[k][1]\n end\n translatorhash\nend",
"def import\n read_dict_file(:langA)\n write_database(:langA)\n\n read_dict_file(:langB)\n write_database(:langB)\n end",
"def load(file)\n data = File.read(file)\n JSONL.parse(data)\n end",
"def translate_file(inp, literal=false)\n pn = Pathname.new(inp)\n # check file exists\n if pn.exist?\n # open and read\n text = File.open(inp).read\n ruleset = text.gsub(/\\r\\n?/, \"\\n\").split(\"\\n\") # split into rules\n out = \"\"\n # feed rules into converter and put output into variable\n ruleset.each { |rule| out << \"#{Phomo2Sce.new(rule).to_sce(literal)}\\n\" }\n out # return translated file\n else\n puts \"Error! Could not find file with path #{inp}\"\n end\nend",
"def load_yaml_file file\r\n load_yaml \"parse_file\", file\r\n end",
"def read_file(path)\n eval(File.read(path), binding, path)\n end",
"def eval_file(file)\n file = File.join(__dir__, file)\n eval(File.read(file), nil, file) # rubocop:disable Security/Eval\nend",
"def load(file_name, default_env = T.unsafe(nil)); end",
"def load(raw)\n raw\n end",
"def load_file(filename)\n instance_eval File.read(filename), filename, 1\n self\n end",
"def open(file, locale)\n new(File.open(file), locale)\n end",
"def initialize(language = :default, replacement = \"?\")\n \n if Symbol === language\n path = \"#{File.dirname(__FILE__)}/mappings/#{language}.yaml\"\n else\n path = language\n end\n \n h = YAML.load_file(path)\n i = Iconv.new(\"UCS-4\",\"UTF-8\")\n \n # use the default replacement if the hash \n @map = Hash.new( i.iconv(replacement).unpack(PackFormat) )\n \n # the mappings file is UTF-8, recode to UCS-4\n h.each { |k,v|\n @map[*i.iconv(k).unpack(PackFormat)] = i.iconv(v).unpack(PackFormat)\n }\n \n @map\n end",
"def eval_file; end",
"def load_file(file)\n kernel_load(file)\n end",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def translate(filename)\r\n\t\t@array_translate = []\r\n\t\tFile.open(filename).each do |line|\r\n\t\t\t@array_translate << line.split\r\n\t\tend\r\n\tend",
"def load_library(path)\n data = YAML.load_file(path)\n # maps the data to their proper language despcriptions\n data.map do |key, value|\n data[key] = { english: value[0], japanese: value[1] }\n end\n data\nend",
"def load(filename, wrap=false) end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end"
] |
[
"0.7082958",
"0.7082958",
"0.6813423",
"0.67102414",
"0.655972",
"0.65539837",
"0.65329677",
"0.6460485",
"0.6437766",
"0.6375245",
"0.6345969",
"0.63019913",
"0.62080586",
"0.62069494",
"0.61903834",
"0.61903834",
"0.61797833",
"0.6172525",
"0.6165779",
"0.6136125",
"0.61024714",
"0.60972947",
"0.608246",
"0.6026353",
"0.598877",
"0.5898173",
"0.5887978",
"0.58870655",
"0.58084935",
"0.5808373",
"0.5793423",
"0.5793423",
"0.57817274",
"0.5757839",
"0.5743445",
"0.57289064",
"0.57289064",
"0.5722789",
"0.5722769",
"0.5718892",
"0.571193",
"0.568679",
"0.5646753",
"0.56404537",
"0.5618116",
"0.5613011",
"0.558861",
"0.5582824",
"0.55740994",
"0.55635536",
"0.5563391",
"0.5562832",
"0.5561949",
"0.55595875",
"0.55584675",
"0.55563664",
"0.55527896",
"0.5547346",
"0.5545506",
"0.5544693",
"0.554284",
"0.55342966",
"0.5532082",
"0.5529481",
"0.5510073",
"0.5509905",
"0.5503529",
"0.550079",
"0.5498414",
"0.5484774",
"0.5481771",
"0.5475064",
"0.54656065",
"0.54628116",
"0.54628116",
"0.545514",
"0.5444145",
"0.5441651",
"0.5440231",
"0.54350805",
"0.54198325",
"0.5417886",
"0.5403821",
"0.5397825",
"0.539516",
"0.5395061",
"0.5389356",
"0.53820926",
"0.5379247",
"0.5374857",
"0.53645164",
"0.53602326",
"0.535181",
"0.5349848",
"0.53469795",
"0.53402543",
"0.53388023",
"0.53354055",
"0.533523",
"0.5331725",
"0.5329765"
] |
0.0
|
-1
|
Loads a YAML translations file. The data must have locales as toplevel keys. source://i18n//lib/i18n/backend/base.rb251
|
def load_yaml(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_yml(filename); end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def load\n if File.file?(@file_name)\n File.open(@file_name, 'r') do |file|\n YAML::load(file)\n end\n else\n default\n end\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def dump_yaml!\n FileUtils.mkdir_p LOCALE_DIR\n File.open(STANDARD_LOCALE_FILE,'w+') { |f| YAML::dump(@translations, f) } \n end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def load_yaml_file(path)\n if (file = find_data_file(path))\n YAML.load_file(file)\n end\n end",
"def load_yaml\n if has_file? \"#{name}.yml\"\n YAML.load_file(path / \"#{name}.yml\").apply_to self\n end\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_yaml(path) # Path must be in /data\n # path must be a yaml file path\n YAML.load_file(File.join(__dir__, \"../data/#{path}.yml\"))\n # YAML keys will be allways strings (never symbols)\n # Returns hash of values (strings)\nend",
"def load(args)\n YAML::load_file(args[:file_name])\n end",
"def load_yaml(args = {})\n file = File.read(args[:file] || CMUX_YAML)\n yaml = YAML.load(file)\n args[:key] ? yaml[args[:key]] : yaml\n rescue Psych::SyntaxError\n message = \"Make sure you've written #{file} in YAML Simple Mapping.\" \\\n ' Please check README.'\n raise message.red\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_yml_data\n if File.exist? self.class.file_location\n # YAML.load_file returns false if the file exists but is empty. So\n # added the || {} to ensure we always return a hash from this method\n YAML.load_file(self.class.file_location) || {}\n else\n {}\n end\n end",
"def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end",
"def loadyaml(filename) YAML.load_file(filename) end",
"def load_metas_for_locale(locale)\n path = metas_path(locale)\n if File.exists?(path)\n YAML.load(File.open(path))\n else\n logger.error \"[Metaslug] #{path} not found.\"\n {}\n end\n end",
"def yaml_load filename\n yaml_string = File.read filename\n\n YAML::load yaml_string\nend",
"def yaml_load filename\n yaml_string = File.read filename\n\n YAML::load yaml_string\nend",
"def load_yaml(data, safe: T.unsafe(nil), whitelist_classes: T.unsafe(nil), whitelist_symbols: T.unsafe(nil), aliases: T.unsafe(nil)); end",
"def load_yml(template, options={})\n case File.extname(template)\n when '.erb'\n parse_erb(template, options)\n else\n YAML.load_file(template)\n end\n end",
"def yaml_load(file)\n\t\tYAML.load_file(file.to_s)\n\tend",
"def load_yaml_file file\r\n load_yaml \"parse_file\", file\r\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def load_database_yaml; end",
"def load_database_yaml; end",
"def load_library(path)\n data = YAML.load_file(path)\n # maps the data to their proper language despcriptions\n data.map do |key, value|\n data[key] = { english: value[0], japanese: value[1] }\n end\n data\nend",
"def generate_yaml(locale_name, translations)\n yaml = YamlDocument.new(\"config/locales/translation_#{locale_name}.yml\", locale_name)\n each_value [], translations do |parents, value|\n node = parents.inject(yaml[locale_name]) {|node, parent| node[parent]}\n node.value = value\n end\n yaml\n end",
"def read_yaml_data_file filename\n data = {}\n File.open(filename, 'r') do |f|\n data = YAML.load(f)\n end\n data\nend",
"def read_yaml_data_file filename\n data = {}\n File.open(filename, 'r') do |f|\n data = YAML.load(f)\n end\n data\nend",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_yaml_data( file )\n yaml_data = {}\n yaml_data.merge!( File.open( file ) { |yf| YAML::load( yf ) } )\n\n return yaml_data\n end",
"def load_yaml(path)\n YAML.load_file File.expand_path(\"../#{path}\", File.dirname(__FILE__))\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end",
"def dump\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n delete_all unless Interpret.soft\n\n records = []\n files.each do |f|\n ar = YAML.load_file f\n locale = ar.keys.first\n records += parse_hash(ar.first[1], locale)\n end\n\n # TODO: Replace with activerecord-import bulk inserts\n transaction do\n records.each {|x| x.save(:validate => false)}\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def yaml(*files, **options, &block) = read(*files, parse: :yaml, ext: ['.yml', '.yaml'], **options, &block)",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def load\n yaml = YAML.load_file(@file_path)\n yaml.each {|k, v| interpolate_setting(yaml, v)}\n settings = OpenStruct.new\n add_hash(settings, yaml)\n\n @lock.synchronize do\n @yaml = yaml\n @settings = settings\n end\n rescue\n puts \"Failed to load file: #{@file_path}\\n#{$!}\"\n end",
"def load yaml\n data = YAML::load yaml \n raise \"Cannot load YAML data\" unless data\n\n @raw = @data = @errors = @commands = nil\n @errors = data.delete('__ERRORS__')\n @commands = data.delete('__COMMANDS__')\n @raw = OpenStruct.new data\n @data = { }\n end",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def load(file_path, local_variables = {})\n yaml = render file_path, local_variables\n YAML.load yaml\n end",
"def data\n YAML::load_file(files[:config])\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load_yaml(path, environment = nil)\n env = environment ? environment.to_s : env_name\n\n contents = File.read(path)\n if contents.empty?\n raise Mongoid::Errors::EmptyConfigFile.new(path)\n end\n\n # These are the classes that can be used in a Mongoid\n # configuration file in addition to standard YAML types.\n permitted_classes = [\n # Symbols occur as values for read preference, for example.\n Symbol,\n # BSON::Binary occur as keyId values for FLE (more precisely,\n # the keyIds are UUIDs).\n BSON::Binary,\n ]\n\n result = ERB.new(contents).result\n data = if RUBY_VERSION < '2.6'\n YAML.safe_load(result, permitted_classes, [], true)\n else\n YAML.safe_load(result, permitted_classes: permitted_classes, aliases: true)\n end\n\n unless data.is_a?(Hash)\n raise Mongoid::Errors::InvalidConfigFile.new(path)\n end\n\n data[env]\n end",
"def load(filename)\n update! YAML.load_file(filename)\n end",
"def load_file(file)\n buf = File.read(file)\n\n # parse the document into a Psych tree; we don't load here because we want\n # the file/line info while creating our entities.\n doc = YAML.parse(buf, filename: file)\n\n # Document should be an Array of Hashes\n seq = doc.children.first or return # ignore empty documents\n load_error!('not a yaml sequence (Array)', file, seq) unless seq.sequence?\n\n # Loop through each Hash\n seq.children.each do |map|\n\n # Make sure it's a mapping before we convert it to a ruby Hash\n load_error!('not a yaml mapping (Hash)', file, map) unless map.mapping?\n entity = YAML.send(:symbolize_names!, map.to_ruby)\n\n # Ensure they're not using some unknown keys\n unknown_keys = entity.keys - SUPPORTED_KEYS\n load_error!(\"unknown keys: #{unknown_keys}\", file, map) unless\n unknown_keys.empty?\n\n load_error!(\"id and update are mutually exclusive\", file, map) if\n entity[:id] and entity[:update]\n\n source = \"#{file}:#{map.start_line + 1}\"\n\n create = {}\n create[:id] = entity[:id] if entity.has_key?(:id)\n create[:update] = entity[:update] if entity.has_key?(:update)\n\n # Create an Array of the various base Entities that will be layered into\n # this Entity\n create[:base] = [entity[:base]].flatten.compact\n\n # Construct an Array of component arguments that will be sent to\n # Morrow::EntityManager#create_entity\n entity[:components] ||= []\n load_error!('The `components` field must be an Array; %s' %\n [ entity[:components].inspect ], file, map) unless\n entity[:components].is_a?(Array)\n\n create[:components] = entity[:components].map do |conf|\n case conf\n when Symbol\n conf\n when String\n conf.to_sym\n when Hash\n load_error!(<<~ERROR, file, map) unless conf.size == 1\n Multiple keys found in single component configuration. Note that\n the `components` field is an Array. Perhaps you missed a '-'\n before the next component after this one.\n ERROR\n\n # A Hash is a component with non-default values. The values may be\n # provided as a Hash, an Array (must have all elements), or a scalar\n # (for single field Components)\n comp, config = conf.first\n case config\n when Hash\n config.rekey! { |k| k.to_sym }\n when Array\n # don't make any changes\n else\n # turn this non-array value into an array of a single element\n config = [ config ]\n end\n { comp.to_sym => config }\n else\n load_error!('Unsupported component configuration type: %s' %\n [ conf.inspect ], file, map)\n end\n end\n\n create[:remove] = entity[:remove] || []\n\n # defer the action if we're not able to do it at the moment\n begin\n create_or_update(**create)\n rescue Morrow::UnknownEntity\n defer(source: source, entity: create)\n rescue Exception => ex\n raise Morrow::Error, <<~ERROR.chomp\n error in entity file: #{source}: #{entity.pretty_inspect\n .chomp.gsub(/\\n/, \"\\n\" + ' ' * 16)}\n ERROR\n end\n end\n\n # Attempt to flush any deferred actions now that we've loaded everything in\n # the file.\n flush\n end",
"def yaml\n @yaml ||= YAML.load_file path\n rescue StandardError\n {}\n end",
"def load_data(data_file)\n puts \"FileGenTask: Loading data from YML file [ #{data_file} ]\" if @verbose\n df = DataFile.new\n @data = df.read( data_file )\n end",
"def read_yaml(base, name)\n self.content = File.read(File.join(base, name))\n\n if self.content =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n self.content = $POSTMATCH\n\n begin\n self.data = YAML.load($1)\n rescue => e\n puts \"YAML Exception reading #{name}: #{e.message}\"\n end\n end\n\n self.data ||= {}\n end",
"def read_yaml(base, name, opts = {})\n begin\n self.content = File.read(File.join(base, name),\n merged_file_read_opts(opts))\n if content =~ /\\A(---\\s*\\n.*?\\n?)^((---|\\.\\.\\.)\\s*$\\n?)/m\n self.content = $POSTMATCH\n self.data = SafeYAML.load($1)\n end\n rescue SyntaxError => e\n Jekyll.logger.warn \"YAML Exception reading #{File.join(base, name)}: #{e.message}\"\n rescue Exception => e\n Jekyll.logger.warn \"Error reading file #{File.join(base, name)}: #{e.message}\"\n end\n\n self.data ||= {}\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_yml_test_case_map()\n YAML::load_file(self.class.test_case_map_path)\n end",
"def read_yaml(base, name)\n begin\n text = File.read(File.join(base, name))\n data = {'layout'=>'default'}\n\n if page_yaml = transfiguration['page_yaml']\n data.merge!(page_yaml)\n end\n\n # commented metadata\n if text =~ /<!--\\s+---\\s*(.*?)-->\\s*$\\n?/m\n text.delete($0)\n data.merge!(YAML.safe_load($1))\n end\n\n self.content = text\n self.data = data\n rescue SyntaxError => e\n puts \"YAML Exception reading #{File.join(base, name)}: #{e.message}\"\n rescue Exception => e\n puts \"Error reading file #{File.join(base, name)}: #{e.message}\"\n end\n\n unless self.data['layout']\n self.data['layout'] = 'page'\n end\n\n return self.data\n end",
"def load_dictionary(lang)\n return false unless lang\n dictionary = File.join(File.dirname(__FILE__), 'dictionaries', \"#{lang}.yml\")\n YAML::load(File.open(dictionary))\n end",
"def load_from_file(file_path)\n require \"erb\"\n opts = YAML.load(ERB.new(File.read(file_path)).result) || {}\n symbolize_keys(opts)\n end",
"def yaml_load(filename)\n\t\tbegin\n\t\t YAML::load(File.read filename)\n\t\trescue\n\t\t\tputs \"Unable to read from file '#{ filename }'.\"\n\t\t\tnil\n\t\tend\n\tend",
"def load_yaml(filename)\n\t\tpath = File.realpath(filename)\n\t\tdata = YAML.load_file(path)\n\t\tload_hash(data)\n\tend",
"def load_module_yaml(file_name)\n\t\tFile.open(file_name) { |file| YAML.load(file) }\n\tend",
"def load_regions\n YAML.load_file(\"#{root_path}/config/countries.yml\")\n end",
"def read_file(path)\r\n YAML::load( File.open(path) )\r\n end",
"def load_library(path)\n # code goes here\n data = YAML.load_file(path)\n \n YAML.dump(\"foo\")\n { :a => 'b'}.to_yaml\n #data.map do |english, japanese|\n # binding.pry\n #end\n binding.pry\nend",
"def load(file = nil)\n @file = file if file\n @cfg = YAML.load_file(@file)\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_yaml(file)\n @data = YAML.load(File.open(file))\n\n @data[\"people\"].each do |yaml_person|\n person = Person.new(yaml_person[\"fname\"], yaml_person[\"surname\"], yaml_person[\"dob\"])\n\n yaml_person[\"emails\"].each do |e|\n person.add_email(e)\n end\n\n yaml_person[\"phones\"].each do |e|\n person.add_phone(e)\n end\n\n add(person) \n end\n end",
"def load_yaml_files(path)\n each_data_file(path).map { |file| YAML.load_file(file) }\n end",
"def read file=STDIN\n\n yaml = case file\n when String\n raise \"Input file not defined\" unless file\n raise \"Input file does not exist\" unless File.exist? file\n raise \"Input file is not readable \" unless File.readable? file\n \n File.read(file)\n when IO\n file.read\n end\n\n raise \"Cannot read YAML data\" unless yaml\n load yaml\n end",
"def data\n exist!\n begin\n data = File.read @path\n data = @encrypter.decrypt(data) if encrypt?\n YAML.load data\n rescue Psych::SyntaxError\n raise EntrySyntaxError\n end\n end",
"def load(data)\n\t\t\t\treset\n\t\t\t\t@config = data['config'] unless data['config'].nil?\n\t\t\t\t@plugin_config = data['plugin-config'] unless data['plugin-config'].nil?\n\t\t\t\t@valid_domains = data['valid_domains'] unless data['valid_domains'].nil?\n\t\t\t\t@default_domains = data['default_domains'] unless data['default_domains'].nil?\n\t\t\t\t@partials = data['partials'] unless data['partials'].nil?\n\t\t\t\tunless data['domains'].nil?\n\t\t\t\t\tdata['domains'].each_pair do |name, domain_data|\n\t\t\t\t\t\t@domains[name].load(domain_data)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\ttrue\n\t\t\tend",
"def load_map_file map_file\n return YAML.load(map_file.read)\nend",
"def load_yaml(yaml_path, variables = nil)\n #puts \"load_yaml #{yaml_path}\"\n if variables\n YAML.load(ERB.new(File.read(yaml_path)).result(OpenStruct.new(variables).instance_eval { binding })) \n else\n YAML.load(ERB.new(File.read(yaml_path)).result)\n end\nend",
"def load_master_data\n #@master = load_yaml(DomainNeutral.master_locale, :master)\n @master = load_yaml(master_locale, :master)\n end",
"def load_storage\n YAML.load_file(file_path) || {}\n end",
"def load_yaml_files\n @room_list = YAML.load_file(__dir__ + '/rooms.yml')\n @weapon_list = YAML.load_file(__dir__ + '/weapons.yml')\n @enemy_list = YAML.load_file(__dir__ + '/enemy.yml')\n @high_score_list = YAML.load_file(__dir__ + '/high_score.yml')\n end",
"def load_yaml(file, env_vars, my = nil)\n\n yaml = YAML.load_file(file)\n eval_map_values(yaml, env_vars, file, my || yaml)\n end",
"def load_yaml(yaml_file)\n fail \"File #{yaml_file} doesn't exist.\" unless File.exist?(yaml_file)\n # Parse YAML file into a tree of nodes\n # Psych::SyntaxError doesn't inherit from StandardError in some versions,\n # so we want to explicitly catch it if using Psych.\n rescue_errors = [::StandardError, ::Psych::SyntaxError]\n yaml_parsed = File.open(yaml_file, 'r') do |f|\n begin\n YAML.parse(f)\n rescue *rescue_errors => e\n raise \"unable to parse #{yaml_file}: #{e}\"\n end\n end\n return {} unless yaml_parsed\n # Validate the node tree\n validate_yaml(yaml_parsed, yaml_file)\n # If validation passed, convert the node tree to a Ruby Hash.\n yaml_parsed.transform\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load_yml\n cfg_file=\"#{::Rails.root}/config/mcommunity.yml\"\n\n begin\n mcommunity_erb = ERB.new(IO.read(cfg_file)).result(binding)\n rescue StandardError, SyntaxError => e\n raise(\"#{cfg_file} could not be parsed with ERB. \\n#{e.inspect}\")\n end\n\n begin\n mcommunity_yml = YAML::load(mcommunity_erb)\n rescue => e\n raise(\"#{cfg_file} was found, but could not be parsed.\\n#{e.inspect}\")\n end\n\n if mcommunity_yml.nil? || !mcommunity_yml.is_a?(Hash)\n raise(\"#{cfg_file} was found, but was blank or malformed.\\n\")\n end\n\n begin\n raise \"The #{::Rails.env} environment settings were not found in #{cfg_file}\" unless mcommunity_yml[::Rails.env]\n mcommunity_cfg = mcommunity_yml[::Rails.env].symbolize_keys\n end\n\n mcommunity_cfg\nend",
"def load_from_file(path)\n YAML.load_file(path).each { |n,v| instance_variable_set(n, v) }\n end",
"def load_yaml(file, default={})\n default.merge(YAML.load_file(file))\n end",
"def load_yaml(file)\n require 'yaml'\n tokens = YAML.load_file(file)\n tokens.each do |token, category|\n @db[token] = category\n end\n end",
"def load_from_yaml(file)\n document_lines = File.readlines(file)\n\n headers = document_lines.enum_for(:each_with_index).\n find_all { |line, _| line =~ /^---/ }\n if headers.empty? || headers.first[1] != 0\n headers.unshift [\"--- name:default\", -1]\n end\n\n options = headers.map do |line, line_number|\n line_options = Hash.new\n line = line.chomp\n line.split(/\\s+/)[1..-1].each do |opt|\n if opt =~ /^(\\w+):(.*)$/\n line_options[$1] = $2\n else\n raise ArgumentError, \"#{file}:#{line_number}: wrong format #{opt}, expected option_name:value, where 'value' has no spaces\"\n end\n end\n line_options['merge'] = (line_options['merge'] == 'true')\n line_options['chain'] = (line_options['chain'] || '').split(',')\n [line_options, line_number]\n end\n options[0][0]['name'] ||= 'default'\n\n options.each do |line_options, line_number|\n if !line_options['name']\n raise ArgumentError, \"#{file}:#{line_number}: missing a 'name' option\"\n end\n end\n\n sections = []\n options.each_cons(2) do |(_, line0), (_, line1)|\n sections << document_lines[line0 + 1, line1 - line0 - 1]\n end\n sections << document_lines[options[-1][1] + 1, document_lines.size - options[-1][1] - 1]\n\n changed_sections = []\n @conf_options = options\n\n sections.each_with_index do |doc, idx|\n doc = doc.join(\"\")\n doc = evaluate_dynamic_content(file, doc)\n\n result = YAML.load(StringIO.new(doc))\n\n conf_options = options[idx].first\n name = conf_options.delete('name')\n changed = in_context(\"while loading section #{name} of #{file}\") do\n add(name, result || Hash.new, conf_options)\n end\n\n if changed\n changed_sections << name\n end\n end\n\t if !changed_sections.empty?\n\t \t@merged_conf.clear\n\t end\n changed_sections\n rescue Exception => e\n raise e, \"error loading #{file}: #{e.message}\", e.backtrace\n end",
"def load_from_yaml(yaml_file)\n data = ::YAML.load_file(yaml_file)\n @headers = data[:headers]\n @currencies = data[:currencies]\n end",
"def load_yaml(base=ENV['PWD'], env=\"active\")\n env = \"dev\" if env == \"active\" and not File.exist? \"#{base}/opt/active\"\n @data = ::YAML.load_file(\"#{base}/opt/#{env}/config.yaml\")\n end",
"def read_yml_file_base(yml_file)\n YAML.load(read_file_base(yml_file))\n end",
"def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def read_yaml(path)\n data = File.read path\n\n # Necessary to be backward-compatible with documentation generated\n # by earliar RDoc versions.\n data = data.gsub(/ \\!ruby\\/(object|struct):(RDoc::RI|RI).*/, '')\n data = data.gsub(/ \\!ruby\\/(object|struct):SM::(\\S+)/,\n ' !ruby/\\1:RDoc::Markup::\\2')\n\n OpenStructHash.convert YAML.load(data)\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def load\n @filename = File.expand_path(file_name('feeds.yml'))\n end",
"def yaml_load\n if File.exist?(yaml_file) && !File.zero?(yaml_file)\n YAML.load_file(yaml_file).sort_by!(&:time).reverse!\n else\n []\n end\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end"
] |
[
"0.72406995",
"0.6987751",
"0.6949591",
"0.6899159",
"0.66687495",
"0.6665493",
"0.6591126",
"0.65860075",
"0.65714854",
"0.6557816",
"0.6534201",
"0.6506259",
"0.6465095",
"0.64310896",
"0.6410187",
"0.63956946",
"0.63916564",
"0.6381389",
"0.63684714",
"0.6359302",
"0.6359302",
"0.6318454",
"0.6315406",
"0.6304266",
"0.62908226",
"0.62839866",
"0.62839866",
"0.6283162",
"0.6277071",
"0.6277071",
"0.62729836",
"0.6268348",
"0.6259906",
"0.625889",
"0.62467515",
"0.61970925",
"0.6180741",
"0.61793816",
"0.61790127",
"0.61790127",
"0.61737704",
"0.61583984",
"0.6146637",
"0.6127568",
"0.6111148",
"0.6101871",
"0.60829383",
"0.60718375",
"0.60718375",
"0.6048097",
"0.6043271",
"0.60285395",
"0.5993594",
"0.5988487",
"0.598445",
"0.5974163",
"0.5968025",
"0.5958651",
"0.594033",
"0.59318626",
"0.5924613",
"0.5912588",
"0.5909746",
"0.59090245",
"0.59079295",
"0.59043884",
"0.58776945",
"0.5869887",
"0.5867125",
"0.5854399",
"0.58277154",
"0.58174765",
"0.58174175",
"0.5809432",
"0.5806434",
"0.57996917",
"0.5797384",
"0.57914484",
"0.57913584",
"0.57858944",
"0.5784024",
"0.5780116",
"0.5774768",
"0.57699704",
"0.5752544",
"0.57464623",
"0.57408744",
"0.57368594",
"0.57290286",
"0.5725839",
"0.57177806",
"0.5709498",
"0.5708636",
"0.56941336",
"0.5693583",
"0.56759745",
"0.56581694",
"0.56555426",
"0.56548125",
"0.5640387"
] |
0.6920773
|
3
|
Loads a YAML translations file. The data must have locales as toplevel keys. source://i18n//lib/i18n/backend/base.rb251
|
def load_yml(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def load_yaml(filename); end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def load\n if File.file?(@file_name)\n File.open(@file_name, 'r') do |file|\n YAML::load(file)\n end\n else\n default\n end\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def dump_yaml!\n FileUtils.mkdir_p LOCALE_DIR\n File.open(STANDARD_LOCALE_FILE,'w+') { |f| YAML::dump(@translations, f) } \n end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def load_yaml_file(path)\n if (file = find_data_file(path))\n YAML.load_file(file)\n end\n end",
"def load_yaml\n if has_file? \"#{name}.yml\"\n YAML.load_file(path / \"#{name}.yml\").apply_to self\n end\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_yaml(path) # Path must be in /data\n # path must be a yaml file path\n YAML.load_file(File.join(__dir__, \"../data/#{path}.yml\"))\n # YAML keys will be allways strings (never symbols)\n # Returns hash of values (strings)\nend",
"def load(args)\n YAML::load_file(args[:file_name])\n end",
"def load_yaml(args = {})\n file = File.read(args[:file] || CMUX_YAML)\n yaml = YAML.load(file)\n args[:key] ? yaml[args[:key]] : yaml\n rescue Psych::SyntaxError\n message = \"Make sure you've written #{file} in YAML Simple Mapping.\" \\\n ' Please check README.'\n raise message.red\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_yml_data\n if File.exist? self.class.file_location\n # YAML.load_file returns false if the file exists but is empty. So\n # added the || {} to ensure we always return a hash from this method\n YAML.load_file(self.class.file_location) || {}\n else\n {}\n end\n end",
"def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end",
"def loadyaml(filename) YAML.load_file(filename) end",
"def load_metas_for_locale(locale)\n path = metas_path(locale)\n if File.exists?(path)\n YAML.load(File.open(path))\n else\n logger.error \"[Metaslug] #{path} not found.\"\n {}\n end\n end",
"def yaml_load filename\n yaml_string = File.read filename\n\n YAML::load yaml_string\nend",
"def yaml_load filename\n yaml_string = File.read filename\n\n YAML::load yaml_string\nend",
"def load_yaml(data, safe: T.unsafe(nil), whitelist_classes: T.unsafe(nil), whitelist_symbols: T.unsafe(nil), aliases: T.unsafe(nil)); end",
"def load_yml(template, options={})\n case File.extname(template)\n when '.erb'\n parse_erb(template, options)\n else\n YAML.load_file(template)\n end\n end",
"def yaml_load(file)\n\t\tYAML.load_file(file.to_s)\n\tend",
"def load_yaml_file file\r\n load_yaml \"parse_file\", file\r\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def load_database_yaml; end",
"def load_database_yaml; end",
"def load_library(path)\n data = YAML.load_file(path)\n # maps the data to their proper language despcriptions\n data.map do |key, value|\n data[key] = { english: value[0], japanese: value[1] }\n end\n data\nend",
"def generate_yaml(locale_name, translations)\n yaml = YamlDocument.new(\"config/locales/translation_#{locale_name}.yml\", locale_name)\n each_value [], translations do |parents, value|\n node = parents.inject(yaml[locale_name]) {|node, parent| node[parent]}\n node.value = value\n end\n yaml\n end",
"def read_yaml_data_file filename\n data = {}\n File.open(filename, 'r') do |f|\n data = YAML.load(f)\n end\n data\nend",
"def read_yaml_data_file filename\n data = {}\n File.open(filename, 'r') do |f|\n data = YAML.load(f)\n end\n data\nend",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_yaml_data( file )\n yaml_data = {}\n yaml_data.merge!( File.open( file ) { |yf| YAML::load( yf ) } )\n\n return yaml_data\n end",
"def load_yaml(path)\n YAML.load_file File.expand_path(\"../#{path}\", File.dirname(__FILE__))\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_file!(file)\n if File.file?(file)\n yaml = %w{.yaml .yml}.include?(File.extname(file))\n text = File.read(file)\n if yaml or /\\A---/ =~ text\n #text = ERB.new(text).result(Object.new.instance_eval{binding})\n data = YAML.load(text)\n data.each do |k,v|\n __send__(\"#{k}=\", v)\n end\n else\n # TODO: Should we really do this here?\n instance_eval(text, file, 0)\n end\n end\n end",
"def dump\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n delete_all unless Interpret.soft\n\n records = []\n files.each do |f|\n ar = YAML.load_file f\n locale = ar.keys.first\n records += parse_hash(ar.first[1], locale)\n end\n\n # TODO: Replace with activerecord-import bulk inserts\n transaction do\n records.each {|x| x.save(:validate => false)}\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def yaml(*files, **options, &block) = read(*files, parse: :yaml, ext: ['.yml', '.yaml'], **options, &block)",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def load\n yaml = YAML.load_file(@file_path)\n yaml.each {|k, v| interpolate_setting(yaml, v)}\n settings = OpenStruct.new\n add_hash(settings, yaml)\n\n @lock.synchronize do\n @yaml = yaml\n @settings = settings\n end\n rescue\n puts \"Failed to load file: #{@file_path}\\n#{$!}\"\n end",
"def load yaml\n data = YAML::load yaml \n raise \"Cannot load YAML data\" unless data\n\n @raw = @data = @errors = @commands = nil\n @errors = data.delete('__ERRORS__')\n @commands = data.delete('__COMMANDS__')\n @raw = OpenStruct.new data\n @data = { }\n end",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def take_yaml(yml)\n @data = YAML.load(yml)\n end",
"def load(file_path, local_variables = {})\n yaml = render file_path, local_variables\n YAML.load yaml\n end",
"def data\n YAML::load_file(files[:config])\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load_yaml(path, environment = nil)\n env = environment ? environment.to_s : env_name\n\n contents = File.read(path)\n if contents.empty?\n raise Mongoid::Errors::EmptyConfigFile.new(path)\n end\n\n # These are the classes that can be used in a Mongoid\n # configuration file in addition to standard YAML types.\n permitted_classes = [\n # Symbols occur as values for read preference, for example.\n Symbol,\n # BSON::Binary occur as keyId values for FLE (more precisely,\n # the keyIds are UUIDs).\n BSON::Binary,\n ]\n\n result = ERB.new(contents).result\n data = if RUBY_VERSION < '2.6'\n YAML.safe_load(result, permitted_classes, [], true)\n else\n YAML.safe_load(result, permitted_classes: permitted_classes, aliases: true)\n end\n\n unless data.is_a?(Hash)\n raise Mongoid::Errors::InvalidConfigFile.new(path)\n end\n\n data[env]\n end",
"def load(filename)\n update! YAML.load_file(filename)\n end",
"def load_file(file)\n buf = File.read(file)\n\n # parse the document into a Psych tree; we don't load here because we want\n # the file/line info while creating our entities.\n doc = YAML.parse(buf, filename: file)\n\n # Document should be an Array of Hashes\n seq = doc.children.first or return # ignore empty documents\n load_error!('not a yaml sequence (Array)', file, seq) unless seq.sequence?\n\n # Loop through each Hash\n seq.children.each do |map|\n\n # Make sure it's a mapping before we convert it to a ruby Hash\n load_error!('not a yaml mapping (Hash)', file, map) unless map.mapping?\n entity = YAML.send(:symbolize_names!, map.to_ruby)\n\n # Ensure they're not using some unknown keys\n unknown_keys = entity.keys - SUPPORTED_KEYS\n load_error!(\"unknown keys: #{unknown_keys}\", file, map) unless\n unknown_keys.empty?\n\n load_error!(\"id and update are mutually exclusive\", file, map) if\n entity[:id] and entity[:update]\n\n source = \"#{file}:#{map.start_line + 1}\"\n\n create = {}\n create[:id] = entity[:id] if entity.has_key?(:id)\n create[:update] = entity[:update] if entity.has_key?(:update)\n\n # Create an Array of the various base Entities that will be layered into\n # this Entity\n create[:base] = [entity[:base]].flatten.compact\n\n # Construct an Array of component arguments that will be sent to\n # Morrow::EntityManager#create_entity\n entity[:components] ||= []\n load_error!('The `components` field must be an Array; %s' %\n [ entity[:components].inspect ], file, map) unless\n entity[:components].is_a?(Array)\n\n create[:components] = entity[:components].map do |conf|\n case conf\n when Symbol\n conf\n when String\n conf.to_sym\n when Hash\n load_error!(<<~ERROR, file, map) unless conf.size == 1\n Multiple keys found in single component configuration. Note that\n the `components` field is an Array. Perhaps you missed a '-'\n before the next component after this one.\n ERROR\n\n # A Hash is a component with non-default values. The values may be\n # provided as a Hash, an Array (must have all elements), or a scalar\n # (for single field Components)\n comp, config = conf.first\n case config\n when Hash\n config.rekey! { |k| k.to_sym }\n when Array\n # don't make any changes\n else\n # turn this non-array value into an array of a single element\n config = [ config ]\n end\n { comp.to_sym => config }\n else\n load_error!('Unsupported component configuration type: %s' %\n [ conf.inspect ], file, map)\n end\n end\n\n create[:remove] = entity[:remove] || []\n\n # defer the action if we're not able to do it at the moment\n begin\n create_or_update(**create)\n rescue Morrow::UnknownEntity\n defer(source: source, entity: create)\n rescue Exception => ex\n raise Morrow::Error, <<~ERROR.chomp\n error in entity file: #{source}: #{entity.pretty_inspect\n .chomp.gsub(/\\n/, \"\\n\" + ' ' * 16)}\n ERROR\n end\n end\n\n # Attempt to flush any deferred actions now that we've loaded everything in\n # the file.\n flush\n end",
"def yaml\n @yaml ||= YAML.load_file path\n rescue StandardError\n {}\n end",
"def load_data(data_file)\n puts \"FileGenTask: Loading data from YML file [ #{data_file} ]\" if @verbose\n df = DataFile.new\n @data = df.read( data_file )\n end",
"def read_yaml(base, name)\n self.content = File.read(File.join(base, name))\n\n if self.content =~ /^(---\\s*\\n.*?\\n?)^(---\\s*$\\n?)/m\n self.content = $POSTMATCH\n\n begin\n self.data = YAML.load($1)\n rescue => e\n puts \"YAML Exception reading #{name}: #{e.message}\"\n end\n end\n\n self.data ||= {}\n end",
"def read_yaml(base, name, opts = {})\n begin\n self.content = File.read(File.join(base, name),\n merged_file_read_opts(opts))\n if content =~ /\\A(---\\s*\\n.*?\\n?)^((---|\\.\\.\\.)\\s*$\\n?)/m\n self.content = $POSTMATCH\n self.data = SafeYAML.load($1)\n end\n rescue SyntaxError => e\n Jekyll.logger.warn \"YAML Exception reading #{File.join(base, name)}: #{e.message}\"\n rescue Exception => e\n Jekyll.logger.warn \"Error reading file #{File.join(base, name)}: #{e.message}\"\n end\n\n self.data ||= {}\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_yml_test_case_map()\n YAML::load_file(self.class.test_case_map_path)\n end",
"def read_yaml(base, name)\n begin\n text = File.read(File.join(base, name))\n data = {'layout'=>'default'}\n\n if page_yaml = transfiguration['page_yaml']\n data.merge!(page_yaml)\n end\n\n # commented metadata\n if text =~ /<!--\\s+---\\s*(.*?)-->\\s*$\\n?/m\n text.delete($0)\n data.merge!(YAML.safe_load($1))\n end\n\n self.content = text\n self.data = data\n rescue SyntaxError => e\n puts \"YAML Exception reading #{File.join(base, name)}: #{e.message}\"\n rescue Exception => e\n puts \"Error reading file #{File.join(base, name)}: #{e.message}\"\n end\n\n unless self.data['layout']\n self.data['layout'] = 'page'\n end\n\n return self.data\n end",
"def load_dictionary(lang)\n return false unless lang\n dictionary = File.join(File.dirname(__FILE__), 'dictionaries', \"#{lang}.yml\")\n YAML::load(File.open(dictionary))\n end",
"def load_from_file(file_path)\n require \"erb\"\n opts = YAML.load(ERB.new(File.read(file_path)).result) || {}\n symbolize_keys(opts)\n end",
"def yaml_load(filename)\n\t\tbegin\n\t\t YAML::load(File.read filename)\n\t\trescue\n\t\t\tputs \"Unable to read from file '#{ filename }'.\"\n\t\t\tnil\n\t\tend\n\tend",
"def load_yaml(filename)\n\t\tpath = File.realpath(filename)\n\t\tdata = YAML.load_file(path)\n\t\tload_hash(data)\n\tend",
"def load_module_yaml(file_name)\n\t\tFile.open(file_name) { |file| YAML.load(file) }\n\tend",
"def load_regions\n YAML.load_file(\"#{root_path}/config/countries.yml\")\n end",
"def read_file(path)\r\n YAML::load( File.open(path) )\r\n end",
"def load_library(path)\n # code goes here\n data = YAML.load_file(path)\n \n YAML.dump(\"foo\")\n { :a => 'b'}.to_yaml\n #data.map do |english, japanese|\n # binding.pry\n #end\n binding.pry\nend",
"def load(file = nil)\n @file = file if file\n @cfg = YAML.load_file(@file)\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_yaml(file)\n @data = YAML.load(File.open(file))\n\n @data[\"people\"].each do |yaml_person|\n person = Person.new(yaml_person[\"fname\"], yaml_person[\"surname\"], yaml_person[\"dob\"])\n\n yaml_person[\"emails\"].each do |e|\n person.add_email(e)\n end\n\n yaml_person[\"phones\"].each do |e|\n person.add_phone(e)\n end\n\n add(person) \n end\n end",
"def load_yaml_files(path)\n each_data_file(path).map { |file| YAML.load_file(file) }\n end",
"def read file=STDIN\n\n yaml = case file\n when String\n raise \"Input file not defined\" unless file\n raise \"Input file does not exist\" unless File.exist? file\n raise \"Input file is not readable \" unless File.readable? file\n \n File.read(file)\n when IO\n file.read\n end\n\n raise \"Cannot read YAML data\" unless yaml\n load yaml\n end",
"def data\n exist!\n begin\n data = File.read @path\n data = @encrypter.decrypt(data) if encrypt?\n YAML.load data\n rescue Psych::SyntaxError\n raise EntrySyntaxError\n end\n end",
"def load(data)\n\t\t\t\treset\n\t\t\t\t@config = data['config'] unless data['config'].nil?\n\t\t\t\t@plugin_config = data['plugin-config'] unless data['plugin-config'].nil?\n\t\t\t\t@valid_domains = data['valid_domains'] unless data['valid_domains'].nil?\n\t\t\t\t@default_domains = data['default_domains'] unless data['default_domains'].nil?\n\t\t\t\t@partials = data['partials'] unless data['partials'].nil?\n\t\t\t\tunless data['domains'].nil?\n\t\t\t\t\tdata['domains'].each_pair do |name, domain_data|\n\t\t\t\t\t\t@domains[name].load(domain_data)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\ttrue\n\t\t\tend",
"def load_map_file map_file\n return YAML.load(map_file.read)\nend",
"def load_yaml(yaml_path, variables = nil)\n #puts \"load_yaml #{yaml_path}\"\n if variables\n YAML.load(ERB.new(File.read(yaml_path)).result(OpenStruct.new(variables).instance_eval { binding })) \n else\n YAML.load(ERB.new(File.read(yaml_path)).result)\n end\nend",
"def load_master_data\n #@master = load_yaml(DomainNeutral.master_locale, :master)\n @master = load_yaml(master_locale, :master)\n end",
"def load_storage\n YAML.load_file(file_path) || {}\n end",
"def load_yaml_files\n @room_list = YAML.load_file(__dir__ + '/rooms.yml')\n @weapon_list = YAML.load_file(__dir__ + '/weapons.yml')\n @enemy_list = YAML.load_file(__dir__ + '/enemy.yml')\n @high_score_list = YAML.load_file(__dir__ + '/high_score.yml')\n end",
"def load_yaml(file, env_vars, my = nil)\n\n yaml = YAML.load_file(file)\n eval_map_values(yaml, env_vars, file, my || yaml)\n end",
"def load_yaml(yaml_file)\n fail \"File #{yaml_file} doesn't exist.\" unless File.exist?(yaml_file)\n # Parse YAML file into a tree of nodes\n # Psych::SyntaxError doesn't inherit from StandardError in some versions,\n # so we want to explicitly catch it if using Psych.\n rescue_errors = [::StandardError, ::Psych::SyntaxError]\n yaml_parsed = File.open(yaml_file, 'r') do |f|\n begin\n YAML.parse(f)\n rescue *rescue_errors => e\n raise \"unable to parse #{yaml_file}: #{e}\"\n end\n end\n return {} unless yaml_parsed\n # Validate the node tree\n validate_yaml(yaml_parsed, yaml_file)\n # If validation passed, convert the node tree to a Ruby Hash.\n yaml_parsed.transform\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load_yml\n cfg_file=\"#{::Rails.root}/config/mcommunity.yml\"\n\n begin\n mcommunity_erb = ERB.new(IO.read(cfg_file)).result(binding)\n rescue StandardError, SyntaxError => e\n raise(\"#{cfg_file} could not be parsed with ERB. \\n#{e.inspect}\")\n end\n\n begin\n mcommunity_yml = YAML::load(mcommunity_erb)\n rescue => e\n raise(\"#{cfg_file} was found, but could not be parsed.\\n#{e.inspect}\")\n end\n\n if mcommunity_yml.nil? || !mcommunity_yml.is_a?(Hash)\n raise(\"#{cfg_file} was found, but was blank or malformed.\\n\")\n end\n\n begin\n raise \"The #{::Rails.env} environment settings were not found in #{cfg_file}\" unless mcommunity_yml[::Rails.env]\n mcommunity_cfg = mcommunity_yml[::Rails.env].symbolize_keys\n end\n\n mcommunity_cfg\nend",
"def load_from_file(path)\n YAML.load_file(path).each { |n,v| instance_variable_set(n, v) }\n end",
"def load_yaml(file, default={})\n default.merge(YAML.load_file(file))\n end",
"def load_yaml(file)\n require 'yaml'\n tokens = YAML.load_file(file)\n tokens.each do |token, category|\n @db[token] = category\n end\n end",
"def load_from_yaml(file)\n document_lines = File.readlines(file)\n\n headers = document_lines.enum_for(:each_with_index).\n find_all { |line, _| line =~ /^---/ }\n if headers.empty? || headers.first[1] != 0\n headers.unshift [\"--- name:default\", -1]\n end\n\n options = headers.map do |line, line_number|\n line_options = Hash.new\n line = line.chomp\n line.split(/\\s+/)[1..-1].each do |opt|\n if opt =~ /^(\\w+):(.*)$/\n line_options[$1] = $2\n else\n raise ArgumentError, \"#{file}:#{line_number}: wrong format #{opt}, expected option_name:value, where 'value' has no spaces\"\n end\n end\n line_options['merge'] = (line_options['merge'] == 'true')\n line_options['chain'] = (line_options['chain'] || '').split(',')\n [line_options, line_number]\n end\n options[0][0]['name'] ||= 'default'\n\n options.each do |line_options, line_number|\n if !line_options['name']\n raise ArgumentError, \"#{file}:#{line_number}: missing a 'name' option\"\n end\n end\n\n sections = []\n options.each_cons(2) do |(_, line0), (_, line1)|\n sections << document_lines[line0 + 1, line1 - line0 - 1]\n end\n sections << document_lines[options[-1][1] + 1, document_lines.size - options[-1][1] - 1]\n\n changed_sections = []\n @conf_options = options\n\n sections.each_with_index do |doc, idx|\n doc = doc.join(\"\")\n doc = evaluate_dynamic_content(file, doc)\n\n result = YAML.load(StringIO.new(doc))\n\n conf_options = options[idx].first\n name = conf_options.delete('name')\n changed = in_context(\"while loading section #{name} of #{file}\") do\n add(name, result || Hash.new, conf_options)\n end\n\n if changed\n changed_sections << name\n end\n end\n\t if !changed_sections.empty?\n\t \t@merged_conf.clear\n\t end\n changed_sections\n rescue Exception => e\n raise e, \"error loading #{file}: #{e.message}\", e.backtrace\n end",
"def load_from_yaml(yaml_file)\n data = ::YAML.load_file(yaml_file)\n @headers = data[:headers]\n @currencies = data[:currencies]\n end",
"def load_yaml(base=ENV['PWD'], env=\"active\")\n env = \"dev\" if env == \"active\" and not File.exist? \"#{base}/opt/active\"\n @data = ::YAML.load_file(\"#{base}/opt/#{env}/config.yaml\")\n end",
"def read_yml_file_base(yml_file)\n YAML.load(read_file_base(yml_file))\n end",
"def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def read_yaml(path)\n data = File.read path\n\n # Necessary to be backward-compatible with documentation generated\n # by earliar RDoc versions.\n data = data.gsub(/ \\!ruby\\/(object|struct):(RDoc::RI|RI).*/, '')\n data = data.gsub(/ \\!ruby\\/(object|struct):SM::(\\S+)/,\n ' !ruby/\\1:RDoc::Markup::\\2')\n\n OpenStructHash.convert YAML.load(data)\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def load\n @filename = File.expand_path(file_name('feeds.yml'))\n end",
"def yaml_load\n if File.exist?(yaml_file) && !File.zero?(yaml_file)\n YAML.load_file(yaml_file).sort_by!(&:time).reverse!\n else\n []\n end\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end"
] |
[
"0.6988969",
"0.6950346",
"0.69206053",
"0.68981314",
"0.6668233",
"0.6665346",
"0.65910846",
"0.6585902",
"0.657155",
"0.65576965",
"0.6534299",
"0.6505571",
"0.64643013",
"0.6430723",
"0.6410576",
"0.63957375",
"0.63915175",
"0.63816226",
"0.63686204",
"0.63591725",
"0.63591725",
"0.6317573",
"0.63155884",
"0.6304825",
"0.6291281",
"0.6283826",
"0.6283826",
"0.6282497",
"0.62771547",
"0.62771547",
"0.6273026",
"0.62685895",
"0.6259373",
"0.62583584",
"0.6246823",
"0.61973023",
"0.6180876",
"0.61799455",
"0.61799455",
"0.61790574",
"0.6173126",
"0.61580443",
"0.61469793",
"0.6126454",
"0.6110916",
"0.61007804",
"0.60830253",
"0.60719496",
"0.60719496",
"0.6047721",
"0.604287",
"0.6028826",
"0.59938824",
"0.59883",
"0.59840614",
"0.5973596",
"0.5968063",
"0.5959174",
"0.59402955",
"0.5931757",
"0.59249187",
"0.5912973",
"0.5910735",
"0.5908276",
"0.5907878",
"0.590415",
"0.58778334",
"0.5871274",
"0.5866809",
"0.5853146",
"0.5827212",
"0.5817865",
"0.5817714",
"0.58093876",
"0.58060384",
"0.5799272",
"0.5797189",
"0.57920194",
"0.57905424",
"0.57869846",
"0.5783231",
"0.57794744",
"0.57751876",
"0.5769862",
"0.57532483",
"0.574676",
"0.5740513",
"0.5736866",
"0.57289535",
"0.5725165",
"0.57178473",
"0.5710191",
"0.5709941",
"0.5694486",
"0.5694263",
"0.5675567",
"0.5657368",
"0.5655308",
"0.56543607",
"0.5640883"
] |
0.7240902
|
0
|
Picks a translation from a pluralized mnemonic subkey according to English pluralization rules : It will pick the :one subkey if count is equal to 1. It will pick the :other subkey otherwise. It will pick the :zero subkey in the special case where count is equal to 0 and there is a :zero subkey present. This behaviour is not standard with regards to the CLDR pluralization rules. Other backends can implement more flexible or complex pluralization rules.
|
def pluralize(locale, entry, count); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pluralize(locale, entry, count)\n\n # return the entry directly if it is a string\n return entry unless entry.is_a?(Hash)\n\n key = pluralizer(locale).call(count.nil? ? 1 : count)\n # fallback to other if :zero is not set\n key = :other if key == :zero && !entry.has_key?(:zero)\n\n # raise a pluralization error only if count is explicitely set and the entry is not available\n # else return the entry that may be a hash or the translated string\n if entry.has_key?(key)\n translation entry[key], :plural_key => key.to_s\n elsif count\n raise I18n::InvalidPluralizationData.new(entry, count)\n else\n translation entry, :plural_key => nil\n end\n end",
"def n_(*msgids)\n count = msgids.pop\n \n translations = FastGettext.current_repository.plural(*msgids)\n selected = FastGettext.current_repository.pluralisation_rule.call(count)\n translations[selected] || msgids[selected] || msgids.last\n end",
"def default_pluralizer(count)\n count == 1 ? :one : :other\n end",
"def plural_keys(*args); end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)\n word = if count == 1 || count.to_s.match?(/^1(\\.0+)?$/)\n singular\n else\n plural || singular.pluralize(locale)\n end\n\n \"#{count || 0} #{word}\"\n end",
"def pluralize_with_count( count=2 )\n count > 1 ? pluralize_without_count : singularize\n end",
"def n_(singular, plural, num)\n # no textdomain configured yet\n if !@my_textdomain\n # it's enough to log just the singular form\n Yast.y2warning(\"No textdomain configured, cannot translate text #{singular.inspect}\")\n Yast.y2warning(\"Called from: #{::Kernel.caller(1).first}\")\n return fallback_n_(singular, plural, num)\n end\n\n # Switching textdomain clears gettext caches so avoid it if possible.\n # difference between _ and n_ is hat we need special cache for plural forms\n found = true\n if !@my_textdomain.include?(FastGettext.text_domain) || !cached_plural_find(singular, plural)\n # Set domain where key is defined.\n found = @my_textdomain.any? do |domain|\n FastGettext.text_domain = domain\n cached_plural_find(singular, plural)\n end\n end\n found ? Translation.n_(singular, plural, num) : fallback_n_(singular, plural, num)\n end",
"def pluralize_key\n ActiveSupport::Inflector.pluralize(key)\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\n end",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def pluralize(count, singular, plural_arg=nil, plural: plural_arg, locale: I18n.locale)\n self.class.pluralize(count, singular, plural_arg, plural: plural, locale: locale)\n end",
"def pluralize(count)\n if custom?\n # todo: make a search from the custom inflector, if doesn't match, simply fallback to @name\n # something like OurInflector.pluralize(@name) || @name\n return @custom_name\n else\n (count == 1 || count =~ /^1([\\.,]0+)?$/) ? \n I18n.t(\"units.#{@yaml}\", :count => 1) : I18n.t(\"units.#{@yaml}\", :count => count)\n end\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend",
"def plural(input)\n input.dup.en.plural\n end",
"def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def plural_noun( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word, pluralize_noun(word, count) )\n\n\t\treturn pre + plural + post\n\tend",
"def plural_adjective( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word, pluralize_special_adjective(word, count) || word )\n\n\t\treturn pre + plural + post\n\tend",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def pluralize_word(count, singular, plural = nil)\n ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def plural( count=2 )\n\t\tphrase = if self.respond_to?( :to_int )\n\t\t\t\tself.numwords\n\t\t\telse\n\t\t\t\tself.to_s\n\t\t\tend\n\n\t\tself.log.debug \"Pluralizing %p\" % [ phrase ]\n\t\tpre = text = post = nil\n\n\t\t# If the string has whitespace, only pluralize the middle bit, but\n\t\t# preserve the whitespace to add back to the result.\n\t\tif md = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase.to_s )\n\t\t\tpre, text, post = md.captures\n\t\telse\n\t\t\treturn phrase\n\t\tend\n\n\t\tplural = postprocess( text,\n\t\t\tpluralize_special_adjective(text, count) ||\n\t\t\tpluralize_special_verb(text, count) ||\n\t\t\tpluralize_noun(text, count) )\n\n\t\treturn pre + plural + post\n\tend",
"def pluralize_unit_with_locale(count, unit, locale)\n singular = locale.t(:\"units.#{unit}\")\n unit_word = count == 1 ? singular : singular.pluralize\n locale.t(:template, count: count, unit: unit_word)\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + (count == 1 ? singular : (plural || singular.pluralize))\n end",
"def simple_pluralize count, singular, plural=nil\n ((count == 1 || count =~ /^1(\\.0+)?$/) ? singular : (plural || singular.pluralize))\n end",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def plural_name\n return ext_text(9001, @id) if Item.id_valid?(@id)\n\n return ext_text(9001, 0)\n end",
"def pluralize(count = nil)\n if count == 1\n self\n else\n MotionSupport::Inflector.pluralize(self)\n end\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count} \" + if count == 1\n singular\n elsif plural\n plural\n elsif Object.const_defined?(\"Inflector\")\n Inflector.pluralize(singular)\n else\n singular + \"s\"\n end\n end",
"def create_pluralized_getter(key)\n define_singleton_method(BOOKWORM_KEYS[key]['plural'].to_sym) do\n self[key]\n end\n end",
"def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def pluralizer num, noun\n if num == 1\n \"#{num} #{noun}\"\n else\n \"#{num} #{noun}s\"\n end\nend",
"def pluralized_array_from_hash(hash, singular_key, plural_key); end",
"def pluralize\n self[-1] == 's' ? \"#{self}es\" : \"#{self}s\"\n end",
"def plural_verb( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word,\n\t\t\tpluralize_special_verb(word, count) ||\n\t\t\tpluralize_general_verb(word, count) )\n\n\t\treturn pre + plural + post\n\tend",
"def pluralisation_rule\n Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}\n end",
"def pluralize(word); end",
"def plural_without_count(count, word)\n count == 1 ? word : word.pluralize\n end",
"def plural\n return word if word.to_s.empty?\n\n find_match(Inflection.configuration.plurals[:noun]) ||\n (uncountable? && word) || find_match(Nouns.plurals) || word\n end",
"def pluralizer(num,noun)\n p noun == \"sheep\" ? \"#{num} #{noun}\" : noun == \"geese\" ? \"#{num} #{noun}\" :\n num == 1 && noun == \"child\" ? \"#{num} #{noun}\" : noun == \"child\" ? \"#{num} #{noun}ren\" :\n noun == \"children\" ? \"#{num} child\" : num == 1 && noun == \"people\" ? \"#{num} person\" :\n num > 1 ? \"#{num} #{noun}s\" : nil\nend",
"def pluralize(singularStr, num)\n if num == 1\n return singularStr\n else\n if singularStr[-1] == \"s\" # singularStr[-1] returns last character of string\n return \"#{singularStr}es\"\n else\n return \"#{singularStr}s\"\n end\n end\n end",
"def pluralize\n p = self[ :plural ]\n p = ! scalar? if p.nil?\n p = 's' if p == false\n p = 'p' if p == true\n p.to_s\n end",
"def plural(word)\n # special exceptions\n return \"\" if word == \"\"\n if result = plural_of[word]\n return result.dup\n end\n result = word.dup\n regex, hash = pluralization_rules\n result.sub!(regex) {|m| hash[m]}\n plural_of[word] = result\n return result\n end",
"def pluralize(l_string) #count, singular, plural = nil)\n # map the arguments like in the original pluralize method\n count, singular, plural = l_string.split(',').map{ |arg| arg.strip}\n\n \"#{count} \" + if count == 1 || count == '1'\n singular\n elsif plural\n plural\n elsif Object.const_defined?(\"Inflector\")\n Inflector.pluralize(singular)\n else\n singular + \"s\"\n end\n end",
"def pluralizer string, n\n if n == 1 \n puts \"#{n} #{string}\"\n elsif n > 1 || n==0\n puts \"#{n} #{string}s\"\n end\nend",
"def pluralizer num, noun\n if num != 1\n \"#{num} #{noun}s\"\n else \"#{num} #{noun}\"\n end\nend",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def pluralizer (num, noun)\n return \"#{num} #{noun}\" if num == 1\n return \"#{num} geese\" if noun == \"goose\"\n return \"#{num} sheep\" if noun == \"sheep\"\n return \"#{num} #{noun}s\"\nend",
"def plural\n\t\tEndings.each { |k, v|\n\t\t\tif name =~ '(.*)' + k + '$'\n\t\t\t\treturn $1.to_s + v\n\t\t\tend\n\t\t}\n\t\treturn \"#{name}s\"\n\tend",
"def plural(n, item)\n n == 1 ? \"#{n} #{item}\" : \"#{n} #{item}s\"\nend",
"def pluralizer number,noun\n if number <= 0\n \"No #{noun}\"\n elsif number == 1\n \"#{number} #{noun}\" \n else\n \"#{number} #{noun}s\"\n end\nend",
"def test_pluralize_one\n assert_equal \"book\", @d.pluralize(\"book\", 1)\n end",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def pluralize_collection collection, noun \n if collection.size == 1 \n \"1 #{noun}\"\n else \n \"#{collection.size} #{noun.pluralize}\"\n end\n end",
"def normalize_count( count, default=2 )\n\t\treturn default if count.nil? # Default to plural\n\t\tif /^(#{PL_count_one})$/i =~ count.to_s ||\n\t\t ( Linguistics::EN.classical? && /^(#{PL_count_zero})$/ =~ count.to_s )\n\t\t\treturn 1\n\t\telse\n\t\t\treturn default\n\t\tend\n\tend",
"def pluralizer num,name\n \n if num >= 2\n p \"#{num} #{name}s.\"\n else\n p \"1 #{name}.\"\n end\nend",
"def plural(num,str)\n\n num_str = number_format(num)\n if num == 1\n return num_str + ' ' + str\n else\n return num_str + ' ' + str.pluralize\n end \n \n end",
"def pluralizer (num, noun)\n return \"#{num} #{noun}\"\n return \"#{num} geese\" if noun == \"goose\"\n return \"#{num} sheep\" if noun == \"sheep\"\n return \"#{num} #{noun}s\"\nend",
"def pluralizer(noun, num)\n if num > 1\n \"#{num} #{noun}s\"\n elsif num === 1\n \"#{num} #{noun}\"\n elsif num === 0\n \"zero #{noun}s\"\n else\n \"Please enter a whole number\"\n end\nend",
"def pluralizer(noun, num)\n if num > 1\n \"#{num} #{noun}s\"\n elsif num === 1\n \"#{num} #{noun}\"\n elsif num === 0\n \"zero #{noun}s\"\n else\n \"Please enter a whole number\"\n end\nend",
"def set_plural(value_or_index = true, value = true)\n if value_or_index.is_a?(Integer)\n @plural[value_or_index] = value\n else\n @plural.collect! { value_or_index }\n end\n end",
"def plural_resource_label(options = {})\n defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,\n default: resource_label.pluralize.titleize }\n resource_name.translate defaults.merge options\n end",
"def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def plural(input)\n input>1 ? 's' : ''\n end",
"def plural(int, str)\r\n return \"#{int} #{str}s\" unless int == 1\r\n \"#{int} #{str}\"\r\n end",
"def pluralizer(num,noun)\n p num > 1 ? \"#{num} #{noun}s\" : nil\nend",
"def pluralizer number,noun\n if number <= 0\n \"No #{noun}\"\n elsif number == 1\n \"#{number} #{noun}\" \n else\n if noun.downcase == 'geese'\n noun = 'goose'\n elsif noun.downcase == 'child'\n noun = 'children'\n elsif noun.downcase == 'person'\n noun = 'people'\n else\n noun = noun.concat('s')\n end\n \"#{number} #{noun}\"\n end\nend",
"def normalize_count( count, default=2 )\n\t\treturn default if count.nil? # Default to plural\n\t\tif /^(#{PL_count_one})$/i =~ count.to_s ||\n\t\t\t\tLinguistics::classical? &&\n\t\t\t\t/^(#{PL_count_zero})$/ =~ count.to_s\n\t\t\treturn 1\n\t\telse\n\t\t\treturn default\n\t\tend\n\tend",
"def pluralize_model(klass, options = {})\n t(\"activerecord.models.#{klass.model_name.i18n_key}\", :count => options[:count] || 2)\n end",
"def target_symbol_plural(*args)\n if args.blank?\n (const_defined?(:TargetSymbolPlural) ? const_get(:TargetSymbolPlural) : (@target_symbol_plural || target_symbol.to_s.pluralize)).to_sym\n else\n self.target_symbol_plural = args.first\n end\n end",
"def plural_target\n @plural_target ||= target.presence && target.to_s.underscore.pluralize\n end",
"def arabic_pluralize(number, singular, double, plural, gender_class='male')\n one = gender_class == 'male' ? 'واحد' : 'واحدة'\n case number\n when 0 then \"لا #{plural}\"\n when 1 then \"#{singular} #{one}\"\n when 2 then \"#{double}\"\n when 3..10 then \"#{number} #{plural}\"\n else \"#{number} #{singular}\"\n end\n end",
"def pluralize( name )\n warn_nyi( \"support for pluralization guides in pluralize()\" )\n return name.pluralize\n end",
"def pluralize(count, word)\n \"#{word}#{'s' unless count.to_i == 1}\"\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def hash_is_for_pluralization?(hash, locale)\n plural_keys = I18n.t('i18n.plural.keys', locale: locale)\n raise missing_pluralisations_message(locale) unless plural_keys.is_a?(Array)\n ((hash.keys.map(&:to_s) - plural_keys.map(&:to_s)) - ['zero']).empty?\n end",
"def cplural(word, n, pad = false)\n sing = word\n plur = word.pluralize\n word = n == 1 ? sing : plur\n pad = [sing, plur].map(&:length).max\n \"%-#{pad}s\" % word\nend",
"def plural(n)\n n == 1 ? \"#{n} bottle\" : \"#{n} bottles\"\nend",
"def pluralize(n, str)\n \"#{n} #{str + (n == 1 ? \"\" : \"s\")}\"\nend",
"def pagy_t(path, vars={})\n value = I18N.dig(*path.to_s.split('.'.freeze))\n if value.is_a?(Hash)\n vars.has_key?(:count) or return value\n plural = (Opts.i18n_plurals ||= -> (c) {c==0 && 'zero' || c==1 && 'one' || 'other'}).call(vars[:count])\n value.has_key?(plural) or return %(invalid pluralization data: \"#{path}\" cannot be used with count: #{vars[:count]}; key \"#{plural}\" is missing.)\n value = value[plural]\n end\n value or return %(translation missing: \"#{path}\")\n sprintf value, Hash.new{|h,k| \"%{#{k}}\"}.merge!(vars) # interpolation\n end",
"def inflect(word,count)\n if count>1\n word.pluralize\n else\n word\n end\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def pluralizer num, noun\n if num != 1\n \"#{num} #{noun}s\"\n elsif num == 1 \n \"#{num} #{noun}\"\n elsif num != 1 && noun == goose\n \"#{num}, geese\"\n end\nend",
"def pluralize(count, word)\n \"#{word}#{'s' unless count.to_f == 1}\"\n end",
"def test_plural_ruby\n\t\tp = Print.new\n\t\tassert_equal('rubies',p.singular_or_plural(0,'rubies'))\n\tend",
"def lookup(locale, key, scope = [], separator = nil)\n return unless key\n keys = I18n.send(:normalize_translation_keys, locale, key, scope)\n @moneta[keys.join('.')]\n end",
"def store_translation(locale, key, text, count=nil)\n if count.nil?\n data = text\n else\n pluralization_index = pluralizer(locale).call(count)\n data = { pluralization_index => text }\n end\n Translation.create_or_update(locale, key, data)\n # merge the stored translation back to the memory collection\n reload!\n end",
"def pluralize(n, singular, plural=nil)\n if n == 1 \n \"1 #{singular}\"\n elsif plural\n \"#{n} #{plural}\"\n else\n \"#{n} #{singular}s\"\n end\n end",
"def one_translation_per_lang_per_key\n translation_exists = Translation.exists?(\n lang: self.lang,\n translator_id: self.translator.id,\n translator_type: self.translator.class.name,\n translation_key_id: self.key.id\n )\n\n unless translation_exists\n true\n else\n false\n self.errors.add(:lang, I18n.t('.one_translation_per_lang_per_key'))\n end\n end",
"def select_translations(args = {})\n hash = grouped_translated_text(args[:locale])\n hash.each { |key, value| hash[key] = value.count }.sort_by { |_key, value| value }.reverse.to_h\n end",
"def pluralise(number, word)\n return (number > 1)? \"#{number} #{word}s\" : \"#{number} #{word}\"\nend",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def pluralizer(num, obj)\n obj.downcase!\n if num > 1\n if obj == \"sheep\"\n return \"#{num} #{obj}\"\n elsif obj == \"goose\"\n return \"#{num} geese\"\n elsif obj == \"child\"\n return \"#{num} children\"\n elsif obj == \"person\"\n return \"#{num} people\"\n elsif obj == \"species\"\n return \"#{num} #{obj}\"\n else\n return \"#{num} #{obj}s\"\n end\n else\n return \"#{num} #{obj}\"\n end\nend",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend"
] |
[
"0.65760964",
"0.6508447",
"0.6155993",
"0.612094",
"0.61165696",
"0.59416956",
"0.5794986",
"0.5783066",
"0.5713492",
"0.57092893",
"0.5707097",
"0.56927174",
"0.56564534",
"0.56412506",
"0.5623333",
"0.5586661",
"0.5562212",
"0.55326295",
"0.55300367",
"0.55134994",
"0.5505622",
"0.5500979",
"0.54860073",
"0.54860073",
"0.54753864",
"0.5464342",
"0.5463999",
"0.5454978",
"0.5443208",
"0.54055226",
"0.5400667",
"0.5389257",
"0.53409857",
"0.5319139",
"0.53075373",
"0.5303789",
"0.52936894",
"0.52768993",
"0.52756256",
"0.52656966",
"0.52656364",
"0.52580506",
"0.5248128",
"0.5244744",
"0.52443665",
"0.52241033",
"0.5218478",
"0.52029234",
"0.5202373",
"0.5202373",
"0.5202373",
"0.5200609",
"0.5199675",
"0.5194911",
"0.51948947",
"0.51943105",
"0.5152447",
"0.5143218",
"0.5131767",
"0.51188344",
"0.51103115",
"0.5108041",
"0.5100258",
"0.5100258",
"0.50956315",
"0.50900126",
"0.5088637",
"0.5087791",
"0.5079361",
"0.50710714",
"0.50653183",
"0.506378",
"0.5061894",
"0.5056499",
"0.505453",
"0.50466675",
"0.50446403",
"0.50382495",
"0.50281304",
"0.50228447",
"0.50181013",
"0.5014772",
"0.49937215",
"0.49874505",
"0.4985224",
"0.49824387",
"0.49775958",
"0.49523035",
"0.4950009",
"0.49458647",
"0.49363828",
"0.4934329",
"0.49340078",
"0.48966843",
"0.48737147",
"0.48731208",
"0.4868052",
"0.48572356",
"0.48429945",
"0.48428062"
] |
0.6254238
|
2
|
Resolves a translation. If the given subject is a Symbol, it will be translated with the given options. If it is a Proc then it will be evaluated. All other subjects will be returned directly. source://i18n//lib/i18n/backend/base.rb147
|
def resolve(locale, object, subject, options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def translate!(key, **options); end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\n result = resolve(locale, object, item, options) #and return result\n result = lookup(locale, result, options[:scope], options)\n return result if result.is_a?(String)\n return result = resolve(locale, object, item, options) if item == subject.last\n end and nil\n else\n resolve(locale, object, subject, options)\n end\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def translate(*args, **opts); end",
"def deep_compile(locale, subject, options)\n if subject.is_a?(Hash)\n subject.each do |key, object|\n subject[key], _had_to_compile_result = deep_compile(locale, object, options)\n end\n else\n compile(locale, subject, options)\n end\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, language: resource.last.to_s.to_sym)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def t(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n translate_or_localize(key, options)\n end",
"def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end",
"def resolve(param)\n return param unless param.is_a?(Symbol)\n return (@resolver || DEFAULT_RESOLVER).call(param)\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def translation_of(text, options)\n src = options[:from]\n dst = options[:to]\n raise \":from and :to are mandatory in method translation_of\" if src.nil? || dst.nil?\n\n diconame = \"#{src}_#{dst}\".to_sym\n dico = @dicts[diconame]\n if dico.is_a? String\n dico = [ dico ]\n end\n if @data[diconame].nil? && dico\n dico.each do |name|\n dico_name_ext = \"#{src}_#{dst}_dict_#{name}\"\n data = load_dictionnary(dico_name_ext).symbolize_keys\n if @data[diconame].nil?\n @data[diconame] = data[diconame]\n else\n @data[diconame].merge! data[diconame]\n end\n end\n end\n tn = @data[diconame][text] if @data[diconame]\n if tn.nil? && google?\n tn = @tr.translate :text => text, :from => src, :to => dst\n end\n if tn.nil? || tn.empty? || tn == text\n tn = text\n if @strict\n tn = \"NT - #{text}\"\n end\n end\n tn\n end",
"def pt( *args )\n translation = ft[ name ]\n args.empty? ? translation : translation[ *args, self ]\n end",
"def subjectify(options = {})\n SubjectifyService.new(options[:value]).content\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def resolve_lexically(resolver, val, ctx)\n case val\n when Hash\n new = {}\n\n val.each do |k, v|\n new[k] = resolve_lexically(resolver, v, [val] + ctx)\n end\n\n new\n when Array\n val.collect do |v|\n resolve_lexically(resolver, v, ctx)\n end\n when String\n val.gsub(/\\$\\{([^\\}]+)\\}/) do\n resolve_symbol(resolver, $1, ctx)\n end\n else\n val\n end\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def render_subject(subject, predicates, options = {}, &block)\n options = options.merge(:haml => haml_template[:rel]) if options[:rel] && haml_template[:rel]\n super(subject, predicates, options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n add_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.resolve_symbol(sym)\n dynamic\n else\n fail(\"Unknown symbol in manifest: #{sym}\")\n end\n end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n as_literal(Math.acosh(resource.as_number.object))\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def render_subject(subject, predicates, **options, &block)\n options = options.merge(haml: @prev_templ[:rel]) if options[:rel] && @prev_templ[:rel]\n @prev_templ = haml_template\n super(subject, predicates, **options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n log_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def translate(key, options)\n I18n.translate(\"#{BASE_KEY}.#{key}\", options)\n end",
"def translation_for(locale, _options = {})\n translation = translations.find { |t| t.key == attribute && t.locale == locale.to_s }\n translation ||= translations.build(locale: locale, key: attribute)\n translation\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, datatype: resource.last)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def resolve(resource, position:)\n case resource\n when RDF::Query::Variable then resource\n when RDF::Literal\n case position\n when :subject\n as_literal(Math.sin(resource.as_number.object))\n when :object\n as_literal(Math.sinh(resource.as_number.object))\n end\n else\n nil\n end\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end",
"def get(key, options = EMPTY_HASH)\n return unless key\n\n result = t.(key, locale: options.fetch(:locale, default_locale))\n\n if result.is_a?(Hash)\n text = result[:text]\n meta = result.dup.tap { |h| h.delete(:text) }\n else\n text = result\n meta = EMPTY_HASH.dup\n end\n\n {\n text: text,\n meta: meta\n }\n end",
"def subjectify(options = {})\n result = []\n all_subjects = []\n sub_array = []\n options[:value].each_with_index do |subject, i|\n spl_sub = subject.split(QUERYSEP)\n sub_array << []\n subject_accum = ''\n spl_sub.each_with_index do |subsubject, j|\n spl_sub[j] = subject_accum + subsubject\n subject_accum = spl_sub[j] + QUERYSEP\n sub_array[i] << spl_sub[j]\n end\n all_subjects[i] = subject.split(QUERYSEP)\n end\n options[:value].each_with_index do |_subject, i|\n lnk = ''\n lnk_accum = ''\n all_subjects[i].each_with_index do |subsubject, j|\n lnk = lnk_accum + link_to(subsubject,\n \"/?f[subject_facet][]=#{CGI.escape sub_array[i][j]}\",\n class: 'search-subject', title: \"Search: #{sub_array[i][j]}\")\n lnk_accum = lnk + content_tag(:span, SEPARATOR, class: 'subject-level')\n end\n result << sanitize(lnk)\n end\n result\n end",
"def human(options = {})\n return @human if i18n_keys.empty? || i18n_scope.empty?\n\n key, *defaults = i18n_keys\n defaults << options[:default] if options[:default]\n defaults << MISSING_TRANSLATION\n\n translation = I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)\n translation = @human if translation == MISSING_TRANSLATION\n translation\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end",
"def resolve(*args)\n value = access(*args)\n value = transform(value) if @final_transform\n return convert(value) if @convert\n value\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def th(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n options.each {|k,v| options[k] = h(v) if v.is_a?(String) }\n translate_or_localize(key, options)\n end",
"def translate(settings); end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def resolve(subject, token, continued: false)\r\n available = context_from(subject)\r\n return Matches.new([], '', token) if available.empty?\r\n if continued\r\n return Matches.execute(available, token, continued: continued)\r\n elsif nested?(token)\r\n drill = denest(available, token)\r\n drill.keep_if{ |e| accept?(e) }\r\n return Matches.new(drill, token, '') unless drill.length != 1\r\n return Matches.new([], '', token)\r\n end\r\n result = available.select{ |e| e.match?(token) }\r\n result = available.select{ |e| e.match?(token, fuzzy: true) } if result.empty?\r\n result.keep_if{ |e| accept? e }\r\n Matches.new(result, (result.empty? ? '' : token), (result.empty? ? token : ''))\r\n end",
"def ft( *args )\n fail \"You need to set the locale with R18n.set('en') or similar. No locale, no helper. Sorry.\" unless r18n\n translation = t.forms[ self.class.translation_name ]\n args.empty? ? translation : translation[ *args ]\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def find_message(kind, options = {})\n options[:scope] ||= translation_scope\n I18n.t(kind, **options)\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def translate(text, options = {})\n response = google_api_call(text,\"#{SERVICE}#{@from}%7C#{@to}#{TEXT_PAR}\",TranslationResponse)\n translation = options[:html] ? response.translation : CGI.unescapeHTML(response.translation)\n translation # return value\n end",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def subject_from_sym(action)\n @@Subjects[action.to_sym]\n end",
"def lookup(options)\n raise 'todo'\n end",
"def find_message(kind, options = {})\n options[:scope] ||= translation_scope\n options[:default] = Array(options[:default]).unshift(kind.to_sym)\n options[:resource_name] = resource_name\n options = devise_i18n_options(options)\n I18n.t(\"#{options[:resource_name]}.#{kind}\", **options)\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate_value(args)\n code = get_field_val(args)\n translate_lang_code(code)\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def t(string, options = {})\n I18n.t(string, **options)\nend",
"def label_from_options\n res = super\n res = res.call if res.is_a? Proc\n res\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n return nil unless resource.literal? || resource.uri?\n begin\n repo = RDF::N3::Repository.new\n repo << RDF::Reader.open(resource, **@options.merge(list_terms: true, base_uri: resource, logger: false))\n content_hash = repo.statements.hash # used as name of resulting formula\n form = RDF::N3::Algebra::Formula.from_enumerable(repo, graph_name: RDF::Node.intern(content_hash))\n log_debug(NAME) {\"form hash (#{resource}): #{form.hash}\"}\n form\n rescue IOError, RDF::ReaderError => e\n log_error(NAME) {\"error loading #{resource}: #{e}\"}\n nil\n end\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def t(key, options = {})\n options[:raise] = true\n translate(key, options)\n end",
"def resolve(object, arguments, context)\n @resolve_proc.call(object, arguments, context)\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def label_from_options\n res = super\n res = res.call if res.is_a? Proc\n res\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume(ctx)\n end",
"def []( name )\n if form and r18n\n value = opts[ name ]\n if value.is_a?( String ) or ( value.nil? and not UNLOCALIZED_OPTIONS.include?( name ) )\n text = pt( name )\n return text.to_s if text.translated?\n end\n end\n super\n end",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def resolve(resource, position:)\n return resource unless position == :subject\n\n log_depth do\n reasoner = RDF::N3::Reasoner.new(resource, **@options)\n conclusions = RDF::N3::Repository.new\n reasoner.execute(think: true) {|stmt| conclusions << stmt}\n\n # The result is a formula containing the conclusions\n form = RDF::N3::Algebra::Formula.from_enumerable(conclusions, **@options).deep_dup\n\n log_info(\"#{NAME} resolved\") {SXP::Generator.string form.to_sxp_bin} \n form\n end\n end",
"def evaluate(options)\n [@symbol, @registry.expand(@symbol).evaluate(options)]\n end",
"def localize(object, **options); end",
"def localize(object, **options); end",
"def localized(key, value = nil)\n self[key] = value if value\n\n case self[key]\n when NilClass then nil\n when Proc then instance_eval(&self[key])\n else _(self[key])\n end\n end",
"def method_missing(sym, *args, &block)\n @subject.send sym, *args, &block\n end",
"def parse_value(v, locale)\n new_value = nil\n case v\n when Symbol then\n lk = @localization_key_object_cache[v.to_s] || \\\n Lit::LocalizationKey.where(localization_key: v.to_s).first\n if lk\n loca = Lit::Localization.active.where(locale_id: locale.id).\n where(localization_key_id: lk.id).first\n new_value = loca.translation if loca && loca.translation.present?\n end\n when String then\n new_value = v\n when Hash then\n new_value = nil\n when Proc then\n new_value = nil # was v.call - requires more love\n else\n new_value = v.to_s\n end\n new_value\n end",
"def method_missing(meth, *args, &blk)\n if meth.to_s =~ /^from_([a-z]+)_to_([a-z]+)$/\n from, to = $1, $2\n return translate(args.first, from, to)\n end\n super\n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n as_literal(Math.atan(resource.as_number.object))\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def generate_field_translations options\n params_hash = direct_translate_to_html(options)\n if options['locale'].to_sym == :de\n params_hash['source'] = 'researcher'\n else\n params_hash = GoogleTranslateCommunicator.get_translations(\n params_hash, options['locale']\n )\n params_hash['source'] = 'GoogleTranslate'\n end\n params_hash\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def resolve_substitutions(context, source)\n new_context = context.add_cycle_marker(self)\n begin\n result_with_path = source.lookup_subst(new_context, @expr, @prefix_length)\n new_context = result_with_path.result.context\n\n if result_with_path.result.value != nil\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\n \"recursively resolving #{result_with_path} which was the resolution of #{expr} against #{source}\",\n context.depth)\n end\n\n recursive_resolve_source = Hocon::Impl::ResolveSource.new(\n result_with_path.path_from_root.last, result_with_path.path_from_root)\n\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\"will recursively resolve against #{recursive_resolve_source}\", context.depth)\n end\n\n result = new_context.resolve(result_with_path.result.value,\n recursive_resolve_source)\n v = result.value\n new_context = result.context\n else\n v = nil\n end\n rescue NotPossibleToResolve => e\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\n \"not possible to resolve #{expr}, cycle involved: #{e.trace_string}\", new_context.depth)\n end\n if @expr.optional\n v = nil\n else\n raise UnresolvedSubstitutionError.new(\n origin,\n \"#{@expr} was part of a cycle of substitutions involving #{e.trace_string}\", e)\n end\n end\n\n if v == nil && !@expr.optional\n if new_context.options.allow_unresolved\n ResolveResult.make(new_context.remove_cycle_marker(self), self)\n else\n raise UnresolvedSubstitutionError.new(origin, @expr.to_s)\n end\n else\n Hocon::Impl::ResolveResult.make(new_context.remove_cycle_marker(self), v)\n end\n\n end",
"def render subject,\n repo: nil, graph: nil, type: nil, language: nil, rewriter: nil\n repo ||= @repo\n # process type\n # process language\n\n # retrieve forward and reverse structs from repo\n # retrieve yr mom\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def lookup_chain = locale(true).lookup",
"def Resolve(maybe_proc, context = nil)\n if maybe_proc.is_a? Proc or maybe_proc.is_a? Method\n if context\n if maybe_proc.arity > 0\n context.instance_eval(&maybe_proc)\n else\n # In case it's a lambda with zero arity instance_eval fails\n context.instance_exec(&maybe_proc)\n end\n else\n maybe_proc.()\n end\n else\n maybe_proc\n end\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def parse(subject, term)\n return term\n end",
"def call(ctx)\n evaluate(solve(ctx))\n end",
"def t_sms_msg(key, options = {})\n # throw in the form_code if it's not there already and we have the form\n options[:form_code] ||= options[:form].current_version.code if options[:form]\n\n # get the reply language (if we have the user, use their pref_lang; if not, use default)\n lang = options[:user] && options[:user].pref_lang ? options[:user].pref_lang.to_sym : I18n.default_locale\n\n # do the translation, raising error on failure\n I18n.t(key, options.merge(locale: lang, raise: true))\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def t_sms_msg(key, options = {})\n # Get some options from Response (if available) unless they're explicitly given\n if elmo_response\n %i(user form mission).each { |a| options[a] = elmo_response.send(a) unless options.has_key?(a) }\n end\n\n # throw in the form_code if it's not there already and we have the form\n options[:form_code] ||= options[:form].current_version.code if options[:form]\n\n # get the reply language (if we have the user, use their pref_lang; if not, use default)\n lang = options[:user] && options[:user].pref_lang ? options[:user].pref_lang.to_sym : I18n.default_locale\n\n # do the translation, raising error on failure\n I18n.t(key, options.merge(locale: lang, raise: true))\n end"
] |
[
"0.6081512",
"0.57755125",
"0.57755125",
"0.5770379",
"0.57339454",
"0.55334115",
"0.55221367",
"0.5483578",
"0.5434893",
"0.54323936",
"0.5372875",
"0.5344528",
"0.533782",
"0.52454305",
"0.5224909",
"0.5148097",
"0.5084306",
"0.50790006",
"0.5060139",
"0.5059775",
"0.5057446",
"0.5045844",
"0.5027579",
"0.50165176",
"0.50164455",
"0.50160486",
"0.4996493",
"0.49461022",
"0.49282917",
"0.4925662",
"0.49025998",
"0.48954618",
"0.48753762",
"0.48506072",
"0.48468915",
"0.48084542",
"0.47867036",
"0.47828284",
"0.47795692",
"0.47757474",
"0.47665066",
"0.47552392",
"0.47223294",
"0.46999225",
"0.46897635",
"0.4666049",
"0.46609503",
"0.46582472",
"0.4655836",
"0.46312976",
"0.46096808",
"0.45837194",
"0.45834008",
"0.456804",
"0.4553778",
"0.45533735",
"0.45392042",
"0.45093304",
"0.4469795",
"0.446311",
"0.44557688",
"0.44533706",
"0.44508037",
"0.44415742",
"0.44284573",
"0.44195536",
"0.4415779",
"0.44121024",
"0.4398954",
"0.4398954",
"0.43922693",
"0.4392128",
"0.43914536",
"0.43786412",
"0.43752822",
"0.4370997",
"0.43613848",
"0.43555337",
"0.435384",
"0.435384",
"0.43415838",
"0.4335858",
"0.43316725",
"0.43299168",
"0.43292746",
"0.43117315",
"0.43099222",
"0.43084514",
"0.4306021",
"0.42909527",
"0.42896384",
"0.4285588",
"0.42855468",
"0.4262461",
"0.42614755",
"0.42605373",
"0.4254156",
"0.42501205",
"0.42456567",
"0.4241992"
] |
0.7048989
|
0
|
Resolves a translation. If the given subject is a Symbol, it will be translated with the given options. If it is a Proc then it will be evaluated. All other subjects will be returned directly. source://i18n//lib/i18n/backend/base.rb147
|
def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resolve(locale, object, subject, options = T.unsafe(nil)); end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def translate!(key, **options); end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\n result = resolve(locale, object, item, options) #and return result\n result = lookup(locale, result, options[:scope], options)\n return result if result.is_a?(String)\n return result = resolve(locale, object, item, options) if item == subject.last\n end and nil\n else\n resolve(locale, object, subject, options)\n end\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def translate(*args, **opts); end",
"def deep_compile(locale, subject, options)\n if subject.is_a?(Hash)\n subject.each do |key, object|\n subject[key], _had_to_compile_result = deep_compile(locale, object, options)\n end\n else\n compile(locale, subject, options)\n end\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, language: resource.last.to_s.to_sym)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def t(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n translate_or_localize(key, options)\n end",
"def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'\n end\n end",
"def resolve(param)\n return param unless param.is_a?(Symbol)\n return (@resolver || DEFAULT_RESOLVER).call(param)\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def pt( *args )\n translation = ft[ name ]\n args.empty? ? translation : translation[ *args, self ]\n end",
"def translation_of(text, options)\n src = options[:from]\n dst = options[:to]\n raise \":from and :to are mandatory in method translation_of\" if src.nil? || dst.nil?\n\n diconame = \"#{src}_#{dst}\".to_sym\n dico = @dicts[diconame]\n if dico.is_a? String\n dico = [ dico ]\n end\n if @data[diconame].nil? && dico\n dico.each do |name|\n dico_name_ext = \"#{src}_#{dst}_dict_#{name}\"\n data = load_dictionnary(dico_name_ext).symbolize_keys\n if @data[diconame].nil?\n @data[diconame] = data[diconame]\n else\n @data[diconame].merge! data[diconame]\n end\n end\n end\n tn = @data[diconame][text] if @data[diconame]\n if tn.nil? && google?\n tn = @tr.translate :text => text, :from => src, :to => dst\n end\n if tn.nil? || tn.empty? || tn == text\n tn = text\n if @strict\n tn = \"NT - #{text}\"\n end\n end\n tn\n end",
"def subjectify(options = {})\n SubjectifyService.new(options[:value]).content\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def resolve_lexically(resolver, val, ctx)\n case val\n when Hash\n new = {}\n\n val.each do |k, v|\n new[k] = resolve_lexically(resolver, v, [val] + ctx)\n end\n\n new\n when Array\n val.collect do |v|\n resolve_lexically(resolver, v, ctx)\n end\n when String\n val.gsub(/\\$\\{([^\\}]+)\\}/) do\n resolve_symbol(resolver, $1, ctx)\n end\n else\n val\n end\n end",
"def render_subject(subject, predicates, options = {}, &block)\n options = options.merge(:haml => haml_template[:rel]) if options[:rel] && haml_template[:rel]\n super(subject, predicates, options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n add_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.resolve_symbol(sym)\n dynamic\n else\n fail(\"Unknown symbol in manifest: #{sym}\")\n end\n end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n as_literal(Math.acosh(resource.as_number.object))\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def render_subject(subject, predicates, **options, &block)\n options = options.merge(haml: @prev_templ[:rel]) if options[:rel] && @prev_templ[:rel]\n @prev_templ = haml_template\n super(subject, predicates, **options) do |predicate|\n if predicate.is_a?(Symbol)\n # Special snippet processing\n # Render associated properties with associated or default formatting\n case predicate\n when :other\n props = predicates.map(&:to_s)\n props -= haml_template[:title_props] || []\n props -= haml_template[:body_props] || []\n props -= haml_template[:description_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n when :other_nested\n props = predicates.map(&:to_s)\n props -= haml_template[:nested_props] || []\n format = lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n else\n # Find appropriate entires from template\n props = haml_template[\"#{predicate}_props\".to_sym]\n log_debug \"render_subject(#{subject}, #{predicate}): #{props.inspect}\"\n format = haml_template[\"#{predicate}_fmt\".to_sym]\n end\n unless props.nil? || props.empty?\n format ||= lambda {|list| list.map {|e| yield(e)}.join(\"\")}\n format.call(props, &block)\n end\n else\n yield(predicate)\n end\n end\n end",
"def translate(key, options)\n I18n.translate(\"#{BASE_KEY}.#{key}\", options)\n end",
"def translation_for(locale, _options = {})\n translation = translations.find { |t| t.key == attribute && t.locale == locale.to_s }\n translation ||= translations.build(locale: locale, key: attribute)\n translation\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, datatype: resource.last)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def resolve(resource, position:)\n case resource\n when RDF::Query::Variable then resource\n when RDF::Literal\n case position\n when :subject\n as_literal(Math.sin(resource.as_number.object))\n when :object\n as_literal(Math.sinh(resource.as_number.object))\n end\n else\n nil\n end\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject(options = {})\n options = { :capitalize => true, :case => Grammar::Case::SUBJECT }.merge(options)\n pronoun_or_noun(@subject, @audience, options)\n end",
"def get(key, options = EMPTY_HASH)\n return unless key\n\n result = t.(key, locale: options.fetch(:locale, default_locale))\n\n if result.is_a?(Hash)\n text = result[:text]\n meta = result.dup.tap { |h| h.delete(:text) }\n else\n text = result\n meta = EMPTY_HASH.dup\n end\n\n {\n text: text,\n meta: meta\n }\n end",
"def subjectify(options = {})\n result = []\n all_subjects = []\n sub_array = []\n options[:value].each_with_index do |subject, i|\n spl_sub = subject.split(QUERYSEP)\n sub_array << []\n subject_accum = ''\n spl_sub.each_with_index do |subsubject, j|\n spl_sub[j] = subject_accum + subsubject\n subject_accum = spl_sub[j] + QUERYSEP\n sub_array[i] << spl_sub[j]\n end\n all_subjects[i] = subject.split(QUERYSEP)\n end\n options[:value].each_with_index do |_subject, i|\n lnk = ''\n lnk_accum = ''\n all_subjects[i].each_with_index do |subsubject, j|\n lnk = lnk_accum + link_to(subsubject,\n \"/?f[subject_facet][]=#{CGI.escape sub_array[i][j]}\",\n class: 'search-subject', title: \"Search: #{sub_array[i][j]}\")\n lnk_accum = lnk + content_tag(:span, SEPARATOR, class: 'subject-level')\n end\n result << sanitize(lnk)\n end\n result\n end",
"def human(options = {})\n return @human if i18n_keys.empty? || i18n_scope.empty?\n\n key, *defaults = i18n_keys\n defaults << options[:default] if options[:default]\n defaults << MISSING_TRANSLATION\n\n translation = I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)\n translation = @human if translation == MISSING_TRANSLATION\n translation\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end",
"def resolve(*args)\n value = access(*args)\n value = transform(value) if @final_transform\n return convert(value) if @convert\n value\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def th(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n options.each {|k,v| options[k] = h(v) if v.is_a?(String) }\n translate_or_localize(key, options)\n end",
"def translate(settings); end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def resolve(subject, token, continued: false)\r\n available = context_from(subject)\r\n return Matches.new([], '', token) if available.empty?\r\n if continued\r\n return Matches.execute(available, token, continued: continued)\r\n elsif nested?(token)\r\n drill = denest(available, token)\r\n drill.keep_if{ |e| accept?(e) }\r\n return Matches.new(drill, token, '') unless drill.length != 1\r\n return Matches.new([], '', token)\r\n end\r\n result = available.select{ |e| e.match?(token) }\r\n result = available.select{ |e| e.match?(token, fuzzy: true) } if result.empty?\r\n result.keep_if{ |e| accept? e }\r\n Matches.new(result, (result.empty? ? '' : token), (result.empty? ? token : ''))\r\n end",
"def ft( *args )\n fail \"You need to set the locale with R18n.set('en') or similar. No locale, no helper. Sorry.\" unless r18n\n translation = t.forms[ self.class.translation_name ]\n args.empty? ? translation : translation[ *args ]\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def find_message(kind, options = {})\n options[:scope] ||= translation_scope\n I18n.t(kind, **options)\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def translate(text, options = {})\n response = google_api_call(text,\"#{SERVICE}#{@from}%7C#{@to}#{TEXT_PAR}\",TranslationResponse)\n translation = options[:html] ? response.translation : CGI.unescapeHTML(response.translation)\n translation # return value\n end",
"def adhoc_test_subj_call\n ->(candidate) { I18n.t('email.test_adhoc_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def subject_from_sym(action)\n @@Subjects[action.to_sym]\n end",
"def lookup(options)\n raise 'todo'\n end",
"def find_message(kind, options = {})\n options[:scope] ||= translation_scope\n options[:default] = Array(options[:default]).unshift(kind.to_sym)\n options[:resource_name] = resource_name\n options = devise_i18n_options(options)\n I18n.t(\"#{options[:resource_name]}.#{kind}\", **options)\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate_value(args)\n code = get_field_val(args)\n translate_lang_code(code)\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def mmm_test_subj_call\n ->(candidate) { I18n.t('email.test_monthly_mail_subject_initial_input', candidate_account_name: candidate.account_name) }\n end",
"def t(string, options = {})\n I18n.t(string, **options)\nend",
"def label_from_options\n res = super\n res = res.call if res.is_a? Proc\n res\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n return nil unless resource.literal? || resource.uri?\n begin\n repo = RDF::N3::Repository.new\n repo << RDF::Reader.open(resource, **@options.merge(list_terms: true, base_uri: resource, logger: false))\n content_hash = repo.statements.hash # used as name of resulting formula\n form = RDF::N3::Algebra::Formula.from_enumerable(repo, graph_name: RDF::Node.intern(content_hash))\n log_debug(NAME) {\"form hash (#{resource}): #{form.hash}\"}\n form\n rescue IOError, RDF::ReaderError => e\n log_error(NAME) {\"error loading #{resource}: #{e}\"}\n nil\n end\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def t(key, options = {})\n options[:raise] = true\n translate(key, options)\n end",
"def resolve(object, arguments, context)\n @resolve_proc.call(object, arguments, context)\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def label_from_options\n res = super\n res = res.call if res.is_a? Proc\n res\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume(ctx)\n end",
"def []( name )\n if form and r18n\n value = opts[ name ]\n if value.is_a?( String ) or ( value.nil? and not UNLOCALIZED_OPTIONS.include?( name ) )\n text = pt( name )\n return text.to_s if text.translated?\n end\n end\n super\n end",
"def subject\n @options.fetch(:subject) { \"Invitation\" }\n end",
"def resolve(resource, position:)\n return resource unless position == :subject\n\n log_depth do\n reasoner = RDF::N3::Reasoner.new(resource, **@options)\n conclusions = RDF::N3::Repository.new\n reasoner.execute(think: true) {|stmt| conclusions << stmt}\n\n # The result is a formula containing the conclusions\n form = RDF::N3::Algebra::Formula.from_enumerable(conclusions, **@options).deep_dup\n\n log_info(\"#{NAME} resolved\") {SXP::Generator.string form.to_sxp_bin} \n form\n end\n end",
"def evaluate(options)\n [@symbol, @registry.expand(@symbol).evaluate(options)]\n end",
"def localize(object, **options); end",
"def localize(object, **options); end",
"def localized(key, value = nil)\n self[key] = value if value\n\n case self[key]\n when NilClass then nil\n when Proc then instance_eval(&self[key])\n else _(self[key])\n end\n end",
"def method_missing(sym, *args, &block)\n @subject.send sym, *args, &block\n end",
"def parse_value(v, locale)\n new_value = nil\n case v\n when Symbol then\n lk = @localization_key_object_cache[v.to_s] || \\\n Lit::LocalizationKey.where(localization_key: v.to_s).first\n if lk\n loca = Lit::Localization.active.where(locale_id: locale.id).\n where(localization_key_id: lk.id).first\n new_value = loca.translation if loca && loca.translation.present?\n end\n when String then\n new_value = v\n when Hash then\n new_value = nil\n when Proc then\n new_value = nil # was v.call - requires more love\n else\n new_value = v.to_s\n end\n new_value\n end",
"def method_missing(meth, *args, &blk)\n if meth.to_s =~ /^from_([a-z]+)_to_([a-z]+)$/\n from, to = $1, $2\n return translate(args.first, from, to)\n end\n super\n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n as_literal(Math.atan(resource.as_number.object))\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def generate_field_translations options\n params_hash = direct_translate_to_html(options)\n if options['locale'].to_sym == :de\n params_hash['source'] = 'researcher'\n else\n params_hash = GoogleTranslateCommunicator.get_translations(\n params_hash, options['locale']\n )\n params_hash['source'] = 'GoogleTranslate'\n end\n params_hash\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def resolve_substitutions(context, source)\n new_context = context.add_cycle_marker(self)\n begin\n result_with_path = source.lookup_subst(new_context, @expr, @prefix_length)\n new_context = result_with_path.result.context\n\n if result_with_path.result.value != nil\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\n \"recursively resolving #{result_with_path} which was the resolution of #{expr} against #{source}\",\n context.depth)\n end\n\n recursive_resolve_source = Hocon::Impl::ResolveSource.new(\n result_with_path.path_from_root.last, result_with_path.path_from_root)\n\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\"will recursively resolve against #{recursive_resolve_source}\", context.depth)\n end\n\n result = new_context.resolve(result_with_path.result.value,\n recursive_resolve_source)\n v = result.value\n new_context = result.context\n else\n v = nil\n end\n rescue NotPossibleToResolve => e\n if Hocon::Impl::ConfigImpl.trace_substitution_enabled\n Hocon::Impl::ConfigImpl.trace(\n \"not possible to resolve #{expr}, cycle involved: #{e.trace_string}\", new_context.depth)\n end\n if @expr.optional\n v = nil\n else\n raise UnresolvedSubstitutionError.new(\n origin,\n \"#{@expr} was part of a cycle of substitutions involving #{e.trace_string}\", e)\n end\n end\n\n if v == nil && !@expr.optional\n if new_context.options.allow_unresolved\n ResolveResult.make(new_context.remove_cycle_marker(self), self)\n else\n raise UnresolvedSubstitutionError.new(origin, @expr.to_s)\n end\n else\n Hocon::Impl::ResolveResult.make(new_context.remove_cycle_marker(self), v)\n end\n\n end",
"def render subject,\n repo: nil, graph: nil, type: nil, language: nil, rewriter: nil\n repo ||= @repo\n # process type\n # process language\n\n # retrieve forward and reverse structs from repo\n # retrieve yr mom\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def lookup_chain = locale(true).lookup",
"def parse(subject, term)\n return term\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def Resolve(maybe_proc, context = nil)\n if maybe_proc.is_a? Proc or maybe_proc.is_a? Method\n if context\n if maybe_proc.arity > 0\n context.instance_eval(&maybe_proc)\n else\n # In case it's a lambda with zero arity instance_eval fails\n context.instance_exec(&maybe_proc)\n end\n else\n maybe_proc.()\n end\n else\n maybe_proc\n end\n end",
"def call(ctx)\n evaluate(solve(ctx))\n end",
"def t_sms_msg(key, options = {})\n # throw in the form_code if it's not there already and we have the form\n options[:form_code] ||= options[:form].current_version.code if options[:form]\n\n # get the reply language (if we have the user, use their pref_lang; if not, use default)\n lang = options[:user] && options[:user].pref_lang ? options[:user].pref_lang.to_sym : I18n.default_locale\n\n # do the translation, raising error on failure\n I18n.t(key, options.merge(locale: lang, raise: true))\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def property(property_name, options = {})\n super\n\n if options[:from]\n if property_name == options[:from]\n fail ArgumentError, \"Property name (#{property_name}) and :from option must not be the same\"\n end\n\n translations_hash[options[:from]] ||= {}\n translations_hash[options[:from]][property_name] = options[:with] || options[:transform_with]\n\n define_method \"#{options[:from]}=\" do |val|\n self.class.translations_hash[options[:from]].each do |name, with|\n self[name] = with.respond_to?(:call) ? with.call(val) : val\n end\n end\n else\n if options[:transform_with].respond_to? :call\n transforms[property_name] = options[:transform_with]\n end\n end\n end"
] |
[
"0.7048549",
"0.57764614",
"0.57764614",
"0.5771221",
"0.57347834",
"0.5534656",
"0.5524339",
"0.54842705",
"0.54361075",
"0.5432805",
"0.5373786",
"0.534529",
"0.5338804",
"0.5246283",
"0.5225907",
"0.5148661",
"0.50838643",
"0.5080042",
"0.5062191",
"0.5061418",
"0.50565755",
"0.5047792",
"0.50293314",
"0.50174624",
"0.5016772",
"0.5016622",
"0.49980298",
"0.49452904",
"0.49288374",
"0.49272248",
"0.49030486",
"0.48971987",
"0.48759732",
"0.48510844",
"0.48485342",
"0.4809381",
"0.47884274",
"0.4783886",
"0.47808334",
"0.47767663",
"0.4767103",
"0.47561896",
"0.47238818",
"0.470116",
"0.46916083",
"0.46666282",
"0.4661961",
"0.4660372",
"0.46572486",
"0.46328717",
"0.46106166",
"0.45849892",
"0.4584523",
"0.45698768",
"0.45551878",
"0.4553659",
"0.45407417",
"0.45119244",
"0.44719812",
"0.44646925",
"0.44562083",
"0.44555485",
"0.44513795",
"0.44425455",
"0.4430101",
"0.44199327",
"0.44164324",
"0.44109255",
"0.43988872",
"0.43988872",
"0.43942434",
"0.43938306",
"0.4391914",
"0.4378531",
"0.43774772",
"0.43724248",
"0.43616283",
"0.4356686",
"0.43543944",
"0.43543944",
"0.4341587",
"0.4336872",
"0.43337917",
"0.43323684",
"0.43303758",
"0.43126908",
"0.43110314",
"0.430975",
"0.43066213",
"0.42910302",
"0.42899948",
"0.42883864",
"0.4286897",
"0.42631912",
"0.42627677",
"0.42622426",
"0.42552105",
"0.4250445",
"0.42476794",
"0.42422533"
] |
0.6081169
|
1
|
Optionally provide path_roots array to normalize filename paths, to make the cached i18n data portable across environments. source://i18n//lib/i18n/backend/cache_file.rb11
|
def path_roots=(_arg0); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def in_cache_dir(*paths)\n paths.reduce(cache_dir) do |base, path|\n Jekyll.sanitized_path(base, path)\n end\n end",
"def in_cache_dir(*paths); end",
"def load_translations_and_collect_file_errors(files); end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def get_files\n self.locales.each do |l|\n self.files[l] = Dir.glob(\"#{self.locale_dir}/*#{l}.#{self.source_format}\")\n\n next if l == self.default_locale\n\n self.files[self.default_locale].each do |original_file|\n locale_file = original_file.gsub(\"#{self.default_locale}.#{self.source_format}\", \"#{l}.#{self.source_format}\")\n\n next if self.files[l].include?(locale_file)\n\n create_locale_file(locale_file, original_file)\n\n self.files[l] << locale_file\n end\n end\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def get_cache_path_names\n if File.exists?(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\"))\n @cache_path_names = YAML::load(File.read(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\")))\n else\n @cache_path_names = {}\n each_file_set(:cache_path_name)\n write_cache_path_file\n end\n end",
"def reload!\n @paths = {}\n\n files.each do |file|\n @paths[file.path] = file\n @paths[file.path_without_extension] ||= file\n end\n\n @paths.freeze\n end",
"def paths\n @paths ||= [\n data_path,\n output_path,\n converted_path,\n converted_fail_path,\n unpacked_path,\n unpacked_fail_path,\n recreated_path,\n ]\n end",
"def filenames_for_current_locale; end",
"def paths(reload = T.unsafe(nil)); end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def file_path\n Dir.glob(config.cache).first || File.join(File.dirname(config.cache),\n File.basename(config.cache).gsub(/_.+\\.txt/, '_0.txt'))\n end",
"def preloaded_module_paths(resolver:, cache_key: T.unsafe(nil)); end",
"def all_paths\n # memoize so we only calculate once\n @all_paths ||= platform_font_paths\n end",
"def decide_filenames key\n filenames = []\n # Origin or developer mode, the translations will be applied to the original\n # file where those where setup, including plugin folders\n if self.class.mode == :origin\n filename, found_locale = get_translation_origin_filename(key)\n # If filename is outside rail.root send it to config/locales/external_#{translations_locale_name}.yml\n filename = replace_external_to_application_file_paths(filename) if filename.present?\n\n # Doesn't exist the translation for current locale, but it does in another\n if found_locale.present? && found_locale.to_s != self.locale.to_s\n # We try to generate the filename replacing the '/existing_locale/' section\n # in path for the new_locale\n filename = find_or_create_origin_filename(filename, found_locale)\n end\n if filename\n filenames << filename\n end\n end\n #\n # Normal app mode, the translation will be dumped together to /config/locales/#{locale}.yml to keep\n # in sync with the original source of the translation\n #\n create_empty_translations_file(application_mode_file_path) if !File.exists?(application_mode_file_path)\n filenames << application_mode_file_path\n #\n # Path to the backup file of the current translation request/transaction\n #\n filenames << log_file_path\n\n filenames\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def update_paths!\n paths = Hash[*roots.map { |r| \n r.self_and_descendants.map { |n| [n.id, { 'path' => n.send(:build_path) }] } }.flatten]\n update paths.keys, paths.values\n end",
"def map_files\n file_map = {}\n entry_file = Pathname.new(map_entry)\n entry_found = false\n case @files\n when Hash\n @files.each do |path, file|\n file_map[path.to_s] = File.expand_path(file.to_s)\n entry_found = true if path.to_s==entry_file.to_s\n end\n else\n base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }\n @files.each do |fn|\n next unless fn\n relpath = strip_path(base_paths, fn) || fn\n file_map[relpath.to_s] = File.expand_path(fn.to_s)\n entry_found = true if relpath==entry_file\n end\n end\n file_map[entry_file.to_s] = File.expand_path(@entry_file.to_s) unless entry_found\n file_map\n end",
"def clean_paths\n cached_used = used_files\n glob_options = File::FNM_DOTMATCH | File::FNM_CASEFOLD\n files = Pathname.glob(root + \"**/*\", glob_options).map(&:to_s)\n\n files.reject! do |candidate|\n candidate = candidate.downcase\n candidate.end_with?('.', '..') || cached_used.any? do |path|\n path = path.downcase\n path.include?(candidate) || candidate.include?(path)\n end\n end\n files\n end",
"def build_cache\n all_files = []\n\n Find.find(@root) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == ?.\n Find.prune\n else\n next\n end\n else\n path.slice!(\"#{@root}/\")\n all_files << path\n end\n end\n\n return all_files\n end",
"def cache_files\n Dir.glob(File.join(@cache_dir, '*'))\n .map{|f| f.gsub(/#{@cache_dir}\\/?/, '')}\n .sort\n end",
"def cache_file_list_path\n File.join config.config_dir, 'file_cache'\n end",
"def get_all_image_cache_paths\n page_cache_directory = ActionController::Base.page_cache_directory.to_s\n page_cache_directory = page_cache_directory.split('/').join('/')\n paths = Dir.glob(\"#{page_cache_directory}#{GLOBAL_CONFIG[:location_images_cache_dir]}/\" +\n \"#{self.url_directory}/#{self.id}/**/*.*\".gsub('//', '/'))\n return paths.map{|p| p.gsub(/^#{page_cache_directory}/, '')}\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def localize_fullpath(locales = nil)\n locales ||= self.translated_in\n _parent_fullpath = self.parent.try(:fullpath)\n _fullpath, _slug = self.fullpath, self.slug\n\n locales.each do |locale|\n Locomotive::Mounter.with_locale(locale) do\n if _fullpath == 'index'\n self.fullpath = 'index'\n elsif _parent_fullpath == 'index'\n self.fullpath = self.slug || _slug\n else\n self.fullpath = File.join(parent.fullpath || _parent_fullpath, self.slug || _slug)\n end\n end\n end\n end",
"def load_all_files\n return unless File.exist?(cookbook_path)\n\n # If cookbook_path is a symlink, Find on Windows Ruby 2.3 will not traverse it.\n # Dir.entries will do so on all platforms, so we iterate the top level using\n # Dir.entries. Since we have different behavior at the top anyway (hidden\n # directories at the top level are not included for backcompat), this\n # actually keeps things a bit cleaner.\n Dir.entries(cookbook_path).each do |top_filename|\n # Skip top-level directories starting with \".\"\n top_path = File.join(cookbook_path, top_filename)\n next if File.directory?(top_path) && top_filename.start_with?(\".\")\n\n # Use Find.find because it:\n # (a) returns any children, recursively\n # (b) includes top_path as well\n # (c) skips symlinks, which is backcompat (no judgement on whether it was *right*)\n Find.find(top_path) do |path|\n # Only add files, not directories\n next unless File.file?(path)\n # Don't add .uploaded-cookbook-version.json\n next if File.basename(path) == UPLOADED_COOKBOOK_VERSION_FILE\n\n relative_path = Chef::Util::PathHelper.relative_path_from(cookbook_path, path)\n path = Pathname.new(path).cleanpath.to_s\n cookbook_settings[:all_files][relative_path] = path\n end\n end\n end",
"def resolve_files(path)\n path = File.expand_path(path, __FILE__)\n\n if File::directory? path\n files = Dir.entries(path).reject! {|s| s =~ /^\\./} # don't include dotfiles\n files.map! {|file| File.join(path, file)}\n files = files.sort_by {|filename| File.size(File.expand_path(filename, path)) }\n else\n files = [path]\n end\n\n files.reject! {|file| File::directory? file}\n\n files\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency across platforms\n @load_paths.concat(Dir[\"#{app_path}/*/\"].map(&:chop).sort!)\n end\n end\n \n @load_paths\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def collect_entries(filename,root,is_erb = false)\r\n sp = ZLocalize::SourceProcessor.new(filename,root,is_erb)\r\n sp.translation_entries.each do |key,te|\r\n if @new_entries[key]\r\n te.references.each do |ref|\r\n @new_entries[key].add_reference(ref)\r\n end\r\n else\r\n @new_entries[key] = te.dup\r\n end\r\n end\r\n end",
"def mungle_paths(paths)\n return paths if terraform.pre_0_12?\n\n paths.map do |path|\n File.directory?(path) ? path : File.dirname(path)\n end.uniq\n end",
"def relativize_paths(paths)\n return paths unless relativize_paths?\n paths.map do |path|\n path.gsub(%r{^#{@directory}/}, '')\n end\n end",
"def resources_path_names=(_arg0); end",
"def paths(reload = false)\n thread_local_store.keys(reload).map(&:to_s)\n end",
"def get_all_image_cache_paths\n page_cache_directory = ActionController::Base.page_cache_directory.to_s\n page_cache_directory = page_cache_directory.split('/').join('/')\n all_irs_keys = IMAGE_RENDER_SIZES.values.map{|v| v.keys}.flatten.uniq.join(',')\n paths = Dir.glob(\"#{page_cache_directory}#{GLOBAL_CONFIG[:coupon_merchant_images_cache_dir]}/\" +\n \"{#{IMAGE_TYPES.join(',')}}/{#{all_irs_keys}}/\" +\n \"#{self.url_directory}/#{self.id}.*\".gsub('//', '/'))\n return paths.map{|p| p.gsub(/^#{page_cache_directory}/, '')}\n end",
"def local_compiled_assets \n @manifest.files.keys.map {|f| File.join(@prefix, f)} \n end",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end",
"def initialize(file_or_folder_paths = [])\n @paths = []\n @paths += file_or_folder_paths\n end",
"def entry_files\n @entry_files = base_files @entry_path\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def file_paths\n @file_paths ||= begin\n files = []\n each_file do |path|\n files << path\n end\n files\n end\n end",
"def data_files\n bag.bag_files.map {|f| Pathname.new(f) }\n end",
"def content_paths\n if @content_paths.nil?\n paths = if filesystem_path.end_with?(\".content.xml\")\n Pathname(filesystem_path).parent.to_s\n elsif sling_initial_content? and filesystem_path.end_with?(\".json\")\n [filesystem_path, filesystem_path.gsub(/.json$/, \"\")].delete_if { |path| !File.exist?(path) }\n else\n filesystem_path\n end\n\n @content_paths = Array(paths)\n end\n\n @content_paths\n end",
"def possible_paths_file(opts, file_name)\n # partial_path is implemented in each store.\n @storage_paths.map { |path| File.join(path, partial_path(opts), file_name) }\n end",
"def paths\n paths = {}\n end",
"def paths\n paths = {}\n end",
"def normalize_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.map(&:dup).map do |path|\n raise ArgumentError.new(\"Invalid path: #{path}\") unless valid_path?(path)\n # Strip leading slash from extension path\n path.gsub!(/^\\/(?=\\*.)/, '')\n # Escape some valid special characters\n path.gsub!(/[.+$\"]/) {|s| '\\\\' + s}\n # Replace * wildcards with .* regex fragment\n path.gsub!(/\\*/, '.*')\n \"^#{path}#{END_URL_REGEX}\"\n end\nend",
"def paths=(raw_paths)\n raw_paths = [raw_paths] unless raw_paths.respond_to? :each\n\n @paths = raw_paths.map { |path| Pathname.new(path) }\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def set_load_paths(*paths)\n $:.concat(paths); load_paths.concat(paths)\n $:.uniq!; load_paths.uniq!\n end",
"def template_paths(name)\r\n \t@templates.inject([]) do |list, path|\r\n \t\tfile_name = File.basename(path)\r\n \t\tfile_name[0, name.length] == name.to_s ? list << path : list\r\n \tend\r\n end",
"def files_hashs\n @files.map do |file|\n hash = case file\n when String\n { url: file }\n when Hash\n file.dup\n else\n raise ArgumentError, 'files must be an Array of Stings or Hashs'\n end\n\n hash[:local_path] = local_path\n hash\n end\n end",
"def allowable_project_paths(paths)\n lproj_paths = Set.new\n lproj_paths_with_files = Set.new\n\n # Remove all file ref under .docc folder, but preserve the .docc folder\n paths = merge_to_docc_folder(paths)\n\n allowable_paths = paths.select do |path|\n path_str = path.to_s\n\n # We add the directory for a Core Data model, but not the items in it.\n next if path_str =~ /.*\\.xcdatamodeld\\/.+/i\n\n # We add the directory for a Core Data migration mapping, but not the items in it.\n next if path_str =~ /.*\\.xcmappingmodel\\/.+/i\n\n # We add the directory for an asset catalog, but not the items in it.\n next if path_str =~ /.*\\.xcassets\\/.+/i\n\n if path_str =~ /\\.lproj(\\/|$)/i\n # If the element is an .lproj directory then save it and potentially\n # add it later if we don't find any contained items.\n if path_str =~ /\\.lproj$/i && path.directory?\n lproj_paths << path\n next\n end\n\n # Collect the paths for the .lproj directories that contain files.\n lproj_path = /(^.*\\.lproj)\\/.*/i.match(path_str)[1]\n lproj_paths_with_files << Pathname(lproj_path)\n\n # Directories nested within an .lproj directory are added as file\n # system references so their contained items are not added directly.\n next if path.dirname.dirname == lproj_path\n end\n\n true\n end\n\n # Only add the path for the .lproj directories that do not have anything\n # within them added as well. This generally happens if the glob within the\n # resources directory was not a recursive glob.\n allowable_paths + lproj_paths.subtract(lproj_paths_with_files).to_a\n end",
"def resolve_paths\n [dataset_dir, parent.dataset_dir]\n end",
"def paths_from_project_root\n @paths_from_project_root ||=\n [Config.project_root]\n end",
"def set_paths(paths, namespace = MAIN_NAMESPACE)\n unless paths.is_a?(::Array)\n paths = [paths]\n end\n @paths[namespace] = []\n paths.each do |path|\n add_path(path, namespace)\n end\n end",
"def entries() Dir.entries(path).map {|f| Path::Name.new(f) } end",
"def file_paths\n @file_paths ||= begin\n files = []\n each_file do |path|\n files << path\n end\n files\n end\n end",
"def create_cache_files\n @cache_path_names = {}\n each_file_set(:create_cache_file)\n write_cache_path_file\n end",
"def resolve_paths names\n if names.any?\n paths = []\n for name in names\n paths.concat Array(resolve_name name)\n end\n paths\n else\n Array(resolve_as_directory test_dir_name)\n end\n end",
"def paths\n @paths ||= {}\n end",
"def localeList\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\t@locales\n\t\tend",
"def paths\n Hash[ (formats + self.class::VERSION_FORMATS.keys).map{ |f| [f, path(f)] } ]\n end",
"def files\n entries.map{ |f| FileObject[path, f] }\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def paths\n @paths ||= {}.with_indifferent_access\n end",
"def paths\n Array(@ruhoh.cascade.paths.map{|h| h[\"path\"]}).map { |path|\n collection_path = File.join(path, resource_name)\n next unless File.directory?(collection_path)\n\n collection_path\n }.compact\n end",
"def paths\n @paths ||= []\n @paths\n end",
"def paths\n @paths ||= []\n @paths\n end",
"def expand_files map, config\n files = Array.new\n if config.has_key? map\n config[map].each do |v|\n m = /^\\/.*/.match v #starts with /, otherwise it's a group name\n if m\n files << m.to_s\n else\n files + (expand_files m.to_s, config)\n end\n end\n end\n return files\nend",
"def get_cached_forums\n #values = Dir.glob(\"*.yml\").map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\n cp = File.expand_path $cache_path\n values = Dir.entries(cp).grep(/\\.yml$/).map{|a| a.sub(\".yml\",\"\").gsub(\"__\",\"/\"); }\nend",
"def initialize(*dirs)\n @dirs = dirs.flatten.map{|dir| dir.to_s}\n @known_files = []\n @last_mtime = {}\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if !@loaded_paths.include?( expanded_path ) && File.exists?( expanded_path )\n $CLASSPATH << expanded_path\n load_paths << expanded_path\n @loaded_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def paths\n @paths ||= begin\n paths = super\n paths.add 'config/routes.rb', with: 'routes.rb'\n paths.add 'config/locales', with: 'locales', glob: \"**/*.{rb,yml}\"\n paths\n end\n end",
"def resolve_paths names\n if context.tag_filters.any?\n # Bats doesn't support tags\n []\n elsif names.any?\n paths = []\n for name in names\n paths.concat Array(resolve_name name)\n end\n paths\n else\n [test_dir]\n end\n end",
"def localized_paths_for(page)\n return {} if page.path == \"index.html\"\n localized_paths = {}\n (langs).each do |locale|\n # Loop over all pages to find the ones using the same templates (proxied_to) for each language\n sitemap.resources.each do |resource|\n next if !resource.is_a?(Middleman::Sitemap::ProxyResource)\n if resource.target_resource == page.target_resource\n if resource.metadata[:options][:locale] == locale\n localized_paths[locale] = resource.url\n break\n end\n end\n end\n end\n\n localized_paths\n end",
"def map *paths\n return if locked?\n @base_url = rootify_url(paths.shift.to_s).freeze\n @canonicals = paths.map { |p| rootify_url(p.to_s) }.freeze\n end",
"def _all_files\n dict = {}\n paths.each do |path|\n FileUtils.cd(path) { \n Dir[glob].each { |id|\n next unless File.exist?(id) && FileTest.file?(id)\n dict[id] = {\n \"id\" => id,\n \"realpath\" => File.realpath(id),\n \"resource\" => resource_name,\n }\n }\n }\n end\n\n dict\n end",
"def data_cache(fpath)\n (@data_caches ||= []) << fpath\n return fpath\n end",
"def file_paths(file_tree, path_so_far = \"\")\n paths = []\n file_tree.keys.each do |key|\n if file_tree[key] == true\n extended_path = path_so_far + \"#{key}\"\n paths << extended_path\n else\n extended_path = path_so_far + \"#{key}/\"\n paths += file_paths(file_tree[key], extended_path)\n end\n end\n paths\nend",
"def initial_paths; end",
"def upload_paths\n @paths ||= begin\n (images + files + renders).map do |name|\n file_path = @directory.join(name)\n\n next unless File.readable?(file_path)\n\n file_path\n end.compact\n end\n end",
"def iterate_over_file_paths\n parsed_file.each do |hit|\n file_path_array << hit[0]\n end\n file_path_array\n end",
"def paths=(paths = {})\n @paths = {}\n paths.each do |name, path|\n if path[path.size - 1, 1] == '/'\n @paths[name] = path\n else\n @paths[name] = \"#{path}/\"\n end\n end\n end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def config_files(name)\n self.cache_files[name] ||= get_config_files(name)\n end",
"def each_file\n return unless block_given?\n\n loc_path = LokaliseRails.locales_path\n Dir[\"#{loc_path}/**/*\"].sort.each do |f|\n full_path = Pathname.new f\n\n next unless file_matches_criteria? full_path\n\n relative_path = full_path.relative_path_from Pathname.new(loc_path)\n\n yield full_path, relative_path\n end\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def template_files\r\n \t[].concat(@templates)\r\n end",
"def resource_output_paths(resource_input_paths)\n resource_input_paths.map do |resource_input_path|\n base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}'\n extname = File.extname(resource_input_path)\n basename = extname == '.xcassets' ? 'Assets' : File.basename(resource_input_path)\n output_extension = Target.output_extension_for_resource(extname)\n File.join(base_path, File.basename(basename, extname) + output_extension)\n end.uniq\n end",
"def load_paths\n @load_paths ||= [\"urls.rb\", \"config/urls.rb\", \"mailers/*.rb\", \"controllers/**/*.rb\", \"controllers.rb\", \"helpers/*.rb\"]\n end",
"def load_paths\n @_load_paths_was = %w(lib models shared).map { |path| Padrino.root(path) }\n @_load_paths ||= @_load_paths_was\n end"
] |
[
"0.6122637",
"0.5991171",
"0.58114535",
"0.5808625",
"0.5790239",
"0.5790239",
"0.57875615",
"0.5785835",
"0.5767829",
"0.57562494",
"0.5744699",
"0.57141316",
"0.56974804",
"0.5668343",
"0.56582797",
"0.5622436",
"0.5606561",
"0.55918765",
"0.558392",
"0.5562617",
"0.5562617",
"0.55509114",
"0.5531846",
"0.5530349",
"0.5499477",
"0.5433952",
"0.541634",
"0.53901535",
"0.5367933",
"0.5352577",
"0.53488714",
"0.5332285",
"0.5306561",
"0.52965784",
"0.52902955",
"0.52773446",
"0.5265641",
"0.5248163",
"0.5235293",
"0.5233281",
"0.52267563",
"0.5215439",
"0.5211486",
"0.5192464",
"0.5191707",
"0.5169137",
"0.5166379",
"0.5166257",
"0.51653266",
"0.5158437",
"0.5154663",
"0.5154663",
"0.51532793",
"0.5146149",
"0.5144893",
"0.51422167",
"0.51379204",
"0.51357967",
"0.51279086",
"0.51262414",
"0.5121914",
"0.5121881",
"0.50995624",
"0.5098726",
"0.50778455",
"0.5075374",
"0.507273",
"0.5055834",
"0.5043985",
"0.50421655",
"0.504203",
"0.504203",
"0.5027815",
"0.502447",
"0.5020692",
"0.5020692",
"0.5020071",
"0.5018868",
"0.5016878",
"0.50090444",
"0.50021076",
"0.4997472",
"0.4995564",
"0.49955013",
"0.49945998",
"0.4990755",
"0.49802363",
"0.4973782",
"0.49696952",
"0.49618167",
"0.49609345",
"0.4953161",
"0.4952587",
"0.49521977",
"0.49453852",
"0.49442565",
"0.49432617",
"0.4941167",
"0.4940055",
"0.4933354"
] |
0.6008322
|
1
|
Track loaded translation files in the `i18n.load_file` scope, and skip loading the file if its contents are still uptodate. source://i18n//lib/i18n/backend/cache_file.rb17
|
def load_file(filename); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations_and_collect_file_errors(files); end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def reload_special(file)\n return unless special_files.any?{ |special_file| File.identical?(special_file, file) }\n if defined?(I18n)\n began_at = Time.now\n I18n.reload!\n update_modification_time(file)\n logger.devel :reload, began_at, file\n end\n true\n end",
"def handle_loading\n check_watched_files\n reload! if !loaded? && load_cooldown_expired?\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end",
"def after_safe_load_succeed(file)\n Cache.clear_after_reload\n after_safe_load(file)\n end",
"def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end",
"def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end",
"def cached_translations_for_language(language)\n translations = Tr8n::Config.current_source.valid_translations_for_key_and_language(self.key, language)\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def mark_loaded(name, file)\n name = cleanpath(name).chomp('.rb')\n file = File.expand_path(file)\n $LOADED_FEATURES << file unless $LOADED_FEATURES.include?(file)\n loaded[name] = [file, File.mtime(file)]\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def cached_translations_for_language(language)\n if Tr8n::RequestContext.current_source\n translations = Tr8n::RequestContext.current_source.valid_translations_for_key_and_language(self.key, language)\n end\n\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_cache\n begin\n file = File.join(\"inline\", File.basename(so_name))\n if require file then\n dir = Inline.directory\n warn \"WAR\\NING: #{dir} exists but is not being used\" if test ?d, dir and $VERBOSE\n return true\n end\n rescue LoadError\n end\n return false\n end",
"def pr_contains_localization_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.strings/).empty?\n end",
"def ensure_source_processed(translated_filename)\n return unless $SOURCE.empty?\n\n source_filename = File.dirname(translated_filename) + '/en.yml'\n source_contents = File.read(source_filename)\n original_source = YAML.safe_load(source_contents)\n convert_source('', original_source['en'])\nend",
"def load_control\n loaded = false\n Dir.entries(\".\").each do |entry|\n begin\n next if entry =~ /rocket|constants/ || entry !~ /\\.rb/\n if last_modified(entry) > $load_time.to_i\n Kernel::load(entry)\n log_string \"Loaded #{entry}\"\n loaded = true\n end\n rescue\n log_string \"Unable to load #{entry}\"\n log_string $!.to_s\n end\n end\n if loaded\n $load_time = Time.now\n end\nend",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def before_safe_load(file)\n Log.debug(\"reload #{file}\")\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def load_cache\n @load_cache\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end",
"def remove_locale_file language\n File.delete yml_path(language) if File.exists?(yml_path language)\n\n new_load_paths = I18n.load_path.map do |path|\n path unless path.include?(\"#{language}.yml\")\n end.compact\n\n I18n.load_path = new_load_paths\n\n I18n.locale = I18n.default_locale\nend",
"def cold_load!\n components_pattern = File.join(@directory, '**', '*' + @suffix)\n info \"Cold loading: #{components_pattern}\"\n Dir.glob(components_pattern).each { |file| reload! file }\n end",
"def clean_cache_and_translations\n $redis.srem(\"otwtranslation_rules_for_#{language_short}\", display_type)\n\n Otwtranslation::Translation.for_language(language_short)\n .where(\"rules != '#{[].to_yaml}'\").each do |translation|\n if translation.rules.include?(id)\n translation.approved = false\n translation.rules = []\n translation.save!\n end\n end\n end",
"def on_file_autoloaded(file)\n cref = autoloads.delete(file)\n cpath = cpath(*cref)\n\n # If reloading is enabled, we need to put this constant for unloading\n # regardless of what cdef? says. In Ruby < 3.1 the internal state is not\n # fully cleared. Module#constants still includes it, and you need to\n # remove_const. See https://github.com/ruby/ruby/pull/4715.\n to_unload[cpath] = [file, cref] if reloading_enabled?\n Zeitwerk::Registry.unregister_autoload(file)\n\n if cdef?(*cref)\n log(\"constant #{cpath} loaded from file #{file}\") if logger\n run_on_load_callbacks(cpath, cget(*cref), file) unless on_load_callbacks.empty?\n else\n raise Zeitwerk::NameError.new(\"expected file #{file} to define constant #{cpath}, but didn't\", cref.last)\n end\n end",
"def load_index_cache?(file)\n load_index_cache(file) if File.exist?(file)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def after_safe_load(file)\n end",
"def load_cache\n @list = YAML::load_file Settings[:cache_file]\n end",
"def load_cache\n return false\n\n if File.exists?(cache_filename)\n File.open(cache_filename, \"r\") do |f|\n save_date = f.readline.to_datetime\n if ( save_date + @@cache_expiration > DateTime.now )\n @data = JSON.parse(f.readline)\n end\n end\n end\n end",
"def safe_load(file, options={})\n began_at = Time.now\n file = figure_path(file)\n return unless options[:force] || file_changed?(file)\n return require(file) if feature_excluded?(file)\n\n Storage.prepare(file) # might call #safe_load recursively\n logger.devel(file_new?(file) ? :loading : :reload, began_at, file)\n begin\n with_silence{ require(file) }\n Storage.commit(file)\n update_modification_time(file)\n rescue Exception => exception\n unless options[:cyclic]\n logger.exception exception, :short\n logger.error \"Failed to load #{file}; removing partially defined constants\"\n end\n Storage.rollback(file)\n raise\n end\n end",
"def __loading_end(file)\n expected, still_open = @load_table[file]\n unbalanced = (@load_level != expected)\n warning = [nil]\n warning << \"UNBALANCED - expected level #{expected}\" if unbalanced\n warning << 'ALREADY CLOSED' unless still_open\n warning = warning.join(' <<<<<<<<<< ')\n __trace { \"<-==== #{__loading_level}#{file}#{warning}\" }\n @load_table[file] = [@load_level, !still_open]\n @load_level -= 1\n @load_table.clear if @load_level.zero?\n nil\nend",
"def check_files(files)\r\n files_before = @file_info.keys\r\n used_files = {} \r\n files.each do |file|\r\n begin\r\n if @file_info[file]\r\n if @file_info[file].timestamp != File.mtime(file)\r\n @file_info[file].timestamp = File.mtime(file)\r\n digest = calc_digest(file)\r\n if @file_info[file].digest != digest\r\n @file_info[file].digest = digest \r\n @file_changed && @file_changed.call(file)\r\n end\r\n end\r\n else\r\n @file_info[file] = FileInfo.new\r\n @file_info[file].timestamp = File.mtime(file)\r\n @file_info[file].digest = calc_digest(file)\r\n @file_added && @file_added.call(file)\r\n end\r\n used_files[file] = true\r\n # protect against missing files\r\n rescue Errno::ENOENT\r\n # used_files is not set and @file_info will be removed below\r\n # notification hook hasn't been called yet since it comes after file accesses\r\n end\r\n end\r\n files_before.each do |file|\r\n if !used_files[file]\r\n @file_info.delete(file)\r\n @file_removed && @file_removed.call(file)\r\n end\r\n end\r\n end",
"def __loading(file)\n __trace { \"====== #{__loading_level}#{file}\" }\nend",
"def load_cache(language)\n\n\t\t\t\t\t\t# Initialize cache structures\n\t\t\t\t\t\tif @o2t.nil?\n\t\t\t\t\t\t\t@o2t = {}\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif @t2o.nil?\n\t\t\t\t\t\t\t@t2o = {}\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Fill cache if empty\n\t\t\t\t\t\tif @o2t[language.to_sym].nil? || @t2o[language.to_sym].nil?\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t@o2t[language.to_sym] = {}\n\t\t\t\t\t\t\t@t2o[language.to_sym] = {}\n\n\t\t\t\t\t\t\tdata = where(slug_language: language.to_s)\n\t\t\t\t\t\t\tdata.each do |item|\n\t\t\t\t\t\t\t\t@o2t[language.to_sym][item.original] = item.translation\n\t\t\t\t\t\t\t\t@t2o[language.to_sym][item.translation] = item.original\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend",
"def __loading_begin(file)\n level, still_open = @load_table[file]\n warning = [nil]\n warning << \"REPEATED - last at level #{level}\" if level\n warning << 'UNCLOSED' if still_open\n warning = warning.join(' <<<<<<<<<< ')\n @load_level += 1\n @load_table[file] = [@load_level, true]\n __trace { \"====-> #{__loading_level}#{file}#{warning}\" }\nend",
"def load_used_phrases\n\t@used_phrases = load_collection_from_file(@phrase_file_name, {});\nend",
"def reload!\n @initialized = false\n @translations = nil\n super\n end",
"def reload\n @ignored = nil\n ignored\n end",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end",
"def load_from_file_cache(file)\n puts \"loading stuff from #{file}\"\n File.open(file, 'r') do |input|\n Marshal.load(input.read)\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def assert_file_named_correctly!(file, translations); end",
"def cached?(file_id)\n synchronize do\n return @cached_files.include?(file_id)\n end\n end",
"def __loading_end(file)\n expected, still_open = @load_table[file]\n unbalanced = (@load_level != expected)\n warning = [nil]\n warning << \"UNBALANCED - expected level #{expected}\" if unbalanced\n warning << 'ALREADY CLOSED' unless still_open\n warning = warning.join(' <<<<<<<<<< ')\n $stderr.puts(\"<-==== #{__loading_level}#{file}#{warning}\")\n @load_table[file] = [@load_level, !still_open]\n @load_level -= 1\n @load_table.clear if @load_level.zero?\n end",
"def missing_localizations(org_base='en-US')\n @langs = {}\n @missing_localizations = {}\n @l_files = Dir[File.join( RAILS_ROOT, '/lang/ui', '*.yml')]\n @l_files.each do |file| \n if YAML.load_file(file)\n @langs[File.basename(file, '.*')] = YAML.load_file(file).symbolize_keys \n else\n p \"error with the following file: #{file}, the file might be empty\"\n end\n end\n @base_keys = @langs[org_base]\n unless @base_keys.blank?\n @langs.each_key do |@lang|\n @base_keys.each_key do |key|\n unless @langs[@lang].include?(key)\n @missing_localizations[@lang] ||= {}\n @missing_localizations[@lang] = @missing_localizations[@lang].merge({key.to_sym => @base_keys[key]})\n end\n end\n end\n else\n p \"your #{org_base} file seems empty\"\n end\n @missing_localizations\n end",
"def load_resources(filename)\n file = File.new(filename)\n content = file.read\n file.close\n \n # replace 'static/my_system/en/current/' => 'static/my_system/en/fe766a8e4c82f8b387effb309563f4fd114248ee/' \n # (where fe766... is current build number)\n \n content.gsub!(/#{self.rez_base}\\/#{ResourceSquasher.project_name}\\/#{self.language}\\/current\\//, \"#{self.rez_base}/#{ResourceSquasher.project_name}/#{self.language}/#{self.build_number}/\")\n\n out = File.new(filename, 'w')\n out.write(content)\n out.close\n \n # skip binary resources\n if filename =~ /\\.html|\\.js|\\.css|\\.txt|\\.json|\\.htm$/i\n content.scan(resource_regex) do |mgroup|\n resource = mgroup.first\n if resource =~ /__sc_chance_mhtml.txt!__/\n $stderr.puts \"skipping dynamic expression resource: #{resource}\"\n next\n end\n #TODO: return value for add_file is true if new file\n # and adding was successful\n if self.file_mapper.add_file(resource)\n added_file = self.file_mapper.old_names[resource]\n if resource =~ /\\.html|\\.js|\\.css|\\.txt|\\.json|\\.htm$/i\n self.load_resources(added_file.old_path)\n end\n else\n end\n end\n end\n end",
"def reload!\n suppress_warnings do \n Dir['./**/*.rb'].each do |f| \n load f\n end\n end\n nil\nend",
"def reload?\n return true unless loaded?\n return false unless Gretel.reload_environments.include?(Rails.env)\n\n loaded_file_mtimes != breadcrumb_files.map { |file| File.mtime(file) }\n end",
"def load_cache\n #orig_enc = @encoding\n\n File.open cache_path, 'rb' do |io|\n @cache = Marshal.load io.read\n end\n\n load_enc = @cache[:encoding]\n\n # TODO this feature will be time-consuming to add:\n # a) Encodings may be incompatible but transcodeable\n # b) Need to warn in the appropriate spots, wherever they may be\n # c) Need to handle cross-cache differences in encodings\n # d) Need to warn when generating into a cache with different encodings\n #\n #if orig_enc and load_enc != orig_enc then\n # warn \"Cached encoding #{load_enc} is incompatible with #{orig_enc}\\n\" \\\n # \"from #{path}/cache.ri\" unless\n # Encoding.compatible? orig_enc, load_enc\n #end\n\n @encoding = load_enc unless @encoding\n\n @cache[:pages] ||= []\n @cache[:main] ||= nil\n @cache[:c_class_variables] ||= {}\n @cache[:c_singleton_class_variables] ||= {}\n\n @cache[:c_class_variables].each do |_, map|\n map.each do |variable, name|\n @c_enclosure_names[variable] = name\n end\n end\n\n @cache\n rescue Errno::ENOENT\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def load_cached_partial(path, context)\n context.registers[:cached_partials] ||= {}\n cached_partial = context.registers[:cached_partials]\n\n if cached_partial.key?(path)\n cached_partial[path]\n else\n unparsed_file = context.registers[:site]\n .liquid_renderer\n .file(path)\n begin\n cached_partial[path] = unparsed_file.parse(File.read(path, **context.registers[:site].file_read_opts))\n rescue Liquid::Error => e\n e.template_name = path\n e.markup_context = \"included \" if e.markup_context.nil?\n raise e\n end\n end\n end",
"def load_cached_partial(path, context)\n context.registers[:cached_partials] ||= {}\n cached_partial = context.registers[:cached_partials]\n\n if cached_partial.key?(path)\n cached_partial[path]\n else\n unparsed_file = context.registers[:globals]\n .liquid_renderer\n .file(path)\n begin\n # Cache a version of the\n cached_partial[path] = unparsed_file.parse(read_file(path, context))\n rescue Liquid::Error => e\n e.template_name = path\n e.markup_context = \"included \" if e.markup_context.nil?\n raise e\n end\n end\n end",
"def load\n @cache = JSON.parse(File.read(file))\n rescue\n @cache = {}\n end",
"def reload!\n require 'pathname'\n Pathname.new(File.expand_path(__FILE__)).parent.find do |path|\n if path.extname == '.rb' and path.mtime > reload_time\n puts path.to_s\n load path.to_s\n end\n end\n clear_plugin_cache\n @reload_time = Time.now\n end",
"def save!\n if self.file =~ LOCALE_INTERPOLATOR\n I18n.available_locales.each do |locale|\n write_file(file_for_locale(locale), self.translations.slice(locale))\n end\n else\n write_file\n end\n end",
"def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end",
"def _valid_file?(name)\n @cache_valid ||= {}\n @cache_valid[name.to_sym] ||= !_config_files(name).empty?\n end",
"def fl(file_name)\n file_name += '.rb' unless file_name =~ /\\.rb/\n @@recent = file_name \n load \"#{file_name}\"\nend",
"def invalidate_current_loaded_file\n if (@current_file_name == nil)\n @main_widget.title = 'Files Rebuilder'\n @main_widget.enable_save(false)\n else\n @main_widget.title = \"Files Rebuilder - #{@current_file_name}\"\n @main_widget.enable_save(true)\n end\n end",
"def load_game(file) \n raise \"I suspect you of cheating.\" if File.mtime(file) != Time.at(File.readlines(file).last.to_i)\nend",
"def __loading_begin(file)\n level, still_open = @load_table[file]\n warning = [nil]\n warning << \"REPEATED - last at level #{level}\" if level\n warning << 'UNCLOSED' if still_open\n warning = warning.join(' <<<<<<<<<< ')\n @load_level += 1\n @load_table[file] = [@load_level, true]\n $stderr.puts(\"====-> #{__loading_level}#{file}#{warning}\")\n end",
"def load_cached\n content = File.open(self.cache_file_name, \"rb\") { |f| f.read }\n puts(\"[MODEL_FILE] Loaded #{self.cache_file_name} from cache\")\n return content\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def unload\n mutex.synchronize do\n # We are going to keep track of the files that were required by our\n # autoloads to later remove them from $LOADED_FEATURES, thus making them\n # loadable by Kernel#require again.\n #\n # Directories are not stored in $LOADED_FEATURES, keeping track of files\n # is enough.\n unloaded_files = Set.new\n\n autoloads.each do |abspath, (parent, cname)|\n if parent.autoload?(cname)\n unload_autoload(parent, cname)\n else\n # Could happen if loaded with require_relative. That is unsupported,\n # and the constant path would escape unloadable_cpath? This is just\n # defensive code to clean things up as much as we are able to.\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n end\n\n to_unload.each do |cpath, (abspath, (parent, cname))|\n # We have to check cdef? in this condition. Reason is, constants whose\n # file does not define them have to be kept in to_unload as explained\n # in the implementation of on_file_autoloaded.\n #\n # If the constant is not defined, on_unload should not be triggered\n # for it.\n if !on_unload_callbacks.empty? && cdef?(parent, cname)\n value = parent.const_get(cname)\n run_on_unload_callbacks(cpath, value, abspath)\n end\n\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n\n unless unloaded_files.empty?\n # Bootsnap decorates Kernel#require to speed it up using a cache and\n # this optimization does not check if $LOADED_FEATURES has the file.\n #\n # To make it aware of changes, the gem defines singleton methods in\n # $LOADED_FEATURES:\n #\n # https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb\n #\n # Rails applications may depend on bootsnap, so for unloading to work\n # in that setting it is preferable that we restrict our API choice to\n # one of those methods.\n $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }\n end\n\n autoloads.clear\n autoloaded_dirs.clear\n to_unload.clear\n lazy_subdirs.clear\n\n Registry.on_unload(self)\n ExplicitNamespace.unregister_loader(self)\n\n @setup = false\n @eager_loaded = false\n end\n end",
"def load(options={})\r\n @before_load_proc = options[:before_load]\r\n @after_load_proc = options[:after_load]\r\n files = @file_provider.call \r\n @num_files = files.size\r\n @files_added = []\r\n @files_changed = []\r\n @files_removed = []\r\n @change_detector.check_files(files)\r\n @progress_monitor = ProgressMonitor.new(options[:on_progress], @files_added + @files_changed)\r\n @files_added.each {|f| file_added(f)}\r\n @files_changed.each {|f| file_changed(f)}\r\n @files_removed.each {|f| file_removed(f)}\r\n @resolver.resolve_model(@model)\r\n end",
"def loading(path)\n load_map[path] = Thread.current unless load_map.key? path\n end",
"def dynamic_load(file) # FilePair\n\t\tbegin\n\t\t\t# NOTE: file timestamps only have 1 sec resolution, so there may be a slight delay when attempting to reload more than once per second.\n\t\t\tif file.changed?\n\t\t\t\tfile.update_time\n\t\t\t\t# NOTE: Timestamps updated whenever load is *attempted*\n\t\t\t\t\t# This is actually what you want.\n\t\t\t\t\t# If you don't do it this way, then when there is a load error,\n\t\t\t\t\t# the system will try and fail to reload the file every tick\n\t\t\t\t\t# of the main loop.\n\t\t\t\t\t# This will generate a lot of useless noise in the log.\n\t\t\t\t\t# However, once the file is updated, you expect the system to\n\t\t\t\t\t# attempt a reload at least once.\n\t\t\t\t\n\t\t\t\tputs \"live loading #{file}\"\n\t\t\t\tload file.to_s\n\t\t\t\tself.successful_reload()\n\t\t\tend\n\t\trescue SyntaxError, ScriptError, NameError => e\n\t\t\t# This block triggers if there is some sort of\n\t\t\t# syntax error or similar - something that is\n\t\t\t# caught on load, rather than on run.\n\t\t\t\n\t\t\t# ----\n\t\t\t\n\t\t\t# NameError is a specific subclass of StandardError\n\t\t\t# other forms of StandardError should not happen on load.\n\t\t\t# \n\t\t\t# If they are happening, something weird and unexpected has happened, and the program should fail spectacularly, as expected.\n\t\t\t\n\t\t\tputs \"FAILURE TO LOAD: #{file}\"\n\t\t\t\n\t\t\tprint_wrapped_error(e)\n\t\t\t\n\t\t\tself.runtime_error()\n\t\tensure\n\t\t\t\n\t\tend\n\tend",
"def load_files\n # load models\n load_models\n puts \"=> Caching files\"\n @@controllers = {}\n @@mailers = {}\n @@layouts={}\n @@views={}\n @@errors={}\n \n # require helper files and include into Doozer::Partial\n helper_files = Dir.glob(File.join(app_path,'app/helpers/*_helper.rb')) \n helper_files.each {|f|\n require f\n key = f.split(\"helpers/\")[1].gsub(/.rb/,'')\n Doozer::Partial.include_view_helper(key)\n }\n \n # cache contoller classes\n controller_files = Dir.glob(File.join(app_path,'app/controllers/*_controller.rb'))\n # we need to load the application_controller first since this might not be the first in the list...\n if controller_files.length > 0\n i=0\n for f in controller_files\n break if i==0 and f.index('application_controller.rb')\n if f.index('application_controller.rb')\n controller_files.insert(0, controller_files.delete(f))\n break\n end\n i+=1\n end\n end\n \n controller_files.each { |f|\n require f \n key = f.split(\"controllers/\")[1].split(\"_controller.rb\")[0]\n if key.index(\"_\")\n value = key.split('_').each{ | k | k.capitalize! }.join('') \n else\n value = key.capitalize\n end\n klass_name = \"#{value}Controller\"\n @@controllers[key.to_sym] = klass_name\n # p \"cache controller: #{key.to_sym}\"\n \n # importing view helpers into controller\n controller_klass = Object.const_get(klass_name)\n # automatically ads the application helper to the class\n controller_klass.include_view_helper('application_helper')\n controller_klass.include_view_helpers\n }\n \n # cache layout erb's\n layout_files = Dir.glob(File.join(app_path,'app/views/layouts/*.erb'))\n layout_files.each {|f|\n key = f.split(\"layouts/\")[1].split(\".html.erb\")[0].gsub(/.xml.erb/, '_xml').gsub(/.json.erb/, '_json').gsub(/.js.erb/, '_js').gsub(/.rss.erb/, '_rss').gsub(/.atom.erb/, '_atom')\n results = []\n File.new(f, \"r\").each { |line| results << line }\n @@layouts[key.to_sym] = ERB.new(results.join(\"\"))\n }\n \n #lood 404 and 500 pages if they exist\n pnf = Doozer::Configs.page_not_found_url\n if pnf\n file = File.join(app_path,\"#{pnf}\")\n results = []\n File.new(file, \"r\").each { |line| results << line }\n @@errors[404] = results.join(\"\")\n else\n @@errors[404] = \"<html><body>Sorry, this page can't be found.</body></html>\"\n end\n ise = Doozer::Configs.internal_server_error_url\n if ise\n file = File.join(app_path,\"#{ise}\")\n results = []\n File.new(file, \"r\").each { |line| results << line }\n @@errors[500] = results.join(\"\")\n else\n @@errors[500] = \"<html><body>There was an internal server error which borked this request.</body></html>\"\n end\n \n @@controllers.each_key { | key |\n # p key.inspect\n files = Dir.glob(File.join(app_path,\"app/views/#{key.to_s}/*.erb\"))\n files.each { | f |\n #!!!don't cache partials here!!!\n view = f.split(\"#{key.to_s}/\")[1].split(\".erb\")[0].gsub(/\\./,'_')\n # p \"check view: #{view}\"\n if not /^_/.match( view )\n # p \"cache view: #{view}\"\n results = []\n File.new(f, \"r\").each { |line| results << line }\n @@views[key] = {} if @@views[key].nil?\n @@views[key][view.to_sym] = ERB.new(results.join(\"\"))\n end\n }\n }\n\n mailer_files = Dir.glob(File.join(app_path,'app/mailers/*_mailer.rb'))\n mailer_files.each { |f|\n require f \n key = f.split(\"mailers/\")[1].split(\"_mailer.rb\")[0]\n if key.index(\"_\")\n value = key.split('_').each{ | k | k.capitalize! }.join('') \n else\n value = key.capitalize\n end\n klass_name = \"#{value}Mailer\"\n @@mailers[key.to_sym] = klass_name\n # puts \"cache mailer: #{key.to_sym}\"\n # importing view helpers into controller\n mailer_klass = Object.const_get(klass_name)\n # automatically ads the application helper to the class\n mailer_klass.include_view_helper('application_helper')\n mailer_klass.include_view_helpers\n }\n \n mail_key = :mail\n mailer_files = Dir.glob(File.join(app_path,\"app/views/#{mail_key.to_s}/*.erb\"))\n mailer_files.each { | f |\n #!!!don't cache partials here!!!\n view = f.split(\"#{mail_key.to_s}/\")[1].split(\".erb\")[0].gsub(/\\./,'_')\n if not /^_/.match( view )\n # puts \"cache view: #{view}\"\n results = []\n File.new(f, \"r\").each { |line| results << line }\n @@views[mail_key] = {} if @@views[mail_key].nil?\n @@views[mail_key][view.to_sym] = ERB.new(results.join(\"\"))\n end\n }\n end",
"def load_watcher\n require 'doozer/watcher'\n \n puts \"=> Watching files for changes\"\n watcher = FileSystemWatcher.new()\n \n # watcher.addDirectory(File.join(File.dirname(__FILE__),'../doozer/'), \"*.rb\")\n watcher.addDirectory( app_path + '/app/', \"**/*\")\n watcher.addDirectory( app_path + '/app', \"**/**/*\")\n watcher.addDirectory( app_path + '/config/', \"*.*\")\n watcher.addDirectory( app_path + '/lib/', \"*.*\")\n watcher.addDirectory( app_path + '/static/', \"*.*\")\n watcher.addDirectory( app_path + '/static/', \"**/**/*\")\n\n watcher.sleepTime = 1\n watcher.start { |status, file|\n if(status == FileSystemWatcher::CREATED) then\n puts \"created: #{file}\"\n load_files\n Doozer::Partial.clear_loaded_partials\n Doozer::MailerPartial.clear_loaded_partials\n elsif(status == FileSystemWatcher::MODIFIED) then\n puts \"modified: #{file}\"\n load_files\n Doozer::Partial.clear_loaded_partials\n Doozer::MailerPartial.clear_loaded_partials\n Doozer::Configs.clear_static_files\n elsif(status == FileSystemWatcher::DELETED) then\n puts \"deleted: #{file}\"\n load_files\n Doozer::Partial.clear_loaded_partials\n Doozer::MailerPartial.clear_loaded_partials\n Doozer::Configs.clear_static_files\n end\n }\n #don't join the thread it messes up rackup threading watcher.join()\n # p watcher.isStarted?\n # p watcher.isStopped?\n # p watcher.foundFiles.inspect\n end",
"def localized_strings?\n @lstrings ||= entry[:localized] && entry[:filename] =~ /strings.js$/\n end",
"def file_cache(token, caching_time_in_minutes=30, &payload)\n file = file_name token\n if FileHelper.not_cached_or_to_old? file, caching_time_in_minutes\n load_from_file_cache file\n else\n write_to_file_cache file, (yield payload)\n end\n end",
"def load_file(file)\n return if @loaded.include? file\n\n # We have to specify Kernel.load, because we have a load method.\n begin\n # Store the file path so we don't try to reload it\n @loaded << file\n Kernel.load(file)\n rescue ScriptError => detail\n # Don't store the path if the file can't be loaded\n # in case it's loadable later on.\n @loaded.delete(file)\n Facter.warn \"Error loading fact #{file} #{detail}\"\n end\n end",
"def load #:nodoc:\n @found ||= {}\n @loaded ||= {}\n @files ||= Gem.find_files('cartage/*.rb')\n\n @files.reverse.each do |path|\n name = File.basename(path, '.rb').to_sym\n @found[name] = path\n end\n\n :repeat while @found.map { |name, plugin|\n load_plugin(name, plugin)\n }.any?\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def load_order\n @cache_load_order = read_load_order unless defined?(@cache_load_order)\n @cache_load_order\n end",
"def file_dumps\r\n Dir.new(translation_base).entries.select{|x| x['.yml']}\r\n end",
"def chunks_translated\n @chunks_translated ||= chunks.map do |chunk|\n cached, missing = cache.cached_and_missing(chunk)\n if missing.empty?\n cached\n else\n cache.store(chunk, cached, call_api(missing))\n end\n end\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def remove_unnecessary_cache_files!\n current_keys = cache_files.map do |file|\n get_cache_key_from_filename(file)\n end\n inmemory_keys = responses.keys\n\n unneeded_keys = current_keys - inmemory_keys\n unneeded_keys.each do |key|\n File.unlink(filepath_for(key))\n end\n end",
"def reload!\n !!silence_warnings do\n $LOADED_FEATURES\n .select { |feat| feat =~ /\\/tak\\// }\n .each { |file| load file }\n end\n rescue => e\n e\n end",
"def load_imports\n while fn = @pending_imports.shift\n next if @imported.member?(fn)\n if fn_task = lookup(fn)\n fn_task.invoke\n end\n load!(fn)\n @imported << fn\n end\n end",
"def source(file)\n @_source_cache[file] ||= (\n File.readlines(file)\n )\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def load_imports\n while fn = @pending_imports.shift\n next if @imported.member?(fn)\n ext = File.extname(fn)\n loader = @loaders[ext] || @default_loader\n loader.load(fn)\n @imported << fn\n end\n end",
"def source(file)\n @_source_cache ||= {}\n @_source_cache[file] ||= (\n File.readlines(file)\n )\n end",
"def process_files\n loaded_files = []\n files.each do |file|\n Async do |task|\n task.async do\n loaded_files << load_file(file[:path], file[:source])\n end\n end\n end\n loaded_files\n end",
"def internal\n @internal ||= load_from_file\n end",
"def examine_uncovered_file(filename)\n # run it through the Loader\n # it will fill out the coverage data for this file\n @loader.load filename\n\n # re-get the lines\n coverage_data[filename]\n end",
"def loaded?\n @loaded ||= false\n end",
"def decide_filenames key\n filenames = []\n # Origin or developer mode, the translations will be applied to the original\n # file where those where setup, including plugin folders\n if self.class.mode == :origin\n filename, found_locale = get_translation_origin_filename(key)\n # If filename is outside rail.root send it to config/locales/external_#{translations_locale_name}.yml\n filename = replace_external_to_application_file_paths(filename) if filename.present?\n\n # Doesn't exist the translation for current locale, but it does in another\n if found_locale.present? && found_locale.to_s != self.locale.to_s\n # We try to generate the filename replacing the '/existing_locale/' section\n # in path for the new_locale\n filename = find_or_create_origin_filename(filename, found_locale)\n end\n if filename\n filenames << filename\n end\n end\n #\n # Normal app mode, the translation will be dumped together to /config/locales/#{locale}.yml to keep\n # in sync with the original source of the translation\n #\n create_empty_translations_file(application_mode_file_path) if !File.exists?(application_mode_file_path)\n filenames << application_mode_file_path\n #\n # Path to the backup file of the current translation request/transaction\n #\n filenames << log_file_path\n\n filenames\n end"
] |
[
"0.64713883",
"0.62355065",
"0.61133826",
"0.6104112",
"0.6056092",
"0.602115",
"0.60041994",
"0.5991724",
"0.5811452",
"0.5780131",
"0.5770043",
"0.5754264",
"0.5694176",
"0.5694176",
"0.56774527",
"0.56449616",
"0.563705",
"0.5634282",
"0.5634282",
"0.56184894",
"0.560932",
"0.5580332",
"0.55560565",
"0.5528187",
"0.54347205",
"0.54178315",
"0.53953713",
"0.5375003",
"0.5360719",
"0.5345695",
"0.5328251",
"0.5324661",
"0.53178257",
"0.5301652",
"0.52587736",
"0.5255719",
"0.5230404",
"0.52279",
"0.522347",
"0.5210688",
"0.52103937",
"0.52011114",
"0.51958543",
"0.5195159",
"0.51943094",
"0.51925284",
"0.5171165",
"0.51481557",
"0.5138311",
"0.51262546",
"0.5119555",
"0.51189196",
"0.5098345",
"0.507966",
"0.50766873",
"0.507015",
"0.5032138",
"0.5022663",
"0.50219584",
"0.50179404",
"0.50146353",
"0.50031507",
"0.5001014",
"0.50003964",
"0.4994098",
"0.49774823",
"0.4974811",
"0.49694163",
"0.49640214",
"0.4947886",
"0.49442646",
"0.4941246",
"0.4940419",
"0.49263197",
"0.4923785",
"0.4921032",
"0.4917937",
"0.49153957",
"0.4903981",
"0.49008495",
"0.4896192",
"0.48942852",
"0.489407",
"0.48939526",
"0.48785338",
"0.4875717",
"0.48709154",
"0.48602802",
"0.48592582",
"0.48565444",
"0.48504",
"0.48499632",
"0.48485264",
"0.48447418",
"0.48418084",
"0.48379374",
"0.4815554",
"0.48151827",
"0.48083618",
"0.47963077",
"0.47962812"
] |
0.0
|
-1
|
Translate absolute filename to relative path for i18n key. source://i18n//lib/i18n/backend/cache_file.rb28
|
def normalized_path(file); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_path\n Dir.glob(config.cache).first || File.join(File.dirname(config.cache),\n File.basename(config.cache).gsub(/_.+\\.txt/, '_0.txt'))\n end",
"def cache_file key\n File.join( store, key+\".cache\" )\n end",
"def file_path(file_name)\n file = file_map[file_name]\n file['path'] ||= @file_cache.update_file(file)\n end",
"def path_to(key)\n key = key.gsub(/[<>:\\\\|?*%]/) {|c| \"%%%03d\" % c.ord}\n File.join(cache_location, key)\n end",
"def get_filename(key)\n\thash = hash(key)\n\n\tif File.exist?(File.join(@cache_dir, hash))\n\t return File.join(@cache_dir, hash)\n\telse\n\t return nil\n\tend\n end",
"def get_cache_file(key)\n _find_file_key(key)\n end",
"def filenames_for_current_locale; end",
"def filename(uri)\n \"#{URI.escape(uri, '/')}.cached\"\n end",
"def file_name(token)\n FileHelper.file_cache_name(file_cache_dir, token)\n end",
"def decide_filenames key\n filenames = []\n # Origin or developer mode, the translations will be applied to the original\n # file where those where setup, including plugin folders\n if self.class.mode == :origin\n filename, found_locale = get_translation_origin_filename(key)\n # If filename is outside rail.root send it to config/locales/external_#{translations_locale_name}.yml\n filename = replace_external_to_application_file_paths(filename) if filename.present?\n\n # Doesn't exist the translation for current locale, but it does in another\n if found_locale.present? && found_locale.to_s != self.locale.to_s\n # We try to generate the filename replacing the '/existing_locale/' section\n # in path for the new_locale\n filename = find_or_create_origin_filename(filename, found_locale)\n end\n if filename\n filenames << filename\n end\n end\n #\n # Normal app mode, the translation will be dumped together to /config/locales/#{locale}.yml to keep\n # in sync with the original source of the translation\n #\n create_empty_translations_file(application_mode_file_path) if !File.exists?(application_mode_file_path)\n filenames << application_mode_file_path\n #\n # Path to the backup file of the current translation request/transaction\n #\n filenames << log_file_path\n\n filenames\n end",
"def cacheFileName(ni)\n @directory_name + \"/\" + ni.path\nend",
"def real_path(filename)\n File.join TEMPLATES_DIR, filename\n end",
"def locale_file_path(locale)\n \"config/locales/#{locale}.yml\"\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def file_path(file_name)\n file_map[file_name]['path']\n end",
"def full_path_from_edict_file(filename=\"\")\n return Rails.root.join(\"data/cedict/#{filename}\").to_s\n end",
"def filename(uri)\n \"#{URI.encode_www_form_component(uri)}.cached\"\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present? \n end",
"def application_mode_file_path locale = locale\n File.join(Translate::Storage.root_dir, \"config\", \"locales\", \"#{locale}.yml\")\n end",
"def cache_filename_for_uri( path )\n uid = Digest::MD5.hexdigest( \"#{@uid}:#{path}\" )\n # NOTE: this path needs to exist with r/w permissions for webserver\n @cache_dir.join( uid )\n end",
"def translate_file(filename)\n f = File.read(filename)\n f = translate_title(f)\n f = translate_body(f)\n f = update_category(f)\n f\n end",
"def cache_path\n File.join @path, 'cache.ri'\n end",
"def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def transliterate_file_name\n\t\t\tfile_names = Array.new\n\t\t\t@attributes.keys.each { |a| file_names << a if a.match(/_file_name{1}$/) }\n\t\t\tfile_names.each do |local_file_name|\n\t\t\t\tif self.send(local_file_name).present? && self.send(local_file_name+'_changed?')\n\t\t\t\t\textension = File.extname(send(local_file_name)).gsub(/^\\.+/, '')\n\t\t\t\t\tfilename = send(local_file_name).gsub(/\\.#{extension}$/, '')\n\t\t\t\t\tself.send(local_file_name.gsub(/_file_name{1}$/, '')).instance_write(:file_name, \"#{transliterate(filename)}.#{transliterate(extension)}\")\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def absolute_path\n if is_url?\n # Use the last path component without the query string plus the name\n # of the resource in Base64. This should be both mildly readable and\n # also unique per invocation.\n url_part = URI(path).path.split(/\\//).last\n base64_name = Base64.strict_encode64(name).gsub(/\\=/, '')\n ::File.join(Chef::Config[:file_cache_path], \"#{base64_name}_#{url_part}\")\n else\n ::File.expand_path(path, Chef::Config[:file_cache_path])\n end\n end",
"def assert_file_named_correctly!(file, translations); end",
"def read_key(key)\n if File.exist?(key.to_s) && File.file?(key.to_s)\n File.read(File.absolute_path(key))\n else\n key\n end\n end",
"def localized_image_filename (source)\n localized_filename = get_language_filename( source, true )\n language_filename = get_language_filename( source, false )\n if language_image_exists?(localized_filename)\n return localized_filename\n elsif language_image_exists?(language_filename)\n return language_filename\n else\n return source\n end\n end",
"def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token}.#{file.extension}\" if original_filename\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def gen_rel_path(file)\n file = \"/secure/news/#{@folder}/#{file}\"\n end",
"def key_file_path(key)\n fname = URI.encode_www_form_component(key)\n hash = Zlib.adler32(fname)\n hash, dir_1 = hash.divmod(0x1000)\n dir_2 = hash.modulo(0x1000)\n fname_paths = []\n\n # Make sure file name doesn't exceed file system limits.\n begin\n fname_paths << fname[0, FILENAME_MAX_SIZE]\n fname = fname[FILENAME_MAX_SIZE..-1]\n end until fname.nil? || fname == \"\"\n\n File.join(@root_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, *fname_paths)\n end",
"def cache_file(input)\n key = Digest.hexencode(Digest::SHA2.digest(input.to_yaml))\n return @directory + \"/\" + key + \".yaml\"\n end",
"def localize_path(path)\n cpath_size = @component_path.size\n return @component_name + path[cpath_size..-1]\n end",
"def absolute_template_filename_for(relative_filename)\n File.expand_path(File.join(self.class.template_load_path, relative_filename))\n end",
"def cache_file_for(klassname)\n File.join cache_file_path, klassname.gsub(/:+/, \"-\")\n end",
"def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end",
"def filename\n \"#{original_filename}+#{secure_token}.#{file.extension}\" if original_filename.present?\n end",
"def key\n uri = DocumentHelper.cur_user_host_address(nil) + '/' + @file_name # get current user host address\n stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file\n return ServiceConverter.generate_revision_id(\"#{uri}.#{stat.to_s}\")\n end",
"def get_language_filename( source, use_locale = false )\n before_substring = source.slice(0,(source.rindex(\".\") ))\n after_substring = source.slice(source.rindex(\".\"), (source.size - before_substring.size) )\n if use_locale\n return \"#{before_substring}-#{GettextLocalize.locale.to_s}#{after_substring}\"\n else\n return \"#{before_substring}-#{GettextLocalize.locale.to_s[0,2]}#{after_substring}\"\n end\n end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def filename\n self.class.path(hash)\n end",
"def localize_resource(tag, sym, loader, uri, dir, subdir, h, props)\n rel_url = tag[sym]\n src_url = absolute_url_for(uri, rel_url)\n\n buf = download_resource(loader, src_url)\n return if (! buf) or (buf.empty?)\n\n path = path_for_url(dir, subdir, rel_url)\n # Fix for super-long filenames. wikipedia, for example, has these\n if path.length > 256\n path = path_for_url(dir, subdir, rel_url[0,256])\n end\n\n local_ref = ref_path(dir, subdir, path)\n\n # localize tag ref\n tag[sym.to_s] = local_ref\n\n # store remote contents in Hash under path\n h[path] = buf\n # TODO: mime-type?\n props[path] = { :origin => src_url, :relative_path => local_ref }\n end",
"def namespaced_keyed_filename\n full_path_to_credential_file\n end",
"def locale_of(filename)\n locale = (filename =~ extension_regex ? $1 : nil)\n locale ? locale.gsub(/^\\./, '').to_sym : nil\n end",
"def key(sass_dirname, sass_basename)\n dir = Digest::SHA1.hexdigest(sass_dirname)\n filename = \"#{sass_basename}c\"\n \"#{dir}/#{filename}\"\n end",
"def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not present for uncached remote file!\n file.uploader.filename.present? ? file.uploader.filename : File.basename(Addressable::URI.parse(file.file_url).path)\n elsif file.respond_to?(:original_name) # e.g. Hydra::Derivatives::IoDecorator\n file.original_name\n elsif file_set.import_url.present?\n # This path is taken when file is a Tempfile (e.g. from ImportUrlJob)\n File.basename(Addressable::URI.parse(file_set.import_url).path)\n else\n File.basename(file)\n end\n end",
"def log_file_path\n @translation_session ||= \"#{Time.now.strftime(\"%Y-%m-%d-%H-%M-%S-%3N\").parameterize}_#{rand(2**8)}\"\n file_path = File.join(self.class.root_dir, \"tmp\", \"locales\", \"log\", locale.to_s, \"#{@translation_session}.yml.backup\")\n create_empty_translations_file(file_path) if !File.exists?(file_path)\n file_path\n end",
"def project_file(fname)\n \"#{@project_path}/#{fname}\"\nend",
"def full_path\n \"templates/#{filename}\"\n end",
"def file_path(filename)\n File.join(path, filename)\n end",
"def cache_file_path\n raise IOError.new 'Write permission is required for cache directory' unless File.writable?(@args[:cache_directory])\n \"#{@args[:cache_directory]}/#{Digest::SHA1.hexdigest((@args[:cache_ref] || @path).to_s + size.to_s + last_modified.to_s)}.cache\"\n end",
"def file_path\n \"#{Time.now.to_f}.#{filename}\"\n end",
"def original_filename; end",
"def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end",
"def cache_filename(url, json)\n uri = URI(url)\n filename = File.join(uri.host, uri.path)\n filename.sub!(/\\/+$/, \"\") # remove trailing slashes\n filename = \"#{filename}.json\" if json\n filename.gsub!(/[^\\w\\.-_\\/\\\\]/, \"-\")\n # strip bad filename characters\n File.join(cache_directory, filename)\n end",
"def cache_file\n @cache_file ||= File.join cache_dir, \"#{full_name}.gem\"\n end",
"def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not present for uncached remote file!\n file.uploader.filename.presence || File.basename(Addressable::URI.unencode(file.file_url))\n elsif file.respond_to?(:original_name) # e.g. Hydra::Derivatives::IoDecorator\n file.original_name\n elsif file_set.import_url.present?\n # This path is taken when file is a Tempfile (e.g. from ImportUrlJob)\n File.basename(Addressable::URI.unencode(file.file_url))\n elsif file.respond_to?(:original_filename) # e.g. Rack::Test::UploadedFile\n file.original_filename\n else\n File.basename(file)\n end\n end",
"def key(uri, options={})\n [self.class.name + \":fontcustom:\" + File.dirname(File.expand_path(uri)), File.basename(uri)]\n end",
"def path(style_name = default_style)\n path = original_filename.nil? ? nil : interpolate(path_option, style_name)\n path.respond_to?(:unescape) ? path.unescape : path\n end",
"def workfile_path(for_file = original_filename)\n # To be safe, keep this directory outside of the the cache directory\n # because calling CarrierWave.clean_cache_files! will remove any files in\n # the cache directory.\n File.join(work_dir, cache_id, version_name.to_s, for_file)\n end",
"def src_for(filename, env={})\n @semaphore.synchronize do\n refresh(env)\n file = @files[filename]\n unless file and file.has_key? :path\n raise \"#{filename.dump} is not available from file server\"\n end\n \"#{file[:path]}?#{file[:mtime].to_i}\"\n end\n end",
"def original_file # Accessor for probably protected value original_filename\r\n original_filename\r\n end",
"def get_file_path(filename)\n File.join(__dir__, filename).freeze\n end",
"def gen_rel_path(file)\n file = \"/secure/video/#{@folder}/#{file}\"\n end",
"def filename\n if original_filename.present?\n \"#{model.story.slug}-#{secure_token}.#{file.extension}\"\n end\n end",
"def file_path\n File.dirname(__FILE__) + '/' + @file_name\n end",
"def keys_file_path_relative_to_home\n return \"~/#{keys_file_path_from_home}\"\n end",
"def template_path(filename)\n File.join(PatienceDiff::TEMPLATE_PATH, filename)\n end",
"def filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end",
"def file_name(rtrack, rrecord, irecsymlink)\n @pix_key = 't'+rtrack.to_s\n if !Image::Cache.has_key(@pix_key) && !record_in_cache?(rrecord, irecsymlink)\n Image::Cache.set_file_name(@pix_key, get_cover_file_name)\n end\n return Image::Cache.full_name(@pix_key)\n end",
"def lookup_file(resource_directory, file)\n file_path = File.join resource_directory, file\n if File.exists?(file_path)\n file_path\n end\n end",
"def user_file_path(file)\n path = \"#{Settings.source_dir}/#{file}\"\n ext = \".#{Settings.partials_extension}\"\n return path if path.end_with? ext\n\n \"#{path}#{ext}\"\n end",
"def path_for original\n current_output_directory.join(file_time_by_filepath(original).strftime(settings[:ordered_time_pattern])).join(original.basename)\n end",
"def results_file_path(key)\n File.join(RAILS_ROOT, \"files\", \"activity_results\", \"results_#{id.to_s}_#{key.to_s}.yml\")\n end",
"def default_component_source_proc(yaml_key, filename)\n integration.path_from_base('public', yaml_key.to_s, \"#{filename}.#{extension}\")\n end",
"def original_fullpath; end",
"def page_file page_name\n file_name = File.basename(page_name).gsub('.', '_')\n\n File.join @path, File.dirname(page_name), \"page-#{file_name}.ri\"\n end",
"def file_path\n File.join(AssetMapper.assets_dir, filename)\n end",
"def label_for(file)\n # filename not present for uncached remote file!\n return uploaded_file_label(file) if file.is_a?(Hyrax::UploadedFile)\n # e.g. Hydra::Derivatives::IoDecorator\n return file.original_name if file.respond_to?(:original_name)\n # This path is taken when file is a Tempfile (e.g. from ImportUrlJob)\n return File.basename(Addressable::URI.unencode(file.file_url)) if file_set.import_url.present?\n File.basename(file.to_s)\n end",
"def access_file_name\n end",
"def filepath_to_id\n @filepath = @filepath[@filepath.index(FILE_REGEX[:dir])..-1]\n FILE_REGEX.each do |attr,regex|\n if match = @filepath.scan(regex).try(:flatten).try(:compact)\n if attr == :ext\n @format = match.shift\n @handler = match.join(\".\")\n else\n self.instance_variable_set \"@#{attr}\", match=match[0]\n unless match.nil?\n attr == :locale ? @filepath.gsub!(/\\.#{match}/,\"\") : @filepath.gsub!(/\\/#{match}/,\"\")\n end\n end\n end\n end\n end",
"def file_path; end",
"def file_path\n dir_name + file_name\n end",
"def file_link\n return \"#{SITE_URL}system/ufiles/#{id}/original/#{ufile_file_name}\"\n end",
"def file_path_for(file)\n ActiveStorage::Blob.service.send(:path_for, file.key)\n end",
"def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end",
"def cache_file_path\n File.join @homepath, 'cache'\n end",
"def filename\n if super.present?\n \"#{secure_token}.#{file.extension}\"\n end\n end",
"def file_path( target )\n # theme.site do not work.\n File.join( original_template_theme.store.path, self.path, file_name(target))\n end",
"def source filename\n source_hash[filename]\n end",
"def original_filename\n instance_read(:file_name)\n end",
"def translation\n @translation ||= name.underscore.split('/').last\n end",
"def absolute_file_name(filename)\n File.expand_path(filename, @base_path)\n end",
"def extensionless_path(file)\n app.cache.fetch(:extensionless_path, file) do\n path = file.dup\n\n end_of_the_line = false\n while !end_of_the_line\n if !::Tilt[path].nil?\n path = path.sub(File.extname(path), \"\")\n else\n end_of_the_line = true\n end\n end\n\n # If there is no extension, look for one\n if File.extname(path).empty?\n input_ext = File.extname(file)\n \n if !input_ext.empty?\n input_ext = input_ext.split(\".\").last.to_sym\n if app.template_extensions.has_key?(input_ext)\n path << \".#{app.template_extensions[input_ext]}\"\n end\n end\n end\n \n path\n end\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def filename\n original_filename\n end"
] |
[
"0.6430694",
"0.63742805",
"0.6372514",
"0.6198732",
"0.6191566",
"0.61423457",
"0.6133886",
"0.61234",
"0.6119151",
"0.61188346",
"0.60943013",
"0.6041107",
"0.60368574",
"0.60319185",
"0.60319185",
"0.59548765",
"0.5950963",
"0.58849734",
"0.5881956",
"0.58752",
"0.5807847",
"0.5804408",
"0.57946795",
"0.577493",
"0.577493",
"0.577493",
"0.57499087",
"0.5743206",
"0.57336736",
"0.57296884",
"0.5716444",
"0.57105434",
"0.57050794",
"0.5688881",
"0.5687392",
"0.56821275",
"0.568046",
"0.56654567",
"0.566336",
"0.565902",
"0.565123",
"0.5646936",
"0.5643545",
"0.56392276",
"0.56307966",
"0.5629394",
"0.5628425",
"0.5618478",
"0.56020117",
"0.5593272",
"0.5585526",
"0.5584318",
"0.5566839",
"0.55660605",
"0.5556855",
"0.5545114",
"0.5537443",
"0.553438",
"0.5531491",
"0.5529259",
"0.5523162",
"0.5521951",
"0.5517918",
"0.55073345",
"0.5505543",
"0.5496429",
"0.5496335",
"0.5495611",
"0.5486822",
"0.54828674",
"0.547896",
"0.54677254",
"0.54638785",
"0.545192",
"0.54508173",
"0.5447945",
"0.54401916",
"0.5431262",
"0.54277205",
"0.54248023",
"0.5417711",
"0.5414209",
"0.5407053",
"0.5405888",
"0.54037017",
"0.53979367",
"0.5396642",
"0.5393767",
"0.53874224",
"0.5376465",
"0.53718686",
"0.53708404",
"0.53690857",
"0.53688866",
"0.5365902",
"0.5363958",
"0.5363823",
"0.5349452",
"0.53460705",
"0.5342869",
"0.5342456"
] |
0.0
|
-1
|
Returns the value of attribute backends. source://i18n//lib/i18n/backend/chain.rb25
|
def backends; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def backends\n # Lets cache the values and return the cache\n if @backends.nil?\n @backends = {}\n backend_instances.each do | name, backend|\n @backends[name] = backend.servers\n end\n end\n @backends\n end",
"def backends=(_arg0); end",
"def backends(service)\n out = Array.new\n # iterate the servers removing aggregates for FRONT/BACKEND\n @stats[service].each do |k, v|\n if not (k == 'FRONTEND' or k == 'BACKEND')\n out = out << k\n end\n end\n out\n end",
"def stringify_backends(backends)\n backend_strings = []\n backends.each do |name, spec|\n backend_strings << \"#{name}=#{spec}\"\n end\n backend_strings\nend",
"def merged_backends\n return []\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def for backend\n registry[backend]\n end",
"def backend(value = nil)\n if value.is_a?(Symbol)\n require \"down/#{value}\"\n @backend = Down.const_get(value.to_s.split(\"_\").map(&:capitalize).join)\n elsif value\n @backend = value\n else\n @backend\n end\n end",
"def backend_name\n config['backend']\n end",
"def get_filter_backends\n return self.class.filter_backends || []\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def set_backend(val)\n end",
"def lookup_chain = locale(true).lookup",
"def core_asset(chain)\n _chain_info = @@chain_infos[chain]\n\n return _chain_info.core.symbol\n end",
"def chain_name\n self.chain.name if self.chain\n end",
"def find_gui_and_backend(gui=nil, gui_select=nil)\n gui = gui.to_sym if gui.kind_of? String\n\n if gui && gui != :auto\n # select backend based on requested gui\n backend = GUI_BACKEND_MAP[gui]\n gui = nil if gui == :agg\n return [gui, backend]\n end\n\n backend = Matplotlib.rcParamsOrig['backend']&.to_sym\n gui = BACKEND_GUI_MAP[backend]\n\n # If we have already had a gui active, we need it and inline are the ones allowed.\n if gui_select && gui != gui_select\n gui = gui_select\n backend = backend[gui]\n end\n\n [gui, backend]\n end",
"def format_extensions\n @trail.extensions - @engines.keys\n end",
"def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end",
"def inject_backends\n BACKEND_TYPES.each do |backend_type|\n (BACKEND_TYPES - [backend_type]).each do |injected_backend|\n backend_instances[backend_type].add_other_backend(\n injected_backend,\n backend_instances[injected_backend]\n )\n end\n end\n end",
"def assemblers\n @assemblers.map { |t| t.name } \n end",
"def backend\n @backend ||= self.class.backend\n end",
"def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end",
"def languages\n translations.map(&:language)\n end",
"def get_extensions\n collection = Occi::Collection.new\n BACKEND_TYPES.each { |backend_type| collection.merge! backend_instances[backend_type].get_extensions }\n collection\n end",
"def backend\n return @backend if @backend && @last_choice_on > 10.minutes.ago\n\n @backend ||= @backends.first\n\n @last_choice_on = Time.now\n challenger, height = @backends\n .reject{|b| b == @backend }\n .collect{|b| [b, b.block_height] }\n .sort_by(&:last)\n .last\n\n @backend = height > (@backend.block_height + 1) ? challenger : @backend\n end",
"def languages\n value.document.fetch(\"#{value.key}_lang\", [])\n end",
"def languages_as_uri\n languages.pluck(:name).map do |language|\n CONTROLLED_VOCABULARIES[:language].send(language)\n end\n end",
"def backend_klass; end",
"def language\n values = super\n values = MetadataHelper.ordered( ordered_values: self.language_ordered, values: values )\n return values\n end",
"def language\n values = super\n values = MetadataHelper.ordered( ordered_values: self.language_ordered, values: values )\n return values\n end",
"def active_backend\n SSHKit::Custom::Config::Store.active_backend\n end",
"def get_addons\n res = product_options.map { |po| po.name }.join(', ')\n unless res.blank?\n res = \"(#{res})\"\n end\n res\n end",
"def backend(backend, options = {})\n @backends ||= []\n if backend.is_a?(Symbol)\n require \"global/backend/#{backend}\"\n backend_class = Global::Backend.const_get(camel_case(backend.to_s))\n @backends.push backend_class.new(options)\n elsif backend.respond_to?(:load)\n @backends.push backend\n else\n raise 'Backend must be either a Global::Backend class or a symbol'\n end\n end",
"def backend\n @backend ||= Configurator.new(self, :backend)\n end",
"def la\n return @la if defined?(@la)\n\n @la ||= @work.language.join(\", \")\n end",
"def get_filter_backends\n return self.class.filter_backends || [\n RESTFramework::ModelFilter, RESTFramework::ModelOrderingFilter\n ]\n end",
"def formats\n providers.keys\n end",
"def languages(options = {})\n Babel.distances(self, options).map() {|item| item.first}\n end",
"def inspect\n \"#<Translations (#{backend}) @names=#{names.join(\", \")}>\"\n end",
"def language_codes_for_select\n configuration(:languages).collect{ |language|\n language[:language_code]\n }\n end",
"def language\n values = super\n values = Deepblue::MetadataHelper.ordered( ordered_values: language_ordered, values: values )\n return values\n end",
"def language_codes_for_select\n configuration(:languages).collect { |language|\n language[:language_code]\n }\n end",
"def extract_code_language(attr); end",
"def transition_from_crypto_providers(value = nil)\n config(:transition_from_crypto_providers, (!value.nil? && [value].flatten.compact) || value, [])\n end",
"def current_command_chain\n @_invocations.values.flatten.map(&:to_sym)\n end",
"def languages\n return @languages\n end",
"def backend_name\n self.class.name.split(\"::\")[-1].split(\"Store\")[0].downcase\n end",
"def interpolators()\n return @interpolators\n end",
"def backend=(backend)\n RSpec.configuration.formatters\n .find_all { |c| c.is_a?(Inspec::Formatters::Base) }\n .each do |fmt|\n fmt.backend = backend\n end\n end",
"def locale_backend; end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def getlist\r\n result = SUPPORTED_LANG_LIST\r\n end",
"def languages_as_uri\n languages.pluck(:name).map do |language|\n ControlledVocabulary.era.language.from_value(language)\n end\n end",
"def transition_from_crypto_providers(value = nil)\n rw_config(\n :transition_from_crypto_providers,\n (!value.nil? && [value].flatten.compact) || value,\n []\n )\n end",
"def providers\n @providers.keys\n end",
"def engines_for_name(name)\n components_for_name(name).last\n end",
"def get_choices\n begin\n choices = case \n when @yaml['choices'] then @yaml['choices']\n when @yaml['eval'] then\n do_eval(@yaml['eval'])\n else \n c = t('helpers.label.' + @form['table'] + '.choices4_' + @yaml['name'] )\n c = 'Error' if c.match( 'translation missing' )\n c\n end\n # Convert string to Array\n choices.class == String ?\n choices.chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )} :\n choices\n rescue Exception => e \n Rails.logger.debug \"Error in select eval. #{e.message}\\n\"\n ['error'] # return empty array when error occures\n end\nend",
"def index\n @backends = Backend.all\n end",
"def site_language\n @attributes[:site_language]\n end",
"def language\n attributes.fetch(:language)\n end",
"def language\n attributes.fetch(:language)\n end",
"def languages\n @bio.fetch('Languages')\n end",
"def engines; engine_names; end",
"def get_loader_for_value(value)\n value\n end",
"def extension_strings\n\t\treturn nil if @extensions.empty?\n\t\treturn @extensions.compact.join('; ')\n\tend",
"def loaded_languages\n @@languages.keys\n end",
"def language\n attributes[\"language\"] || \"en\"\n end",
"def framework_bundles\n @cached_framework_bundles ||= framework_names.map { |x| bundle_for(x) }\n end",
"def extensions\n return @extensions\n end",
"def extensions\n return @extensions\n end",
"def extensions\n return @extensions\n end",
"def ost_valuechain_text\n if(Rails.env.production? && GlobalConstant::Base.main_sub_environment?)\n 'Main Ethereum Network'\n else\n 'Ropsten Test Network'\n end\n end",
"def each_locale_and_translated_attribute\r\n used_locales.each do |locale|\r\n translated_attribute_names.each do |name|\r\n yield locale, name\r\n end\r\n end\r\n end",
"def available?\n @backends.present?\n end",
"def backend_configs(keys_and_values:)\n keys_and_values\n .inject self do |additional_options, (key, value)|\n additional_options\n .backend_config(\n key: key,\n value: value\n )\n end\n end",
"def engine_extensions\n exts = extensions\n\n if offset = extensions.index(format_extension)\n exts = extensions[offset+1..-1]\n end\n\n exts.select { |ext| @environment.engines(ext) }\n end",
"def key_lang\n if @is_result\n @lang[0, @lang.length - RESULT_SUFFIX_LENGTH]\n else\n @lang\n end\n end",
"def load_backends(path = MDS::DEFAULT_BACKEND_PATHS)\r\n Dir.glob(File.expand_path(path)) do |path|\r\n begin\r\n require path\r\n rescue LoadError\r\n end\r\n end\r\n end",
"def get_selected_providers\n params.keys.select do |k|\n k.include? \"provider\"\n end.map do |checkbox|\n checkbox.split(\":\").last\n end\n end",
"def servers(backend = nil)\n my_servers = []\n if backend.nil?\n # return all servers\n backend_instances.each_value do | backend|\n my_servers << backend.server_names\n end\n else\n begin\n my_servers = backend_instances[backend].server_names\n rescue KeyError => e\n \"The backend #{backend} is not a valid argument\"\n end\n end\n # return a list of serv\n my_servers.flatten.uniq\n end",
"def backend=(backend); end",
"def languages\n @item_attributes.first.languages.first.language.inject([]) do |m, l|\n m << (l.send('name').to_s rescue nil)\n m\n end.compact.uniq\n end",
"def extlang\n return nil unless @language\n decompose_language unless @primary\n @extlang\n end",
"def get_choices\n begin\n choices = case\n when @yaml['eval'] then\n choices_in_eval(@yaml['eval'])\n when @yaml['choices'] then\n @yaml['choices'].match('helpers.') ? choices_in_helper(@yaml['choices']) : @yaml['choices']\n else\n choices_in_helper()\n end\n return choices unless choices.class == String\n\n choices.chomp.split(',').map { |e| e.match(':') ? e.split(':') : e }\n rescue Exception => e\n Rails.logger.error \"\\nError in select eval. #{e.message}\\n\"\n Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?\n ['error'] # return empty array when error occures\n end\nend",
"def curve_names\n self.curves.keys\n end",
"def renderers\n instance.options[:renderers]\n end",
"def renderers\n instance.options[:renderers]\n end",
"def loaded_languages\n @@cached_language_data.keys\n end",
"def result\n value.value.each_with_index.map do |literal, idx|\n language = languages[idx]\n type = datatypes[idx]\n if language == \"eng\" && type == \"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\"\n literal\n elsif language.present?\n RDF::Literal.new(literal, language: language, datatype: type)\n else\n RDF::Literal.new(literal, datatype: type)\n end\n end\n end",
"def language_options(current_value = nil)\n standard_options = [ [t('patient.helper.language.English'),nil] ]\n full_set = standard_options + Config.find_or_create_by(config_key: 'language').options\n\n options_plus_current(full_set, current_value)\n end",
"def bases_c\n base_composition[:c]\n end",
"def choices_as_text\n values = custom_attribute_choices.map { |c| c.value }\n values.join(\"\\n\")\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def languages\n return [] if @grpc.property.nil?\n @languages ||= Array(@grpc.property.detected_languages).map do |l|\n Language.from_grpc l\n end\n end",
"def languages\n h2 :languages\n p (langs = @record.languages).empty? ? '-' : langs.map(&:to_s).join(', ')\n gap\n end"
] |
[
"0.6028862",
"0.5753905",
"0.55582607",
"0.5541924",
"0.5420075",
"0.5180032",
"0.5069253",
"0.5029616",
"0.49384916",
"0.4811482",
"0.47198647",
"0.47198647",
"0.47013897",
"0.46853134",
"0.46760073",
"0.4660199",
"0.46557003",
"0.46506983",
"0.46330804",
"0.46274912",
"0.46254095",
"0.46236435",
"0.46081823",
"0.4585363",
"0.45769235",
"0.45743665",
"0.4573768",
"0.4570872",
"0.4543515",
"0.4541614",
"0.4541614",
"0.4510324",
"0.45002103",
"0.44960392",
"0.44899136",
"0.44880542",
"0.44812354",
"0.44478622",
"0.4438664",
"0.44323802",
"0.44169295",
"0.44141415",
"0.43905255",
"0.43866998",
"0.43853232",
"0.43517262",
"0.43488294",
"0.4346498",
"0.43399382",
"0.4326409",
"0.43227208",
"0.43079305",
"0.43079305",
"0.43079305",
"0.42880395",
"0.42880395",
"0.4281197",
"0.42803013",
"0.4268212",
"0.425986",
"0.42415357",
"0.42386177",
"0.4226159",
"0.42260957",
"0.42182937",
"0.42182937",
"0.421731",
"0.42083207",
"0.4202216",
"0.41963086",
"0.41959703",
"0.41876602",
"0.41862226",
"0.41666454",
"0.41666454",
"0.41666454",
"0.41658103",
"0.41633728",
"0.4159313",
"0.41540232",
"0.4153087",
"0.41473192",
"0.41451752",
"0.41429588",
"0.41388336",
"0.41257164",
"0.4125356",
"0.412098",
"0.41133326",
"0.41009852",
"0.40973663",
"0.40973663",
"0.40972325",
"0.4085277",
"0.408478",
"0.40828913",
"0.40814131",
"0.40813535",
"0.40765092",
"0.4076158"
] |
0.5782034
|
1
|
Sets the attribute backends
|
def backends=(_arg0); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def backend=(backend); end",
"def set_backend(val)\n end",
"def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end",
"def backends; end",
"def add_backend_attributes(backend_attributes)\n @converter_options[:attributes].merge!(backend_attributes)\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def backend=(backend)\n RSpec.configuration.formatters\n .find_all { |c| c.is_a?(Inspec::Formatters::Base) }\n .each do |fmt|\n fmt.backend = backend\n end\n end",
"def backends\n # Lets cache the values and return the cache\n if @backends.nil?\n @backends = {}\n backend_instances.each do | name, backend|\n @backends[name] = backend.servers\n end\n end\n @backends\n end",
"def set_backend\n @backend = Backend.find(params[:id])\n end",
"def attribute_sets=(value)\n @attribute_sets = value\n end",
"def add_backend(auth_backend)\n @backends << auth_backend\n end",
"def set_attribute(name, value); end",
"def enable_backend\n add option: \"-backend=true\"\n end",
"def inject_backends\n BACKEND_TYPES.each do |backend_type|\n (BACKEND_TYPES - [backend_type]).each do |injected_backend|\n backend_instances[backend_type].add_other_backend(\n injected_backend,\n backend_instances[injected_backend]\n )\n end\n end\n end",
"def post_code_attribute_set(instance, name, attributes)\n self.default_attribute_set(instance, name, attributes)\n end",
"def set_attr band, musician #, instrument\n @band = band\n @musician = musician\n # @instrument = instrument\n end",
"def backend_klass; end",
"def configure_inline_support(backend)\n # Temporally monky-patching IRuby kernel to enable flushing and closing figures.\n # TODO: Make this feature a pull-request for sciruby/iruby.\n kernel = ::IRuby::Kernel.instance\n kernel.extend HookExtension unless kernel.respond_to?(:events)\n if backend == GUI_BACKEND_MAP[:inline]\n if kernel.respond_to?(:register_event)\n kernel.register_event(:post_execute, method(:flush_figures))\n else\n @post_execute_func = kernel.events.register(:post_execute, &method(:flush_figures))\n end\n\n # TODO: save original rcParams and overwrite rcParams with IRuby-specific configuration\n new_backend_name = :inline\n else\n if kernel.respond_to?(:unregister_event)\n kernel.unregister_event(:post_execute, method(:flush_figures))\n elsif @post_execute_func\n kernel.events.unregister(:post_execute, @post_execute_func)\n @post_execute_func = nil\n end\n\n # TODO: restore saved original rcParams\n new_backend_name = :not_inline\n end\n if new_backend_name != @current_backend\n # TODO: select figure formats\n @current_backend = new_backend_name\n end\n end",
"def set_appearance_set(charset_base)\n @charset_base = charset_base\n update_appearance\n end",
"def backend\n @backend ||= Configurator.new(self, :backend)\n end",
"def set_behaviors\n BEHAVIORS.keys.each do |behavior|\n set_behavior(behavior, options[behavior]) if options.key?(behavior)\n end\n # BUG Hash must be last due to the weird Libmemcached multi-behaviors\n set_behavior(:hash, options[:hash])\n end",
"def framework=(fw)\n @framework = fw\n end",
"def cache_backend=(cache_adaptor)\n cache.memcache = cache_adaptor\n end",
"def attr_setter(*attrs)\n code, made = '', []\n attrs.each do |a|\n code << \"def #{a}(*a); a.size > 0 ? (@#{a}=a[0]; self) : @#{a} end\\n\"\n made << a.to_sym\n end\n module_eval(code)\n made\n end",
"def set_attributes(attrs = {})\n attrs.each do |key, value|\n set_attribute(key, value)\n end\n end",
"def setAttrib(name,value)\n\t\t@attributes[name] = value\n\tend",
"def cache_backend=(cache_adaptor)\n if defined?(@cache)\n cache.cache_backend = cache_adaptor\n else\n @cache = MemoizedCacheProxy.new(cache_adaptor)\n end\n end",
"def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end",
"def backend(backend, options = {})\n @backends ||= []\n if backend.is_a?(Symbol)\n require \"global/backend/#{backend}\"\n backend_class = Global::Backend.const_get(camel_case(backend.to_s))\n @backends.push backend_class.new(options)\n elsif backend.respond_to?(:load)\n @backends.push backend\n else\n raise 'Backend must be either a Global::Backend class or a symbol'\n end\n end",
"def activate_matplotlib(backend)\n require 'matplotlib'\n Matplotlib.interactive(true)\n\n backend = backend.to_s\n Matplotlib.rcParams['backend'] = backend\n\n require 'matplotlib/pyplot'\n Matplotlib::Pyplot.switch_backend(backend)\n\n # TODO: should support wrapping python function\n # plt = Matplotlib::Pyplot\n # plt.__pyobj__.show._needmain = false\n # plt.__pyobj__.draw_if_interactive = flag_calls(plt.__pyobj__.draw_if_interactive)\n end",
"def reset_backend_config(mountconf)\n set_unmount_backend_config mountconf\n set_mount_backend_config mountconf\n end",
"def enable_matplotlib(gui=nil)\n gui, backend = find_gui_and_backend(gui, @gui_select)\n\n if gui != :inline\n if @gui_select.nil?\n @gui_select = gui\n elsif gui != @gui_select\n $stderr.puts \"Warning: Cannot change to a different GUI toolkit: #{gui}. Using #{@gui_select} instead.\"\n gui, backend = find_gui_and_backend(@gui_select)\n end\n end\n\n activate_matplotlib(backend)\n configure_inline_support(backend)\n # self.enable_gui(gui)\n # register matplotlib-aware execution runner for ExecutionMagics\n\n [gui, backend]\n end",
"def set attribute, value\n attributes[attribute] = value\n end",
"def attribute_setter(attribute_name)\n \"set#{attribute_name.to_s.camelcase(:upper)}\"\n end",
"def attr_set_sb4(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def ambition_adapter=(klass)\n @@ambition_adapter ||= {}\n # should this be doing the same check for respond_to?(:name) like above?\n @@ambition_adapter[name] = klass\n end",
"def add_backend(backend)\n hash = fetcher.client.post(\"#{Director.put_path(self)}/backend/#{backend.name}\")\n !hash.nil?\n end",
"def attribute_set(name, value)\n @dirty[name] = true\n @attributes[:current][name] = value\n end",
"def backend\n @backend ||= self.class.backend\n end",
"def attr_set_ub4(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def setupBackend\n lBackendInitHere = false\n if (!@BackendInit)\n @BackendInstance.init_session(@Conf[:Backends][@Backend])\n @BackendInit = true\n lBackendInitHere = true\n end\n yield\n if (lBackendInitHere)\n @BackendInstance.close_session\n @BackendInit = false\n end\n end",
"def set_attribute(a,b)\n write_attribute(a,b)\n end",
"def renderer=(value)\n @renderer = value\n end",
"def set_crypto_hooks\n\n Binding.setopt_crypto_hooks(\n self,\n method(:aes_encrypt),\n method(:aes_decrypt),\n method(:random),\n method(:hmac_sha_512),\n method(:hmac_sha_256),\n method(:hmac_hash),\n )\n end",
"def attribute_set(name, value)\n properties[name].set(self, value)\n end",
"def decorate(klass, *attributes, **set_options)\n attributes.flatten.each do |attribute|\n decorable[klass] << attribute.to_s\n options[klass][attribute.to_s] = set_options.deep_dup\n end\n end",
"def default_adapter=(adapter); end",
"def default_adapter=(adapter); end",
"def default_adapter=(adapter); end",
"def update!(**args)\n @backend_type = args[:backend_type] if args.key?(:backend_type)\n @backend_uri = args[:backend_uri] if args.key?(:backend_uri)\n @backends = args[:backends] if args.key?(:backends)\n @health_check_uri = args[:health_check_uri] if args.key?(:health_check_uri)\n @load_balancer_type = args[:load_balancer_type] if args.key?(:load_balancer_type)\n end",
"def set_attributes(attrs)\n if attrs.has_key?(\"filters\")\n attrs = attrs.merge(attrs[\"filters\"])\n end\n super(attrs)\n end",
"def tool_attrs=(tool_attributes={})\n tool_attributes.each_pair do |k,v|\n tool.send(\"#{k}=\", v)\n end\n end",
"def adapter=(adapter)\n Adapter.use = adapter\n end",
"def set_attribute(ents, handle, name, value)\n ents.each { |e|\n e.set_attribute(handle, name, value)\n }\n end",
"def register converter, *backends\n backends.each {|backend| backend == '*' ? (registry.default = converter) : (registry[backend] = converter) }\n end",
"def SetOverride(attrname, attrtype, values)\n assert { attrname.instance_of? String }\n assert { [SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT].include?(attrtype) }\n assert { values.instance_of? Hash }\n\n @overrides << { 'attr' => attrname, 'type' => attrtype, 'values' => values }\n\t end",
"def mobility_backend_class(name)\n @backends ||= BackendsCache.new(self)\n @backends[name.to_sym]\n end",
"def use_backend(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"use_backend \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def []=(attribute, value)\n attribute = attribute.to_s.gsub(/[^a-zA-Z0-9_\\-]/, '').gsub('_', '-')\n # FIXME => Attributes per class\n unless POSSIBLE_ATTRIBUTES.include? attribute\n # FIXME: Log, don't print\n puts \"Warning! Attribute #{attribute} not recognized\"\n @canvas << js_method('attr', {attribute => value})\n return nil\n end\n @canvas << js_method('attr', {attribute => value})\n return self\n end",
"def set_adapter_scheme(scheme)\n @scheme = scheme\n @@adapters[scheme.to_sym] = self\n end",
"def initialize(backend = nil, params = {})\n\t\t\t\t\t@backend = backend\n\t\t\t\t\tself.assign_attributes(params)\n\t\t\t\tend",
"def []= attribute, value\n `#@native.setAttribute(#{attribute}, #{value})`\n end",
"def initialize_options(original_options)\n super\n\n case options[:backend]\n when String, Symbol, Class\n @backend, @backend_options = options[:backend], options.dup\n when Array\n @backend, @backend_options = options[:backend]\n @backend_options = @backend_options.merge(options)\n when NilClass\n @backend = @backend_options = nil\n else\n raise ArgumentError, \"backend must be either a backend name, a backend class, or a two-element array\"\n end\n\n @backend = load_backend(backend)\n end",
"def engine_adapter=(name_or_adapter_or_class)\n self._engine_adapter = interpret_adapter(name_or_adapter_or_class)\n end",
"def attributes=(*args)\n define_dynamic_answer_setters!\n super(*args)\n end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def for backend\n registry[backend]\n end",
"def set_attribute(attribute,value,index=0)\n index = normalize_index(index)\n# puts \"<br>SETTING ATTRIBUTE #{attribute}[#{index}]=#{value} [caller: #{trace}]\"\n @attributes[index] ||= {}\n @attributes[index][normalize_attribute(attribute)] = value\n end",
"def AttributeSerializer(*args, &blk)\n if args.first.is_a?(Class)\n klass, context_name, attribs = (args.size == 3) ? args : [args[0], :default, args[1]]\n AttributeSerializer.add_context_set klass, context_name, attribs, &blk\n else\n AttributeSerializer.generate(args[1] || :default, args[0])\n end\nend",
"def bed_types_attributes=(attributes)\n attr_array = attributes.collect {|item| item[1][:id] }\n self.bed_type_ids = attr_array\n super\n end",
"def set_backend_category\n @backend_category = Backend::Category.find(params[:id])\n end",
"def add_backend_options(backend_options)\n @converter_options.merge!(backend_options)\n end",
"def attribute_set(name, value) \n if (name.to_sym == :aspects)\n @assigned_aspects = value\n else\n super(name, value)\n end\n end",
"def attr_set_ub2(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def attribute_to_set; end",
"def attr_set_sb2(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def fields=(attrib_array)\n\n touch()\n @custom_fields = true\n @fields = attrib_array.map { |field| \n (field.is_a?(Hash))? field : field.to_s \n }\n # Delegate fields to fieldsets first\n @fieldsets.each_pair { |name,fieldset|\n fieldset_fields = []\n @fields.delete_if { |field|\n (fieldset.has_field?(field))? (fieldset_fields << field.to_s; true) : false\n }\n fieldset.fields = fieldset_fields\n }\n attrib_array.each { |attrib|\n if attrib.is_a?(Hash) then\n attrib.each_pair { |fieldset_name, fieldset_fields|\n legend = false\n if fieldset_fields.is_a?(Hash) then\n legend = fieldset_fields[:legend]\n fieldset_fields = fieldset_fields[:fields]\n end\n # This is a configuration for a fieldset. \n # There are two cases: \n fieldset = @fieldsets[fieldset_name.to_s]\n if fieldset then \n # - The fieldset already has been added to this form. \n # In this case, just pass field settings along to \n # the fieldset. \n fieldset.fields = fieldset_fields\n else\n # - There is no fieldset with given name in this form. \n # In this case, we expect that at least the given \n # form fields are present in this form, and we \n # implicitly create a Fieldset instance here. \n fieldset = Fieldset.new(:name => fieldset_name, :legend => legend)\n fieldset_fields.each { |field|\n existing_field = @element_map[field.to_s]\n fieldset.add(existing_field) if existing_field\n }\n fieldset.fields = fieldset_fields\n add(fieldset)\n end\n }\n end\n }\n @elements.each { |field|\n if field.respond_to?(:is_form_field) then\n # Update element map only if referenced element is a \n # Form_Field, do not include Fieldset elements. \n @element_map[field.name.to_s] = field \n elsif field.is_a?(Fieldset) then\n end\n }\n end",
"def setup_attribute_type(klass)\n klass.schema.each do |attr, config|\n klass._attribute_types[attr] = self.setup_layer_type(klass, config.split(/[|]/), 0)\n end\n end",
"def define_attribute_setter(attribute_name, options)\n define_method \"#{attribute_name}=\" do |value|\n send(\"#{attribute_name}_will_change!\") unless value == send(attribute_name)\n\n value = ActiveModel::Type.lookup(options[:type]).deserialize(value) if options[:type]\n\n instance_variable_set(\"@#{attribute_name}\", value)\n end\n end",
"def io_selector_backend(backend); end",
"def backend_name\n config['backend']\n end",
"def registerTarget(target, backends: nil, serverless: false)\n cloud_desc\n\n @backend_cache.each { |b|\n next if backends and !backends.include?(b.name)\n\n b.backends ||= []\n if serverless\n b.health_checks = []\n b.timeout_sec = nil\n b.port_name = nil\n end\n next if b.backends.map { |ext| ext.group }.include?(target)\n b.backends << MU::Cloud::Google.compute(:Backend).new(\n group: target\n )\n MU.log \"Adding target #{target} to backend service #{b.name}\", details: b\n b.self_link =~ /\\/projects\\/[^\\/]+\\/([^\\/]+)\\/backendServices/\n region = Regexp.last_match[1] == \"global\" ? nil : Regexp.last_match[1]\n method = \"update_#{region ? \"region_\" : \"\"}backend_service\".to_sym\n args = [@project_id]\n args << region if region\n args << b.name\n args << b\n MU::Cloud::Google.compute(credentials: @credentials).send(method, *args)\n }\n\n end",
"def dataset_writer(*attributes)\n attributes.flatten.each do |attr_name|\n next if method_defined?(\"#{attr_name}=\")\n\n class_eval <<-RUBY, __FILE__, __LINE__ + 1\n def #{attr_name}=(value)\n dataset_set(:#{attr_name}, value)\n end\n RUBY\n end\n end",
"def specify(attrs)\n attrs[:sources] ||= attrs[:language].to_s\n attrs[:source_ext] ||= attrs[:language].to_s\n attrs.each { |name, value| instance_variable_set(\"@#{name}\", value) }\n end",
"def load_backends(path = MDS::DEFAULT_BACKEND_PATHS)\r\n Dir.glob(File.expand_path(path)) do |path|\r\n begin\r\n require path\r\n rescue LoadError\r\n end\r\n end\r\n end",
"def set_attribute_set\n @attribute_set = AttributeSet.find(params[:id])\n end",
"def framework= (fw)\n @framework = Testify::Framework::Base.find(fw)\n end",
"def set_fonts\n font_families.update Elegant.configuration.fonts\n fallback_fonts ['Fallback']\n end",
"def attr_set_ub1(attr_type, attr_value)\n #This is a stub, used for indexing\n end",
"def set_attribute(name, value)\n @attributes[name] = value\n end",
"def []=( attrname, value )\n\t\tattrtype = self.find_attribute_type( attrname.to_sym ) or\n\t\t\traise ArgumentError, \"unknown attribute %p\" % [ attrname ]\n\t\tvalue = Array( value ) unless attrtype.single?\n\n\t\tself.mark_dirty\n\t\tif value.nil?\n\t\t\t@values.delete( attrtype.name.to_sym )\n\t\telse\n\t\t\t@values[ attrtype.name.to_sym ] = value\n\t\tend\n\n\t\t# If the objectClasses change, we (may) need to re-apply mixins\n\t\tif attrname.to_s.downcase == 'objectclass'\n\t\t\tself.log.debug \" objectClass change -- reapplying mixins\"\n\t\t\tself.apply_applicable_mixins( self.dn )\n\t\telse\n\t\t\tself.log.debug \" no objectClass changes -- no need to reapply mixins\"\n\t\tend\n\n\t\treturn value\n\tend",
"def extensions=(extensions)\n @extensions = Array extensions\n end",
"def backend; end",
"def backend\n set_default_backend unless defined?(@backend)\n raise OEmbed::FormatNotSupported, :xml unless defined?(@backend)\n @backend\n end",
"def []=(attribute_name, value = nil)\n raise \"Please set the source data set before attempting to set values.\" unless @current_source_data_set\n \n attribute_name = attribute_name.to_sym\n value.strip! if value.kind_of? String\n \n # Are we updating an existing value?\n existing = @attributes[@current_language][attribute_name] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n \n if existing\n\n # An attribute that allows multiple values?\n if existing.kind_of? ManyValues\n # Always clear attribute values before re-adding them\n # That way we add new but remove values.\n existing.clear\n unless value.blank?\n value.split(',').each {|v| existing.add(v)}\n end\n # Single value attribute\n elsif existing.value != value\n existing.source_data_set_id = @current_source_data_set.id\n\n unless value.blank?\n existing.value = value\n existing.changed = true\n else\n existing.value = nil\n existing.deleted = true\n end\n end\n\n elsif !value.blank?\n \n # Look up the attribute to get its details: required, allow_many, data_type.\n attribute_definition = PublicEarth::Db::Attribute.find_by_name(attribute_name.to_s) ||\n PublicEarth::Db::Attribute.find_by_name!(attribute_name.to_s.singularize)\n \n # If the attribute allows many values, we need an array.\n if attribute_definition.allow_many?\n @attributes[@current_language][attribute_name] ||= ManyValues.new(self, \n PublicEarth::Db::Details::Attribute.new(self, nil, \n attribute_name, value.split(','), nil, @current_language, @current_source_data_set.id, attribute_definition.readonly, 9999, false, \n false, attribute_definition.allow_many, attribute_definition.data_type))\n return @attributes[@current_language][attribute_name].add(value)\n \n # Otherwise just set the attribute equal to the new value\n else\n @attributes[@current_language][attribute_name] = PublicEarth::Db::Details::Attribute.new(self, nil, \n attribute_name, value, nil, @current_language, @current_source_data_set.id, attribute_definition.readonly, 9999, false, \n false, attribute_definition.allow_many, attribute_definition.data_type)\n @attributes[@current_language][attribute_name].changed = true\n end\n end\n end",
"def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end",
"def backend(value = nil)\n if value.is_a?(Symbol)\n require \"down/#{value}\"\n @backend = Down.const_get(value.to_s.split(\"_\").map(&:capitalize).join)\n elsif value\n @backend = value\n else\n @backend\n end\n end",
"def set_glade_active_record(obj = self)\r\n return if not defined? obj.attributes\r\n obj.attributes.each_pair { |key, val| fill_control(class_name(obj) + \".\" + key, val) }\r\n end",
"def get_filter_backends\n return self.class.filter_backends || [\n RESTFramework::ModelFilter, RESTFramework::ModelOrderingFilter\n ]\n end",
"def set_attribute_for element, attr, value\n AXUIElementSetAttributeValue(element, attr, value)\n end"
] |
[
"0.65605336",
"0.6500653",
"0.6433733",
"0.6365601",
"0.6104919",
"0.5916037",
"0.5811745",
"0.57213545",
"0.5719456",
"0.5555846",
"0.54233223",
"0.5414856",
"0.53305554",
"0.52814925",
"0.50719905",
"0.50671947",
"0.5053091",
"0.50285685",
"0.5026914",
"0.50216365",
"0.5016554",
"0.50135803",
"0.49993837",
"0.49851298",
"0.49739102",
"0.4973466",
"0.49144673",
"0.4907265",
"0.49004918",
"0.48618147",
"0.4839895",
"0.48391464",
"0.4826972",
"0.48117173",
"0.48078972",
"0.4801184",
"0.47970563",
"0.47953966",
"0.47951043",
"0.47931418",
"0.47900012",
"0.47873116",
"0.47778714",
"0.4772221",
"0.4762121",
"0.47543642",
"0.47352448",
"0.47352448",
"0.47352448",
"0.47347298",
"0.472953",
"0.47277206",
"0.47226936",
"0.47172794",
"0.47166866",
"0.47154942",
"0.4714044",
"0.47011593",
"0.46991035",
"0.46691525",
"0.4662142",
"0.46585813",
"0.4656657",
"0.4653743",
"0.46501672",
"0.46448213",
"0.4644072",
"0.46280104",
"0.46261397",
"0.4623524",
"0.46234673",
"0.4619674",
"0.4618336",
"0.46151856",
"0.46135753",
"0.4610211",
"0.46009785",
"0.45941365",
"0.4592943",
"0.45857373",
"0.45811164",
"0.45736337",
"0.45727167",
"0.4571265",
"0.4563271",
"0.4560583",
"0.45560881",
"0.45560732",
"0.45556197",
"0.45526147",
"0.4547604",
"0.45367408",
"0.45354533",
"0.45312217",
"0.45305166",
"0.4530243",
"0.4527744",
"0.4520403",
"0.45195177",
"0.45093572"
] |
0.66283345
|
0
|
This is approximately what gets used in ActiveSupport. However since we are not guaranteed to run in an ActiveSupport context it is wise to have our own copy. We underscore it to not pollute the namespace of the including class. source://i18n//lib/i18n/backend/chain.rb117
|
def _deep_merge(hash, other_hash); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def freeze\n context and inclusions and super\n end",
"def lookup_chain = locale(true).lookup",
"def initialize\n super('unify')\n freeze\n end",
"def transitive_closure() self.class.new(self).transitive_closure!; end",
"def underscore\n dup.underscore!\n end",
"def underscore\n self.dup.underscore!\n end",
"def chain_file\n super\n end",
"def inherited(klass)\n super\n klass.instance_variable_set(:@transforms, transforms.dup)\n klass.instance_variable_set(:@translations_hash, translations_hash.dup)\n end",
"def included( hooked_instance )\n \n super if defined?( super )\n \n end",
"def use_i18n; end",
"def include_helpers(scope); end",
"def _prefixes; end",
"def init_translations; end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'curation_concerns/base']\n end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'curation_concerns/base']\n end",
"def chain_state\n super\n end",
"def dup\n super.tap do |instance|\n instance.instance_variable_set(:@chain, instance.chain.dup)\n end\n end",
"def translatable\n self._translatable[base_name]\n end",
"def local_prefixes; end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def underscore\n new_string = gsub(NAMESPACE_SEPARATOR, UNDERSCORE_SEPARATOR)\n new_string.gsub!(/([A-Z\\d]+)([A-Z][a-z])/, UNDERSCORE_DIVISION_TARGET)\n new_string.gsub!(/([a-z\\d])([A-Z])/, UNDERSCORE_DIVISION_TARGET)\n new_string.gsub!(/[[:space:]]|\\-/, UNDERSCORE_DIVISION_TARGET)\n new_string.downcase!\n self.class.new new_string\n end",
"def translations; end",
"def underscore code\n code.\n gsub(/\\bload\\b/, '_load').\n gsub(/\\brels\\b/, '_rels').\n gsub(/\\bnode\\b/, '_node')\n end",
"def included(base = nil, &block)\n super\n\n if base\n base.send :include, Stringex::ActsAsUrl::ActsAsUrlInstanceMethods\n base.send :extend, Stringex::ActsAsUrl::ActsAsUrlClassMethods\n end\n end",
"def underscore\n Bodhi::Support.underscore(self.class.name)\n end",
"def clone\r\n obj = super\r\n return obj unless respond_to?(:translated_attribute_names)\r\n obj.instance_variable_set(:@globalize, nil )\r\n each_locale_and_translated_attribute do |locale, name|\r\n obj.globalize.write(locale, name, globalize.fetch(locale, name) )\r\n end\r\n return obj\r\n end",
"def translations_hash; end",
"def freeze\n __getobj__.freeze\n super()\n end",
"def initialize(*)\n super\n @extensions = optimize_extensions\n end",
"def escaper=(_); end",
"def with_dup\n original = MorePossessive::Inflector::Inflections.instance_variable_get(:@__instance__)\n MorePossessive::Inflector::Inflections.instance_variable_set(:@__instance__, original.dup)\n ensure\n MorePossessive::Inflector::Inflections.instance_variable_set(:@__instance__, original)\n end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def transitive_closure\n end",
"def prepended_modules; end",
"def apply_locale; end",
"def translate(field)\n super(\"#{@_i18n_scope}.#{field}\")\n end",
"def inherit_from(hash)\n unless hash == self\n up_chain.unchain_from(self) if up_chain.respond_to?(:unchain_from, true)\n self.up_chain = hash\n up_chain.down_chain_to(self) if up_chain.respond_to?(:down_chain_to, true)\n end\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def _prefixes # :nodoc:\n self.class._prefixes\n end",
"def _prefixes # :nodoc:\n self.class._prefixes\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def initialize_copy( other )\n\t\tsuper\n\t\tself.apply_applicable_mixins( @dn, @entry )\n\t\tself.after_initialize\n\tend",
"def extended(*) end",
"def chain_with(scope_name)\n self + klass.send(scope_name)\n end",
"def inject_translatable_block\n inject_into_class model_path, class_name, generate_translatable_block\n end",
"def instance_ancestors_cache; end",
"def extended( hooked_instance )\n\n super if defined?( super )\n \n end",
"def static_forwarding\n super\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def singleton_ancestors_cache; end",
"def _lex_trans_keys=(_arg0); end",
"def _lex_trans_keys=(_arg0); end",
"def _lex_trans_keys=(_arg0); end",
"def _lex_trans_keys=(_arg0); end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def include( *modules )\n \n super if defined?( super )\n original_include( *modules )\n \n end",
"def underscore(klass)\n return klass unless /::/.match?(klass)\n\n word = klass.to_s.gsub('::'.freeze, '.'.freeze)\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/, '\\1_\\2'.freeze)\n word.gsub!(/([a-z\\d])([A-Z])/, '\\1_\\2'.freeze)\n word.downcase!\n word\n end",
"def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end",
"def _(text)\n text\n end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'hyrax/base']\n end",
"def camelize\n dup.tap(&:camelize!)\n end",
"def _prepare_context; end",
"def chain\n [self]\n end",
"def to_citrus # :nodoc:\n 'super'\n end",
"def before_include_or_extend( & block )\n \n add_hook_context( :before_include )\n add_hook_context( :before_extend )\n action( & block ) if block_given?\n \n return self\n \n end",
"def initialize(*args)\n @chain = args || []\n end",
"def prepend(arg, &block)\n begin # rails edge after 2.1.0 eliminated need for block.binding\n concat(arg) + block.call\n rescue\n concat(arg, block.binding) + block.call\n end\n end",
"def setup_mass_copy_translations\n end",
"def begin_of_association_chain\n return nil unless active_admin_config.scope_to?(self)\n MethodOrProcHelper.render_in_context(self, active_admin_config.scope_to_method)\n end",
"def nice_partials_locale_prefix_from_view_context_and_block(context, block)\n root_paths = context.view_renderer.lookup_context.view_paths.map(&:path)\n partial_location = block.source_location.first.dup\n root_paths.each { |path| partial_location.gsub!(/^#{path}\\//, '') }\n partial_location.split('.').first.gsub('/_', '/').gsub('/', '.')\nend",
"def superview_chain\n @superview_chain ||= []\n end",
"def mixed_case(preserve_prefixed_underscores: true)\n LuckyCase.mixed_case self, preserve_prefixed_underscores: preserve_prefixed_underscores\n end",
"def third_party_processors; end",
"def use(*)\n super\n end",
"def chain_name\n self.chain.name if self.chain\n end",
"def base; self; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def underscore_with_customizations(camel_cased_word)\n word = camel_cased_word.gsub('GitHub', 'Github').\n gsub('ITunes', 'Itunes')\n underscore_without_customizations(word)\n end",
"def private; end",
"def prefix=(_); end",
"def chain *messages, &guard\n return self if messages.empty? or not(\n (block_given? ? (yield_or_eval(&guard)) : self))\n\n (send_as_function messages.shift).chain(*messages, &guard)\n end",
"def translated_extended_request_state\n super\n end",
"def initialize(*_)\n super\n SfnAws.load!\n @translators = Smash.new\n end",
"def underscore\n self.to_s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def lang(orig); end",
"def included; end",
"def __with_locale__(locale, &block)\n yield\n end",
"def initialize ( _caller )\n super\n end",
"def initialize ( _caller )\n super\n end",
"def wrapped_in=(_arg0); end",
"def initialize(*args) # :nodoc:\n super\n add_machined_helpers\n end",
"def context\n Object.new.extend(Rango::Helpers)\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def include=(_arg0); end",
"def inspect\n \"#<Translations (#{backend}) @names=#{names.join(\", \")}>\"\n end"
] |
[
"0.5785937",
"0.54091036",
"0.52652746",
"0.5110023",
"0.50062156",
"0.49867928",
"0.4923765",
"0.49087626",
"0.49065316",
"0.48771864",
"0.4865894",
"0.48566875",
"0.48519343",
"0.48506147",
"0.48506147",
"0.48376495",
"0.47736067",
"0.4762625",
"0.47577792",
"0.47304142",
"0.47304142",
"0.47281283",
"0.4722021",
"0.4711603",
"0.4667205",
"0.46663052",
"0.46637273",
"0.46607292",
"0.46373782",
"0.46362382",
"0.46346667",
"0.46260792",
"0.45974702",
"0.45844597",
"0.4580442",
"0.45769066",
"0.45762768",
"0.45748034",
"0.4573006",
"0.4569567",
"0.4569567",
"0.45685944",
"0.45682913",
"0.45618957",
"0.4560681",
"0.455835",
"0.45558715",
"0.45555636",
"0.45510337",
"0.45505252",
"0.45505252",
"0.45326886",
"0.4519786",
"0.4519786",
"0.4519786",
"0.4519786",
"0.45175743",
"0.45131946",
"0.45123914",
"0.4509482",
"0.45073572",
"0.45065925",
"0.44923523",
"0.44885638",
"0.4485856",
"0.4485814",
"0.44835755",
"0.4480232",
"0.4479268",
"0.44776917",
"0.44772345",
"0.4476036",
"0.4473086",
"0.4472175",
"0.44622612",
"0.44611534",
"0.44574094",
"0.4452254",
"0.4451588",
"0.44495124",
"0.44495124",
"0.44495124",
"0.44495124",
"0.44474685",
"0.44434366",
"0.44389832",
"0.44368646",
"0.44323578",
"0.44319057",
"0.44298914",
"0.4425331",
"0.44213313",
"0.44184923",
"0.44134393",
"0.44134393",
"0.44115075",
"0.44110388",
"0.4406625",
"0.44057575",
"0.4405481",
"0.44019532"
] |
0.0
|
-1
|
Overwrites the Base backend translate method so that it will try each locale given by I18n.fallbacks for the given locale. E.g. for the locale :"deDE" it might try the locales :"deDE", :de and :en (depends on the fallbacks implementation) until it finds a result with the given options. If it does not find any result for any of the locales it will then throw MissingTranslation as usual. The default option takes precedence over fallback locales only when it's a Symbol. When the default contains a String, Proc or Hash it is evaluated last after all the fallback locales have been tried. source://i18n//lib/i18n/backend/fallbacks.rb41
|
def translate(locale, key, options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def languagefallback()\n merge(languagefallback: 'true')\n end",
"def ar_fallbacks(force = false)\n return @@ar_fallbacks if @@ar_fallbacks\n return fallbacks unless force\n @@ar_fallbacks = Globalize::Locale::Fallbacks.new\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def fallbacks\n @fallbacks ||= {}\n end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def fallbacks=(fallbacks); end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def use_and_copy_default_locale_translations_if_they_exist(locale, key)\n default_locale_entry = lookup(Locale.default_locale, key)\n return unless default_locale_entry\n\n if default_locale_entry.is_a?(Array)\n default_locale_entry.each_with_index do |entry, index|\n locale.create_translation(key, nil, index) if entry\n end\n else\n locale.create_translation(key, nil) \n end\n\n return default_locale_entry\n end",
"def assign_defaults(options)\n # Normalizes languages keys from symbols to strings\n normalize_language_keys(options)\n\n # Build a complete list of the required languages\n enabled_languages = detect_languages(options)\n\n # Get all languages used in existing settings\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n current.each do |language, value|\n enabled_languages << language unless enabled_languages.include?(language)\n end\n end\n\n # Check folder list (an empty folder signifies a language is required)\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n next unless File.directory?(lang_folder) # We don't want to read txt as they are non localised\n language = File.basename(lang_folder)\n enabled_languages << language unless enabled_languages.include?(language)\n end\n\n return unless enabled_languages.include?(\"default\")\n UI.message(\"Detected languages: \" + enabled_languages.to_s)\n\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n default = current[\"default\"]\n next if default.nil?\n\n enabled_languages.each do |language|\n value = current[language]\n next unless value.nil?\n\n current[language] = default\n end\n current.delete(\"default\")\n end\n end",
"def assign_defaults(options)\n # Normalizes languages keys from symbols to strings\n normalize_language_keys(options)\n\n # Build a complete list of the required languages\n enabled_languages = detect_languages(options)\n\n # Get all languages used in existing settings\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n current.each do |language, value|\n enabled_languages << language unless enabled_languages.include?(language)\n end\n end\n\n # Check folder list (an empty folder signifies a language is required)\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n next unless File.directory?(lang_folder) # We don't want to read txt as they are non localised\n language = File.basename(lang_folder)\n enabled_languages << language unless enabled_languages.include?(language)\n end\n\n return unless enabled_languages.include?(\"default\")\n UI.message(\"Detected languages: \" + enabled_languages.to_s)\n\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n default = current[\"default\"]\n next if default.nil?\n\n enabled_languages.each do |language|\n value = current[language]\n next unless value.nil?\n\n current[language] = default\n end\n current.delete(\"default\")\n end\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def default(locale, object, subject, options = {})\n options = options.dup.reject { |key, value| key == :default }\n case subject\n when Array\n subject.count - 1\n subject.each do |item|\n result = resolve(locale, object, item, options) #and return result\n result = lookup(locale, result, options[:scope], options)\n return result if result.is_a?(String)\n return result = resolve(locale, object, item, options) if item == subject.last\n end and nil\n else\n resolve(locale, object, subject, options)\n end\n end",
"def fallback\n @@fallback\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def default_url_options(options = {})\n # use merge to keep current params\n options.merge({ locale: ((I18n.locale == I18n.default_locale) ? nil : I18n.locale) })\n #options.merge({ locale: I18n.locale})\n end",
"def set_locale(host, params, default_locale = I18n.default_locale)\r\n case I18n.config.language_detection_method\r\n when I18n::Config::DETECT_LANGUAGE_FROM_URL_PARAM\r\n lang = params[I18n.config.language_url_param.to_sym]\r\n when I18n::Config::DETECT_LANGUAGE_FROM_SUBDOMAIN\r\n @@hosts ||= Hash.new\r\n if @@hosts.has_key?(host)\r\n return @@hosts[host]\r\n end\r\n lang = get_locale(host)\r\n end\r\n if lang.present? && locale_enabled?(lang)\r\n I18n.locale = lang\r\n return true\r\n end\r\n I18n.locale = I18n.default_locale\r\n return (lang.present? && I18n.locale_available?(lang)) ? false : nil\r\n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def preferred_language_from(locales)\n (accepted_languages & locales).first\n end",
"def set_locale_to_best_available\n best_locale = params[:locale] # Locale in URL always takes precedent\n best_locale = find_best_locale if best_locale.blank?\n\n # Assigning a value to I18n.locale *looks* like a\n # global variable setting, and setting a global\n # variable would be bad since we're multi-threaded.\n # However, this is *not* setting a global variable, it's setting a\n # per-Thread value (which is safe). Per the i18n guide,\n # \"The locale can be either set pseudo-globally to I18n.locale\n # (which uses Thread.current like, e.g., Time.zone)...\".\n I18n.locale = best_locale.to_sym\n end",
"def fallbacks; end",
"def fallbacks; end",
"def invoke_fallbacks_for(name, base)\n return nil unless base && fallbacks[base.to_sym]\n invoked_fallbacks = []\n\n Array(fallbacks[base.to_sym]).each do |fallback|\n next if invoked_fallbacks.include?(fallback)\n invoked_fallbacks << fallback\n\n klass = find_by_namespace(name, fallback)\n return klass if klass\n end\n\n nil\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def find_first_valid_translation_for_language(language, token_values)\n translation = find_first_valid_translation(language, token_values)\n return [language, translation] if translation\n\n if Tr8n::Config.enable_fallback_languages?\n # recursevily go into the fallback language and look there\n # no need to go to the default language - there obviously won't be any translations for it\n # unless you really won't to keep the keys in the text, and translate the default language\n if language.fallback_language and not language.fallback_language.default?\n return find_first_valid_translation_for_language(language.fallback_language, token_values)\n end\n end \n \n [language, nil]\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def default_url_options(options = {})\n if I18n.locale.to_sym.eql?(I18n.default_locale.to_sym) ||\n params[:locale]\n {}.merge(options)\n else\n { locale: I18n.locale }.merge(options)\n end\n end",
"def lookup_chain = locale(true).lookup",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def enforce_available_locales!(locale); end",
"def human(options = {})\n return @human if i18n_keys.empty? || i18n_scope.empty?\n\n key, *defaults = i18n_keys\n defaults << options[:default] if options[:default]\n defaults << MISSING_TRANSLATION\n\n translation = I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)\n translation = @human if translation == MISSING_TRANSLATION\n translation\n end",
"def each_locale(include_default_locale = true, &block)\n current_locale = ::Mongoid::Fields::I18n.locale\n _locales = include_default_locale ? self.locales : (self.locales - [self.default_locale])\n\n _locales.each do |locale|\n ::Mongoid::Fields::I18n.with_locale(locale) do\n yield locale, current_locale.to_s == locale.to_s\n end\n end\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def compatible_language_from(locales)\n accepted_languages.map do |language| # en-US\n locales.find do |locale| # en\n language == locale || language.split('-', 2).first == locale.split('-', 2).first\n end\n end.compact.first\n end",
"def default_url_options(options={})\n (I18n.locale.to_sym.eql?(I18n.default_locale.to_sym) ? {} : {locale: I18n.locale})\n end",
"def register_fallback(*providers)\n @@fallback += providers\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def compute_effective_locale\n # Priority order:\n # 1.query parameter 'lang'\n # 2.cookie 'lang'\n # 3.browser setting\n requested_lang = params[:lang] || cookies[:lang]\n if self.offered_locales.include? requested_lang\n yield requested_lang if block_given?\n return requested_lang\n end\n\n parse_and_match_accept_language || 'en'\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def translate_external(facets, options)\n facets_string = \"[\" + facets.map {|facet| \":#{facet}\"}.join(\", \") + \"]\"\n class_eval <<-HERE\n @@facet_options = {}\n attr_writer :fully_loaded\n def fully_loaded?; @fully_loaded; end\n @@globalize_facets = #{facets_string}\n @@preload_facets ||= @@globalize_facets\n class << self\n\n def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end\n\n def globalize_facets\n @@globalize_facets\n end\n\n def globalize_facets_hash\n @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|\n hash[facet.to_s] = true; hash\n }\n end\n\n def untranslated_fields\n @@untranslated_fields ||=\n column_names.map {|cn| cn.intern } - globalize_facets\n end\n\n def preload_facets; @@preload_facets; end\n def postload_facets\n @@postload_facets ||= @@globalize_facets - @@preload_facets\n end\n alias_method :globalize_old_find_every, :find_every unless\n respond_to? :globalize_old_find_every\n end\n alias_method :globalize_old_reload, :reload\n alias_method :globalize_old_destroy, :destroy\n alias_method :globalize_old_create_or_update, :create_or_update\n alias_method :globalize_old_update, :update\n\n include Globalize::DbTranslate::TranslateObjectMethods\n extend Globalize::DbTranslate::TranslateClassMethods\n\n HERE\n\n facets.each do |facet|\n bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s\n class_eval <<-HERE\n @@facet_options[:#{facet}] ||= {}\n @@facet_options[:#{facet}][:bidi] = #{bidi}\n\n def #{facet}\n if not_original_language\n raise WrongLanguageError.new(@original_language, Locale.language)\n end\n load_other_translations if\n !fully_loaded? && !self.class.preload_facets.include?(:#{facet})\n result = read_attribute(:#{facet})\n return nil if result.nil?\n result.direction = #{facet}_is_base? ?\n (Locale.base_language ? Locale.base_language.direction : nil) :\n (@original_language ? @original_language.direction : nil)\n\n # insert bidi embedding characters, if necessary\n if @@facet_options[:#{facet}][:bidi] &&\n Locale.language && Locale.language.direction && result.direction\n if Locale.language.direction == 'ltr' && result.direction == 'rtl'\n bidi_str = \"\\xe2\\x80\\xab\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'\n bidi_str = \"\\xe2\\x80\\xaa\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n end\n end\n\n return result\n end\n\n def #{facet}=(arg)\n raise WrongLanguageError.new(@original_language, Locale.language) if\n not_original_language\n write_attribute(:#{facet}, arg)\n end\n\n def #{facet}_is_base?\n self['#{facet}_not_base'].nil?\n end\n HERE\n end\n end",
"def with_default_locale(&block)\n ::Mongoid::Fields::I18n.with_locale(self.default_locale) do\n yield\n end\n end",
"def default_url_options(options = {})\n { locale: I18n.locale }.merge options\n end",
"def ar_fallbacks=(fallbacks)\n @@ar_fallbacks = fallbacks\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def fallbacks?\n return true if options[:fallbacks].nil?\n !!options[:fallbacks]\n end",
"def resolve(locale, object, subject, options = T.unsafe(nil)); end",
"def default_url_options(_options = {})\n { locale: I18n.locale }\n end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def correct_locale\n (locales.select{|loc|loc.locale == I18n.locale.to_s}.first || locales.first)\n end",
"def default_url_options(options = nil)\n { locale: I18n.locale }\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def default_url_options(options = {})\n {locale: I18n.locale}\n end",
"def meth(fallback: nil)\nend",
"def meth(fallback: nil)\nend",
"def default_url_options(options = {})\n logger.debug \"default_url_options is passed options: #{options.inspect}\\n\"\n { locale: I18n.default_locale != I18n.locale ? I18n.locale : nil }\n end",
"def default_url_options(options={})\n options.merge(locale: locale)\n end",
"def default_url_options(options={})\n { :locale => I18n.locale }.merge(options)\n end",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def default_language?\n return true unless params[:locale]\n\n params[:locale].to_s == I18n.default_locale.to_s\n end",
"def default_url_options(options = {})\n options.merge(locale: locale)\n end",
"def default_url_options(options={})\n { locale: I18n.locale }\n end",
"def default_url_options(options={})\n { locale: I18n.locale }\n end",
"def default_url_options(options={})\n { locale: I18n.locale }\n end",
"def default_url_options(options={})\n { locale: I18n.locale }\n end",
"def default_url_options(options = {})\n options.merge({ locale: I18n.locale })\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def set_best_locale\n if ( RAILS_ENV == 'test' )\n code = 'en'\n else\n code = Translation.reconcile_user_data_with_http_request_language(\n request,\n logged_in? ? current_user : nil\n )\n end\n\n Translation.set_best_locale( code )\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def lookup(locale, key, scope = [], options = {})\r\n return '' if translations_blocked\r\n\r\n if ::LinguaFranca.debugging? && available_locales.include?(::LinguaFranca.debugging)\r\n locale = ::LinguaFranca.debugging\r\n end\r\n\r\n result = super(locale, key, scope, options)\r\n\r\n key = key_name(key, scope)\r\n\r\n return result\r\n end",
"def enabled_locales=(values)\n languages = values.reject{|x| x.blank?}\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def fallback_to_default(localization_key, localization)\n localization_key.localizations.where.not(default_value: nil). \\\n where.not(id: localization.id).first&.default_value\n end",
"def default_url_options(options={})\n options.merge({locale: I18n.locale})\n end",
"def locale_to_translate_into\n multilanguage_site = settings.multilanguage_site\n default_language = settings.default_language\n if multilanguage_site and session[:locale] != default_language\n session[:locale]\n else\n nil\n end\n end",
"def localise(args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n object = args.last.respond_to?(:available_in_locale?) ? args.pop : nil\n options[:locale] ||= (defined?(params) && params[:locale] || I18n.locale)\n if (options[:locale].to_s == \"en\") || (object && !object.available_in_locale?(options[:locale]))\n options.delete(:locale)\n end\n args.push(object) if object\n args.push(options)\n args\n end",
"def default_url_options(options = {})\n {locale: I18n.locale}\n end",
"def default_url_options(options = {})\n {locale: I18n.locale}\n end"
] |
[
"0.80864644",
"0.68280923",
"0.6678587",
"0.66095275",
"0.6457375",
"0.62876064",
"0.62848794",
"0.6255123",
"0.6195622",
"0.61422807",
"0.60571635",
"0.60564685",
"0.59982437",
"0.59956896",
"0.59906256",
"0.58794403",
"0.581109",
"0.5762872",
"0.56726027",
"0.5646645",
"0.56018233",
"0.5593314",
"0.5583241",
"0.5577576",
"0.5573634",
"0.5558451",
"0.555248",
"0.55299664",
"0.55235684",
"0.5517655",
"0.5516364",
"0.5496661",
"0.5494397",
"0.5485827",
"0.5471156",
"0.5467171",
"0.54619706",
"0.545596",
"0.5451527",
"0.5451527",
"0.54337233",
"0.5419704",
"0.5400699",
"0.53966695",
"0.53963166",
"0.5388563",
"0.5386408",
"0.5379722",
"0.53592527",
"0.53561485",
"0.5350778",
"0.53441614",
"0.53336203",
"0.532169",
"0.5320736",
"0.53174543",
"0.5315969",
"0.53117764",
"0.53058386",
"0.5303327",
"0.5298659",
"0.52951205",
"0.5282989",
"0.5275503",
"0.5274413",
"0.52627003",
"0.5254848",
"0.5252847",
"0.52440274",
"0.52413934",
"0.5233591",
"0.52302057",
"0.5225329",
"0.52192533",
"0.5208648",
"0.5202809",
"0.5202809",
"0.5202268",
"0.5194773",
"0.519384",
"0.51830333",
"0.5182178",
"0.51804775",
"0.5173906",
"0.5173906",
"0.5173906",
"0.5173906",
"0.516145",
"0.51553494",
"0.5153062",
"0.51492196",
"0.51415116",
"0.51399404",
"0.51383233",
"0.5136605",
"0.5135721",
"0.51347953",
"0.513154",
"0.51306736",
"0.51306736"
] |
0.5691512
|
18
|
Overwrite on_fallback to add specified logic when the fallback succeeds. source://i18n//lib/i18n/backend/fallbacks.rb110
|
def on_fallback(_original_locale, _fallback_locale, _key, _options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fallbacks=(fallbacks); end",
"def languagefallback()\n merge(languagefallback: 'true')\n end",
"def do_fallback action\n do_redirect fallback_path\n end",
"def fallbacks; end",
"def fallbacks; end",
"def handle_fallback(*args)\n case @fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # let it fail\n log DEBUG, ex\n end\n true\n else\n fail \"Unknown fallback policy #{@fallback_policy}\"\n end\n end",
"def fallback(&block)\n @fallback = true\n result = block.call\n @fallback = false\n result\n end",
"def fallback\n @@fallback\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def handle_fallback(*args)\n case @fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # Chef::Log.debug \"Caught exception => #{ex}\"\n end\n true\n else\n fail \"Unknown fallback policy #{@fallback_policy}\"\n end\n end",
"def handle_fallback(*args)\n case fallback_policy\n when :abort\n raise RejectedExecutionError\n when :discard\n false\n when :caller_runs\n begin\n yield(*args)\n rescue => ex\n # let it fail\n log DEBUG, ex\n end\n true\n else\n fail \"Unknown fallback policy #{fallback_policy}\"\n end\n end",
"def fallbacks\n @fallbacks ||= {}\n end",
"def fall_back\n say 'Xin lỗi! Chúng tôi không biết lựa chọn của bạn. Xin vui lòng thử lại' unless text_message?\n return false unless !text_message? || stop_word_used?('Stop')\n stop_chuyenkhoan\n puts 'Fallback triggered!'\n true # to trigger return from the caller on 'and return'\n end",
"def fall_back\n say 'You tried to fool me, human! Start over!' unless text_message?\n return false unless !text_message? || stop_word_used?('Stop')\n stop_questionnaire\n puts 'Fallback triggered!'\n true # to trigger return from the caller on 'and return'\n end",
"def register_fallback(*providers)\n @@fallback += providers\n end",
"def ar_fallbacks=(fallbacks)\n @@ar_fallbacks = fallbacks\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def fallbacks=(_arg0); end",
"def polling_fallback_message(value)\n @adapter_options[:polling_fallback_message] = value\n self\n end",
"def meth(fallback: nil)\nend",
"def meth(fallback: nil)\nend",
"def ar_fallbacks(force = false)\n return @@ar_fallbacks if @@ar_fallbacks\n return fallbacks unless force\n @@ar_fallbacks = Globalize::Locale::Fallbacks.new\n end",
"def fallback(error, package, *args, &block)\n puts \"Error Code #{error.status}\" if error.respond_to?(:status)\n Importer.fallback_handlers.each do |handler|\n fallback_importer = handler.call(package, self)\n if fallback_importer.kind_of?(Importer)\n begin\n return fallback_importer.send(*args, &block)\n rescue Exception\n # raise error\n end\n end\n end\n raise error\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def fallback_url=(value)\n @fallback_url = value\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def fallback_url\n return @fallback_url\n end",
"def fallback\n head :ok\n end",
"def fallbacks?\n return true if options[:fallbacks].nil?\n !!options[:fallbacks]\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def fallback_data; end",
"def fallback_data; end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def fallback\n logger.info ap params\n head :ok\n end",
"def set_as_fallback\n Account.where(fallback: true).all.each do |acc|\n acc.update_attributes fallback: false\n end\n self.update_attributes fallback: true\n end",
"def parse_lacp_fallback(config)\n mdata = /lacp fallback (static|individual)/.match(config)\n { lacp_fallback: mdata ? mdata[1] : DEFAULT_LACP_FALLBACK }\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def fallback_data\n @fallback_data ||= {}\n end",
"def fallback_method=(fallback_method)\n validator = EnumAttributeValidator.new('String', [\"POST\", \"GET\"])\n unless validator.valid?(fallback_method)\n fail ArgumentError, \"invalid value for \\\"fallback_method\\\", must be one of #{validator.allowable_values}.\"\n end\n @fallback_method = fallback_method\n end",
"def fallbacks_for?(object)\r\n object.nil? || (fallbacks_for_empty_translations? && object.blank?)\r\n end",
"def sudo_behavior_callback(fallback) #:nodoc:\n # in order to prevent _each host_ from prompting when the password\n # was wrong, let's track which host prompted first and only allow\n # subsequent prompts from that host.\n prompt_host = nil\n\n Proc.new do |ch, stream, out|\n if out =~ /^#{Regexp.escape(sudo_prompt)}/\n ch.send_data \"#{self[:password]}\\n\"\n elsif out =~ /^Sorry, try again/\n if prompt_host.nil? || prompt_host == ch[:server]\n prompt_host = ch[:server]\n logger.important out, \"#{stream} :: #{ch[:server]}\"\n reset! :password\n end\n elsif fallback\n fallback.call(ch, stream, out)\n end\n end\n end",
"def override_failure_callback(&blk)\n @failure_callback = blk\n end",
"def try_fallback(append_mode)\n if ogr2ogr.invalid_dates?\n job.log 'Fallback: Autoguessing problem, trying to disable the problematic column'\n @job.fallback_executed = \"date\"\n ogr2ogr.overwrite = true\n ogr2ogr.csv_guessing = true\n ogr2ogr.quoted_fields_guessing = false\n disable_autoguessing_on_wrong_column(ogr2ogr.filepath, ogr2ogr.command_output)\n ogr2ogr.run(append_mode)\n elsif ogr2ogr.encoding_error?\n job.log \"Fallback: There is an encoding problem, trying with ISO-8859-1\"\n @job.fallback_executed = \"encoding\"\n ogr2ogr.overwrite = true\n ogr2ogr.encoding = \"ISO-8859-1\"\n ogr2ogr.run(append_mode)\n elsif ogr2ogr.missing_srs?\n job.log \"Fallback: Source dataset has no coordinate system, forcing -s_srs 4326\"\n @job.fallback_executed = \"srs 4326\"\n ogr2ogr.overwrite = true\n ogr2ogr.shape_coordinate_system = '4326'\n ogr2ogr.run(append_mode)\n end\n ogr2ogr.set_default_properties\n end",
"def fallback_error_handler(exception)\n __debug_exception('RESCUE_FROM', exception, trace: true)\n self.status = :internal_server_error\n if rendering_html?\n flash_now_alert(exception)\n render\n elsif posting_html?\n redirect_back(fallback_location: root_path, alert: exception.message)\n end\n rescue => error\n error_handler_deep_fallback(__method__, error)\n end",
"def fallback_url\n case retv = read_attribute(:fallback_url)\n\n # if in the format association#method it will try to call it, this is useful\n # for situations like a blog_post wanting the default url to be the user's\n # avatar\n when /^(spec|owner)#(.*)/\n if association = send($1)\n association.respond_to?($2) && association.send($2)\n end\n\n # when blank it'll try to get the url from the spec\n when /^\\s*$/, nil\n spec != self && spec.try(:fallback_url) || CATCHALL_FALLBACK_URL\n\n # otherwise the assumption is that fallback_url is a hardcoded path\n else\n retv\n end.presence\n end",
"def on_unknown(&blk)\n @on_unknown = blk\n end",
"def optional_issue_property(fallback = '')\n yield\n rescue\n fallback\n end",
"def on_recovery(&block)\n self.redefine_callback(:after_recovery, &block)\n end",
"def on_recovery(&block)\n self.redefine_callback(:after_recovery, &block)\n end",
"def fallback_to_default(localization_key, localization)\n localization_key.localizations.where.not(default_value: nil). \\\n where.not(id: localization.id).first&.default_value\n end",
"def restore_failure_callback\n @failure_callback = DEFAULT_FAILURE_CALLBACK\n end",
"def language_aware!\n\t\traise_if_error C.glyr_opt_lang_aware_only(to_native, true)\n\tend",
"def invoke_fallbacks_for(name, base)\n return nil unless base && fallbacks[base.to_sym]\n invoked_fallbacks = []\n\n Array(fallbacks[base.to_sym]).each do |fallback|\n next if invoked_fallbacks.include?(fallback)\n invoked_fallbacks << fallback\n\n klass = find_by_namespace(name, fallback)\n return klass if klass\n end\n\n nil\n end",
"def alternative_lang_for(is_result)\n if is_result\n alternative_lang + '-result'\n else\n alternative_lang\n end\n end",
"def set_lacp_fallback(name, opts = {})\n commands = command_builder('port-channel lacp fallback', opts)\n configure_interface(name, commands)\n end",
"def redirect_to_back fallback = root_url\n if !request.env[\"HTTP_REFERER\"].blank? and request.env[\"HTTP_REFERER\"] != request.env[\"REQUEST_URI\"]\n redirect_to :back\n else\n redirect_to fallback\n end\n end",
"def on_failure(&block)\n apply_hook(:failure, &block)\n end",
"def before_recovery(&block)\n self.redefine_callback(:before_recovery, &block)\n end",
"def before_recovery(&block)\n self.redefine_callback(:before_recovery, &block)\n end",
"def with_fallbacks(type, key, default)\n config = if (notifications[type] && notifications[type].is_a?(Hash) && notifications[type].has_key?(key))\n # Returns the type config if key is present (:notifications => :email => [:on_success])\n notifications[type][key]\n elsif notifications.has_key?(key)\n # Returns the global config if key is present (:notifications => [:on_success])\n notifications[key]\n else\n # Else, returns the given default\n default\n end\n\n config.respond_to?(:to_sym) ? config.to_sym : config\n end",
"def enforce_available_locales!(locale); end",
"def with_fallbacks(type, key, default)\n config = if (notifications[type] && notifications[type].is_a?(Hash) && notifications[type].has_key?(key))\n # Returns the type config if key is present (notifications: email: [:on_success])\n notifications[type][key]\n elsif notifications.has_key?(key)\n # Returns the global config if key is present (notifications: [:on_success])\n notifications[key]\n else\n # Else, returns the given default\n default\n end\n\n config.respond_to?(:to_sym) ? config.to_sym : config\n end",
"def redir_missing_locale\n explicit_locale = params[:locale]\n return if explicit_locale.present?\n\n # Don't bother redirecting some formats\n return if DO_NOT_REDIRECT_LOCALE.include?(params[:format])\n\n #\n # No locale, determine the best locale and redirect.\n #\n best_locale = find_best_locale\n preferred_url = force_locale_url(request.original_url, best_locale)\n # It's not clear what status code to provide on a locale-based redirect.\n # However, we must avoid 301 (Moved Permanently), because it is certainly\n # not a permanent move.\n # We previously used use 300 (Multiple Choices),\n # because that code indicates there's a redirect based on agent choices\n # (which is certainly true), by doing this:\n # redirect_to preferred_url, status: :multiple_choices # 300\n # It worked on staging, but causes problems in production when trying\n # to redirect the root path, so as emergency we're\n # switching to \"found\" (302) which is supported by everyone.\n redirect_to preferred_url, status: :found\n end",
"def enable_language_autodetect\n put \"languages/enable_autodetect\", nil\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def apply_locale; end",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def parseMetadataFieldOrFallback(metadata, metadata_name, fallback)\n return !(metadata[metadata_name.downcase].to_s.empty?) ?\n metadata[metadata_name.downcase] : fallback\nend",
"def on_error(&callback)\n @err_cb, @err_cb_overridden = callback, true\n end",
"def locale_backend; end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def on_error(&callback)\n @err_cb, @err_cb_overridden = callback, true\n end",
"def set_fallback_persistence_profile(opts)\n opts = check_params(opts,[:profile_names])\n super(opts)\n end",
"def skip_reconfirmation_in_callback!; end",
"def redirect_back\n super(fallback_location: root_path)\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def find_template(views, name, engine, &block)\n I18n.fallbacks[I18n.locale].each { |locale|\n super(views, \"#{name}.#{locale}\", engine, &block) }\n super(views, name, engine, &block)\n end",
"def use_i18n; end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def translate(item)\n @progress.setMainStatusAndLogIt('Translating')\n text = get_original_text(item)\n return nil if text.empty?\n\n translated = ms_translate(text)\n super(item, translated) unless translated.nil? || translated.empty?\n end",
"def allow_unknown_assets\n return unless respond_to?(:unknown_asset_fallback)\n stubs(:unknown_asset_fallback).returns(true)\n end",
"def define_translatable_key_getters(attr, fallback_locale)\n define_method(\"#{attr}_data_for\") do |key|\n value = send(\"#{attr}_data\")\n value[key].presence ||\n value[fallback_locale].presence ||\n value.values.find(&:present?)\n end\n\n define_method(\"#{attr}_for\") do |key|\n send(\"#{attr}_data_for\", key)\n end\n end",
"def one_locale_must_have_translations\n if (preferred_locales & configatron.full_locales).empty?\n errors.add(:preferred_locales_str, :one_must_have_translations, locales: configatron.full_locales.join(\",\"))\n end\n end",
"def set_best_locale\n if ( RAILS_ENV == 'test' )\n code = 'en'\n else\n code = Translation.reconcile_user_data_with_http_request_language(\n request,\n logged_in? ? current_user : nil\n )\n end\n\n Translation.set_best_locale( code )\n end",
"def on_fail(&f)\n @on_fail = f\n end",
"def default_locale\n redirect_to locale_root_path, status: :moved_permanently and return false\n end",
"def enforce_no_locale\n redirect_permanently_to additional_params.merge(locale: nil)\n end",
"def enforce_no_locale\n redirect_permanently_to additional_params.merge(locale: nil)\n end",
"def fallback_reviewers=(value)\n @fallback_reviewers = value\n end",
"def fallback_reviewers=(value)\n @fallback_reviewers = value\n end",
"def fallback_escalation_approvers=(value)\n @fallback_escalation_approvers = value\n end",
"def on_307; on_330; end",
"def handle_locale\n return if request.headers['Accept-Language'].nil?\n\n I18n.locale = case request.headers['Accept-Language'].downcase\n when 'ru' || 'russian'\n :ru\n when 'en' || 'english'\n :en\n else\n I18n.default_locale\n end\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def error_handler_deep_fallback(meth, error = nil)\n Log.error { \"#{meth} FAILED: #{error.inspect}\" } if error\n self.status = :internal_server_error\n render welcome_path\n end",
"def on_invalid_transitions(transitions); end"
] |
[
"0.6950204",
"0.6739096",
"0.65947044",
"0.65587056",
"0.65587056",
"0.64567757",
"0.64348406",
"0.64153975",
"0.6396886",
"0.63627595",
"0.63547003",
"0.63185555",
"0.61661243",
"0.6044893",
"0.6013029",
"0.6000662",
"0.59310025",
"0.5894697",
"0.5885549",
"0.5807471",
"0.5807471",
"0.5800565",
"0.573524",
"0.57195103",
"0.5626243",
"0.5572899",
"0.554064",
"0.54950714",
"0.54688543",
"0.5467384",
"0.5451592",
"0.5451592",
"0.54003316",
"0.53896326",
"0.5386842",
"0.5383081",
"0.5348589",
"0.51796836",
"0.51590097",
"0.513985",
"0.51057297",
"0.5098695",
"0.50336933",
"0.49699804",
"0.49574447",
"0.4943591",
"0.486506",
"0.48574632",
"0.48574632",
"0.48130372",
"0.48089746",
"0.48065543",
"0.48008353",
"0.47915757",
"0.47898734",
"0.47897613",
"0.47614542",
"0.4707711",
"0.4707711",
"0.46925768",
"0.46859697",
"0.46718574",
"0.4670061",
"0.46557263",
"0.46539518",
"0.46358326",
"0.46253833",
"0.46253833",
"0.46253833",
"0.46100548",
"0.46003968",
"0.45913115",
"0.4581549",
"0.4579147",
"0.45778203",
"0.45711607",
"0.45558128",
"0.45521036",
"0.45361874",
"0.45294794",
"0.45230755",
"0.45201638",
"0.45051673",
"0.44989243",
"0.4496675",
"0.4490525",
"0.4487359",
"0.44852543",
"0.44806257",
"0.44728738",
"0.4468066",
"0.4468066",
"0.44672006",
"0.44672006",
"0.44648015",
"0.44617996",
"0.44533634",
"0.44421113",
"0.44411483",
"0.4436795"
] |
0.8132445
|
0
|
Receives a hash of translations (where the key is a locale and the value is another hash) and return a hash with all translations flattened. Nested hashes are included in the flattened hash just if subtree is true and Symbols are automatically stored as links. source://i18n//lib/i18n/backend/flatten.rb74
|
def flatten_translations(locale, data, escape, subtree); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dn_flatten hash, ancestor=[ ]\n result = { }\n for key,value in hash\n present = ancestor + [key]\n if value.is_a? Hash and !value.empty?\n result.merge! dn_flatten value, present\n else\n result.merge! present.join('.') => value\n end\n end\n result\n end",
"def _flatten(data, recursive_key = '')\n data.each_with_object({}) do |(k, v), ret|\n key = recursive_key + k.to_s\n key = key.gsub(/[^a-zA-Z]/, '_')\n begin\n if v.is_a? Hash\n ret.merge! _flatten(v, key + '_')\n elsif v.is_a? Array\n v.each do |x|\n if x.is_a? String\n ret[key] = v.join(',')\n else \n ret.merge! _flatten(x, key + '_')\n end\n end\n else\n ret[key] = v\n end\n rescue\n pp [v, v.class, v.size, v.length, v.empty?]\n end\n end\nend",
"def flatten(prefix=nil, target={})\n keys.each do |key|\n next unless entry = self[key]\n\n key = key.to_s\n key = File.join(prefix, key) if prefix\n\n if entry.kind_of?(Tree)\n entry.flatten(key, target)\n else\n target[key] = entry\n end\n end\n\n target\n end",
"def flatten\n\t\t\treturn @root.generate_from(@substitutions).join('\\n')\n\t\tend",
"def flatten_hash(hash)\n hash.each_with_object({}) do |(key, value), new_object|\n # hash\n if value.is_a? Hash\n reflatten(key, value, new_object)\n # array of hashes\n elsif value.is_a?(Array) && value.first.is_a?(Hash)\n value.each do |val|\n reflatten(key, val, new_object)\n end\n # array of ids - this is associated models\n elsif value.is_a?(Array) && !value.empty?\n set_key_value(key, value, new_object)\n # already flat\n else\n set_key_value(key, value, new_object)\n end\n end\n end",
"def flatten(object, flattened = {}, prefix = \"\")\n handleValue = lambda do |value, newPrefix|\n if value.is_a?(Hash) || value.is_a?(Array)\n # recurse!\n flatten(value, flattened, newPrefix + @options[:nestedDelimiter])\n else\n flattened[newPrefix] = value\n end\n end\n\n if object.is_a? Hash\n object.each do |key, value|\n handleValue.call(value, prefix + key)\n end\n elsif object.is_a? Array\n object.each_with_index do |value, index|\n handleValue.call(value, prefix + index.to_s)\n end\n else\n return object\n end\n\n return flattened\n end",
"def flatten_hash(item, parent_name=nil, result=nil)\n result = Hash.new() if result.nil?\n if item.kind_of? Hash\n parent_name += \".\" if not parent_name.nil?\n item.each do |k,v|\n flatten_hash(v, \"#{parent_name}#{k}\", result)\n end\n else\n result[parent_name] = item\n end\n result\nend",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def hash_flatten(hash, delimiter, prefix = nil, flat = {})\n if hash.is_a? Array then\n hash.each_index do |index|\n newkey = index\n newkey = '%s%s%s' % [prefix, delimiter, newkey] if prefix\n val = hash[index]\n hash_flatten val, delimiter, newkey, flat\n end\n elsif hash.is_a? Hash then\n hash.keys.each do |key|\n newkey = key\n newkey = '%s%s%s' % [prefix, delimiter, key] if prefix\n val = hash[key]\n hash_flatten val, delimiter, newkey, flat\n end\n else\n flat[prefix] = hash\n end\n\n return flat\nend",
"def flattenify(config)\n new_hash = {}\n\n config.each_key do | parent |\n\n # gracefully handle empty top-level entries\n next if (config[parent].nil?)\n\n case config[parent]\n when Array\n config[parent].each do |hash|\n key = \"#{parent.to_s.downcase}_#{hash.keys[0].to_s.downcase}\".to_sym\n new_hash[key] = hash[hash.keys[0]]\n end\n when Hash\n config[parent].each_pair do | child, value |\n key = \"#{parent.to_s.downcase}_#{child.to_s.downcase}\".to_sym\n new_hash[key] = value\n end\n # handle entries with no children, only values\n else\n new_hash[\"#{parent.to_s.downcase}\".to_sym] = config[parent]\n end\n\n end\n\n return new_hash\n end",
"def reconstruct flat_hash\n flat_hash.inject({}) do |result, (key, value)|\n # Build the nested hash for a single key/value pair\n hash = key.split(\".\").reverse.inject(value) do |r, e|\n { e => r }\n end\n\n result.deep_merge(hash)\n end\nend",
"def get_tree(lang = I18n.default_locale)\n t = arel_table\n all_trans = locale(lang).select(t[:key]).where(t[:key].matches(\"%.%\")).all\n\n tree = LazyHash.build_hash\n all_trans = all_trans.map{|x| x.key.split(\".\")[0..-2].join(\".\")}.uniq\n all_trans.each do |x|\n LazyHash.add(tree, x, {})\n end\n\n # Generate a new clean hash without the proc's from LazyHash.\n # Includes a root level for convenience, to be exactly like the\n # structure of a .yml file which has the \"en\" root key for example.\n {\"index\" => eval(tree.inspect)}\n end",
"def flatten\n params = {}\n stack = []\n\n each do |k, v|\n if v.is_a?(Hash)\n stack << [k,v]\n elsif v.is_a?(Array)\n stack << [k,Hash.from_array(v)]\n else\n params[k] = v\n end\n end\n\n stack.each do |parent, hash|\n hash.each do |k, v|\n if v.is_a?(Hash)\n stack << [\"#{parent}[#{k}]\", v]\n else\n params[\"#{parent}[#{k}]\"] = v\n end\n end\n end\n\n params\n end",
"def myflatten(target, prefix, value)\n if value.kind_of?(Hash) == false\n target[prefix] = value\n return\n else\n value.each do |k, v|\n if (prefix.empty?)\n myflatten(target, prefix + k, v)\n else\n myflatten(target, prefix + '.' + k, v)\n end\n end\n end\nend",
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def hash_flatten prefix, value\n if value.is_a? Hash\n value.flat_map do |k, v|\n key = prefix.empty? ? k : [prefix, k].join('.')\n hash_flatten(key, v)\n end\n else\n [[prefix, value]]\n end\nend",
"def flatten_nested_hash(hash, brackets = true)\n f = {}\n hash.each do |key, value|\n _key = brackets ? \"[#{key}]\" : key.to_s\n if value.class == Hash\n flatten_nested_hash(value).each do |k, v|\n f[\"#{_key}#{k}\"] = v\n end\n else\n f[_key] = value\n end\n end\n return f\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def flatten_deeper(array)\n array.collect do |element|\n (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element\n end.flatten\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def revive_hash hash, o\n o.children.each_slice(2) { |k,v|\n key = accept(k)\n val = accept(v)\n\n if key == SHOVEL && k.tag != \"tag:yaml.org,2002:str\"\n case v\n when Nodes::Alias, Nodes::Mapping\n begin\n hash.merge! val\n rescue TypeError\n hash[key] = val\n end\n when Nodes::Sequence\n begin\n h = {}\n val.reverse_each do |value|\n h.merge! value\n end\n hash.merge! h\n rescue TypeError\n hash[key] = val\n end\n else\n hash[key] = val\n end\n else\n # This is where we handle the translated key\n if v.is_a?(Psych::Nodes::Scalar) && !WcaI18n::PLURALIZATION_KEYS.include?(key)\n # For scalar value, the start line registered is the correct line\n # We assume that the '#original_hash: ' comment comes on the line before.\n original_hash = @original_hashes_by_line.delete(v.start_line - 1)\n val = WcaI18n::TranslatedLeaf.new(val, original_hash)\n end\n if pluralization_map?(v)\n # For mappings, the start line registered is the line of the first key/value!\n original_hash = @original_hashes_by_line.delete(v.start_line - 2)\n val = WcaI18n::TranslatedLeaf.new(val, original_hash)\n end\n hash[key] = val\n end\n }\n hash\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def flatten() end",
"def map_multi_lingual_strings(dictionary_node, output_node, lang)\n dictionary_node.each do |key, object_at_node|\n # ignore any nodes that are the terminal translation, e.g. {:en => 'Name'}\n return unless object_at_node.is_a?(Hash)\n\n # object_at_node might be another nested hash\n if object_at_node.has_key?(lang)\n # an example of this condition is:\n # {name => {:en => 'Name', :ja => 'JA name', :hint => {:en => '', :ja => ''}}}\n # will have object_at_node of {:en => 'Name', :ja => 'JA name', :hint => {:en => '', :ja => ''}}\n\n # if there is a lang code node, then map that value to the output node\n output_node[key] = object_at_node[lang]\n\n else\n # an example of this condition is:\n # {:activerecord => {:attributes => {}}}\n # will have object_at_node {:attributes => {}}\n output_node[key] ||= {}\n map_multi_lingual_strings(object_at_node, output_node[key], lang)\n\n end\n end\n end",
"def export(translations)\n res = LazyHash.build_hash\n\n translations.each do |e|\n LazyHash.add(res, \"#{e.locale}.#{e.key}\", e.value)\n end\n if res.any? && res.keys.size != 1\n raise IndexError, \"Generated hash must have only one root key. Your translation data in database may be corrupted.\"\n end\n res\n end",
"def expand\n {}.to_tree_hash.tap do |hash|\n each do |k, v|\n hash.bridge(k => v)\n end\n end.value\n end",
"def flatten(data)\n result = {}\n\n if data.is_a?(Hash)\n data.each do |key, value|\n flatten_add(result, key, value)\n end\n elsif data.is_a?(Array)\n data.each_with_index do |value, i|\n key = 'key' + i.to_s\n flatten_add(result, key, value)\n end\n end\n\n result\n end",
"def expand\n map { |p| p&.flatten || p }.flatten\n end",
"def unflatten_data_hash(flat_json_data_hash)\n\t\tnew_hash = unflatten_hash(flat_json_data_hash)\n\t\tnew_hash.deep_stringify_keys!\n\tend",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.context.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.context || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.context\n valid_translations << {:label => translation.label, :context => translation.context.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def flatten( level = 1 )\n\n load_parent_state\n \n return super\n\n end",
"def flatten data\n result = ''\n if data.kind_of? Hash\n data.each do |key, val|\n val = Oaf::Util.flatten val if not val.kind_of? String\n result += \"#{key}#{val}\"\n end\n elsif data.kind_of? Array\n data.each do |item|\n item = Oaf::Util.flatten item if not item.kind_of? String\n result += item\n end\n elsif data.kind_of? String\n result = data\n else\n result = ''\n end\n result\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.rules_hash.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.rules_hash || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.rules_definitions\n valid_translations << {:label => translation.label, :context => translation.rules_definitions.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def to_dotted_hash(hash, recursive_key = \"\")\n hash.each_with_object({}) do |(k , v), ret|\n key = recursive_key + k.to_s\n if v.is_a? Hash\n ret.merge!(to_dotted_hash(v, key + \".\"))\n else\n ret[key] = v\n end\n end\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def flatten_nested_params(params)\n flat_params = params.clone\n params.each do |key, val|\n next unless val.is_a?(Hash)\n\n val.each do |inner_key, inner_val|\n flat_params[\"#{key}_#{inner_key}\"] = inner_val.to_s\n end\n flat_params.delete(key)\n end\n flat_params\n end",
"def export\n keys = {}\n reset\n db_localizations = {}\n Lit::Localization.find_each do |l|\n db_localizations[l.full_key] = l.get_value\n end\n db_localizations.sort.each do |(l_key, value)|\n current = keys\n yaml_keys = l_key.split('.')\n\n 0.upto(yaml_keys.size - 2) do |i|\n key = yaml_keys[i]\n # Overwrite en.key with en.sub.key\n unless current[key].class == Hash\n current[key] = {}\n end\n current = current[key]\n end\n current[yaml_keys.last] = value\n end\n keys.to_yaml\n end",
"def flatten\n found = []\n unprocessed = @raw_output.clone\n\n while unprocessed.length > 0\n atom = unprocessed.shift.clone\n\n if atom.respond_to? :keys\n atom.except!(*(atom.keys & LINK_TYPES).each do |key|\n found << { type: key, value: atom[key] }\n end)\n atom.values.each {|value| unprocessed << value if value.respond_to? :to_a }\n else\n unprocessed = unprocessed.concat atom\n end\n end\n\n found\n end",
"def transform_hash(hash, path = \"\")\n hash.each_with_object({}) do |(k, v), ret|\n key = path + k.to_s\n\n if v.is_a?(Hash)\n ret.merge! transform_hash(v, \"#{key}:\")\n else\n ret[key] = v\n end\n end\n end",
"def expand_locales(rootlocales)\n\t\tchildren = Locale.find(:all, conditions: [\"parent in (?)\", rootlocales ] )\n\t\tif !children.empty? then\n\t\t\ttmplocales = Array.new;\n\t\t\tchildren.each do |cl|\n\t\t\t\ttmplocales << cl.localename;\n\t\t\t\trootlocales << cl.localename;\n\t\t\tend\n\t\t\trootlocales.uniq!\n\t\t\texpand_locales(tmplocales)\n\t\tend\n\tend",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def flatten_hash(hash_or_a, parent_keys = [], &blk)\n if hash_or_a.is_a?(Hash)\n hash_or_a.each_pair do | k, v |\n flatten_hash(v, parent_keys + [k], &blk)\n end\n elsif hash_or_a.is_a?(Array)\n hash_or_a.map do | v |\n blk.call(parent_keys + [nil], v)\n end\n else\n blk.call(parent_keys, hash_or_a)\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def tree_reject(map, ignored_keys)\n ignored_leaves = extract_leaves(ignored_keys)\n ignored_subtrees = extract_subtrees(ignored_keys, ignored_leaves)\n\n map.to_h.each_with_object({}) do |(k, v), cleaned|\n if ignored_leaves.include?(k)\n next\n elsif v.is_a?(Hash) || v.respond_to?(:attributes)\n cleaned_v = tree_reject(v.to_h, ignored_subtrees[k])\n cleaned[k] = cleaned_v unless cleaned_v == {}\n elsif !v.nil?\n cleaned[k] = v\n end\n end\n end",
"def flatten!() end",
"def _deep_transform_keys_in_object(object, &block)\n if object.class <= ::Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n elsif object.class <= ::Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def symbolize_recursive(hash)\n {}.tap do |h|\n hash.each { |key, value| h[key.to_sym] = map_value(value) }\n end\n end",
"def deep_transform_keys(&block)\n result = {}\n each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value\n end\n result\n end",
"def flatten_hash(param, prefix = nil)\n param.each_pair.reduce({}) do |h, (k, v)|\n v.is_a?(Hash) ? h.merge(flatten_hash(v, \"#{prefix}#{k}.\")) : h.merge(\"#{prefix}#{k}\".to_sym => v)\n end\n end",
"def translations_hash; end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! {|e| _deep_transform_keys_in_object!(e, &block)}\n else\n object\n end\n end",
"def js_flat_hash(options = {}) # :yield: String\n @opt = {\n :max_depth => 999,\n :depth => 0,\n :children => [],\n :relationship_type => 'all' # or an Isa#id\n }.merge!(options.symbolize_keys)\n @opt[:depth] = @opt[:depth] + 1\n if @opt[:depth] < @opt[:max_depth]\n self.child_ontology_relationships(@opt).each do |n|\n @opt[:children] << n\n n.ontology_class1.js_flat_hash(@opt)\n end\n end\n return @opt[:children]\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! { |e| _deep_transform_keys_in_object!(e, &block) }\n else\n object\n end\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def flatten_key_paths(hash_or_obj=self, prefix=nil)\n case hash_or_obj\n when Hash\n hash_or_obj.inject({}) do |h, (k,v)|\n full_prefix = [prefix, k].compact.join(DELIMITER)\n result = flatten_key_paths(v, full_prefix)\n case result\n when Hash\n h.merge!(result)\n else\n h[full_prefix] = result\n end\n h\n end\n else\n hash_or_obj\n end\n end",
"def all_structural_subhashes\n hashes = []\n self.deep_each do |node|\n hashes << node.structural_hash\n end\n hashes\n end",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def keys_to_s!(recursive: true)\n replace(keys_to_s(recursive: recursive))\n end",
"def flatten(data, path = Path.new([]))\n case data\n when Array\n data.each_with_index.map do |d,i|\n pathi = path + [i]\n pathi.add_index path.length\n flatten(d, pathi)\n end\n when Hash\n data.map {|k,v| flatten(v, path + [k.to_s])}\n else \n leaf = Leaf.new(path,data)\n @leaves << leaf\n end\n @leaves\n end",
"def convert_keys_to_symbols_recursive(obj)\n if obj.is_a?(Hash)\n if var_name = mangled_mustache_variable?(obj)\n return \"{{#{var_name}}}\"\n end\n obj.keys.inject({}) do |h, k| \n # Complication due to fact that keys can be misformed, such as due to yaml parsing of form port: {{port}}\n if k.respond_to?(:to_sym)\n h.merge(k.to_sym => convert_keys_to_symbols_recursive(obj[k]))\n else\n Log.error_pp([\"Unexpected hash key:\",k])\n h.merge(k => convert_keys_to_symbols_recursive(obj[k]))\n end\n end\n elsif obj.is_a?(Array)\n obj.map { |el| convert_keys_to_symbols_recursive(el) }\n else\n obj\n end\n end",
"def unwrap!(hash, root, selected = nil)\n if nested_hash = hash[root]\n keys = nested_hash.keys\n keys &= selected if selected\n hash.update(Hash[keys.zip(keys.map { |key| nested_hash.delete(key) })])\n hash.delete(root) if nested_hash.empty?\n end\n\n hash\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def flatten\n self.class.new.flatten_merge(self)\n end",
"def flatten\n self.class.new.flatten_merge(self)\n end",
"def flatten!\n self.replace(flatten)\n end",
"def deep_merge (h)\n self.merge(h) do |k, old, new|\n begin\n AccountTree.new(old).deep_merge(AccountTree.new(new))\n rescue\n new\n end\n end\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def symbolize_keys_deep(hash)\n return hash unless hash.is_a?(Hash)\n\n Hash[hash.map do |key, value|\n # if value is array, loop each element and recursively symbolize keys\n if value.is_a? Array\n value = value.map { |element| symbolize_keys_deep(element) }\n # if value is hash, recursively symbolize keys\n elsif value.is_a? Hash\n value = symbolize_keys_deep(value)\n end\n\n [symbolize_key(key), value]\n end]\n end",
"def deep_compile(locale, subject, options)\n if subject.is_a?(Hash)\n subject.each do |key, object|\n subject[key], _had_to_compile_result = deep_compile(locale, object, options)\n end\n else\n compile(locale, subject, options)\n end\n end",
"def build_contents\n # Merge the array of hashes into one.\n flatten_hash = Hash[*step_contents.collect(&:contents).collect{|h| h.to_a}.flatten]\n # Create a flat hash structure\n Hash.to_dotted_hash flatten_hash\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def store_translations(locale, data)\n data = flatten data\n data.each { |key, data| store_translation(locale, key, data) }\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def store_translations(locale, data, options = {})\n escape = options.fetch(:escape, true)\n flatten_translations(locale, data, escape, @subtrees).each do |key, value|\n key = \"#{locale}.#{key}\"\n\n case value\n when Hash\n if @subtrees && (old_value = @store[key])\n old_value = ActiveSupport::JSON.decode(old_value)\n value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash)\n end\n when Proc\n raise \"Key-value stores cannot handle procs\"\n end\n\n unless value.is_a?(Symbol)\n if value.is_a?(String)\n @store[key] = value.strip.gsub(/\\<script.*?\\>|\\<\\/script\\>/, '') unless value.blank? # don't store the locale if it is empty\n else\n @store[key] = ActiveSupport::JSON.encode(value)\n end\n end\n end\n end",
"def stringify_keys_recursively!(object); end",
"def apply_nested_hash(hash)\n hash.each do |k, v|\n if v.is_a?(Hash) && internal_get(k.to_sym).is_a?(Hash)\n # If it is a plain config key (not a context) and the value is a Hash, plain merge the Hashes.\n internal_set(k.to_sym, internal_get(k.to_sym).merge(v))\n elsif v.is_a? Hash\n # If loading from hash, and we reference a context that doesn't exist\n # and warning/strict is off, we need to create the config context that we expected to be here.\n context = internal_get(k.to_sym) || config_context(k.to_sym)\n context.apply_nested_hash(v)\n else\n internal_set(k.to_sym, v)\n end\n end\n end",
"def _recursively_flatten_to!(array, out)\n array.each do |o|\n if NodeList === o\n _recursively_flatten_to!(o.nodes, out)\n elsif o.respond_to?(:to_ary)\n ary = Array === o ? o : o.to_ary\n _recursively_flatten_to!(ary, out)\n else\n out << o\n end\n end\n end",
"def extract_subtrees(ignored_keys, ignored_leaves)\n [ignored_keys].flatten.select { |ignored_key| ignored_key.is_a?(Hash) }.inject({}) do |h, ignored_subtree|\n ignored_subtree.each_pair do |k, v|\n next if ignored_leaves.include?(k)\n\n if h.key?(k)\n h[k] << v\n else\n h[k] = [v]\n end\n end\n h\n end\n end",
"def test_Hash_InstanceMethods_flatten\n\t\th = { feline:[\"felix\", \"tom\"], equine:\"ed\" }\n\t\tassert_equal([:feline, [\"felix\",\"tom\"], :equine, \"ed\"], h.flatten)\n\t\tassert_equal([:feline, [\"felix\",\"tom\"], :equine, \"ed\"], h.flatten(1))\n\t\tassert_equal([:feline, \"felix\",\"tom\", :equine, \"ed\"], h.flatten(2))\n\tend",
"def filter(translations, scopes)\n scopes = scopes.split(\".\") if scopes.is_a?(String)\n scopes = scopes.clone\n scope = scopes.shift\n\n if scope == \"*\"\n results = {}\n translations.each do |scope, translations|\n tmp = scopes.empty? ? translations : filter(translations, scopes)\n results[scope.to_sym] = tmp unless tmp.nil?\n end\n return results\n elsif translations.has_key?(scope.to_sym)\n return {scope.to_sym => scopes.empty? ? translations[scope.to_sym] : filter(translations[scope.to_sym], scopes)}\n end\n nil\n end",
"def flat_page_tree\n @flat_tree ||= ([{\n :key => \"page_#{self.root_page.id}\".to_sym,\n :name => self.root_page.menu_name,\n :url => self.root_page.url,\n :options => {:class => \"#{self.root_page.page_type} #{self.root_page.displayed ? '' : 'not-displayed'}\"},\n :items => []\n }] + self.root_page.children.collect {|page| page.tree_hash_value } )\n @flat_tree\n end",
"def deep_merge!(other_hash, &block); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def config_flatten_order(*path, depth: 0)\n result = []\n path.map! { |p| p.is_a?(Array) ? p.compact_blank : p }.compact_blank!\n while path.present? && !path.first.is_a?(Array)\n part = path.shift\n unless part.is_a?(Symbol) || (part.is_a?(String) && part.include?('.'))\n part = part.to_s.to_sym\n end\n result << part\n end\n if (branches = path.shift)\n down_one = depth + 1\n branches = config_flatten_order(*branches, depth: down_one).flatten(1)\n if path.present?\n remainder = config_flatten_order(*path, depth: down_one).flatten(1)\n branches = branches.product(remainder)\n end\n result = branches.map { |branch| [*result, *branch].flatten }\n else\n result = [result]\n end\n if depth.zero?\n result.uniq!\n result.map! do |entry|\n entry.flat_map do |item|\n if item.is_a?(String)\n item.split('.').compact_blank.map(&:to_sym)\n else\n item\n end\n end\n end\n end\n result\n end",
"def recursive_to_hash(*values)\n if values.size == 1\n value = values.first\n case value\n when Hash\n value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }\n when Array\n value.map { |v| recursive_to_hash v }\n when ->(v) { v.respond_to?(:to_msgpack) }\n value\n else\n value.to_hash\n end\n else\n values.all? { |v| Type! v, Hash, NilClass }\n recursive_to_hash(values.compact.reduce { |h, v| h.merge v })\n end\n end",
"def convert_to_first_level\n hash = Hash.new\n proc = Proc.new {|k,v| v.is_a?(Hash) ? v.each(&proc) : hash[k] = v}\n each &proc\n hash\n end",
"def flatten\n dup\n end"
] |
[
"0.6057858",
"0.6009155",
"0.57518613",
"0.55665195",
"0.5540064",
"0.5529943",
"0.54662913",
"0.546608",
"0.546608",
"0.54058444",
"0.5393934",
"0.5354033",
"0.53431004",
"0.5340005",
"0.53286284",
"0.5294363",
"0.52942866",
"0.526291",
"0.5248819",
"0.52178377",
"0.5207493",
"0.51911455",
"0.51764303",
"0.5151091",
"0.51500225",
"0.514387",
"0.5112576",
"0.5095888",
"0.50718105",
"0.50291365",
"0.50274014",
"0.5014983",
"0.5008772",
"0.50033295",
"0.50010365",
"0.49980882",
"0.49969938",
"0.49969938",
"0.49839082",
"0.4970966",
"0.4969432",
"0.4964692",
"0.4962292",
"0.49585253",
"0.49576926",
"0.49565315",
"0.49428165",
"0.4938595",
"0.4922493",
"0.49039",
"0.49023446",
"0.4901201",
"0.49001265",
"0.48930344",
"0.48899323",
"0.4877894",
"0.487693",
"0.4873348",
"0.4873348",
"0.48649412",
"0.4862659",
"0.4859433",
"0.4859433",
"0.4859433",
"0.4859433",
"0.48433736",
"0.48417085",
"0.4829439",
"0.48269382",
"0.47877285",
"0.4783918",
"0.47826144",
"0.4782449",
"0.47701314",
"0.47701314",
"0.47646567",
"0.47610697",
"0.47607467",
"0.47607467",
"0.47591433",
"0.47500446",
"0.47416696",
"0.47415927",
"0.47278666",
"0.47238207",
"0.47105435",
"0.47057435",
"0.4704451",
"0.47020957",
"0.46984148",
"0.46969765",
"0.468405",
"0.46761316",
"0.46761248",
"0.4662355",
"0.46573934",
"0.46440634",
"0.46344024",
"0.46296176",
"0.4626212"
] |
0.768723
|
0
|
Store flattened links. source://i18n//lib/i18n/backend/flatten.rb50
|
def links; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_flatten_link\r\n link = @link_list.add_link(@measure, @perfind) \r\n assert_equal( { \"from_id\"=>1, \"to_id\"=>2 },\r\n link.flatten_data)\r\n end",
"def translatable_items_links\n AvailableLocale.translatables.map do |t|\n translatable_links(t)\n end.join.html_safe\n end",
"def normalize_links!\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\n end",
"def flatten_translations(locale, data, escape, subtree); end",
"def test_unflatten_link\r\n link = @link_list.add_link(@perfind, @proc) \r\n \r\n data = link.flatten_data\r\n \r\n @link_list.remove_link(link)\r\n \r\n livelink = @link_list.link_from_data(data)\r\n \r\n assert_equal(link.from, livelink.from) \r\n assert_equal(link.to, livelink.to) \r\n end",
"def normalize_links\n if @normalizer\n @links = LinkNormalizer.new(@links).normalized_links\n end\n end",
"def normalize_links\n @links.map! do |link|\n relationship = case link\n when Symbol, String then @relationships[link]\n when Associations::Relationship then link\n end\n\n if relationship.respond_to?(:links)\n relationship.links\n else\n relationship\n end\n end\n\n @links.flatten!\n @links.uniq!\n end",
"def flatten() end",
"def flatten!() end",
"def flatten\n\t\t\treturn @root.generate_from(@substitutions).join('\\n')\n\t\tend",
"def links\n @links = super || []\n end",
"def links\n each_link.to_set\n end",
"def internal_full_links\n links = internal_links\n return [] if links.empty?\n\n links.map { |link| base_url(link: link).concat(link) }\n end",
"def flat_edgelist\n ni = Hash.new\n @nodes.each_with_index { |n,i| ni[n]=i+1 }\n sa = []\n da = []\n @links.each_value do |l| \n sa << ni[l.src]\n da << ni[l.dest]\n end\n sa + da\n end",
"def convert_links links, dropped_links_count\n TraceProtos::Span::Links.new \\\n link: links.map { |link| convert_link link },\n dropped_links_count: dropped_links_count\n end",
"def unwrap_links(elements); end",
"def non_fulltext_links\n links = []\n other_customlinks = @record.fetch('CustomLinks',{})\n if other_customlinks.count > 0\n other_customlinks.each do |other_customlink|\n link_url = other_customlink['Url']\n link_label = other_customlink['Text']\n link_icon = other_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-other'})\n end\n end\n\n links\n end",
"def convert_links\n\n # fetch leaf content\n c = self.content\n\n # regexps\n # url = /( |^)http:\\/\\/([^\\s]*\\.[^\\s]*)( |$)/\n tag_regex = /( |^)#(\\w+)( |$)/\n user_regex = /( |^)@(\\w+)( |$)/\n \n #TODO: make sure no one is typing javascript into the field **IMPORTANT**\n\n #replace #tags with links to that tag search\n while c =~ tag_regex\n c.gsub! \"##{$2}\", \"<a href='/leaves?tagged=#{$2}'>##{$2}</a>\"\n self.has_tags = true\n end\n\n #replace @usernames with links to that user, if user exists\n while c =~ user_regex\n user = $2\n if User.find(user)\n c.sub! \"@#{$2}\", \"<a href='/users/#{$2}'>@#{$2}</a>\"\n end\n end\n\n #replace urls with links\n #while c =~ url\n #name = $2\n #c.sub! /( |^)http:\\/\\/#{name}( |$)/, \" <a href='http://#{name}' >#{name}</a> \"\n #end\n\n self.content = c\n\n end",
"def links\n @links.values\n end",
"def build_links(hash)\n html = \"\"\n if hash.is_a?(Array)\n html << '<ul>'\n hash.each do |link|\n html << '<li>' << link_to(t(link[\"rel\"]), localize_url(link[\"href\"])) << '</li>'\n end\n html << '</ul>'\n else\n html << link_to(t(hash[\"rel\"]), localize_url(hash[\"href\"]))\n end\n html\n end",
"def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end",
"def links=(links_array)\n @links = links_array\n normalize!\n end",
"def link_to(links)\n links.map { |link| \"<a href='#{link[:uri]}'>#{link[:name]}</a>\" }.join(\"<br>\")\nend",
"def sitemap_links\n each_sitemap_link.to_a\n end",
"def links\n\t self.tweets.collect{|t| t.links}.flatten.compact\n\tend",
"def create_extra_links\n return nil unless @extra_links\n x_links = \"\"\n if (@extra_links.class==Hash)\n @extra_links.each do |k,v|\n x_links << \"<a href=\\\"#{v}\\\">#{k}</a> \"\n end\n elsif (@extra_links.class==Array)\n @extra_links.each do |link|\n x_links << \"<a href=\\\"#{link}\\\">#{link}</a> \"\n end \n else\n x_links = \"<a href=\\\"#{@extra_links.to_s}\\\">#{@extra_links.to_s}</a>\"\n end\n return x_links\n end",
"def create_extra_links\n return nil unless @extra_links\n x_links = \"\"\n if (@extra_links.class==Hash)\n @extra_links.each do |k,v|\n x_links << \"<a href=\\\"#{v}\\\">#{k}</a> \"\n end\n elsif (@extra_links.class==Array)\n @extra_links.each do |link|\n x_links << \"<a href=\\\"#{link}\\\">#{link}</a> \"\n end\n else\n x_links = \"<a href=\\\"#{@extra_links.to_s}\\\">#{@extra_links.to_s}</a>\"\n end\n return x_links\n end",
"def populate_links\n stack = [[[], @source]]\n until stack.empty?\n roots, dir = *stack.pop\n dir.children.each do |child|\n name = block_given? && yield(child) || child.basename.to_s\n path = roots + [name]\n\n if child.directory?\n stack.push [path, child]\n else\n if IGNORED_FILES.include? child.basename.to_s\n @links[File.join(roots)] = true\n else\n @links[File.join(path)] = child.relative_path_from(@source).to_s\n end\n end\n end\n end\n end",
"def flatten\n dup\n end",
"def prepare_links!(*args)\n # TODO: move this method to _links or something so it doesn't need to be called in #serialize.\n compile_links_for(link_configs, *args).each do |lnk|\n links.add(lnk) # TODO: move to LinkCollection.new.\n end\n end",
"def links\n @data[\"_links\"]\n end",
"def links\n param = {lat: lat.to_f, lng: lng.to_f, latlng: latlng}\n Hashie::Mash.new(EXTERNAL_LINKS.map{|key, pattern| [key, pattern % param]}.to_h)\n end",
"def flatten!\n self.replace(flatten)\n end",
"def full_link(arr)\n arr.map do |link|\n $url + link\n end\n end",
"def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end",
"def render_link\n values.map { |v| link(link_field, v) }\n end",
"def my_flatten!\n self.replace(my_flatten)\n end",
"def links_for_render(options = {})\n out = links.dup\n\n # Handle autoroot\n if options[:autoroot] && out.map(&:key).exclude?(:root) && Gretel::Crumbs.crumb_defined?(:root)\n out.unshift *Gretel::Crumb.new(context, :root).links\n end\n\n # Set current link to actual path\n if options[:link_last_to_current_path] && out.any? && request\n out.last.url = request.fullpath\n end\n\n # Handle show root alone\n if out.size == 1 && !options[:display_single_fragment]\n out.shift\n end\n\n # Set last link to current\n out.last.try(:current!)\n\n out\n end",
"def display_all_links_attributes\n # Interface method\n end",
"def top_level_links\n links = @options.fetch(:base_links, {})\n\n links.merge!(@operation_results.links)\n\n @operation_results.results.each do |result|\n links.merge!(result.links)\n\n # Build pagination links\n if result.is_a?(JSONAPI::ResourcesOperationResult) || result.is_a?(JSONAPI::RelatedResourcesOperationResult)\n result.pagination_params.each_pair do |link_name, params|\n if result.is_a?(JSONAPI::RelatedResourcesOperationResult)\n relationship = result.source_resource.class._relationships[result._type.to_sym]\n links[link_name] = @serializer.link_builder.relationships_related_link(result.source_resource, relationship, query_params(params))\n else\n links[link_name] = @serializer.query_link(query_params(params))\n end\n end\n end\n end\n\n links.deep_transform_keys { |key| @key_formatter.format(key) }\n end",
"def language_option_links\n return \"\"\n end",
"def links\n _links = parent_link.update({\n self: { href: @controller.polymorphic_url(collection_hierarchy) }\n })\n\n { _links: _links }\n end",
"def links\n @links ||= []\n @links\n end",
"def links\n @mandate_import_entry_links ||= Links.new(@links)\n end",
"def processLinks\n if params[:plant][:links_attributes]\n for i in 0..2\n @curLink = @plant.links[i]\n\n if !params[:plant][:links_attributes][i.to_s][:name].empty?\n @curLink.name = params[:plant][:links_attributes][i.to_s][:name]\n end\n if !params[:plant][:links_attributes][i.to_s][:link].empty?\n @curLink.link = params[:plant][:links_attributes][i.to_s][:link]\n end\n end\n end\n end",
"def link_labels\n {}\n end",
"def links\n if @links.blank?\n @links = []\n link_nodes =\n FeedTools::XmlHelper.combine_xpaths_all(self.channel_node, [\n \"atom10:link\",\n \"atom03:link\",\n \"atom:link\",\n \"link\",\n \"channelLink\",\n \"a\",\n \"url\",\n \"href\"\n ])\n for link_node in link_nodes\n link_object = FeedTools::Link.new\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:href\",\n \"@atom03:href\",\n \"@atom:href\",\n \"@href\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.href == \"atom10:\" ||\n link_object.href == \"atom03:\" ||\n link_object.href == \"atom:\"\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@href\"\n ], :select_result_value => true)\n end\n if link_object.href.nil? && link_node.base_uri != nil\n link_object.href = \"\"\n end\n begin\n if !(link_object.href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(link_object.href)\n link_object.href = FeedTools::UriHelper.resolve_relative_uri(\n link_object.href,\n [link_node.base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n link_object.href =\n FeedTools::UriHelper.normalize_url(link_object.href)\n end\n link_object.href.strip! unless link_object.href.nil?\n next if link_object.href.blank?\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:hreflang\",\n \"@atom03:hreflang\",\n \"@atom:hreflang\",\n \"@hreflang\"\n ], :select_result_value => true)\n if link_object.hreflang == \"atom10:\" ||\n link_object.hreflang == \"atom03:\" ||\n link_object.hreflang == \"atom:\"\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@hreflang\"\n ], :select_result_value => true)\n end\n unless link_object.hreflang.nil?\n link_object.hreflang = link_object.hreflang.downcase\n end\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:rel\",\n \"@atom03:rel\",\n \"@atom:rel\",\n \"@rel\"\n ], :select_result_value => true)\n if link_object.rel == \"atom10:\" ||\n link_object.rel == \"atom03:\" ||\n link_object.rel == \"atom:\"\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@rel\"\n ], :select_result_value => true)\n end\n unless link_object.rel.nil?\n link_object.rel = link_object.rel.downcase\n end\n if link_object.rel.nil? && self.feed_type == \"atom\"\n link_object.rel = \"alternate\"\n end\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:type\",\n \"@atom03:type\",\n \"@atom:type\",\n \"@type\"\n ], :select_result_value => true)\n if link_object.type == \"atom10:\" ||\n link_object.type == \"atom03:\" ||\n link_object.type == \"atom:\"\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@type\"\n ], :select_result_value => true)\n end\n unless link_object.type.nil?\n link_object.type = link_object.type.downcase\n end\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:title\",\n \"@atom03:title\",\n \"@atom:title\",\n \"@title\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.title == \"atom10:\" ||\n link_object.title == \"atom03:\" ||\n link_object.title == \"atom:\"\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@title\"\n ], :select_result_value => true)\n end\n # This catches the ambiguities between atom, rss, and cdf\n if link_object.title == link_object.href\n link_object.title = nil\n end\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:length\",\n \"@atom03:length\",\n \"@atom:length\",\n \"@length\"\n ], :select_result_value => true)\n if link_object.length == \"atom10:\" ||\n link_object.length == \"atom03:\" ||\n link_object.length == \"atom:\"\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@length\"\n ], :select_result_value => true)\n end\n if !link_object.length.nil?\n link_object.length = link_object.length.to_i\n else\n if !link_object.type.nil? && link_object.type[0..4] != \"text\" &&\n link_object.type[-3..-1] != \"xml\" &&\n link_object.href =~ /^http:\\/\\//\n # Retrieve the length with an http HEAD request\n else\n link_object.length = nil\n end\n end\n @links = [] if @links.nil?\n @links << link_object\n end\n end\n return @links\n end",
"def links\n linked_to.map{|to|[self,to]}\n end",
"def gather_urls_and_texts(source)\n toc_md = fs.read(source)\n base_node = get_html(toc_md).css('html')\n\n nav_items(base_node).map do |element|\n href = element['href']\n expanded_href = (source.dirname + href).relative_path_from(source_for_site_gen)\n next_source = absolute_source_from_path(expanded_href)\n\n raise SubnavBrokenLinkError.new(<<-ERROR) unless next_source\nBroken link found in subnav for product_id: #{config.id}\n\nLink: #{expanded_href}\nSource file: #{source}\n ERROR\n raise SubnavDuplicateLinkError.new(<<-ERROR) if @parsed_files.has_key?(next_source)\n)\nDuplicate link found in subnav for product_id: #{config.id}\n\nLink: #{expanded_href}\nOriginal file: #{@parsed_files[next_source]}\nCurrent file: #{source}\n ERROR\n\n @parsed_files[next_source] = source\n nested_urls_and_texts = gather_urls_and_texts(next_source)\n nested_links = {}\n nested_links.merge!(nestedLinks: nested_urls_and_texts) unless nested_urls_and_texts.empty?\n\n {url: '/' + expanded_href.to_s, text: element.inner_text}.merge(nested_links)\n end\n end",
"def links(data)\n\tlinks =\n\t\tdata.collect do |course, deps|\n\t\t\tdeps.collect do |dependency|\n\t\t\t\t[course, dependency]\n\t\t\tend\n\t\tend\n\tlinks =\n\t\tlinks.flatten(1).collect do |course, dependency|\n\t\t\t{\n\t\t\t\t'source' => dependency,\n\t\t\t\t'target' => course,\n\t\t\t\t'color' => '#3399FF'\n\t\t\t}\n\t\tend\n\t\n\treturn links\nend",
"def build_links(links)\n return [] if links.nil?\n\n links.map { |k, v| HelpScout::Link.new(Util.underscore(k.to_s).to_sym, v[:href]) }\n end",
"def to_s\n ret = build_link\n ret << tree.to_s if tree\n\n ret\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def to_s\n inject([]) { |acc, link| acc << \"[#{link.key}, #{link.val}]\" }.join(\", \")\n end",
"def all_links\n self.fulltext_links + self.non_fulltext_links\n end",
"def flatten\n found = []\n unprocessed = @raw_output.clone\n\n while unprocessed.length > 0\n atom = unprocessed.shift.clone\n\n if atom.respond_to? :keys\n atom.except!(*(atom.keys & LINK_TYPES).each do |key|\n found << { type: key, value: atom[key] }\n end)\n atom.values.each {|value| unprocessed << value if value.respond_to? :to_a }\n else\n unprocessed = unprocessed.concat atom\n end\n end\n\n found\n end",
"def links\n @links ||= parsed_links.map{ |l| URL.absolutify(URL.unrelativize(l, scheme), base_url) }.compact.uniq\n end",
"def links\n data['links']\n end",
"def links_and_their_aliases(page_hash)\n @links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def links_and_their_aliases(page_hash)\n @links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def ensmallen_links\n links = []\n (self.urls + self.media).each do |link|\n links << {\n 'url' => link.url.to_s,\n 'display_url' => link.display_url.to_s,\n 'expanded_url' => link.expanded_url.to_s,\n 'indices' => link.indices\n }\n end\n\n #always sort results, so clients can easily reverse to loop and s//\n links.sort { |x,y| x['indices'][0] <=> y['indices'][0] }\n end",
"def links\n @links ||= parsed_links.map{ |l| absolutify_url(unrelativize_url(l)) }.compact.uniq\n end",
"def links\n typed_set(entities, Occi::Core::Link)\n end",
"def flatten!\n nil\n end",
"def update_paths_linked_to_from_path(document)\n document.domain_specific_paths.each do |url|\n link_uri_path = normalize_path Addressable::URI.parse(url.strip).path\n document_uri_path = normalize_path document.uri.path\n next if link_uri_path == document_uri_path\n\n store_path link_uri_path\n store_path_linked_to_from(link_uri_path, [document_uri_path])\n end\n end",
"def links\n json_hyperschema[\"links\"] || []\n end",
"def all\n @all ||= raw.map { |link| URL.absolutify(link, base_url) }.compact.uniq\n end",
"def links\n links = Hash.new([])\n order = []\n each_with_rescue(@notes) do |note|\n order << note.row\n links[note.row] += [link_helper(note)]\n end\n\n html = ''\n order.uniq!\n order.each do |row|\n html << \"#{row.is_a?(String) ? row : row.to_s.camelize}: #{links[row].join(\" | \\n\")}<br />\"\n end\n html\n end",
"def eds_all_links(options = nil)\n values, opt = extract_config_value(options)\n non_html = rendering_non_html?(opt)\n types = opt.delete(:type)\n result =\n Array.wrap(values).reject(&:blank?).map { |value|\n hash = value.is_a?(Hash) ? value.symbolize_keys : { url: value }\n next unless types.blank? || types.include?(value[:type])\n hash.except(:expires).merge(raw: non_html)\n }.compact\n if non_html\n result.map! { |hash| make_eds_link(**hash) }\n (values.is_a?(Array) || (result.size > 1)) ? result : result.first\n elsif result.present?\n separator = opt[:separator] || \"<br/>\\n\"\n result.map { |hash| make_eds_link(**hash) }.join(separator).html_safe\n else\n return_empty(__method__)\n end\n end",
"def links_and_their_aliases(page_hash)\n links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def flatten!\n # buggerit\n raise NotImplementedError\n end",
"def kramdown_links(links)\n s = ''\n links.each_with_index do |(key, value), index|\n s += \"#{index + 1}. [#{key}](#{value}){:target=\\\\\\\"_blank\\\\\\\"}{:rel=\\\\\\\"noopener\\\\\\\"}\\n\\n\"\n end\n s += '\n\n\"'\nend",
"def resolve_all_links()\n @links.each_value { |lnk|\n set_link_target(lnk) if lnk.target.nil?\n }\n end"
] |
[
"0.64987916",
"0.6374803",
"0.62614495",
"0.6160253",
"0.6079002",
"0.5951829",
"0.59395635",
"0.58430517",
"0.57470155",
"0.55781007",
"0.5577545",
"0.55084294",
"0.5495729",
"0.5456861",
"0.5456288",
"0.5436947",
"0.54067767",
"0.5398912",
"0.539842",
"0.5397416",
"0.53751856",
"0.5340001",
"0.5338319",
"0.53365856",
"0.5333962",
"0.5320884",
"0.53133774",
"0.5308526",
"0.53055",
"0.5295413",
"0.5291251",
"0.52771044",
"0.5268297",
"0.5244456",
"0.52232057",
"0.52190465",
"0.52116185",
"0.5186018",
"0.5164611",
"0.51504654",
"0.51419985",
"0.5132411",
"0.51305157",
"0.51091945",
"0.50953025",
"0.5083048",
"0.5078432",
"0.5069991",
"0.5062419",
"0.5054355",
"0.50414836",
"0.504125",
"0.50188094",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50178796",
"0.50144595",
"0.5008476",
"0.50004756",
"0.49985698",
"0.4997881",
"0.4997881",
"0.4992381",
"0.49911097",
"0.49909273",
"0.49848682",
"0.4983949",
"0.49833673",
"0.49828076",
"0.4977613",
"0.49738425",
"0.49674776",
"0.49562934",
"0.49503398",
"0.49489856"
] |
0.52297366
|
35
|
Shortcut to I18n::Backend::Flatten.normalize_flat_keys and then resolve_links. source://i18n//lib/i18n/backend/flatten.rb44
|
def normalize_flat_keys(locale, key, scope, separator); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def normalize_links!\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\n end",
"def flatten_translations(locale, data, escape, subtree); end",
"def normalize_links\n @links.map! do |link|\n relationship = case link\n when Symbol, String then @relationships[link]\n when Associations::Relationship then link\n end\n\n if relationship.respond_to?(:links)\n relationship.links\n else\n relationship\n end\n end\n\n @links.flatten!\n @links.uniq!\n end",
"def normalize_links\n if @normalizer\n @links = LinkNormalizer.new(@links).normalized_links\n end\n end",
"def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def flatten() end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def flatten!() end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def flatten_hash(hash)\n hash.each_with_object({}) do |(key, value), new_object|\n # hash\n if value.is_a? Hash\n reflatten(key, value, new_object)\n # array of hashes\n elsif value.is_a?(Array) && value.first.is_a?(Hash)\n value.each do |val|\n reflatten(key, val, new_object)\n end\n # array of ids - this is associated models\n elsif value.is_a?(Array) && !value.empty?\n set_key_value(key, value, new_object)\n # already flat\n else\n set_key_value(key, value, new_object)\n end\n end\n end",
"def test_flatten_link\r\n link = @link_list.add_link(@measure, @perfind) \r\n assert_equal( { \"from_id\"=>1, \"to_id\"=>2 },\r\n link.flatten_data)\r\n end",
"def reconstruct flat_hash\n flat_hash.inject({}) do |result, (key, value)|\n # Build the nested hash for a single key/value pair\n hash = key.split(\".\").reverse.inject(value) do |r, e|\n { e => r }\n end\n\n result.deep_merge(hash)\n end\nend",
"def test_unflatten_link\r\n link = @link_list.add_link(@perfind, @proc) \r\n \r\n data = link.flatten_data\r\n \r\n @link_list.remove_link(link)\r\n \r\n livelink = @link_list.link_from_data(data)\r\n \r\n assert_equal(link.from, livelink.from) \r\n assert_equal(link.to, livelink.to) \r\n end",
"def _flatten(data, recursive_key = '')\n data.each_with_object({}) do |(k, v), ret|\n key = recursive_key + k.to_s\n key = key.gsub(/[^a-zA-Z]/, '_')\n begin\n if v.is_a? Hash\n ret.merge! _flatten(v, key + '_')\n elsif v.is_a? Array\n v.each do |x|\n if x.is_a? String\n ret[key] = v.join(',')\n else \n ret.merge! _flatten(x, key + '_')\n end\n end\n else\n ret[key] = v\n end\n rescue\n pp [v, v.class, v.size, v.length, v.empty?]\n end\n end\nend",
"def my_flatten!\n self.replace(my_flatten)\n end",
"def test_Hash_InstanceMethods_flatten\n\t\th = { feline:[\"felix\", \"tom\"], equine:\"ed\" }\n\t\tassert_equal([:feline, [\"felix\",\"tom\"], :equine, \"ed\"], h.flatten)\n\t\tassert_equal([:feline, [\"felix\",\"tom\"], :equine, \"ed\"], h.flatten(1))\n\t\tassert_equal([:feline, \"felix\",\"tom\", :equine, \"ed\"], h.flatten(2))\n\tend",
"def dn_flatten hash, ancestor=[ ]\n result = { }\n for key,value in hash\n present = ancestor + [key]\n if value.is_a? Hash and !value.empty?\n result.merge! dn_flatten value, present\n else\n result.merge! present.join('.') => value\n end\n end\n result\n end",
"def myflatten(target, prefix, value)\n if value.kind_of?(Hash) == false\n target[prefix] = value\n return\n else\n value.each do |k, v|\n if (prefix.empty?)\n myflatten(target, prefix + k, v)\n else\n myflatten(target, prefix + '.' + k, v)\n end\n end\n end\nend",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def flatten!\n self.replace(flatten)\n end",
"def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def hash_flatten prefix, value\n if value.is_a? Hash\n value.flat_map do |k, v|\n key = prefix.empty? ? k : [prefix, k].join('.')\n hash_flatten(key, v)\n end\n else\n [[prefix, value]]\n end\nend",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def normalize_fields!\n # TODO: normalize Array of Symbol, String or DM::Property\n\n # TODO: loop over fields, and if the resource doesn't match\n # self.resource, append the property's resource to @links\n # eg:\n #if property.resource != self.resource\n # @links << discover_path_for_property(property)\n #end\n end",
"def translatable_items_links\n AvailableLocale.translatables.map do |t|\n translatable_links(t)\n end.join.html_safe\n end",
"def flatten\n found = []\n unprocessed = @raw_output.clone\n\n while unprocessed.length > 0\n atom = unprocessed.shift.clone\n\n if atom.respond_to? :keys\n atom.except!(*(atom.keys & LINK_TYPES).each do |key|\n found << { type: key, value: atom[key] }\n end)\n atom.values.each {|value| unprocessed << value if value.respond_to? :to_a }\n else\n unprocessed = unprocessed.concat atom\n end\n end\n\n found\n end",
"def to_flat include_key=true\n if include_key.is_a? Proc\n sort_key = include_key.call(self)\n elsif include_key && respond_to?(:key)\n sort_key = [self.class.resource_name, key].flatten.join(\"-\")\n else\n sort_key = self.class.resource_name\n end\n [sort_key, *to_a.map(&:to_flat)]\n end",
"def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end",
"def expand_keys(key)\n key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, k|\n keys << [keys.last, k].compact.join(FLATTEN_SEPARATOR)\n end\n end",
"def flatten(prefix=nil, target={})\n keys.each do |key|\n next unless entry = self[key]\n\n key = key.to_s\n key = File.join(prefix, key) if prefix\n\n if entry.kind_of?(Tree)\n entry.flatten(key, target)\n else\n target[key] = entry\n end\n end\n\n target\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def flattenize(replacements = nil)\n replace = replacements || Louisville::StringExtensions.pre_ascii_replacements\n Louisville::StringExtensions.downcase(asciify(replace)).gsub(/[^a-z\\s\\d]/, \"\").to_s\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def flatmap(h, e, prefix = '')\n e.each do |k,v|\n if v.is_a?(Hash)\n flatmap(h, v, prefix+k+\"_\")\n else\n if not v.is_a? Array\n if v.is_a? String\n v = v.split.join(' ')\n v = v[0,10000] + ' ...' if v.size > 10000\n end\n\n h[prefix+k] = v\n end\n end\n end\n h\nend",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def hash_flatten(hash, delimiter, prefix = nil, flat = {})\n if hash.is_a? Array then\n hash.each_index do |index|\n newkey = index\n newkey = '%s%s%s' % [prefix, delimiter, newkey] if prefix\n val = hash[index]\n hash_flatten val, delimiter, newkey, flat\n end\n elsif hash.is_a? Hash then\n hash.keys.each do |key|\n newkey = key\n newkey = '%s%s%s' % [prefix, delimiter, key] if prefix\n val = hash[key]\n hash_flatten val, delimiter, newkey, flat\n end\n else\n flat[prefix] = hash\n end\n\n return flat\nend",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def flatten\n\t\t\treturn @root.generate_from(@substitutions).join('\\n')\n\t\tend",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def flatten(object, flattened = {}, prefix = \"\")\n handleValue = lambda do |value, newPrefix|\n if value.is_a?(Hash) || value.is_a?(Array)\n # recurse!\n flatten(value, flattened, newPrefix + @options[:nestedDelimiter])\n else\n flattened[newPrefix] = value\n end\n end\n\n if object.is_a? Hash\n object.each do |key, value|\n handleValue.call(value, prefix + key)\n end\n elsif object.is_a? Array\n object.each_with_index do |value, index|\n handleValue.call(value, prefix + index.to_s)\n end\n else\n return object\n end\n\n return flattened\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_keys_recursively!(object); end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def flatten(source)\n source.each_with_object({}) do |(key, value), sink|\n if value.is_a? String\n sink[key] = value\n else\n flatten(value).each do |k, v|\n new_key = k.start_with?(/\\d/) ? \"#{key}#{k}\" : \"#{key}.#{k}\"\n sink[new_key] = v\n end\n end\n end\n end",
"def replace_with_translation_keys(model_errors)\n return model_errors if internationalized?\n deep_translation_replace(model_errors)\n end",
"def keys_flat(body)\n if body.class == Hash\n arr = []\n body.each do |key, value|\n arr << \"#{keys_flat key}=>#{keys_flat value}\"\n end\n body = arr\n end\n if body.class == Array\n str = ''\n body.map! do |value|\n keys_flat value\n end.sort!.each do |value|\n str << value\n end\n end\n if body.class != String\n body = body.to_s << body.class.to_s\n end\n body\n end",
"def deep_stringify_keys\n deep_transform_keys { |key| key.to_s }\n end",
"def lookup_chain = locale(true).lookup",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end",
"def normalize_to_list!(obj, key, nested_key: ActiveSupport::Inflector.singularize(key))\n if obj[key].is_a?(Hash)\n if obj[key][nested_key].is_a?(Hash)\n obj[key] = [obj[key][nested_key]]\n else\n obj[key] = obj[key][nested_key]\n end\n elsif obj[key].is_a?(String)\n obj[key] = []\n end\n end",
"def transform_keys(&block); end",
"def normalize_cache_key(key)\n if key.is_a?(Array)\n key.map { |part| normalize_cache_key(part) }.join('/')\n else\n key.to_s\n end\n end",
"def unflatten_data_hash(flat_json_data_hash)\n\t\tnew_hash = unflatten_hash(flat_json_data_hash)\n\t\tnew_hash.deep_stringify_keys!\n\tend",
"def flatten!\n nil\n end",
"def flatten data\n result = ''\n if data.kind_of? Hash\n data.each do |key, val|\n val = Oaf::Util.flatten val if not val.kind_of? String\n result += \"#{key}#{val}\"\n end\n elsif data.kind_of? Array\n data.each do |item|\n item = Oaf::Util.flatten item if not item.kind_of? String\n result += item\n end\n elsif data.kind_of? String\n result = data\n else\n result = ''\n end\n result\n end",
"def expand\n map { |p| p&.flatten || p }.flatten\n end",
"def denormalize(key)\n @key_strings[normalize(key)] || key\n end",
"def flatten!\n # buggerit\n raise NotImplementedError\n end",
"def transform_keys!(&block); end",
"def top_level_links\n links = @options.fetch(:base_links, {})\n\n links.merge!(@operation_results.links)\n\n @operation_results.results.each do |result|\n links.merge!(result.links)\n\n # Build pagination links\n if result.is_a?(JSONAPI::ResourcesOperationResult) || result.is_a?(JSONAPI::RelatedResourcesOperationResult)\n result.pagination_params.each_pair do |link_name, params|\n if result.is_a?(JSONAPI::RelatedResourcesOperationResult)\n relationship = result.source_resource.class._relationships[result._type.to_sym]\n links[link_name] = @serializer.link_builder.relationships_related_link(result.source_resource, relationship, query_params(params))\n else\n links[link_name] = @serializer.query_link(query_params(params))\n end\n end\n end\n end\n\n links.deep_transform_keys { |key| @key_formatter.format(key) }\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def deep_convert_keys(&key_conversion_block)\n if (block_given?)\n result={}\n self.each_pair do |k, v|\n case v\n when String, Fixnum then\n result[yield(k)]=v\n when Hash then\n result[yield(k)]=v.deep_convert_keys(&key_conversion_block)\n when Array then\n result[yield(k)]=v.collect { |a| a.deep_convert_keys(&key_conversion_block) }\n when NilClass then\n result[yield(k)]=\"NIL\"\n else\n raise ArgumentError, \"Unhandled type #{v.class}\"\n end\n end\n return result\n end\n return self # return self if no key conversion block was given to this method\n end",
"def uri_normalizer; end",
"def deep_underscore_keys\n deep_transform_keys { |key| key.to_s.underscore }\n end",
"def normalize\n inject({}) do |hash, kv|\n k, v = kv\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n hash[k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join] = v\n hash\n end\n end",
"def flatten_deeper(array)\n array.collect do |element|\n (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element\n end.flatten\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def flatten\n raise\n end",
"def _deep_transform_keys_in_object(object, &block)\n if object.class <= ::Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n elsif object.class <= ::Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def flatten(value)\n if value.is_a?(Array)\n value.flatten.map{ |v| flatten(v) }\n elsif value.is_a?(Hash)\n value.to_a.sort_by do |k| \n k[0].to_s\n end.map { |v| flatten(v) }.flatten\n else\n value.to_s\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def resolve_all(key, &block)\n map do |hash|\n hash = hash.dup\n hash[key] = hash[key].resolve(&block)\n hash\n end\n end",
"def stringify_keys_recursively!(object); end",
"def unwrap_links(elements); end"
] |
[
"0.6134193",
"0.60334873",
"0.598983",
"0.59615266",
"0.56846285",
"0.5613128",
"0.5611419",
"0.5534217",
"0.55025566",
"0.54849684",
"0.5479207",
"0.5479207",
"0.5437252",
"0.54320985",
"0.53847706",
"0.5365686",
"0.53631747",
"0.53597885",
"0.5337433",
"0.53102684",
"0.53005683",
"0.53002197",
"0.5299018",
"0.5297868",
"0.52968687",
"0.5296757",
"0.5296757",
"0.5296757",
"0.5296757",
"0.52767545",
"0.52620846",
"0.52127707",
"0.5161055",
"0.51465285",
"0.51463085",
"0.5137423",
"0.5135114",
"0.5133773",
"0.5130186",
"0.5124791",
"0.51175416",
"0.5114693",
"0.511221",
"0.511221",
"0.51000124",
"0.51000124",
"0.51000124",
"0.508694",
"0.5081668",
"0.50785077",
"0.50770074",
"0.5062159",
"0.5062159",
"0.5058547",
"0.50492907",
"0.5046681",
"0.5044672",
"0.5044193",
"0.5030511",
"0.5030511",
"0.5030511",
"0.5030511",
"0.5029461",
"0.5025798",
"0.5011264",
"0.5004971",
"0.4983844",
"0.49702847",
"0.4967195",
"0.49637568",
"0.49632096",
"0.49496198",
"0.49441636",
"0.49281192",
"0.49127296",
"0.49041167",
"0.48966363",
"0.48743916",
"0.48640323",
"0.48633477",
"0.48599294",
"0.4856393",
"0.48504186",
"0.48450536",
"0.48169383",
"0.4815135",
"0.4805395",
"0.47978762",
"0.4789321",
"0.47839928",
"0.47738862",
"0.47695625",
"0.47653884",
"0.4762248",
"0.4760475",
"0.47547835",
"0.47452885",
"0.47330585",
"0.4728574"
] |
0.685187
|
1
|
normalize_keys the flatten way. This method is significantly faster and creates way less objects than the one at I18n.normalize_keys. It also handles escaping the translation keys. source://i18n//lib/i18n/backend/flatten.rb20
|
def normalize_flat_keys(locale, key, scope, separator); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def normalize_keys(hash)\n hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)|\n new_hash[key.parameterize(separator: \"_\")] = value\n new_hash\n end\n end",
"def normalize\n inject({}) do |hash, kv|\n k, v = kv\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n hash[k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join] = v\n hash\n end\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def normalize_keys\n transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def deep_camelize_keys!(first_letter = :upper)\n deep_transform_keys! { |key| key.to_s.camelize(first_letter) rescue key }\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def flatten_translations(locale, data, escape, subtree); end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def _flatten(data, recursive_key = '')\n data.each_with_object({}) do |(k, v), ret|\n key = recursive_key + k.to_s\n key = key.gsub(/[^a-zA-Z]/, '_')\n begin\n if v.is_a? Hash\n ret.merge! _flatten(v, key + '_')\n elsif v.is_a? Array\n v.each do |x|\n if x.is_a? String\n ret[key] = v.join(',')\n else \n ret.merge! _flatten(x, key + '_')\n end\n end\n else\n ret[key] = v\n end\n rescue\n pp [v, v.class, v.size, v.length, v.empty?]\n end\n end\nend",
"def transform_keys!(&block); end",
"def deep_stringify_keys\n deep_transform_keys { |key| key.to_s }\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def transform_keys(&block); end",
"def keys_flat(body)\n if body.class == Hash\n arr = []\n body.each do |key, value|\n arr << \"#{keys_flat key}=>#{keys_flat value}\"\n end\n body = arr\n end\n if body.class == Array\n str = ''\n body.map! do |value|\n keys_flat value\n end.sort!.each do |value|\n str << value\n end\n end\n if body.class != String\n body = body.to_s << body.class.to_s\n end\n body\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end",
"def expand_keys(key)\n key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, k|\n keys << [keys.last, k].compact.join(FLATTEN_SEPARATOR)\n end\n end",
"def deep_underscore_keys\n deep_transform_keys { |key| key.to_s.underscore }\n end",
"def keys_to_s!(recursive: true)\n replace(keys_to_s(recursive: recursive))\n end",
"def stringify_keys\n transform_keys { |key| key.to_s rescue key }\n end",
"def normalize_keys(hash)\n hash.each{|k, v|\n hash.delete(k) unless @@valid_types.include?(v.class)\n if k.is_a?(String)\n hash.delete(k)\n hash[k.gsub(/\\-/, \"_\").to_sym] = v\n elsif !k.is_a?(Symbol) # elsunless\n hash.delete(k)\n end\n }\n return hash\nend",
"def keys_to_sym clean: false\n self.inject({}){|memo,(k,v)| memo[clean ? k.to_s.to_clean_sym : k.to_s.to_sym] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_sym(clean:clean) : v); memo}\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def normalize_language_keys(options)\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n current.keys.each do |language|\n current[language.to_s] = current.delete(language)\n end\n end\n\n options\n end",
"def normalize_language_keys(options)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n current.keys.each do |language|\n current[language.to_s] = current.delete(language)\n end\n end\n\n options\n end",
"def munge_keys d\n\t\t\t\tif d.kind_of? Array\n\t\t\t\t\td.each do |o|\n\n\t\t\t\t\t\tnext if explicit_keys(o) && explicit_customer_key(o)\n\n\t\t\t\t\t\tformatted = []\n\t\t\t\t\t\to['CustomerKey'] = customer_key unless explicit_customer_key o\n\t\t\t\t\t\tunless explicit_properties(o)\n\t\t\t\t\t\t\to.each do |k, v|\n\t\t\t\t\t\t\t\tnext if k == 'CustomerKey'\n\t\t\t\t\t\t\t\tformatted.concat FuelSDK.format_name_value_pairs k => v\n\t\t\t\t\t\t\t\to.delete k\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\to['Keys'] = {'Key' => formatted }\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tformatted = []\n\t\t\t\t\td.each do |k, v|\n\t\t\t\t\t\tnext if k == 'CustomerKey'\n\t\t\t\t\t\tformatted.concat FuelSDK.format_name_value_pairs k => v\n\t\t\t\t\t\td.delete k\n\t\t\t\t\tend\n\t\t\t\t\td['CustomerKey'] = customer_key\n\t\t\t\t\td['Keys'] = {'Key' => formatted }\n\t\t\t\tend\n\t\t\tend",
"def stringify_keys_recursively!(object); end",
"def stringify_keys!\n transform_keys!{ |key| key.to_s }\n end",
"def denormalize(key)\n @key_strings[normalize(key)] || key\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def reconstruct flat_hash\n flat_hash.inject({}) do |result, (key, value)|\n # Build the nested hash for a single key/value pair\n hash = key.split(\".\").reverse.inject(value) do |r, e|\n { e => r }\n end\n\n result.deep_merge(hash)\n end\nend",
"def normalize_key(key)\n KEY_NORMALIZER.call(key)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def normalize(hash)\n hash.symbolize_keys if hash\n end",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def normalize_to_list!(obj, key, nested_key: ActiveSupport::Inflector.singularize(key))\n if obj[key].is_a?(Hash)\n if obj[key][nested_key].is_a?(Hash)\n obj[key] = [obj[key][nested_key]]\n else\n obj[key] = obj[key][nested_key]\n end\n elsif obj[key].is_a?(String)\n obj[key] = []\n end\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def sanitize_keys(hash)\n new_hash = Hash.new\n hash.each do |key,value|\n sanitized_key = key.downcase.tr(\" \", \"_\")\n\n if value.is_a? Hash\n new_hash[sanitized_key] = sanitize_keys(value)\n else\n new_hash[sanitized_key] = value\n end\n end\n return new_hash\n end",
"def normalize_key(key)\n self.class.normalize_key(key)\n end",
"def replace_with_translation_keys(model_errors)\n return model_errors if internationalized?\n deep_translation_replace(model_errors)\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def flatten(source)\n source.each_with_object({}) do |(key, value), sink|\n if value.is_a? String\n sink[key] = value\n else\n flatten(value).each do |k, v|\n new_key = k.start_with?(/\\d/) ? \"#{key}#{k}\" : \"#{key}.#{k}\"\n sink[new_key] = v\n end\n end\n end\n end",
"def deep_convert_keys(&key_conversion_block)\n if (block_given?)\n result={}\n self.each_pair do |k, v|\n case v\n when String, Fixnum then\n result[yield(k)]=v\n when Hash then\n result[yield(k)]=v.deep_convert_keys(&key_conversion_block)\n when Array then\n result[yield(k)]=v.collect { |a| a.deep_convert_keys(&key_conversion_block) }\n when NilClass then\n result[yield(k)]=\"NIL\"\n else\n raise ArgumentError, \"Unhandled type #{v.class}\"\n end\n end\n return result\n end\n return self # return self if no key conversion block was given to this method\n end",
"def dasherize_keys(data)\n return nil if data.nil?\n return data.map { |obj| dasherize_keys obj } if data.is_a? Array\n if data.is_a? Hash\n return Hash[data.map {|k, v| [k.to_s.dasherize, dasherize_keys(v)] }]\n end\n return data\n end",
"def keys_to_sym!(clean: false, recursive: true)\n replace(keys_to_sym(clean: clean, recursive: recursive))\n end",
"def simplify_key_value_list(elements)\n # remove everything form right to left till the double unerline\n elements.each do |element|\n element.keyValueList.transform_keys! do |key|\n index = key.index('__')\n if !index.nil?\n key.slice(index + 2, key.length)\n else\n key\n end\n end\n end\n end",
"def _squish(hash)\n hash = _flatten(hash)\n hash.each_with_object({}) do |(k, v), ret|\n k = k.gsub(/extensions|com|instructure|canvas/, '').gsub(/_+/, '_').gsub(/^_/, '').downcase\n ret[k] = v\n end\nend",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def dasherize_keys(hash)\n hash.deep_transform_keys do |key|\n key.to_s.dasherize\n end\n end",
"def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def stringify_keys!\n keys.each{|k| \n v = delete(k)\n self[k.to_s] = v\n v.stringify_keys! if v.is_a?(Hash)\n v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array)\n }\n self\n end",
"def sanitize_keys(value)\n if value.is_a?(Hash)\n value.map { |k, v|\n k = k.to_s.downcase.tr('^a-z0-9_', '_').to_sym\n v = sanitize_keys(v)\n [k, v]\n }.to_h\n elsif value.is_a?(Array) && (value.size > 1)\n value.map { |v| sanitize_keys(v) }\n elsif value.is_a?(Array)\n sanitize_keys(value.first)\n elsif value.is_a?(String) && value.include?(FileFormat::FILE_FORMAT_SEP)\n value.split(FileFormat::FILE_FORMAT_SEP).compact_blank\n else\n value\n end\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def flatten_hash(hash)\n hash.each_with_object({}) do |(key, value), new_object|\n # hash\n if value.is_a? Hash\n reflatten(key, value, new_object)\n # array of hashes\n elsif value.is_a?(Array) && value.first.is_a?(Hash)\n value.each do |val|\n reflatten(key, val, new_object)\n end\n # array of ids - this is associated models\n elsif value.is_a?(Array) && !value.empty?\n set_key_value(key, value, new_object)\n # already flat\n else\n set_key_value(key, value, new_object)\n end\n end\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def normalize_key(key)\n keys = split_key(key)\n if (keys[0] =~ /HKLM|HKEY_LOCAL_MACHINE/)\n keys[0] = 'HKEY_LOCAL_MACHINE'\n elsif (keys[0] =~ /HKCU|HKEY_CURRENT_USER/)\n keys[0] = 'HKEY_CURRENT_USER'\n elsif (keys[0] =~ /HKU|HKEY_USERS/)\n keys[0] = 'HKEY_USERS'\n elsif (keys[0] =~ /HKCR|HKEY_CLASSES_ROOT/)\n keys[0] = 'HKEY_CLASSES_ROOT'\n elsif (keys[0] =~ /HKCC|HKEY_CURRENT_CONFIG/)\n keys[0] = 'HKEY_CURRENT_CONFIG'\n elsif (keys[0] =~ /HKPD|HKEY_PERFORMANCE_DATA/)\n keys[0] = 'HKEY_PERFORMANCE_DATA'\n elsif (keys[0] =~ /HKDD|HKEY_DYN_DATA/)\n keys[0] = 'HKEY_DYN_DATA'\n else\n raise ArgumentError, \"Cannot normalize unknown key: #{key}\"\n end\n print_status(\"Normalized #{key} to #{keys.join(\"\\\\\")}\") if $blab\n return keys.join(\"\\\\\")\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def normalize_fields\n new_fields = CICPHash.new\n fields.each do |key, value|\n new_fields[key] = ApeItem.create(key, value).normalize_encodings\n end\n @fields = new_fields\n end",
"def normalize_keys(hash, method = :to_s)\n hash = hash.dup\n hash.keys.each do |k|\n normalized_key = k.respond_to?(method) ? k.send(method) : k\n hash[normalized_key] = hash.delete(k)\n end\n hash\n end",
"def stringify_keys!\n replace stringify_keys\n end",
"def flatmap(h, e, prefix = '')\n e.each do |k,v|\n if v.is_a?(Hash)\n flatmap(h, v, prefix+k+\"_\")\n else\n if not v.is_a? Array\n if v.is_a? String\n v = v.split.join(' ')\n v = v[0,10000] + ' ...' if v.size > 10000\n end\n\n h[prefix+k] = v\n end\n end\n end\n h\nend",
"def transform_params\n params.transform_keys! { |key| key.underscore }\n end",
"def transform_keys!\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def symbolize_keys_recursively!(object); end"
] |
[
"0.7088645",
"0.69359946",
"0.6900623",
"0.687252",
"0.66158926",
"0.6584695",
"0.64313006",
"0.64258945",
"0.6407195",
"0.63808405",
"0.6367964",
"0.6353864",
"0.6283611",
"0.6254634",
"0.62532336",
"0.62529534",
"0.6252492",
"0.6250688",
"0.6248819",
"0.6235353",
"0.6200009",
"0.61985093",
"0.61985093",
"0.61873585",
"0.61873585",
"0.61579794",
"0.61579794",
"0.61579794",
"0.61550593",
"0.61550593",
"0.6137952",
"0.6137952",
"0.6137952",
"0.6137952",
"0.6128263",
"0.6089824",
"0.6074161",
"0.60674345",
"0.6049559",
"0.60455745",
"0.60413826",
"0.6034008",
"0.6026462",
"0.60200673",
"0.6004924",
"0.59957844",
"0.59812826",
"0.5970629",
"0.59603465",
"0.59298104",
"0.59058344",
"0.589527",
"0.58836424",
"0.58550453",
"0.58405334",
"0.5831634",
"0.5830508",
"0.5807977",
"0.579384",
"0.5792856",
"0.5787553",
"0.57597035",
"0.5756985",
"0.5744844",
"0.57198477",
"0.57198477",
"0.57198477",
"0.57053334",
"0.5692611",
"0.5692611",
"0.56807375",
"0.56442386",
"0.5630357",
"0.56104994",
"0.5606362",
"0.5605215",
"0.5590571",
"0.5580122",
"0.55658346",
"0.55603325",
"0.5547172",
"0.5533874",
"0.5527072",
"0.55265737",
"0.55188644",
"0.5510009",
"0.5489923",
"0.5485794",
"0.5481067",
"0.5481067",
"0.54753995",
"0.54679996",
"0.5466",
"0.5462474",
"0.5459208",
"0.5453986",
"0.5442518",
"0.5439236",
"0.5431612"
] |
0.7964173
|
0
|
Returns the value of attribute store. source://i18n//lib/i18n/backend/key_value.rb71
|
def store; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def value\n attributes.fetch(:value)\n end",
"def value\n @attributes[:value]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def get_value(key)\n self[key]\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def value\n self['value']\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def value\n @property_hash[:value]\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def value\n record.send(name).value\n end",
"def get_value(attribute_id)\n get_custom_value_hash\n return @custom_value_hash[attribute_id]\n end",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def value\n attributes['FieldValue']\n end",
"def value\n self[@name]\n end",
"def get_item_value(key)\n @attributes[key] = get_item_record(key) unless @attributes.has_key?(key)\n @attributes[key]\n end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def get_value\n read_attribute('text_value')\n end",
"def get\n @value\n end",
"def _read_attribute(key); end",
"def get_value name\n get name\n end",
"def get_value\n value\n end",
"def get_value\n value\n end",
"def value(key)\n @hash[key]\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def value(context)\n context[@value]\n end",
"def value\n YAML::load(self[:value])\n end",
"def value\n YAML::load(self[:value])\n end",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def get_value\n @value\n end",
"def value(key = :value)\n @record.send key\n end",
"def get(value)\n value\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def get\n data[\"_value\"]\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\r\n @value\r\n end",
"def value_for(resource)\n resource.send(key)\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def variable_value(key)\n 'value'\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n value = nil\n quoted_string29 = nil\n number30 = nil\n\n begin\n # at line 125:35: ( quoted_string | number )\n # at line 125:35: ( quoted_string | number )\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == QUOTE )\n alt_43 = 1\n elsif ( look_43_0 == DIGIT )\n alt_43 = 2\n else\n raise NoViableAlternative( \"\", 43, 0 )\n end\n case alt_43\n when 1\n # at line 125:37: quoted_string\n @state.following.push( TOKENS_FOLLOWING_quoted_string_IN_attribute_value_1234 )\n quoted_string29 = quoted_string\n @state.following.pop\n # --> action\n value = quoted_string29 \n # <-- action\n\n when 2\n # at line 125:85: number\n @state.following.push( TOKENS_FOLLOWING_number_IN_attribute_value_1240 )\n number30 = number\n @state.following.pop\n # --> action\n value = ( number30 && @input.to_s( number30.start, number30.stop ) ).to_i \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return value\n end",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def [](key)\n attributes[key]\n end",
"def value\r\n \tbase_value = read_attribute('value')\r\n \t#\r\n \tif ! base_value.nil?\r\n \treturn YAML::load(base_value)\r\n end\r\n return nil\r\n\tend",
"def get\n val\n end",
"def get\n val\n end",
"def value\n Array.wrap(\n if respond_to?(\"#{@attribute}_value\".to_sym)\n send(\"#{@attribute}_value\".to_sym)\n else\n @value\n end\n )\n end",
"def value\n YAML::load(self[:value])\n end",
"def key\n attributes[:key]\n end",
"def [](key)\n @store[key]\n end",
"def value\n return @value\n end",
"def value\n return @value\n end",
"def value\n return @value\n end",
"def get_value\n @value \n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def valGetter\n \"#{DataMetaDom.getterName(@fld)}()\" + ( isMapping ? '.getKey()' : '')\n end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def value\n return @children['value'][:value]\n end",
"def localized_dynamic_attribute_value(field)\n if field.is_a?(String)\n field = self.content_type.find_field(field)\n end\n\n return nil if field.nil?\n\n value = (self.dynamic_attributes || {})[field.name.to_sym]\n\n # DEBUG puts \"[#{field.name.inspect}] #{value.inspect} / #{field.localized.inspect} / #{value.is_a?(Hash).inspect}\"\n\n if !field.is_relationship? && field.localized && value.is_a?(Hash)\n # get the localized value for the current locale\n _value = value[Locomotive::Mounter.locale]\n\n # no value for the current locale, give a try to the main one\n if _value.nil? && Locomotive::Mounter.locale != self.main_locale\n _value = value[self.main_locale]\n end\n\n value = _value\n end\n\n value # DEBUG .tap { |v| puts \"[#{field.name}] returning #{v.inspect}\" }\n end",
"def value\n parsed_value\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def [](key)\n @attributes.get(key)\n end",
"def get(key)\n \n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def _get(key)\r\n\t\treturn _get_with_connection(@connection, @store_name, key, true)\r\n end",
"def get_value val=nil\n if @klass == 'String'\n return @value\n elsif @klass == 'Hash'\n return @value[val]\n elsif @klass == 'Array'\n return @value[val]\n else\n return @value\n end\n end",
"def fetch_value( oid, key )\n\t\toid = normalize_oid( oid )\n\t\tkey = normalize_key( key )\n\t\tdata = @storage[ oid ] or return nil\n\n\t\treturn data[ key ]\n\tend",
"def value_for_key(key)\n if respond_to?(key)\n send key\n elsif attributes.include? key\n attributes[key]\n else\n row.send key\n end\n end",
"def get(value)\n case value\n when Symbol\n @values[value]\n when String\n @values[value.to_sym]\n when Integer\n @values[value]\n end\n end",
"def value\n return @val\n end",
"def value \n @value\n end",
"def object_value_from_dynamo_data(dynamo_record)\n dynamo_record[dynamo_attribute_key]\n end",
"def []( attrname )\n\t\tattrsym = attrname.to_sym\n\n\t\tif @values.key?( attrsym )\n\t\t\t# self.log.debug \" value for %p is cached (%p).\" % [ attrname, @values[attrsym] ]\n\t\telse\n\t\t\tself.log.debug \" value for %p is NOT cached.\" % [ attrsym ]\n\t\t\tvalue = self.get_converted_object( attrsym )\n\t\t\tself.log.debug \" converted value is: %p\" % [ value ]\n\t\t\tvalue.freeze if\n\t\t\t\tself.class.freeze_converted_values? &&\n\t\t\t\tvalue.respond_to?( :freeze )\n\t\t\t@values[ attrsym ] = value if value\n\t\tend\n\n\t\treturn @values[ attrsym ]\n\tend",
"def value\n @value ||= extract_value\n end",
"def kwattr_values(attribute_name); end",
"def object_value(dynamo_data)\n dynamo_data[dynamo_attribute_key].send dynamo_attribute_value_type_key\n end",
"def []( key )\n _meta_data[key.to_s]\n end",
"def value\n self.send :\"#{_mapped_value_column}\"\n end",
"def get_value(value) #method\n if is_memory(value)\n @current_context[value]\n else\n digested_value = digest_constant(value)\n if is_number(digested_value)\n get_type(digested_value)\n elsif is_bool(digested_value)\n get_type(digested_value)\n else\n digested_value\n end\n end\n end",
"def [](key_)\n @attributes[key_.to_s]\n end",
"def [](key)\n @attributes[key]\n end",
"def value\n data.value\n end",
"def get_value(render_context)\n return @message.translate(render_context)\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end"
] |
[
"0.7275061",
"0.69266886",
"0.69018704",
"0.66743445",
"0.6652223",
"0.6612008",
"0.65270466",
"0.6488031",
"0.64869785",
"0.6470758",
"0.6448968",
"0.63930184",
"0.63240355",
"0.6313026",
"0.63064104",
"0.6255721",
"0.6224604",
"0.62069124",
"0.619038",
"0.619038",
"0.6177303",
"0.6171127",
"0.6170257",
"0.6132996",
"0.61177444",
"0.61177444",
"0.6112754",
"0.6091652",
"0.6086202",
"0.6079693",
"0.6079693",
"0.6070957",
"0.6067576",
"0.60581374",
"0.6052172",
"0.6032137",
"0.6032137",
"0.602684",
"0.6024007",
"0.60189277",
"0.60005563",
"0.5968594",
"0.5968594",
"0.5965042",
"0.595604",
"0.5955295",
"0.59446436",
"0.5936441",
"0.59306425",
"0.59297955",
"0.59287775",
"0.59264296",
"0.59264296",
"0.5905331",
"0.59008914",
"0.5886097",
"0.58841807",
"0.5870338",
"0.5870338",
"0.5870338",
"0.586798",
"0.5856886",
"0.5856886",
"0.5856886",
"0.5856886",
"0.5856886",
"0.5856886",
"0.5856886",
"0.585197",
"0.58506393",
"0.58506393",
"0.5849461",
"0.5835114",
"0.5835114",
"0.5829191",
"0.58156097",
"0.58102626",
"0.58087695",
"0.58015794",
"0.5800335",
"0.57900155",
"0.5789727",
"0.5788765",
"0.5788482",
"0.578613",
"0.57664907",
"0.5760428",
"0.57574797",
"0.57568616",
"0.5756104",
"0.57509893",
"0.57118696",
"0.5695842",
"0.5692801",
"0.56926244",
"0.5690334",
"0.56900024",
"0.568973",
"0.567739",
"0.5672012",
"0.56706333"
] |
0.0
|
-1
|
Sets the attribute store
|
def store=(_arg0); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def store=(store)\n @store = store\n end",
"def store= store\n super\n\n @attributes .each do |attr| attr.store = store end\n @constants .each do |const| const.store = store end\n @includes .each do |incl| incl.store = store end\n @extends .each do |ext| ext.store = store end\n @method_list.each do |meth| meth.store = store end\n end",
"def set_store\n @store = Store.find(params[:store_id]) if params[:store_id]\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find_by name: (params[:store_name])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.friendly.find(params[:id])\n end",
"def set_store\n @store = current_account.stores.find(params[:id])\n end",
"def set_store\n @store = current_account.stores.find(params[:id])\n end",
"def set_attribute_set\n @attribute_set = AttributeSet.find(params[:id])\n end",
"def store=(store)\n @store = begin\n if store.class < APICache::AbstractStore\n store\n elsif store.class.to_s =~ /Moneta/\n MonetaStore.new(store)\n elsif store.nil?\n nil\n else\n raise ArgumentError, \"Please supply an instance of either a moneta store or a subclass of APICache::AbstractStore\"\n end\n end\n end",
"def store(attr_name, attr_options = {})\n attr_name = attr_name.to_sym\n if attributes.has_key? attr_name\n raise \"You should only call store or key once for #{model.name}##{attr_name}\"\n end\n attributes[attr_name] = DataMiner::Attribute.new self, attr_name, attr_options\n end",
"def store(attr_name, attr_options = {})\n attr_name = attr_name.to_sym\n if attributes.has_key? attr_name\n raise \"You should only call store or key once for #{model.name}##{attr_name}\"\n end\n attributes[attr_name] = DataMiner::Attribute.new self, attr_name, attr_options\n end",
"def set_store\n @store = Store.find(params[:id])\n # @cartridge_array = @store.get_cartridge_array\n end",
"def setStoreAktiveMap(storeName)\n if (storeName == \"NULL\")\n @xmlStoreMap = nil\n else\n @xmlStore[storeName] = @XML\n @xmlStoreMap = storeName\n end\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n @store = Store.find(params[:id])\n end",
"def set_store\n if !params[:store_id].nil?\n @store = Store.find(params[:store_id])\n else\n @store = @item.store\n end\n end",
"def set_store\n @store = current_user.stores.find_by_id(params[:id]) ||\n Store.find_by_id_and_organization_id!(\n params[:id],\n current_user.organizations.map(&:id)\n )\n end",
"def set_store\n\t\t\t@store = Store.includes(stocks: :item).find(params[:id])\n\t\tend",
"def set_store\n @store = Store.friendly.find(params[:id])\n end",
"def set_mstore\n @mstore = Mstore.find(params[:id])\n end",
"def store_attribute(store_name, name, type, **options)\n _define_accessors_methods(store_name, name)\n\n _define_predicate_method(name) if type == :boolean\n\n decorate_attribute_type(store_name, \"typed_accessor_for_#{name}\") do |subtype|\n Type::TypedStore.create_from_type(subtype, name, type, **options)\n end\n\n _prepare_local_stored_attributes(store_name, name)\n end",
"def store= store\n @store = store\n @store.rdoc = self\n end",
"def set_item_store\n @itemstore = ItemStore.find(params[:id])\n end",
"def set_store\n @store = Store.where(id: params[:id]).take\n end",
"def set_store\n @store = Store.find(params[:id])\n @store.books = StoreBook.joins(\"JOIN books ON store_books.book_id = books.id\").where(store_id: params[:id]).select(\"books.*\")\n end",
"def set_store_manager\n @store_manager = StoreManager.find(params[:id])\n end",
"def set_store\n @store = Stock.find(params[:id])\n end",
"def set_admin_store\n @admin_store = Store.find(params[:id])\n end",
"def set_attribute(name, value); end",
"def set attribute, value\n attributes[attribute] = value\n end",
"def edit_store(edited_store)\n store = Store.find(edited_store.uid)\n store.attributes = edited_store.attributes\n store.save!\n end",
"def set_store_item\n @store_item = StoreItem.find(params[:id])\n end",
"def store(store_name, options = {})\n accessors = options.delete(:accessors)\n _orig_store(store_name, options)\n store_accessor(store_name, *accessors) if accessors\n end",
"def attribute_sets=(value)\n @attribute_sets = value\n end",
"def set_storeinfo\n @storeinfo = Storeinfo.find(params[:id])\n end",
"def set_keyword_store\n @keyword_store = KeywordStore.find(params[:id])\n end",
"def attribute_to_set; end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def store name = nil\n name ? @store = name : @store\n end",
"def store_attribute locator, attribute_name, variable_name\r\n command 'storeAttribute', \"#{locator}@#{attribute_name}\", variable_name\r\n end",
"def set_store_area\n @store_area = StoreArea.find(params[:id])\n end",
"def set_store_product\n @store_product = StoreProduct.find(params[:id])\n end",
"def set_book_store\n @book_store = BookStore.find(params[:id])\n end",
"def set_attribute(id, attr)\n\t\t\t@current_context.set_attribute(id, attr)\n\t\tend",
"def set_store_tab\n @store_tab = StoreTab.find(params[:id])\n end",
"def set_attribute(ents, handle, name, value)\n ents.each { |e|\n e.set_attribute(handle, name, value)\n }\n end",
"def set_store_detail\n @store_detail = StoreDetail.find(params[:id])\n end",
"def set_store_add\n @store_add = StoreAdd.find(params[:id])\n end",
"def set_BottleStore\n @bottle_store = BottleStore.find(params[:id])\n end",
"def set(name, type = :string)\n class_name = marshal_class_name(name, type)\n \n fields << {:name => name.to_s, :type => :set}\n class_eval \"def #{name}; @#{name} ||= SetProxy.new(self.store, field_key('#{name}'), Marshal::#{class_name}); end\"\n eval_writer(name)\n end",
"def add_store (regex, store_name, store)\n\n @stores << [ regex, store_name, store]\n\n store.application_context = @application_context \\\n if store.respond_to?(:application_context=)\n end",
"def attribute_set(name, value)\n @dirty[name] = true\n @attributes[:current][name] = value\n end",
"def set_store_book\n @store_book = StoreBook.find(params[:id])\n end",
"def attribute_set(name, value)\n \n name = name.to_sym\n \n if properties.has_key?(name)\n properties[name].set(self, value)\n else\n @metadata[name] = value\n end\n \n end",
"def attribute_set(name, value)\n properties[name].set(self, value)\n end",
"def namespace=(ns) @namespace = @store.namespace = ns; end",
"def a_dbm=(dbm)\n set_dbm(dbm, SYNTH_A)\n end",
"def cert_store=(cert_store); end",
"def cert_store=(cert_store); end",
"def set_store_order\n @store_order = StoreOrder.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_bread_store\n @bread_store = BreadStore.find(params[:id])\n end",
"def set_store_to_visit\n @store_to_visit = StoreToVisit.find(params[:id])\n end",
"def set_attribute(attribute,value,index=0)\n index = normalize_index(index)\n# puts \"<br>SETTING ATTRIBUTE #{attribute}[#{index}]=#{value} [caller: #{trace}]\"\n @attributes[index] ||= {}\n @attributes[index][normalize_attribute(attribute)] = value\n end",
"def store\n @store\n end",
"def store\n @store\n end",
"def set_attributes(attrs)\n @attributes = attrs.to_smash\n true\n end",
"def set_cakestore\n @cakestore = Cakestore.find(params[:id])\n end",
"def with_data_store(data_store)\n reconfigure(configuration.with(data_store: data_store))\n end",
"def trace_store=(*args)\n @trace_store = nil\n @trace_store_opts = args\n end",
"def setAttrib(name,value)\n\t\t@attributes[name] = value\n\tend",
"def set_drug_store\n @drug_store = DrugStore.find(params[:id])\n end",
"def []=(index, value)\n\t\t@store[index] = value\n\tend",
"def initialize(store)\n @store = store\n end",
"def []=(attribute_name, value = nil)\n raise \"Please set the source data set before attempting to set values.\" unless @current_source_data_set\n \n attribute_name = attribute_name.to_sym\n value.strip! if value.kind_of? String\n \n # Are we updating an existing value?\n existing = @attributes[@current_language][attribute_name] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n \n if existing\n\n # An attribute that allows multiple values?\n if existing.kind_of? ManyValues\n # Always clear attribute values before re-adding them\n # That way we add new but remove values.\n existing.clear\n unless value.blank?\n value.split(',').each {|v| existing.add(v)}\n end\n # Single value attribute\n elsif existing.value != value\n existing.source_data_set_id = @current_source_data_set.id\n\n unless value.blank?\n existing.value = value\n existing.changed = true\n else\n existing.value = nil\n existing.deleted = true\n end\n end\n\n elsif !value.blank?\n \n # Look up the attribute to get its details: required, allow_many, data_type.\n attribute_definition = PublicEarth::Db::Attribute.find_by_name(attribute_name.to_s) ||\n PublicEarth::Db::Attribute.find_by_name!(attribute_name.to_s.singularize)\n \n # If the attribute allows many values, we need an array.\n if attribute_definition.allow_many?\n @attributes[@current_language][attribute_name] ||= ManyValues.new(self, \n PublicEarth::Db::Details::Attribute.new(self, nil, \n attribute_name, value.split(','), nil, @current_language, @current_source_data_set.id, attribute_definition.readonly, 9999, false, \n false, attribute_definition.allow_many, attribute_definition.data_type))\n return @attributes[@current_language][attribute_name].add(value)\n \n # Otherwise just set the attribute equal to the new value\n else\n @attributes[@current_language][attribute_name] = PublicEarth::Db::Details::Attribute.new(self, nil, \n attribute_name, value, nil, @current_language, @current_source_data_set.id, attribute_definition.readonly, 9999, false, \n false, attribute_definition.allow_many, attribute_definition.data_type)\n @attributes[@current_language][attribute_name].changed = true\n end\n end\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end",
"def set_store_transaction\n @store_transaction = StoreTransaction.find(params[:id])\n end",
"def cert_store= cert_store\n @agent.cert_store = cert_store\n end",
"def []= key, value\n @store.transaction { @store[key] = value }\n end",
"def set_attribute(x)\n if attr_name = attribute(x)\n if collection?(x)\n send(attr_name) << yield\n else\n send(\"#{attr_name}=\", yield)\n end\n end\n end",
"def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end",
"def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end",
"def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end",
"def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end",
"def set_attribute params\n sequel_db = get_db params[:database]\n sequel_db.transaction do\n attribute_record = sequel_db[:attributes].where( :object_id => params[:persistence_id], :name => params[:name].to_s ) # convert name to String as Symbol breaks sqlite\n\n if attribute_record.empty?\n # If the attribute doesn't exist, we must INSERT and not UPDATE\n attribute_record.insert :object_id => params[:persistence_id], :name => params[:name].to_s, :value => params[:value] # convert name to String as Symbol breaks sqlite\n else\n attribute_record.update :value => params[:value]\n end\n end\n nil\n end"
] |
[
"0.6954436",
"0.6744716",
"0.6744155",
"0.67336833",
"0.6701682",
"0.66674626",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.6648697",
"0.66077995",
"0.6590807",
"0.6590807",
"0.650644",
"0.6481785",
"0.6469278",
"0.6469278",
"0.64049846",
"0.6382195",
"0.6378199",
"0.6378199",
"0.6378199",
"0.6378199",
"0.63460463",
"0.6305174",
"0.627396",
"0.6238566",
"0.6228031",
"0.6221527",
"0.6163304",
"0.6119587",
"0.6118934",
"0.6080042",
"0.6079493",
"0.6046149",
"0.60246533",
"0.60223436",
"0.6004094",
"0.59782004",
"0.59720945",
"0.5941025",
"0.5939444",
"0.5934258",
"0.59335387",
"0.59322983",
"0.59203905",
"0.58709157",
"0.5859968",
"0.57855576",
"0.57822764",
"0.57617074",
"0.57294387",
"0.57140297",
"0.5711134",
"0.5706783",
"0.56994",
"0.56970775",
"0.56716865",
"0.56669843",
"0.5659594",
"0.5651827",
"0.5648407",
"0.56256694",
"0.5613723",
"0.5609037",
"0.5602085",
"0.5602085",
"0.55946124",
"0.5594487",
"0.5594487",
"0.5563227",
"0.55623746",
"0.55622745",
"0.55413616",
"0.55413616",
"0.55394",
"0.553493",
"0.55297357",
"0.551765",
"0.55144876",
"0.55088264",
"0.55070245",
"0.55017555",
"0.5500547",
"0.5487619",
"0.5487619",
"0.5482558",
"0.54570395",
"0.54471195",
"0.54419047",
"0.5437853",
"0.5436488",
"0.5436488",
"0.5436488",
"0.5436488",
"0.54303217"
] |
0.0
|
-1
|
Queries the translations from the keyvalue store and converts them into a hash such as the one returned from loading the haml files source://i18n//lib/i18n/backend/key_value.rb115
|
def translations; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translations_hash; end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def translations\n @translations ||= {}\n end",
"def translations\n OneclickRefernet::Translation.where(key: self.code)\n end",
"def translate_all(keys)\n returning ActiveSupport::OrderedHash.new do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.t(key, :default => key_suffix, :locale => locale_name)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation != key_suffix ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.t(key, :default => key, :locale => locale_name)\n oh[key] = existing_translation != key ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def user_languages_hash\n result = Hash.new\n\n I18n.available_locales.each do |locale|\n result[t(\"languages.#{locale.to_s}\")] = locale.to_s\n end\n \n return result\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def translation_hash\n Hash[ opts.select{ |k, v| v.is_a? String }.sort_by{ |k, v| [ translation_order( k ), k ] } ]\n end",
"def export\n keys = {}\n reset\n db_localizations = {}\n Lit::Localization.find_each do |l|\n db_localizations[l.full_key] = l.get_value\n end\n db_localizations.sort.each do |(l_key, value)|\n current = keys\n yaml_keys = l_key.split('.')\n\n 0.upto(yaml_keys.size - 2) do |i|\n key = yaml_keys[i]\n # Overwrite en.key with en.sub.key\n unless current[key].class == Hash\n current[key] = {}\n end\n current = current[key]\n end\n current[yaml_keys.last] = value\n end\n keys.to_yaml\n end",
"def translated_locales\n self.i18n.keys\n end",
"def resolve_runtime_locale_values(hsh)\n hsh.each do |key, value|\n if value.is_a?(Hash)\n meta = value[helpers::META[:meta]]\n if meta && (meta.to_h)[helpers::META[:decorators][:runtime_locales]]\n hsh[key] = get_runtime_locale_value(value)\n else\n hsh[key] = resolve_runtime_locale_values(value)\n end\n end\n end\n return hsh\n end",
"def keystroke_translations\n @keystroke_translations ||= begin\n hash = { \"\\n\" => \"return\",\n \"\\\\\" => \"\\\\\\\\\",\n \"\\\"\" => \"\\\\\\\"\" }\n hash.default_proc = proc { |hash,key| hash[key] = \"\\\"#{key}\\\"\" }\n hash\n end\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def get(key, options = EMPTY_HASH)\n return unless key\n\n result = t.(key, locale: options.fetch(:locale, default_locale))\n\n if result.is_a?(Hash)\n text = result[:text]\n meta = result.dup.tap { |h| h.delete(:text) }\n else\n text = result\n meta = EMPTY_HASH.dup\n end\n\n {\n text: text,\n meta: meta\n }\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def languages\n value.document.fetch(\"#{value.key}_lang\", [])\n end",
"def add_v1_translations dictionary\n\n ['eligibility', 'accommodation', 'purpose'].each do |trans_type|\n\n trans = dictionary.keys.select { |key| key.to_s.match(/^#{trans_type}_/) }\n trans.each do |tran|\n new_key = tran.sub(\"#{trans_type}_\", \"\")\n dictionary[new_key] = dictionary[tran]\n end\n end\n\n dictionary\n\n end",
"def list\n @@translatable ||= Hash.new\n end",
"def export(translations)\n res = LazyHash.build_hash\n\n translations.each do |e|\n LazyHash.add(res, \"#{e.locale}.#{e.key}\", e.value)\n end\n if res.any? && res.keys.size != 1\n raise IndexError, \"Generated hash must have only one root key. Your translation data in database may be corrupted.\"\n end\n res\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def index\n @translations = TRANSLATION_STORE\n end",
"def extract_hash\n\n value = @array.extract_hash if @array\n value = @valueItem.extract_hash if @valueItem\n value = @map.extract_hash if @map\n\n @text = value\n\n return if @type == 'index'\n return if @type == 'hidden'\n return if @type == 'version'\n return if @type == 'class'\n return if @type == 'method'\n return if @type == 'import'\n return if @type == 'allow'\n return if @type == 'expect'\n\n formatted_key = Substitutions.process UnicodeEscapes.process @key\n {formatted_key => @text}\n end",
"def composite_keys \n Hash.new.tap do |hash|\n SPREE_MODULES.each do |mod|\n hash.merge! get_translation_keys(\"spree_#{mod}\")\n end\n end\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def write_to_file keys\n init_translations_and_ignore_app_mode_file_dump if self.class.mode == :origin\n # Hash to capture the files updated on origin mode and the keys for each one\n result = {}\n keys.each do |key, value|\n #\n # Search the files where the translation will be applied to\n decide_filenames(key).each do |filename| \n (result[filename] ||= []) << key\n # Apply the current translation to the filenames\n #\n # It will save a key 'ubiquo.categories.index.title' with a value 'Title'\n # mergin the content of $filename with it\n #\n # Load the file\n hash = YAML.load_file(filename)\n # Morph the translation key\n # from: 'ubiquo.categories.index.title'\n # to: { :ubiquo => {\n # :categories => {\n # :index => {\n # :title => 'Title'\n # }\n # }\n # }\n # }\n # }\n branch_hash = Translate::Keys.to_deep_hash({key => value})\n #\n # Cast all the hash keys to String\n #\n branch_hash = Translate::File.deep_stringify_keys({self.locale => branch_hash})\n #\n # Merge the translation with the content of the file\n #\n #\n hash.deep_merge!(branch_hash)\n #\n # Save to file updated to disk\n Translate::File.new(filename).write(hash)\n end \n end\n result\n end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def parse_key_value\n to_transaction { to_h }\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def translations\n\t\t\tvalues(\"http://scta.info/property/hasTranslation\")\n\t\tend",
"def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end",
"def key_lang\n if @is_result\n @lang[0, @lang.length - RESULT_SUFFIX_LENGTH]\n else\n @lang\n end\n end",
"def texts_to_translations(db_texts, texts)\n db_text_map = hashify(db_texts, proc { |i| i.from_text.value })\n texts.collect do |text|\n next unless (db_text = db_text_map[text.to_s])\n @listener.update_progress(1) if @listener\n provider = db_text.provider\n translation = build_text(db_text.value, @to_locale)\n Result.new(text, translation, provider, from_database: true)\n end.compact\n end",
"def replace_with_translation_keys(model_errors)\n return model_errors if internationalized?\n deep_translation_replace(model_errors)\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def get_dictionary_translation html_doc\n translations = Array.new\n translation = html_doc.xpath(\"//span[@id='result_box']\")\n translation.each do |t|\n add_translation t.text\n end\n translations\n end",
"def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end",
"def translations_for_select\n configuration(:translations).collect{ |translation|\n [translation[:language], translation[:language_code]]\n }\n end",
"def translate(key)\n read(key.to_s)\n end",
"def translate(details)\n self.translations = Hash[details.map { |k, v| [k.to_s, v.to_s] }].reverse_merge(translations)\n end",
"def cama_language_plugin_get_hash_value(g, keys)\n return {} if g.nil?\n k = keys.shift\n g = g[k.to_sym]\n (keys.any? ? cama_language_plugin_get_hash_value(g || {}, keys) : g) || {}\n end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def translatable\n self._translatable[base_name]\n end",
"def store_translations(locale, data, options = {})\n escape = options.fetch(:escape, true)\n flatten_translations(locale, data, escape, @subtrees).each do |key, value|\n key = \"#{locale}.#{key}\"\n\n case value\n when Hash\n if @subtrees && (old_value = @store[key])\n old_value = ActiveSupport::JSON.decode(old_value)\n value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash)\n end\n when Proc\n raise \"Key-value stores cannot handle procs\"\n end\n\n unless value.is_a?(Symbol)\n if value.is_a?(String)\n @store[key] = value.strip.gsub(/\\<script.*?\\>|\\<\\/script\\>/, '') unless value.blank? # don't store the locale if it is empty\n else\n @store[key] = ActiveSupport::JSON.encode(value)\n end\n end\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def store_translations(locale, data)\n flatten_data(locale => data).each do |key, value|\n self[key] = value\n end\n end",
"def texts_translated\n @texts_translated ||= tokens_translated.map do |group|\n group.map { |value, type| type == :text ? value : fix_ascii(value) }.join\n end\n end",
"def translate(details)\n self.translations = Hash[details.map { |k,v| [k.to_s, v.to_s] }].reverse_merge(self.translations)\n end",
"def search_conditions_as_hash(locale)\n [\n { :value => I18n.t(\"advanced_searches.text_search_field.all_words\", locale: locale), :key => \"all_words\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.one_word\", locale: locale), :key => \"one_word\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.exact\", locale: locale), :key => \"exact\"}\n ]\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def t(key)\n I18n.translate(key).html_safe\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def content\n result = {}\n page_contents.each do |page_content|\n result[page_content.key] = page_content.value\n end\n result\n end",
"def index\n @translations = @locale.translations.all(:order => \"raw_key, pluralization_index\")\n end",
"def init_translations; end",
"def pagy_t(key, opts = {})\n Pagy::I18n.translate(@pagy_locale ||= nil, key, opts)\n end",
"def store_translations(locale, data)\n data = flatten data\n data.each { |key, data| store_translation(locale, key, data) }\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def validate\n untranslated = self.get_untranslated_keys\n untranslated.each { |key|\n puts \"WARNING: \\\"#{key['id']}\\\" is not translated in #{key['untranslated']} languages\"\n }\n end",
"def store_translations(locale, data, options = {})\n locale = locale.to_sym\n translations[locale] ||= {}\n data = data.deep_symbolize_keys\n translations[locale].deep_merge!(data)\n end",
"def translate(text,dictonary)\nend",
"def translate_attributes\n info = {}\n translate.each do |attribute_name, label|\n info[label] = send(attribute_name)\n end\n info\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def to_trans(ret = true)\n trans = TransObject.new(self.title, self.class.name)\n\n values = retrieve_resource\n values.each do |name, value|\n name = name.name if name.respond_to? :name\n trans[name] = value\n end\n\n @parameters.each do |name, param|\n # Avoid adding each instance name twice\n next if param.class.isnamevar? and param.value == self.title\n\n # We've already got property values\n next if param.is_a?(Puppet::Property)\n trans[name] = param.value\n end\n\n trans.tags = self.tags\n\n # FIXME I'm currently ignoring 'parent' and 'path'\n\n trans\n end",
"def translate_property_key(value)\n return resource_translation_matrix.key(value) if resource_translation_matrix &&\n resource_translation_matrix.value?(value)\n\n value.to_s\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def translate(to, values)\n if to.class == @importer\n key, val = 0, 1\n elsif to.class == @exporter\n key, val = 1, 0\n else\n raise Customs::Manifest::NoTranslationFound.new \"No translation was found for #{to.class}\"\n end\n @manifest.inject({}) { |hash, map| hash.merge(map[key] => values[map[val]]) }\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def to_h\n { languages: languages.map(&:to_h), break_type: break_type,\n prefix_break: prefix_break?, bounds: bounds.map(&:to_h),\n text: text }\n end",
"def translated\n find_all do |entry|\n entry.translated?\n end\n end",
"def translate(settings); end",
"def translate_recipe\n @translated_recipe = {}\n # google trad call\n translate = Google::Cloud::Translate::V2.new(\n project_id: ENV[\"CLOUD_PROJECT_ID:\"],\n credentials: ENV[\"GOOGLE_APPLICATION_CREDENTIALS\"],\n )\n translated_ingredients = @recipe_hash[:ingredients_list].map do |ingredient|\n translation = translate.translate ingredient, to: \"en\"\n translation.text.inspect\n end\n # new hash with translated infos\n @translated_recipe[:ingredients_list] = translated_ingredients.join(\"\\n\").gsub! /\"/, \"|\"\n end",
"def values(namespace)\n keys(namespace).try(:inject, inflector.convert_hash({})) { |acc, key|\n acc[key] = get(namespace, key)\n acc\n }\n end",
"def translate!(key, **options); end",
"def models_to_translate\n Utility.models_to_translate\n end",
"def to_h\n phrase.to_h.tap do |hash|\n hash[:old_key] = old_phrase.key if old_phrase\n end\n end",
"def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n next unless entry[prop]\n value = entry.delete(prop)\n prop = case(prop)\n when \"old\"\n \"old_default\"\n when \"t\"\n \"translation\"\n end\n entry[prop] = value\n end\n I18n::Translate.set(key, entry, data, @translate.options[:separator])\n end\n data\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.context.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.context || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.context\n valid_translations << {:label => translation.label, :context => translation.context.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def select_translations(args = {})\n hash = grouped_translated_text(args[:locale])\n hash.each { |key, value| hash[key] = value.count }.sort_by { |_key, value| value }.reverse.to_h\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def cached_translations_for_language(language)\n if Tr8n::RequestContext.current_source\n translations = Tr8n::RequestContext.current_source.valid_translations_for_key_and_language(self.key, language)\n end\n\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end",
"def translations\n collection = Collection.new\n\n # add all translations from the database to the collection\n collection.add(find_database_translations(@texts)) if @use_db\n\n # request translations for all texts that aren't in the database\n untranslated = untranslated(collection)\n if untranslated.present?\n provider_translations = find_provider_translations(untranslated)\n save_database_translations(provider_translations)\n collection.add(provider_translations)\n end\n\n # puts collection.description\n collection\n end"
] |
[
"0.7221288",
"0.69811535",
"0.64487255",
"0.62537754",
"0.6169108",
"0.61664224",
"0.61107737",
"0.6027025",
"0.6013877",
"0.5980078",
"0.59714925",
"0.58560467",
"0.58380735",
"0.58132577",
"0.5808619",
"0.5800313",
"0.5789081",
"0.5772418",
"0.5760478",
"0.5727814",
"0.57032627",
"0.57023036",
"0.57010204",
"0.56639284",
"0.5645159",
"0.5640687",
"0.56389475",
"0.5620896",
"0.5609116",
"0.5597963",
"0.5594708",
"0.5558521",
"0.5555956",
"0.5555956",
"0.5555956",
"0.5555956",
"0.5540714",
"0.55101436",
"0.55032116",
"0.54838276",
"0.54768395",
"0.5473541",
"0.5461328",
"0.54527",
"0.5434635",
"0.5417703",
"0.5401098",
"0.5395663",
"0.53822696",
"0.53798455",
"0.5362618",
"0.5362618",
"0.5359777",
"0.53512347",
"0.5329165",
"0.53222203",
"0.53174907",
"0.53060377",
"0.5300201",
"0.52937365",
"0.52773553",
"0.5269461",
"0.5267258",
"0.52547586",
"0.52482265",
"0.5240174",
"0.5232657",
"0.5232434",
"0.5227869",
"0.5221196",
"0.5210797",
"0.5199308",
"0.51946163",
"0.51904196",
"0.5181643",
"0.5175943",
"0.5173857",
"0.5173515",
"0.5171637",
"0.5154696",
"0.51504374",
"0.5137107",
"0.5133041",
"0.5119769",
"0.5116107",
"0.5115299",
"0.51136214",
"0.511279",
"0.51122236",
"0.5108624",
"0.5104275",
"0.51015365",
"0.50948435",
"0.5089797",
"0.50873774",
"0.50872165",
"0.5086333",
"0.5082383",
"0.5078837",
"0.5066216"
] |
0.59110403
|
11
|
Parse the load path and extract all locales. source://i18n//lib/i18n/backend/lazy_loadable.rb99
|
def available_locales; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def localeList\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\t@locales\n\t\tend",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def _lookup!(path)\n found = nil\n\n $LOAD_PATH.each do |base|\n rb_file = File.join( base, \"translation_maps\", \"#{path}.rb\" )\n yaml_file = File.join( base, \"translation_maps\", \"#{path}.yaml\" )\n prop_file = File.join(base, \"translation_maps\", \"#{path}.properties\" )\n\n if File.exist? rb_file\n found = eval( File.open(rb_file).read , binding, rb_file )\n break\n elsif File.exist? yaml_file\n found = YAML.load_file(yaml_file)\n break\n elsif File.exist? prop_file\n found = Traject::TranslationMap.read_properties(prop_file)\n break\n end\n end\n\n # Cached hash can't be mutated without weird consequences, let's\n # freeze it!\n found.freeze if found\n\n return found\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n begin\n require(pathname = path+\"/\"+filename)\n trace :loading, \"Loaded #{pathname}\"\n filename\n rescue LoadError => e\n trace :loading, \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n rescue Exception => e\n $stderr.puts \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n end\n end.compact\n end\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def loadable_constants_for_path(path, bases = autoload_paths)\n path = path.chomp(\".rb\")\n expanded_path = File.expand_path(path)\n paths = []\n\n bases.each do |root|\n expanded_root = File.expand_path(root)\n next unless expanded_path.start_with?(expanded_root)\n\n root_size = expanded_root.size\n next if expanded_path[root_size] != ?/\n\n nesting = expanded_path[(root_size + 1)..-1]\n paths << nesting.camelize unless nesting.blank?\n end\n\n paths.uniq!\n paths\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def lookup_chain = locale(true).lookup",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def lookup_parts\n @yaml_parts = ActiveSupport::OrderedHash.new\n @ruby_parts = []\n \n self.lang_file_dirs.each do |lang_file_dir|\n yaml_parts_in_this_dir = Dir.glob(File.join(lang_file_dir, \"#{self.lang_code}*.yml\")).sort\n @yaml_parts[lang_file_dir] = yaml_parts_in_this_dir.collect {|part| File.basename(part)}\n ruby_part_in_this_dir = File.join(lang_file_dir, \"#{self.lang_code}.rb\")\n @ruby_parts << ruby_part_in_this_dir if File.exists?(ruby_part_in_this_dir)\n end\n \n [@yaml_parts, @ruby_parts]\n end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def load_all_metas\n Thread.current[:metas] = I18n.available_locales.inject({}) do |acc, locale|\n acc.merge!(load_metas_for_locale(locale))\n acc\n end\n end",
"def load_paths\n @load_paths ||= Config::LoadPaths.new\n end",
"def available_locales_initialized?; end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def loaded_languages\n @@languages.keys\n end",
"def loaded_languages\n @@cached_language_data.keys\n end",
"def load_paths\n @load_paths ||= [\"urls.rb\", \"config/urls.rb\", \"mailers/*.rb\", \"controllers/**/*.rb\", \"controllers.rb\", \"helpers/*.rb\"]\n end",
"def yaml_parts_in_loading_order\n ordered_yaml_parts = []\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.sort_by{|part| File.basename(part, '.yml').split('.').size}.each do |part|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n ordered_yaml_parts\n end",
"def load_translations_and_collect_file_errors(files); end",
"def get_locales\n fall_back = [:ru].to_yaml\n locales = CustomSetting.find_or_create_by_name(\"languages\").value || fall_back\n begin\n locales = YAML::load(locales)\n rescue\n locales = YAML::load(fall_back)\n end\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def available_locales_set; end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def _load(path)\n path = Pathname.new(path)\n @loader.load(path)\n end",
"def load_all\n return if defined?(@loaded_all)\n\n load_env\n\n paths = search_path\n unless paths.nil?\n paths.each do |dir|\n # dir is already an absolute path\n Dir.glob(File.join(dir, '*.rb')).each do |path|\n # exclude dirs that end with .rb\n load_file(path) if File.file?(path)\n end\n end\n end\n\n @loaded_all = true\n end",
"def available_locales\n []\n end",
"def discover_locale\n locales = Dir[\"#{locale_dir}/*\"]\n locales.map! { |e| File.basename(e) }\n locales.join(\" \")\n end",
"def default_i18n_with_milkshake\n default_i18n = default_i18n_without_milkshake\n default_i18n.load_path.concat(Milkshake.environment.locale_paths)\n default_i18n.load_path.uniq!\n default_i18n\n end",
"def loadall(env)\n self.class.loadall(@path, env)\n end",
"def load_all\n @internal_loader.load_all(self)\n end",
"def available_locales\n translations = Dir.glob('config/locales/*').map { |locale| locale.split('/').last.split('.').first }\n locales = []\n translations.each do |t|\n value = (t == 'zh' ? 'zh-CN' : t)\n locales << [LanguageList::LanguageInfo.find(t).name, value]\n end\n locales\n end",
"def load(path); end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def lookup!\n $LOAD_PATH.each do |base|\n Dir[File.join(base, *file_lookup_paths)].each do |path|\n path = path.delete_prefix(\"#{base}/\")\n require path\n rescue Exception\n # No problem\n end\n end\n end",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency\n self.class.mixable_app_types.keys.map(&:to_s).sort.each do |type|\n path = \"#{app_path}/#{type}\"\n @load_paths << path if File.directory?(path)\n end\n end\n end\n \n @load_paths\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency across platforms\n @load_paths.concat(Dir[\"#{app_path}/*/\"].map(&:chop).sort!)\n end\n end\n \n @load_paths\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def resolve_paths(loaders)\n mod_resolver = loaders.instance_variable_get(:@module_resolver)\n all_mods = mod_resolver.instance_variable_get(:@all_module_loaders)\n end",
"def preloaded_module_paths(resolver:, cache_key: T.unsafe(nil)); end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def get_language_completion(locale)\r\n @@language_completion ||= {}\r\n locale = locale.to_s\r\n\r\n if @@language_completion.has_key?(locale)\r\n return @@language_completion[locale]\r\n end\r\n\r\n # return nil if we haven't got all of our base translations in\r\n return nil unless File.exists?(\"config/locales/#{locale}.yml\")\r\n\r\n # return the percentage of translations in use\r\n @@language_completion[locale] = _get_language_completion(locale, translation_info(locale))\r\n\r\n end",
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def includes_load_paths; end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load_path; end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end",
"def collect_loaded_features\n @loaded_features = []\n $LOADED_FEATURES.each {|file|\n $LOAD_PATH.each {|dir|\n file_path = File.join(dir, file)\n if File.identical?(file_path, @me)\n next\n end\n if File.file?(file_path)\n @loaded_features << file_path\n next\n end\n }\n }\n end",
"def loaded_resources\n @_loaded_resources ||= []\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def load_path(match, options={})\n return [] if options[:from]\n\n options = valid_load_options(options)\n\n found = []\n $LOAD_PATH.uniq.each do |path|\n list = Dir.glob(File.join(File.expand_path(path), match))\n list = list.map{ |d| d.chomp('/') }\n # return absolute path unless relative flag\n if options[:relative]\n # the extra '' in File.join adds a '/' to the end of the path\n list = list.map{ |f| f.sub(File.join(path, ''), '') }\n end\n found.concat(list)\n end\n found\n end",
"def eager_load_all\n Registry.loaders.each(&:eager_load)\n end",
"def load_imports\n while fn = @pending_imports.shift\n next if @imported.member?(fn)\n ext = File.extname(fn)\n loader = @loaders[ext] || @default_loader\n loader.load(fn)\n @imported << fn\n end\n end",
"def load_path\n paths, file = [\"\"], current_file\n paths << File.dirname(file) if file\n paths + LOAD_PATH\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def load!\n if(path)\n if(File.directory?(path))\n conf = Dir.glob(File.join(path, '*')).sort.inject(Smash.new) do |memo, file_path|\n memo.deep_merge(load_file(file_path))\n end\n elsif(File.file?(path))\n conf = load_file(path)\n else\n raise Errno::ENOENT.new path\n end\n conf\n end\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def load_resources\n resource_path = File.join(File.dirname(__FILE__), \"resources\")\n Similar.load_all_ruby_files_from_path(resource_path)\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def load_metas_for_locale(locale)\n path = metas_path(locale)\n if File.exists?(path)\n YAML.load(File.open(path))\n else\n logger.error \"[Metaslug] #{path} not found.\"\n {}\n end\n end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def locales\n get(\"locales\")[\"locales\"]\n end",
"def translated_locales\n self.i18n.keys\n end",
"def partial_load\n if @loader\n names = @loader.get_league_names\n @league_names = names unless names.empty?\n end\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def on_namespace_loaded(namespace)\n if subdirs = lazy_subdirs.delete(namespace.name)\n subdirs.each do |subdir|\n set_autoloads_in_dir(subdir, namespace)\n end\n end\n end"
] |
[
"0.6734436",
"0.64431256",
"0.6354007",
"0.6354007",
"0.6298475",
"0.6288107",
"0.62688625",
"0.6185744",
"0.60980767",
"0.6091885",
"0.60335535",
"0.5944286",
"0.5915943",
"0.5872034",
"0.5813465",
"0.58125365",
"0.578604",
"0.578604",
"0.57639205",
"0.57400817",
"0.573697",
"0.57292235",
"0.57236093",
"0.5713955",
"0.5713955",
"0.57043654",
"0.57035834",
"0.570311",
"0.56933385",
"0.56818455",
"0.56617296",
"0.5656808",
"0.5642193",
"0.5637941",
"0.5637697",
"0.5602644",
"0.5596089",
"0.55944437",
"0.5584818",
"0.55654305",
"0.55118054",
"0.5482357",
"0.5473556",
"0.5460031",
"0.5452312",
"0.5445398",
"0.54284585",
"0.5422544",
"0.54212457",
"0.5412886",
"0.5396983",
"0.538993",
"0.5382919",
"0.5379391",
"0.53738266",
"0.5366628",
"0.53635573",
"0.5363538",
"0.5328071",
"0.53190863",
"0.53141594",
"0.53118294",
"0.53090686",
"0.52876663",
"0.5276274",
"0.52669865",
"0.52648735",
"0.5244779",
"0.52333474",
"0.5223014",
"0.52157",
"0.5214445",
"0.5207237",
"0.5207237",
"0.52053785",
"0.51958966",
"0.51820606",
"0.5181385",
"0.51727885",
"0.5169718",
"0.5167328",
"0.5167205",
"0.5164276",
"0.5163162",
"0.51617604",
"0.51601785",
"0.515308",
"0.515301",
"0.5152579",
"0.51516557",
"0.5149956",
"0.5149849",
"0.5148232",
"0.51434356",
"0.5143329",
"0.51231724",
"0.5120981",
"0.5118104",
"0.5113683"
] |
0.55900156
|
38
|
Eager loading is not supported in the lazy context. source://i18n//lib/i18n/backend/lazy_loadable.rb90
|
def eager_load!; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def eager_load; end",
"def eager_load; end",
"def eager_load; end",
"def before_eager_load(&block); end",
"def lazy_load(resource)\n # If we're trying to load a lazy property, load it. Otherwise, lazy-load\n # any properties that should be eager-loaded but were not included\n # in the original :fields list\n property_names = lazy? ? [ name ] : model.properties(resource.repository.name).defaults.map { |property| property.name }\n resource.send(:lazy_load, property_names)\n end",
"def lazy\n raise Error, \"lazy loading disabled\" if model.cti_subclass_load == :eager_only\n clone(:eager_load => false)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def lazy?; @lazy; end",
"def eager\n raise Error, \"eager loading disabled\" if model.cti_subclass_load == :lazy_only\n clone(:eager_load => true)\n end",
"def eager_load=(_arg0); end",
"def eager_load=(_arg0); end",
"def eager_load=(_arg0); end",
"def forbid_lazy_load\n @forbid_lazy_load = true\n self\n end",
"def use_i18n; end",
"def apply_lazyloading\n @query = @query.includes(:user).includes(theme: :moderator)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def rake_eager_load; end",
"def rake_eager_load; end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def placeholder_eager_loader\n cached_fetch(:placeholder_eager_loader) do\n Sequel::Dataset::PlaceholderLiteralizer.loader(associated_dataset) do |pl, ds|\n apply_eager_limit_strategy(eager_loading_dataset.where(predicate_key=>pl.arg), eager_limit_strategy)\n end\n end\n end",
"def lazy\n Fetcher.new(self).lazy\n end",
"def eager_loading_use_associated_key?\n true\n end",
"def init_translations; end",
"def lazy_load(source)\n # SEL: load all related resources in the source collection\n if source.saved? && source.collection.size > 1\n eager_load(source.collection)\n end\n\n unless loaded?(source)\n set!(source, collection_for(source))\n end\n end",
"def with_sql_first(sql)\n obj = super\n obj.allow_lazy_load if obj.is_a?(InstanceMethods)\n obj\n end",
"def fetch\n update_attributes(application.api_client.get(\n \"language/#{locale}/definition\", {},\n {\n cache_key: self.class.cache_key(locale)\n }\n ))\n rescue Tml::Exception => ex\n Tml.logger.error(\"Failed to load language: #{ex}\")\n self\n end",
"def eager_load_namespaces; end",
"def eager_loader_key\n self[:key]\n end",
"def neofiles_lazy_loadable(obj)\n def obj.__lazy_load\n return if @__lazy_loaded\n @__lazy_loaded = true\n from_db = self.class.find(id)\n attributes.merge! from_db.attributes.with_indifferent_access.slice(*NEOFILES_LAZY_ATTRS)\n end\n\n def obj.read_attribute(field)\n __lazy_load if field.in? NEOFILES_LAZY_ATTRS\n super(field)\n end\n\n NEOFILES_LAZY_ATTRS.each do |field|\n obj.define_singleton_method field do\n __lazy_load\n super()\n end\n end\n end",
"def translatable\n self._translatable[base_name]\n end",
"def eager_load_paths=(_arg0); end",
"def eager_loading_use_associated_key?\n false\n end",
"def eager_load!(scope = Grape)\n # get modules\n scope.constants.each do |const_name|\n const = scope.const_get(const_name)\n\n next unless const.respond_to?(:eager_load!)\n\n const.eager_load!\n\n # check its modules, they might need to be loaded as well.\n eager_load!(const)\n end\nend",
"def lazy_load(source)\n # TODO: if the collection is not loaded, then use a subquery\n # to load it.\n\n # SEL: load all related resources in the source collection\n if source.saved? && source.collection.size > 1\n source.collection.send(name)\n end\n\n unless loaded?(source)\n set!(source, collection_for(source))\n end\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def _load_associated_object(opts, dynamic_opts)\n # The implementation that loads these associations does\n # .all.first, which would result in the object returned being\n # marked as forbidding lazy load.\n obj = super\n obj.allow_lazy_load if obj.is_a?(InstanceMethods)\n obj\n end",
"def translates_preload(*facets)\n module_eval <<-HERE\n @@preload_facets = facets\n HERE\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def l(*args); I18n.l(*args) end",
"def eager_loader_key\n self[:eager_loader_key]\n end",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def inject_translatable_block\n inject_into_class model_path, class_name, generate_translatable_block\n end",
"def eager_load_all\n Registry.loaders.each(&:eager_load)\n end",
"def i18n_scope\n :mongoid\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def eager_load(object, ns)\n if object.kind_of?(Hash)\n ns.merge!(object.symbolize_keys)\n elsif object.respond_to?(:attributes)\n ns.merge!(object.attributes.symbolize_keys)\n else\n object.instance_variables.each do |var|\n ns[var.gsub(/^@/, '').to_sym] = object.instance_variable_get(var)\n end\n end\n end",
"def finalize_associations\n allow_lazy_load_for_static_cache_associations\n super\n end",
"def lazy\n yield\n yield\nend",
"def _load_associated_objects(opts, dynamic_opts={})\n if opts.can_have_associated_objects?(self) && opts[:type] == :many_to_one && opts.associated_class.respond_to?(:cache_get_pk)\n _load_associated_object(opts, dynamic_opts)\n else\n super\n end\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def load_all_lazy_relationships(object, level = NESTING_START_LEVEL)\n return if level >= LAZY_NESTING_LEVELS\n return unless object\n\n return unless lazy_relationships\n\n lazy_relationships.each_value do |lrm|\n load_lazy_relationship(lrm, object, level)\n end\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def engine_eager_load! \n railties.all(&:eager_load!)\n config.eager_load_paths.each do |load_path|\n matcher = /\\A#{Regexp.escape(load_path)}\\/(.*)\\.rb\\Z/\n Dir.glob(\"#{load_path}/**/*.rb\").sort.each do |file|\n # remove the previous class (if exists) and require again (with new load path/order)\n name = file.sub(matcher, '\\1')\n class_name = ActiveSupport::Inflector.camelize name\n Object.send(:remove_const, class_name) if Object.const_defined?(class_name)\n require_dependency name\n end\n end\n end",
"def allow_lazy_load_for_static_cache_associations\n # :nocov:\n if defined?(::Sequel::Plugins::StaticCache::ClassMethods)\n # :nocov:\n @association_reflections.each_value do |ref|\n if ref.associated_class.is_a?(::Sequel::Plugins::StaticCache::ClassMethods)\n ref[:forbid_lazy_load] = false\n end\n end\n end\n end",
"def i18n_scope\n :neo4j\n end",
"def eager_load(options)\n @eager_load = options\n end",
"def l_proxy(*sections)\n ArkanisDevelopment::SimpleLocalization::Language.app_proxy(*sections)\n end",
"def uses_eager_load?\n return opts[:eager_load] unless opts[:eager_load].nil?\n [:eager, :eager_only].include?(model.cti_subclass_load)\n end",
"def translations; end",
"def translation_scope\n \"order_details.notices\"\n end",
"def rake_eager_load=(_arg0); end",
"def rake_eager_load=(_arg0); end",
"def get(data, ctx, lazy=false) # IDENTITY TRACKING AND LAZY LOADING\n entity_key = extract_key(data)\n key = [self, entity_key]\n # extract_key is generated ad-hoc by model compiler!\n if cached = ctx.entity_cache[key]\n cached\n else\n ctx.entity_cache[key] = get(*entity_key)\n # get is generated ad-hoc by model compiler\n end\n end",
"def lazy?\n @lazy\n end",
"def lazy?\n @lazy\n end",
"def lazy?\n @lazy\n end",
"def pref_label\n if pref_labels.loaded?\n # use select if association is already loaded\n @cached_pref_labels ||= pref_labels.select(&:published?).each_with_object({}) do |label, hash|\n if hash[label.language]\n Rails.logger.warn(\"Two pref_labels (#{hash[label.language]}, #{label}) for one language (#{label.language}). Taking the second one.\")\n end\n hash[label.language] = label\n end\n else\n # use scope otherwise\n @cached_pref_labels ||= pref_labels.published.each_with_object({}) do |label, hash|\n if hash[label.language]\n Rails.logger.warn(\"Two pref_labels (#{hash[label.language]}, #{label}) for one language (#{label.language}). Taking the second one.\")\n end\n hash[label.language] = label\n end\n end\n\n lang = I18n.locale.to_s == 'none' ? nil : I18n.locale.to_s\n\n if @cached_pref_labels[lang].nil?\n # Fallback to the main language\n @cached_pref_labels[lang] = pref_labels.select{ |l|\n l.language.to_s == Iqvoc::Concept.pref_labeling_languages.first.to_s\n }.first\n end\n @cached_pref_labels[lang]\n end",
"def eager_load_keys(keys)\n # Speed up pulls by priming the page's placeholder keys\n end",
"def with_all_rich_text\n eager_load(rich_text_association_names)\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def add_lazy_loader(loader, attributes=nil)\n # guard against invalid call\n if identifier.nil? then raise ValidationError.new(\"Cannot add lazy loader to an unfetched domain object: #{self}\") end\n # the attributes to lazy-load\n attributes ||= loadable_attributes\n return if attributes.empty?\n # define the reader and writer method overrides for the missing attributes\n pas = attributes.select { |pa| inject_lazy_loader(pa) }\n logger.debug { \"Lazy loader added to #{qp} attributes #{pas.to_series}.\" } unless pas.empty?\n end",
"def t(...)\n I18n.t(...)\nend",
"def i18n_scope\n :activemodel\n end",
"def i18n_scope\n :activemodel\n end",
"def i18n_scope\n :activemodel\n end",
"def _load(dependency_map, current, h)\n dependency_map.each do |ta, deps|\n unless key = pk(ta, h)\n ta_h = hfor(ta, h)\n unless ta_h.values.any?\n assoc_name = alias_map[ta]\n unless (assoc = current.associations).has_key?(assoc_name)\n assoc[assoc_name] = type_map[ta] ? [] : nil\n end\n next\n end\n key = hkey(ta_h)\n end\n rm, rp, assoc_name, tm, rcm = @ta_map[ta]\n unless rec = rm[key]\n rec = rm[key] = rp.call(hfor(ta, h))\n end\n\n if tm\n unless (assoc = current.associations).has_key?(assoc_name)\n assoc[assoc_name] = []\n end\n assoc[assoc_name].push(rec) \n rec.associations[rcm] = current if rcm\n else\n current.associations[assoc_name] ||= rec\n end\n # Recurse into dependencies of the current object\n _load(deps, rec, h) unless deps.empty?\n end\n end",
"def lazy_preload(*args)\n check_if_method_has_arguments!(:lazy_preload, args)\n spawn.lazy_preload!(*args)\n end",
"def _load_relation name\n relation = self.relations.select { |rel| rel.name == name }.first\n if relation.type == :has_many\n _load_has_many relation\n elsif relation.type == :belongs_to\n _load_belongs_to relation\n else\n raise \"Unkown relation type\"\n end\n end",
"def render_related_resource_language(presenter)\n return nil if presenter.related_resource.empty?\n\n is_multiple = presenter.related_resource.count > 1\n translation_key = \"spot.collections.show.related_resource_#{is_multiple ? 'multiple' : 'single'}\"\n\n links = presenter.related_resource.map { |url| link_to(url, url, target: '_blank').html_safe }\n t(translation_key, link_html: links.to_sentence).html_safe\n end",
"def dynamic_loadable_module\n super\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def eager_load(a, eager_assoc=@opts[:eager])\n return if a.empty?\n # Key is foreign/primary key name symbol\n # Value is hash with keys being foreign/primary key values (generally integers)\n # and values being an array of current model objects with that\n # specific foreign/primary key\n key_hash = {}\n # Reflections for all associations to eager load\n reflections = eager_assoc.keys.map{|assoc| model.association_reflection(assoc) || (raise Sequel::UndefinedAssociation, \"Model: #{self}, Association: #{assoc}\")}\n \n # Populate the key_hash entry for each association being eagerly loaded\n reflections.each do |r|\n if key = r.eager_loader_key\n # key_hash for this key has already been populated,\n # skip populating again so that duplicate values\n # aren't added.\n unless id_map = key_hash[key]\n id_map = key_hash[key] = Hash.new{|h,k| h[k] = []}\n\n # Supporting both single (Symbol) and composite (Array) keys.\n a.each do |rec|\n case key\n when Array\n if (k = key.map{|k2| rec.get_column_value(k2)}) && k.all?\n id_map[k] << rec\n end\n when Symbol\n if k = rec.get_column_value(key)\n id_map[k] << rec\n end\n else\n raise Error, \"unhandled eager_loader_key #{key.inspect} for association #{r[:name]}\"\n end\n end\n end\n else\n id_map = nil\n end\n \n loader = r[:eager_loader]\n associations = eager_assoc[r[:name]]\n if associations.respond_to?(:call)\n eager_block = associations\n associations = {}\n elsif associations.is_a?(Hash) && associations.length == 1 && (pr_assoc = associations.to_a.first) && pr_assoc.first.respond_to?(:call)\n eager_block, associations = pr_assoc\n end\n loader.call(:key_hash=>key_hash, :rows=>a, :associations=>associations, :self=>self, :eager_block=>eager_block, :id_map=>id_map)\n a.each{|object| object.send(:run_association_callbacks, r, :after_load, object.associations[r[:name]])} unless r[:after_load].empty?\n end \n end",
"def initialize(*args)\n super\n\n unless @ref.macro == :has_one or @ref.macro == :has_many\n raise ArgumentError, \"#{@ref.active_record.name}##{@ref.name} cannot be eager loaded because only `has_one` and `has_many` are supported for `through` associations\"\n end\n if (polys = @ref.chain.select(&:polymorphic?)).any?\n names = polys.map { |r| \"#{r.active_record.name}##{r.name}\" }\n raise ArgumentError, \"#{@ref.active_record.name}##{@ref.name} cannot be eager loaded because these `through` associations are polymorphic: #{names.join ', '}\"\n end\n unless @optimizer == :none or @optimizer == :select\n raise ArgumentError, \"Unrecognized optimizer '#{@optimizer}'\"\n end\n\n chain = @ref.chain.reverse\n @chain = chain.each_with_index.map { |x, i|\n Link.new(x.source_reflection.name, x.source_reflection.macro, x, chain[i + 1])\n }\n @loader = build_loader\n end",
"def translations\n relationships.translations\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def eager_load_results(opts, eo, &block)\n opts.eager_load_results(eo, &block)\n end",
"def propagate_dependent_option_with_shared_translations record\n # if this model is not translatable, act normally\n yield && return unless record.class.is_translatable?\n\n if should_propagate_dependent_option? record\n klass.translating_relations do\n yield\n end\n end\n update_foreign_keys_to_point_another_translation record if record.translations.exists?\n end",
"def lazy?\n false\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def lookup_chain = locale(true).lookup",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.story_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.story_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end"
] |
[
"0.65472996",
"0.65472996",
"0.65472996",
"0.589751",
"0.5847515",
"0.5797289",
"0.57864857",
"0.57864857",
"0.57429194",
"0.56940943",
"0.56790775",
"0.5674697",
"0.5671582",
"0.5671582",
"0.5671582",
"0.5616953",
"0.56122524",
"0.56041926",
"0.559358",
"0.558242",
"0.558242",
"0.55807555",
"0.557673",
"0.5558548",
"0.5478722",
"0.54769784",
"0.5474365",
"0.54184335",
"0.5415517",
"0.5401843",
"0.5370947",
"0.5370352",
"0.53604555",
"0.535376",
"0.5326544",
"0.5305587",
"0.53046817",
"0.5291259",
"0.52900636",
"0.52585644",
"0.5192308",
"0.5185988",
"0.51830417",
"0.51733905",
"0.51640785",
"0.51560706",
"0.5149023",
"0.51397073",
"0.5133485",
"0.5133245",
"0.51254404",
"0.510708",
"0.507543",
"0.5059944",
"0.5059944",
"0.5052783",
"0.5052026",
"0.504274",
"0.5028066",
"0.5014744",
"0.50123775",
"0.4993558",
"0.4989237",
"0.49834383",
"0.49534684",
"0.49512374",
"0.49512374",
"0.49213406",
"0.4919105",
"0.49190181",
"0.49190181",
"0.49151063",
"0.49128953",
"0.49078846",
"0.48966527",
"0.4894051",
"0.48812932",
"0.48708603",
"0.4857818",
"0.4857818",
"0.4857818",
"0.4857066",
"0.48210013",
"0.48203963",
"0.47906852",
"0.4787147",
"0.47846928",
"0.47810453",
"0.47805756",
"0.47694787",
"0.47680494",
"0.47661513",
"0.47531545",
"0.47465444",
"0.47443238",
"0.47426495",
"0.47350538"
] |
0.6535038
|
5
|
Returns whether the current locale is initialized.
|
def initialized?; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def available_locales_initialized?; end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def locale_available?(locale); end",
"def initialized?\n !!@initialized\n end",
"def initialized?\n @state == STATE_INITIALIZED\n end",
"def initialized?\n @initialized || false\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n end",
"def init?\n @init\n end",
"def initialized?\n defined?(@state) && @state\n end",
"def init?\n status == :init\n end",
"def localized?\n self.locales.size > 1\n end",
"def has_available_locale? locale\n available_locales.include?(locale.to_sym)\n end",
"def initialized\n @initialized ||= false\n end",
"def locale_enabled?(locale)\r\n locale.to_s == I18n.default_locale.to_s || (get_language_completion(locale) || -1) >= I18n.config.language_threshold\r\n end",
"def localized?\n true\n end",
"def initted?\n @initted\n end",
"def initted?\n @initted\n end",
"def valid_locale?(locale)\n FastGettext.available_locales.include?(locale)\n end",
"def explicit_locale? = @explicit_locale",
"def initialized?\n !(version.zero?)\n end",
"def has_locale? locale\n locales.include?(locale.to_sym)\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def default_language?\n return true unless params[:locale]\n\n params[:locale].to_s == I18n.default_locale.to_s\n end",
"def localized?\n false\n end",
"def initialized?\n !!get_main_hub\n end",
"def localized?\n @localized ||= (self.languages_count > 1)\n end",
"def fully_translated?\n locale_counts.all? do |locale_code, _|\n fully_translated_in?(locale_code)\n end\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def valid_locale?\n unless I18n.available_locales.detect {|alc| alc == I18n.locale }\n redirect_to root_with_locale_url(:locale => I18n.default_locale)\n return false\n end\n true\n end",
"def is_initialized?; @is_initialized; end",
"def has_locale?(locale)\n @locales.has_key?(locale.to_s)\n end",
"def localize_present?\n options[:localize] == :present\n end",
"def initialized\n @initialized\n end",
"def localize_present?\n false\n end",
"def is_game_time_initialized()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.Timer_is_game_time_initialized(@handle.ptr)\n result\n end",
"def valid_locale?(locale_str)\n @loaded_locales.any? { |loc| loc.short == locale_str }\n end",
"def initiative_started?\n find_init.present?\n end",
"def initialized?\n !@data.nil?\n end",
"def in_locale?(locale)\n\t\tin_locale = false\n\t\tif locale == :ka && Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\telsif locale != :ka && !Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\tend\n\t\treturn in_locale\n\tend",
"def in_locale?(locale)\n\t\tin_locale = false\n\t\tif locale == :ka && Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\telsif locale != :ka && !Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\tend\n\t\treturn in_locale\n\tend",
"def check_availability(locale)\n if ['en', 'es'].include? locale.to_s\n locale\n else\n false\n end\n end",
"def initialized?\r\n if ENV[\"RAILS_ENV\"] == \"test\" || !User.table_exists? || $setup_disabled \r\n return false\r\n else \r\n $tmp_env = ENV[\"RAILS_ENV\"] || \"development\"\r\n return true\r\n end \r\n end",
"def engine_initialized?\n\t\t\t\t\tsuper && sass_functions_initialized?\n\t\t\t\tend",
"def has_language?\n !language.nil?\n end",
"def initialized?\n server.present? && username.present? && api_token.present?\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def international?\n @international\n end",
"def lang?\n self.lang.nil? ? false : true\n end",
"def verify_locale(locale)\n site_locales.include?(locale.to_s) ? locale : preferred_default_locale\n end",
"def initialized?\n raise RuntimeError, \"You probably forgot to call #content or give the :from option when instantiating the object.\" if @content.nil?\n @content.initialized?\n end",
"def verify_locale(locale)\n (site_locales.include? locale.to_s) ? locale : preferred_default_locale\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language? ||\n params[:locale].presence == ::I18n.default_locale.to_s\n end",
"def english_header?\n result = File.exists?(@@default_en)\n if result\n @@log.info \"#{__method__}: Default English was found at #{@@default_en}\"\n else\n @@log.error \"#{__method__}: Cannot find the default English localization file. Check the value of @@default_en in this script.\"\n end\n result\n end",
"def initial?\n Machine[@target_class].initial_state_name == self.name\n end",
"def available_locales; end",
"def available_locales; end",
"def localized?\n self.entries_custom_fields.where(localized: true).count > 0\n end",
"def is_rtl_locale\n I18n.locale.to_s.eql?(\"he\")\n end",
"def supported_language?(locale)\n self.supported_languages.include?(locale.to_s)\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def _ready?\n true\n end",
"def current_library?\n !current_library.nil?\n end",
"def available_locales\n @available_locales ||= self.languages.published\n end",
"def has_default_country_code?\n country_code == Phonie.configuration.default_country_code\n end",
"def is_initial?\n initial\n end",
"def available_locales_set; end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def fully_translated_in?(locale_code)\n (locale_counts[locale_code] || -1) >= phrase_count\n end",
"def is_default_calendar\n return @is_default_calendar\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def verificar_locale\n \n end",
"def local?\n false\n end",
"def loaded?\n @loaded ||= false\n end",
"def translated?\n return false if obsolete? || fuzzy?\n not untranslated?\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n !!@loaded\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language?\n end",
"def localized_strings?\n @lstrings ||= entry[:localized] && entry[:filename] =~ /strings.js$/\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n @loaded ||= false\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def system\n locale_from_env || default_locale\n end",
"def english?\n return @famille.english? if @famille\n return session[:lang] && session[:lang] == 'en'\n end"
] |
[
"0.75861937",
"0.7351446",
"0.7344053",
"0.7281233",
"0.72687453",
"0.7245525",
"0.7242455",
"0.7238693",
"0.7238693",
"0.6974474",
"0.68707436",
"0.6794784",
"0.67677003",
"0.6748638",
"0.67189324",
"0.6680789",
"0.66416013",
"0.6630796",
"0.6629202",
"0.6629202",
"0.6628812",
"0.66184324",
"0.6578627",
"0.65775037",
"0.6576945",
"0.64626586",
"0.64610344",
"0.6394094",
"0.6387813",
"0.6372015",
"0.63710475",
"0.63710475",
"0.6361744",
"0.6310279",
"0.62902564",
"0.62850523",
"0.6282218",
"0.6189116",
"0.6170701",
"0.6157126",
"0.6131422",
"0.61252826",
"0.60713273",
"0.60713273",
"0.6043229",
"0.6033651",
"0.586833",
"0.58562213",
"0.579114",
"0.5769481",
"0.57495856",
"0.5748155",
"0.5740862",
"0.57381266",
"0.57223636",
"0.5719594",
"0.5690936",
"0.5651469",
"0.5618868",
"0.5614207",
"0.5614207",
"0.5610227",
"0.5608153",
"0.5584719",
"0.5552926",
"0.5537934",
"0.55181724",
"0.55160964",
"0.5504558",
"0.5502349",
"0.549485",
"0.5481319",
"0.5462176",
"0.5462176",
"0.54547805",
"0.5453162",
"0.54528373",
"0.54458064",
"0.54389656",
"0.5423062",
"0.5414324",
"0.5408059",
"0.5406463",
"0.5406463",
"0.5404818",
"0.54040587",
"0.5400558",
"0.53991836",
"0.5398221",
"0.5387573",
"0.5387573",
"0.5387573",
"0.5387573",
"0.5387573",
"0.5387573",
"0.5357539",
"0.5343843"
] |
0.56124884
|
64
|
Clean up translations and uninitialize all locales. source://i18n//lib/i18n/backend/lazy_loadable.rb80
|
def reload!; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reload!\n @initialized = false\n @translations = nil\n super\n end",
"def clear_available_locales_set; end",
"def clear_translations!\r\n @translation_caches = {}\r\n @stop_merging_translated_attributes = nil\r\n end",
"def reset_i18n()\n I18n.backend = I18n::Backend::Simple.new\nend",
"def init_translations; end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def reload\r\n translated_attribute_names.each { |name| @attributes.delete(name.to_s) }\r\n globalize.reset\r\n super\r\n end",
"def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def fillin_translations\n collection_types = Hyrax::CollectionType.all\n collection_types.each do |c|\n next unless c.title =~ /^translation missing/\n oldtitle = c.title\n c.title = I18n.t(c.title.gsub(\"translation missing: en.\", ''))\n c.save\n Rails.logger.debug \"#{oldtitle} changed to #{c.title}\"\n end\n end",
"def delete_translations\n end",
"def clean_cache_and_translations\n $redis.srem(\"otwtranslation_rules_for_#{language_short}\", display_type)\n\n Otwtranslation::Translation.for_language(language_short)\n .where(\"rules != '#{[].to_yaml}'\").each do |translation|\n if translation.rules.include?(id)\n translation.approved = false\n translation.rules = []\n translation.save!\n end\n end\n end",
"def reset_stats!\r\n @@available_locales = nil\r\n @@enabled_locales = nil\r\n @@language_completion = nil\r\n @@all_translation_info = nil\r\n @@datetime_vars = nil\r\n end",
"def silence_errors\n require 'fast_gettext/translation_repository/base'\n translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale')\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def untranslated\n find_all do |entry|\n entry.untranslated?\n end\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def translations\n @translations ||= {}\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def finalize!\n all_files.each { |f| Kernel.require f } if eager_load\n all_files.clear\n self\n end",
"def untranslated(collection)\n @texts.reject { |i| collection.translated?(i, @provider.name) }\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def finalize_associations\n allow_lazy_load_for_static_cache_associations\n super\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def unrealize\n return unless @realized\n unrealize_dependents\n unrealize_self\n @realized = false\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def seed_page_content_translations!\n I18n.available_locales.each do |locale|\n seed_content_for_locale locale.to_s\n end\n end",
"def reset!\n @loaded_projects = nil\n end",
"def other_locales_with_translations(website)\n all_locales_with_translations(website) - [I18n.locale.to_s]\n end",
"def remove_locale_file language\n File.delete yml_path(language) if File.exists?(yml_path language)\n\n new_load_paths = I18n.load_path.map do |path|\n path unless path.include?(\"#{language}.yml\")\n end.compact\n\n I18n.load_path = new_load_paths\n\n I18n.locale = I18n.default_locale\nend",
"def load_all_metas\n Thread.current[:metas] = I18n.available_locales.inject({}) do |acc, locale|\n acc.merge!(load_metas_for_locale(locale))\n acc\n end\n end",
"def available_locales_initialized?; end",
"def unload_all\n @last_unload = []\n loaded_safe.each do |plugin|\n unload_one plugin\n @last_unload << plugin\n end\n unload_one TWG::Core\n end",
"def translations; end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def unrealize_dependents\n dependents.each do |dependents|\n dependents.unrealize\n end\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def globalize_object(model)\n return unless pol_cfg.multilang?\n pol_cfg.languages.each do |lang|\n next if model.globalize_translations.map(&:locale).include?(lang.to_sym)\n model.globalize_translations.build({ :locale => lang })\n end\n end",
"def load_resources\n ActiveAdmin.unload!\n yield\n reload_menus!\n reload_routes!\n end",
"def load_resources\n ActiveAdmin.unload!\n yield\n reload_menus!\n reload_routes!\n end",
"def missing_locales\n project.locales.reject do |locale|\n translations.map(&:locale_id).include? locale.id\n end\n end",
"def reset_locale(locale = nil, force = false)\n return if explicit_locale? and !force\n @locale = locale\n @territory = nil\n @data_locale = nil\n @locale_config = nil\n @timezone = nil\n @calendar = nil\n @currency = nil\n @info = {}\n end",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def expire_author_init_chars_cache\n I18n.available_locales.each do |locale|\n Rails.cache.delete(\"author_init_chars_#{I18n.locale}\")\n end\n end",
"def translations\n collection = Collection.new\n\n # add all translations from the database to the collection\n collection.add(find_database_translations(@texts)) if @use_db\n\n # request translations for all texts that aren't in the database\n untranslated = untranslated(collection)\n if untranslated.present?\n provider_translations = find_provider_translations(untranslated)\n save_database_translations(provider_translations)\n collection.add(provider_translations)\n end\n\n # puts collection.description\n collection\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def destroy_all\n destroy(load_target).tap do\n reset\n loaded!\n end\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def clear\n if loaded?\n orphan_resources(self)\n end\n super\n end",
"def unregister_all\n @@urls = {}\n @@fallback = []\n end",
"def unload!\n unload_resources!\n reset_menu!\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def each\n each_locale { |locale| yield Translation.new(self, locale) }\n end",
"def setup_mass_copy_translations\n end",
"def reset_data\n ExpressTranslate.reset\n puts \"Reset successful!\"\n end",
"def unload_target!\n listeners_for(:before_load_target).each(&:before_load_target)\n clear_dynamic_resources\n clear_dynamic_resources(:static)\n Origen::Pins.clear_pin_aliases\n $dut = nil\n end",
"def fill_with_default_slug\n return if self.localized?\n\n # we do not want to add a new translation because the content entry\n # is not truly \"localized\".\n __locales = self._locales.dup\n\n default_slug = self._slug_translations[self.mounting_point.default_locale]\n\n self.mounting_point.locales.each do |locale|\n Locomotive::Mounter.with_locale(locale) do\n self._slug = default_slug if self._slug.blank?\n end\n end\n\n self._locales = __locales\n end",
"def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end",
"def load_translations_and_collect_file_errors(files); end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def destroy_empty_translations(required_attributes)\n empty_translations = select{ |t| required_attributes.map(&t.method(:send)).none? }\n destroy(empty_translations) if empty_translations.any?\n end",
"def unfold_languages\n {\n name: :name,\n keywords: :keywords,\n description: :description,\n privacyURL: :privacy_url,\n supportURL: :support_url,\n marketingURL: :marketing_url,\n releaseNotes: :release_notes\n }.each do |json, attribute|\n instance_variable_set(\"@#{attribute}\".to_sym, LanguageItem.new(json, languages))\n end\n end",
"def cleanup\n @transition_map.each do |type, events_to_transition_arrays|\n events_to_transition_arrays.each do |event, transitions|\n transitions.clear\n end\n end\n\n @transition_map = nil\n @state_machine = nil\n @entry_actions = nil\n @exit_actions = nil\n end",
"def clear_transforms\n rm(\"/augeas/load/*\")\n end",
"def all_locales\n locales = slugged_attributes\n .map { |attr| send(\"#{attr}_translations\").keys if respond_to?(\"#{attr}_translations\") }\n .flatten.compact.uniq\n locales = I18n.available_locales if locales.empty?\n locales\n end",
"def empty_column_translation\n @column_translation = {}\n end",
"def set_language_dependent_sorting\n for model in APPCTRL_TRANSLATABLE_MODELS\n model.set_sorting() if model.respond_to?( :set_sorting )\n end\n end",
"def enforce_available_locales!(locale); end",
"def missing_localizations(org_base='en-US')\n @langs = {}\n @missing_localizations = {}\n @l_files = Dir[File.join( RAILS_ROOT, '/lang/ui', '*.yml')]\n @l_files.each do |file| \n if YAML.load_file(file)\n @langs[File.basename(file, '.*')] = YAML.load_file(file).symbolize_keys \n else\n p \"error with the following file: #{file}, the file might be empty\"\n end\n end\n @base_keys = @langs[org_base]\n unless @base_keys.blank?\n @langs.each_key do |@lang|\n @base_keys.each_key do |key|\n unless @langs[@lang].include?(key)\n @missing_localizations[@lang] ||= {}\n @missing_localizations[@lang] = @missing_localizations[@lang].merge({key.to_sym => @base_keys[key]})\n end\n end\n end\n else\n p \"your #{org_base} file seems empty\"\n end\n @missing_localizations\n end",
"def clear\n @autoloaded_classes.to_a.reverse_each do |klass|\n RubyCodeAutoreloader::ClassLoader.remove_constant(klass)\n @autoloaded_classes.delete(klass)\n end\n\n @existing_modules_before_load.clear\n @autoloaded_files = []\n ActiveSupport::DescendantsTracker.clear\n ActiveSupport::Dependencies.clear\n end",
"def purge_all\n initialize\n end",
"def disable_clear_and_finalize; end",
"def import_translations(path, page)\n old_translations = page.translations.pluck(:locale)\n new_translations = []\n\n Dir[\"#{path}content.*.html\"].each do |file_path|\n locale = File.basename(file_path).match(%r{content\\.(\\w+)\\.html})[1]\n new_translations << locale\n\n translation = page.translations.where(locale: locale).first_or_initialize\n\n next unless fresh_seed?(translation, file_path)\n\n # reading file content in, resulting in a hash\n fragments_hash = parse_file_content(file_path)\n\n # parsing attributes section\n attributes_yaml = fragments_hash.delete(\"attributes\")\n attrs = YAML.safe_load(attributes_yaml)\n\n # applying attributes\n layout = site.layouts.find_by(identifier: attrs.delete(\"layout\")) || page.try(:layout)\n translation.attributes = attrs.merge(\n layout: layout\n )\n\n # applying fragments\n old_frag_identifiers = translation.fragments.pluck(:identifier)\n\n new_frag_identifiers, fragments_attributes =\n construct_fragments_attributes(fragments_hash, translation, path)\n translation.fragments_attributes = fragments_attributes\n\n if translation.save\n message = \"[CMS SEEDS] Imported Translation \\t #{locale}\"\n ComfortableMexicanSofa.logger.info(message)\n\n # cleaning up old fragments\n frags_to_remove = old_frag_identifiers - new_frag_identifiers\n translation.fragments.where(identifier: frags_to_remove).destroy_all\n\n else\n message = \"[CMS SEEDS] Failed to import Translation \\n#{locale}\"\n ComfortableMexicanSofa.logger.warn(message)\n end\n end\n\n # Cleaning up removed translations\n translations_to_remove = old_translations - new_translations\n page.translations.where(locale: translations_to_remove).destroy_all\n end",
"def use_i18n; end",
"def index\n @translations = @locale.translations.all(:order => \"raw_key, pluralization_index\")\n end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance_or_fallback(locale)\n end\n end",
"def cleanup\n @models.reverse_each(&:destroy_all)\n end",
"def missing_translations\n @translations.select { |x, v| v.nil? or v.blank? }\n end",
"def unload\n mutex.synchronize do\n # We are going to keep track of the files that were required by our\n # autoloads to later remove them from $LOADED_FEATURES, thus making them\n # loadable by Kernel#require again.\n #\n # Directories are not stored in $LOADED_FEATURES, keeping track of files\n # is enough.\n unloaded_files = Set.new\n\n autoloads.each do |abspath, (parent, cname)|\n if parent.autoload?(cname)\n unload_autoload(parent, cname)\n else\n # Could happen if loaded with require_relative. That is unsupported,\n # and the constant path would escape unloadable_cpath? This is just\n # defensive code to clean things up as much as we are able to.\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n end\n\n to_unload.each do |cpath, (abspath, (parent, cname))|\n # We have to check cdef? in this condition. Reason is, constants whose\n # file does not define them have to be kept in to_unload as explained\n # in the implementation of on_file_autoloaded.\n #\n # If the constant is not defined, on_unload should not be triggered\n # for it.\n if !on_unload_callbacks.empty? && cdef?(parent, cname)\n value = parent.const_get(cname)\n run_on_unload_callbacks(cpath, value, abspath)\n end\n\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n\n unless unloaded_files.empty?\n # Bootsnap decorates Kernel#require to speed it up using a cache and\n # this optimization does not check if $LOADED_FEATURES has the file.\n #\n # To make it aware of changes, the gem defines singleton methods in\n # $LOADED_FEATURES:\n #\n # https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb\n #\n # Rails applications may depend on bootsnap, so for unloading to work\n # in that setting it is preferable that we restrict our API choice to\n # one of those methods.\n $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }\n end\n\n autoloads.clear\n autoloaded_dirs.clear\n to_unload.clear\n lazy_subdirs.clear\n\n Registry.on_unload(self)\n ExplicitNamespace.unregister_loader(self)\n\n @setup = false\n @eager_loaded = false\n end\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def translated_locales\r\n all.distinct(\"locale\").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)\r\n end"
] |
[
"0.6890106",
"0.6849679",
"0.6837956",
"0.6833947",
"0.6544167",
"0.65328145",
"0.639525",
"0.6362533",
"0.6293889",
"0.62539196",
"0.62218136",
"0.61651367",
"0.60983944",
"0.60973525",
"0.6094566",
"0.60881585",
"0.60881585",
"0.60396343",
"0.6032227",
"0.6020931",
"0.5892163",
"0.57935035",
"0.57633626",
"0.57452273",
"0.57236767",
"0.569309",
"0.5675507",
"0.56543",
"0.564616",
"0.5559751",
"0.5526641",
"0.55263174",
"0.550585",
"0.54930615",
"0.5454841",
"0.5422947",
"0.54176277",
"0.53917235",
"0.537899",
"0.53702533",
"0.5367433",
"0.5364089",
"0.5347322",
"0.53458405",
"0.53414285",
"0.5328807",
"0.5326499",
"0.52919334",
"0.5286966",
"0.5286966",
"0.5284579",
"0.5281346",
"0.52731943",
"0.52615935",
"0.52543694",
"0.5249996",
"0.52352875",
"0.52326924",
"0.52310663",
"0.5209188",
"0.5187672",
"0.5178093",
"0.51674443",
"0.5157205",
"0.513194",
"0.5130933",
"0.5127748",
"0.5115885",
"0.50888354",
"0.50864923",
"0.5086134",
"0.5084336",
"0.5074974",
"0.50746644",
"0.5069218",
"0.5044948",
"0.5041592",
"0.50254655",
"0.5025436",
"0.50215536",
"0.5001595",
"0.49970716",
"0.49780792",
"0.49778014",
"0.4967433",
"0.49633735",
"0.4963288",
"0.49550685",
"0.4954192",
"0.49477997",
"0.49436125",
"0.49398696",
"0.49398696",
"0.49348998",
"0.4934669",
"0.49266887",
"0.49197078",
"0.49158227",
"0.49153936",
"0.49153936",
"0.4911573"
] |
0.0
|
-1
|
Load translations from files that belong to the current locale.
|
def init_translations; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations_and_collect_file_errors(files); end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def create_locale_files\n @i18n_scope = model.i18n_scope.to_s\n @i18n_key = model.model_name.i18n_key.to_s\n @columns = model.column_names\n\n options[:locales].each do |locale|\n @locale = locale\n locale_file = File.join(\n 'config/locales/models', model_name.underscore, \"#{@locale}.yml\"\n )\n template 'locale.yml', locale_file\n end\n rescue NameError\n puts \"#{model_name} is undefined.\"\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def i18n\n %w(en es).each do |locale|\n copy_file \"i18n.#{ locale }.yml\", \"config/locales/seo_landing_pages.#{ locale }.yml\"\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def get_files\n self.locales.each do |l|\n self.files[l] = Dir.glob(\"#{self.locale_dir}/*#{l}.#{self.source_format}\")\n\n next if l == self.default_locale\n\n self.files[self.default_locale].each do |original_file|\n locale_file = original_file.gsub(\"#{self.default_locale}.#{self.source_format}\", \"#{l}.#{self.source_format}\")\n\n next if self.files[l].include?(locale_file)\n\n create_locale_file(locale_file, original_file)\n\n self.files[l] << locale_file\n end\n end\n end",
"def import_translations(path, page)\n old_translations = page.translations.pluck(:locale)\n new_translations = []\n\n Dir[\"#{path}content.*.html\"].each do |file_path|\n locale = File.basename(file_path).match(%r{content\\.(\\w+)\\.html})[1]\n new_translations << locale\n\n translation = page.translations.where(locale: locale).first_or_initialize\n\n next unless fresh_seed?(translation, file_path)\n\n # reading file content in, resulting in a hash\n fragments_hash = parse_file_content(file_path)\n\n # parsing attributes section\n attributes_yaml = fragments_hash.delete(\"attributes\")\n attrs = YAML.safe_load(attributes_yaml)\n\n # applying attributes\n layout = site.layouts.find_by(identifier: attrs.delete(\"layout\")) || page.try(:layout)\n translation.attributes = attrs.merge(\n layout: layout\n )\n\n # applying fragments\n old_frag_identifiers = translation.fragments.pluck(:identifier)\n\n new_frag_identifiers, fragments_attributes =\n construct_fragments_attributes(fragments_hash, translation, path)\n translation.fragments_attributes = fragments_attributes\n\n if translation.save\n message = \"[CMS SEEDS] Imported Translation \\t #{locale}\"\n ComfortableMexicanSofa.logger.info(message)\n\n # cleaning up old fragments\n frags_to_remove = old_frag_identifiers - new_frag_identifiers\n translation.fragments.where(identifier: frags_to_remove).destroy_all\n\n else\n message = \"[CMS SEEDS] Failed to import Translation \\n#{locale}\"\n ComfortableMexicanSofa.logger.warn(message)\n end\n end\n\n # Cleaning up removed translations\n translations_to_remove = old_translations - new_translations\n page.translations.where(locale: translations_to_remove).destroy_all\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def load_english_a\n File.open(\"test/test_files/english_a.txt\", \"r\").read\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def read\n result = {}\n \n Dir[File.join(Rails.root.join('config/locales'), '*.yml')].sort.each do |file|\n yml = YAML::load(IO.read(file))\n hash = @locale ? yml.to_hash[@locale] : yml.to_hash\n result.deep_merge! hash unless hash.nil?\n end\n\n result\n end",
"def load_yml(filename)\n require 'yaml' unless defined? YAML\n data = YAML::load(IO.read(filename))\n data.each {|locale, d| merge_names(locale, d)}\n end",
"def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end",
"def get_po\r\n\r\n send_file(\"#{Rails.root}/po/#{params[:locale]}/#{APP_SID}.po\",\r\n :filename => \"#{APP_SID}.po\",\r\n :type => \"text/x-gettext-translation\")\r\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def dump\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n delete_all unless Interpret.soft\n\n records = []\n files.each do |f|\n ar = YAML.load_file f\n locale = ar.keys.first\n records += parse_hash(ar.first[1], locale)\n end\n\n # TODO: Replace with activerecord-import bulk inserts\n transaction do\n records.each {|x| x.save(:validate => false)}\n end\n end",
"def remove_locale_file language\n File.delete yml_path(language) if File.exists?(yml_path language)\n\n new_load_paths = I18n.load_path.map do |path|\n path unless path.include?(\"#{language}.yml\")\n end.compact\n\n I18n.load_path = new_load_paths\n\n I18n.locale = I18n.default_locale\nend",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def localeList\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\t@locales\n\t\tend",
"def load!(files)\n raise NoConfigFiles if !files || files.empty?\n files.each do |path|\n load path if File.readable?(File.expand_path(path))\n end\n end",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def translate_file(filename)\n f = File.read(filename)\n f = translate_title(f)\n f = translate_body(f)\n f = update_category(f)\n f\n end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def update_sources\n source_files_path = Dir['config/locales/**/*.en-EU.yml']\n source_files_path.each do |path|\n puts \"update #{path}\"\n @crowdin.update_file([{ dest: \"/#{File.basename(path).gsub('en-EU', 'en')}\",\n source: path }])\n end\n\n source_files_path = Dir['config/locales/main/en-EU.yml']\n source_files_path.each do |path|\n puts \"update #{path}\"\n @crowdin.update_file([{ dest: '/main.en.yml',\n source: path }])\n end\n end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end",
"def setLocale locale\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\tif @locales.empty?\n\t\t\t\traise SimpleLion::FilesystemException.new(@basepath, \"No SLLF files present!\")\n\t\t\tend\n\t\t\tif locale != nil\n\t\t\t\tif !@locales.include?(locale)\n\t\t\t\t\traise SimpleLion::FileException.new(@basepath + \"/\" + locale + \".sllf\", \"No such locale!\")\n\t\t\t\tend\n\t\t\t\t@locale = locale\n\t\t\t\t@file = []\n\t\t\t\tfilepath = @basepath + \"/\" + @locale + \".sllf\"\n\t\t\t\tFile.open(filepath) do |fh|\n\t\t\t\t\tname = \"\"\n\t\t\t\t\tvalue = \"\"\n\t\t\t\t\tcategory = nil\n\t\t\t\t\tcategories = []\n\t\t\t\t\ti = 0\n\t\t\t\t\tfh.readlines.each do |line|\n\t\t\t\t\t\tline.strip!\n\t\t\t\t\t\ti = i+1\n\t\t\t\t\t\tif line[0] == '['\n\t\t\t\t\t\t\tif !name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Not adding previous string because found the beginning of another string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tparsed = line.partition(\"[\").last.partition(\"]\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"[\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"[\").last.partition(\"]\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = parsed\n\t\t\t\t\t\telsif line[0] == '{'\n\t\t\t\t\t\t\tparsed = line.partition(\"{\").last.partition(\"}\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"{\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"{\").last.partition(\"}\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty category declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif parsed == \"end\"\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Encountered end-of-category not matching to a category! Skipping...\\n\"\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\ttmpcat = category\n\t\t\t\t\t\t\t\t\t\tcategory = categories.pop\n\t\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t\t@file << tmpcat\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(tmpcat)\n\t\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tif category != nil\n\t\t\t\t\t\t\t\t\t\tcategories << category\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tcategory = SimpleLion::LocalizationCategory.new(parsed)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tvalue = line\n\t\t\t\t\t\t\tif name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping value of invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif value.empty?\n\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping empty value of string!\\n\"\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tstr = SimpleLion::LocalizationString.new(name, value)\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t@file << str\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(str)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = \"\"\n\t\t\t\t\t\t\tvalue = \"\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def locale_file_path(locale)\n \"config/locales/#{locale}.yml\"\n end",
"def ensure_source_processed(translated_filename)\n return unless $SOURCE.empty?\n\n source_filename = File.dirname(translated_filename) + '/en.yml'\n source_contents = File.read(source_filename)\n original_source = YAML.safe_load(source_contents)\n convert_source('', original_source['en'])\nend",
"def load(filename)\n files= filename.include?(',') ? filename.split(',') : [filename]\n @yml = files.inject({}) do |total_merge,file|\n total_merge.merge!(::YAML.load(ERB.new(File.read(\"#{yml_directory}/#{file}\")).result(binding)))\n end\n end",
"def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end",
"def load_resources\n resource_path = File.join(File.dirname(__FILE__), \"resources\")\n Similar.load_all_ruby_files_from_path(resource_path)\n end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end",
"def translations\n collection = Collection.new\n\n # add all translations from the database to the collection\n collection.add(find_database_translations(@texts)) if @use_db\n\n # request translations for all texts that aren't in the database\n untranslated = untranslated(collection)\n if untranslated.present?\n provider_translations = find_provider_translations(untranslated)\n save_database_translations(provider_translations)\n collection.add(provider_translations)\n end\n\n # puts collection.description\n collection\n end",
"def translations; end",
"def setup_language_resources\n I18n.load_path = ['features/resources/localisation/english.yml']\n\n case ENV['Language']\n when 'english'\n I18n.locale = :en\n when 'spanish'\n I18n.locale = :es\n when 'italian'\n I18n.locale = :it\n else\n abort(\"Incorrect language set, cannot continue the test run: supported are 'english', 'italian' or 'spanish'\")\n end\nend",
"def run\n locales.each do |locale|\n # checking that all files / keys exist for any non.default locale\n self.files[locale].each do |file|\n build_hash(file)\n create_csv(file, locale)\n end\n end\n end",
"def import\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_import_file_given')) and return unless params[:importfile].present?\n filename = params[:importfile].original_filename\n extension = filename.sub(/.*\\./, '')\n if extension == 'yml'\n hash = YAML.load_file(params[:importfile].tempfile.path) rescue nil\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.cannot_parse_yaml')) and return unless hash\n CouchbaseI18n.traverse_flatten_keys(hash).each do |key, value|\n existing = CouchbaseI18n::Translation.find_by_translation_key(key)\n if existing\n if existing.translation_value != value\n existing.translation_value = value\n existing.translated = true\n existing.save\n end\n else\n CouchbaseI18n::Translation.create :translation_key => key, :translation_value => value\n end\n end \n else\n redirect_to({:action => :index, :offset => params[:offset]}, :alert => I18n.t('couchbase_i18n.translation.no_proper_import_extension', :extension => extension)) and return \n end\n redirect_to({:action => :index, :offset => params[:offset]}, :notice => I18n.t('couchbase_i18n.translation.file_imported', :filename => filename))\n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def file_dumps\r\n Dir.new(translation_base).entries.select{|x| x['.yml']}\r\n end",
"def save!\n if self.file =~ LOCALE_INTERPOLATOR\n I18n.available_locales.each do |locale|\n write_file(file_for_locale(locale), self.translations.slice(locale))\n end\n else\n write_file\n end\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def fill_file_ios(language, translations)\n translations[:filename] = language.to_s.downcase + \".lproj/\" + \"Localizable.strings\"\n file = translations[:file]\n\n # Header\n file.puts \"/*\"\n file.puts \" Localizable.strings\"\n file.puts \" \" + @project.name\n file.puts \"\"\n file.puts \" Created on Translate Community on \" + Time.new.strftime(\"%d.%m.%y\")\n file.puts \"*/\"\n file.puts \"\"\n\n # Content\n translations.each do |key, value|\n unless key == :file or key == :filename\n file.puts \"\\\"\" + key.gsub(/[^\\\\]\"|^\"/) { |s| (s.size > 1 ? s.first : \"\") + \"\\\\\\\"\"} + \"\\\" = \\\"\" + value[:value].gsub(/[^\\\\]\"|^\"/) {|s| (s.size > 1 ? s.first : \"\") + \"\\\\\\\"\"} + \"\\\";\"\n end\n end\n\n file.close\n end",
"def process_locale(locale)\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(\"#{locale}_tmp\")\n\n # Remove temporary directory if it exists\n FileUtils.rm_rf output_dir\n\n # Output results to temporary directory\n Dir[templ_dir.join('**/*.yml')].each do |f|\n process_file(\n Pathname.new(f).relative_path_from(templ_dir), # Filename\n locale, # Locale\n \"#{locale}_tmp\" # Output locale \n )\n end\n\n # Override the locales folder\n FileUtils.rm_rf local_dir\n FileUtils.mv output_dir, local_dir\n end",
"def generate\n I18n.backend.load_translations\n translations = wrap(source_translations)\n I18n.backend.store_translations(destination_locale, translations)\n I18n.available_locales += [destination_locale]\n end",
"def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end",
"def load_files(*files)\n dsl = DSL.new(self)\n files.each do |file|\n next unless File.file?(file) # TODO: warn ?\n #begin\n dsl.instance_eval(File.read(file), file)\n #rescue => e\n # raise e if $DEBUG\n # warn e.message\n #end\n end\n end",
"def upload_files(locale_files, default_locale:)\n is_default = ->(l) { l.locale_name == default_locale }\n\n # Ensure the locales all exist\n STDERR.puts('Creating locales')\n known_locales = fetch_locales.index_by(&:name)\n threaded_request(locale_files) do |locale_file|\n unless known_locales.has_key?(locale_file.locale_name)\n create_locale(locale_file.locale_name, default: is_default.(locale_file))\n end\n end\n\n # Upload the files in a stable order, ensuring the default locale is first.\n locale_files.sort! do |a, b|\n next -1 if is_default.(a)\n next 1 if is_default.(b)\n\n a.locale_name <=> b.locale_name\n end\n\n uploads = {}\n\n uploads = locale_files.to_h do |locale_file|\n STDERR.puts(\"Uploading #{locale_file}\")\n upload_id = upload_file(locale_file)\n [upload_id, locale_file]\n end\n\n # Validate the uploads, retrying failures as necessary\n successful_upload_ids = {}\n\n STDERR.puts('Verifying uploads...')\n until uploads.empty?\n threaded_request(uploads.to_a) do |upload_id, locale_file|\n upload = phraseapp_request(Phrase::UploadsApi, :upload_show, @project_id, upload_id)\n\n case upload.state\n when \"enqueued\", \"processing\"\n STDERR.puts(\"#{locale_file}: still processing\")\n when \"success\"\n STDERR.puts(\"#{locale_file}: success\")\n successful_upload_ids[locale_file.locale_name] = upload_id\n uploads.delete(upload_id)\n when \"error\"\n STDERR.puts(\"#{locale_file}: upload failure, retrying\")\n new_upload_id = upload_file(locale_file)\n uploads.delete(upload_id)\n uploads[new_upload_id] = locale_file\n else\n raise RuntimeError.new(\"Unknown upload state: #{upload.state}\")\n end\n end\n\n sleep(2) unless uploads.empty?\n end\n\n successful_upload_ids\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def lang_files\n @@languages\n end",
"def loadFiles( reload = false )\n\t\t\t\tfiles().each do |file|\n\t\t\t\t\tfile.load( reload )\n\t\t\t\tend\n\t\t\tend",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.yaml_parts_in_loading_order.each do |yaml_part|\n yaml_data = YAML.load_file(yaml_part)\n part_sections = File.basename(yaml_part, '.yml').split('.')\n part_sections.delete_at 0 # delete the 'en' at the beginning\n if part_sections.empty?\n @data.merge! yaml_data\n else\n begin\n target_section = @data[*part_sections]\n raise EntryNotFound unless target_section.respond_to? :merge!\n target_section.merge! yaml_data\n rescue EntryNotFound\n @data[*part_sections] = yaml_data\n end\n end\n end\n \n @ruby_parts.each do |ruby_part|\n Kernel.load ruby_part\n end\n end",
"def create_local\n template \"config/locales/en.rb\", \"config/locales/#{class_name.underscore}.en.yml\"\n end",
"def translations\n @translations ||= {}\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def filenames_for_current_locale; end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def missing_localizations(org_base='en-US')\n @langs = {}\n @missing_localizations = {}\n @l_files = Dir[File.join( RAILS_ROOT, '/lang/ui', '*.yml')]\n @l_files.each do |file| \n if YAML.load_file(file)\n @langs[File.basename(file, '.*')] = YAML.load_file(file).symbolize_keys \n else\n p \"error with the following file: #{file}, the file might be empty\"\n end\n end\n @base_keys = @langs[org_base]\n unless @base_keys.blank?\n @langs.each_key do |@lang|\n @base_keys.each_key do |key|\n unless @langs[@lang].include?(key)\n @missing_localizations[@lang] ||= {}\n @missing_localizations[@lang] = @missing_localizations[@lang].merge({key.to_sym => @base_keys[key]})\n end\n end\n end\n else\n p \"your #{org_base} file seems empty\"\n end\n @missing_localizations\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def assert_file_named_correctly!(file, translations); end"
] |
[
"0.8110398",
"0.8110398",
"0.8002204",
"0.7828437",
"0.7494513",
"0.7494513",
"0.7382705",
"0.7329905",
"0.725488",
"0.7182078",
"0.7167792",
"0.71451235",
"0.71451235",
"0.6969895",
"0.6852915",
"0.6847574",
"0.6830502",
"0.68037724",
"0.6780127",
"0.6670729",
"0.66265965",
"0.6533084",
"0.64989793",
"0.6456759",
"0.6445825",
"0.63377887",
"0.63192874",
"0.6285082",
"0.62767357",
"0.6276464",
"0.62635994",
"0.6204956",
"0.61997414",
"0.6182364",
"0.6168926",
"0.6103834",
"0.60947555",
"0.6085054",
"0.6082236",
"0.606021",
"0.60514385",
"0.5996456",
"0.5980758",
"0.5961024",
"0.5947116",
"0.59384286",
"0.5933586",
"0.59169286",
"0.5897739",
"0.58876395",
"0.585174",
"0.58338404",
"0.582577",
"0.5798988",
"0.5768087",
"0.5762249",
"0.5747769",
"0.5741118",
"0.5720591",
"0.5692051",
"0.568651",
"0.56803095",
"0.56762713",
"0.5665237",
"0.56531",
"0.5642596",
"0.56255853",
"0.5618438",
"0.5616301",
"0.56082225",
"0.559552",
"0.55937994",
"0.5592511",
"0.55892485",
"0.55842936",
"0.5583052",
"0.55827934",
"0.557172",
"0.55537426",
"0.55420256",
"0.5534976",
"0.5533221",
"0.5531452",
"0.5521004",
"0.5513173",
"0.55093485",
"0.55072075",
"0.55045104",
"0.54940075",
"0.54887384",
"0.5465595",
"0.54655206",
"0.54645723",
"0.54545027",
"0.5450887",
"0.54464334",
"0.5441147",
"0.54353833",
"0.54273725",
"0.54237586"
] |
0.57182807
|
59
|
Checks if a filename is named in correspondence to the translations it loaded. The locale extracted from the path must be the single locale loaded in the translations.
|
def assert_file_named_correctly!(file, translations); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_translation? translation_file\n raise TranslationFileNotFound, \"Translation file is required\" unless translation_file\n raise TranslationFileNotFound, \"Unable to find Translation File #{translation_file}\" unless File.exists?(translation_file)\n end",
"def has_file? name\n File.file? path / name\n end",
"def translate_file?(page)\n test = page\n test = test.gsub('./', '') if page[0..1] == './'\n test = test.gsub('.text.html.erb', '')\n test = test.gsub('.text.plain.erb', '')\n test = test.gsub('.html.erb', '')\n test.split('.').length == 1\n end",
"def localized_strings?\n @lstrings ||= entry[:localized] && entry[:filename] =~ /strings.js$/\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def check_locale(dict_name, filepath)\n num_errors = 0\n locale_hash = recursive_parsing(YAML.load_file(filepath))\n\n FFI::Hunspell.dict(dict_name) do |dict|\n customize_dictionary(dict_name, dict)\n locale_hash.each do |key, sentence|\n # Ignore any variables for spell checking.\n sentence.gsub!(/%{\\w+}/, '')\n # Ignore the expected temperature guidance.\n sentence.gsub!('100.4°F/38°C', '')\n # Track if we already printed the YAML path and the sentence.\n already_put_context = false\n words = sentence.scan(/[[:alpha:]\\w'-]+/)\n words.each do |word|\n # Safety check if word is not actually a String.\n next if !word.is_a? String\n # dict.check? returns true if correctly spelled and false if incorrect.\n next if dict.check?(word)\n # Detected an error, so print the error and suggested fixes.\n if !already_put_context\n puts \"\\n\\t#{key}\"\n puts \"\\t#{sentence}\"\n already_put_context = true\n end\n puts \"\\t\\tSPELLING ERROR: #{word}\"\n puts \"\\t\\t\\tSUGGESTIONS: #{dict.suggest(word)}\"\n num_errors += 1\n end\n end\n end\n puts \"\\n\\tFound #{num_errors} errors when checking locale file #{filepath}\"\n num_errors\n end",
"def contain?(filename); end",
"def file?(name)\n File.file?(path(name))\n end",
"def file_exists?(name)\n File.file?(File.join(path, name))\n end",
"def file?(path)\n ::File.file?(prefixed(path))\n end",
"def load_translations_and_collect_file_errors(files); end",
"def has_file?(path)\n @data[:files].has_key? path.to_sym\n end",
"def correctly_named?(file)\n chunks = file.basename.to_s.split('.')\n\n return true if name_checks_out?(chunks)\n\n raise Aur::Exception::LintBadName\n end",
"def english_header?\n result = File.exists?(@@default_en)\n if result\n @@log.info \"#{__method__}: Default English was found at #{@@default_en}\"\n else\n @@log.error \"#{__method__}: Cannot find the default English localization file. Check the value of @@default_en in this script.\"\n end\n result\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def marshalized_text_file_exist?(filename)\n if PSDK_CONFIG.release?\n vdfilename = VD_TEXT_FILENAME\n ::Kernel::Loaded[vdfilename] = Yuki::VD.new(vdfilename, :read) unless ::Kernel::Loaded.key?(vdfilename)\n return ::Kernel::Loaded[vdfilename].exists?(File.basename(filename))\n end\n return File.exist?(filename)\n end",
"def path_existance_check(path_name_param, path_name, lang_choice)\n if Dir.exists?(path_name_param)\n haml_existance_check(path_name, lang_choice)\n return 0\n else\n $flag = 2\n if lang_choice == 1\n puts 'No such directory found'\n else\n puts \"Aucun répertoire de ce type n'a été trouvé\"\n end\n return -1\n end\n end",
"def local_import?(ln, words)\r\n tmp = nil\r\n\r\n settings.file_order.each do |f|\r\n words[1..-1].each do |w|\r\n w.delete!(\"'\\\"\")\r\n # Remove . from relative path\r\n while w[0] == \".\" do w = w[1..-1] end\r\n\r\n tmp = ln if f.include?(w.downcase)\r\n end\r\n end\r\n\r\n removed << tmp unless tmp.nil?\r\n !tmp.nil?\r\n end",
"def file?(path)\n File.file?(path_of(path))\n end",
"def exists?(filename)\n @catalog.file_entries.find { |f| filename == f.name.strip }\n end",
"def pr_contains_localization_changes\n files = danger_file.git.added_files + danger_file.git.modified_files\n\n !files.grep(/.strings/).empty?\n end",
"def test_file_existence(filename, path, file_data = nil)\n return true if file_data&.exists?(filename.downcase)\n return true if File.exist?(format(Common_filename_format, path, filename).downcase)\n false\n end",
"def key_exist?(key)\n FastGettext.key_exist?(key)\n rescue Errno::ENOENT => error\n Yast.y2warning(\"File not found when translating '#{key}' on textdomain #{@my_textdomain}'. \"\\\n \"Error: #{error}. Backtrace: #{error.backtrace}\")\n false\n end",
"def check_file(path, extnames)\n check_file_extname(path, extnames)\n check_file_exist(path)\n end",
"def special_rename?(path)\n %w[\n thor_template.gemspec\n exe/thor_template\n lib/thor_template.rb\n ].include?(path)\n end",
"def knows?(name)\n !find_file(name).nil?\n end",
"def file?(file_path)\n nlst(file_path)[0] == file_path\n end",
"def strict_file_exists?(path)\n directory = `dirname #{path}`.chomp\n name = `basename #{path}`.chomp\n !`find \"#{directory}\" -name \"#{name}\"`.empty?\n end",
"def check\n prefix = File.basename(@file)\n if File.exist?(@file)\n @message = \"#{prefix} : Expected file exists\"\n true\n else\n @message = \"#{prefix} : Expected file not found.\"\n false\n end\n end",
"def contains? path\n @contents.any? do |line|\n File.fnmatch? line, path\n end\n end",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def loaded?(path)\n path = cleanpath(path).chomp('.rb')\n loaded.include?(path)\n end",
"def file_exist?(path)\n full_path = ::File.join(@static_server.root, ::Merb::Parse.unescape(path))\n ::File.file?(full_path) && ::File.readable?(full_path)\n end",
"def decide_filenames key\n filenames = []\n # Origin or developer mode, the translations will be applied to the original\n # file where those where setup, including plugin folders\n if self.class.mode == :origin\n filename, found_locale = get_translation_origin_filename(key)\n # If filename is outside rail.root send it to config/locales/external_#{translations_locale_name}.yml\n filename = replace_external_to_application_file_paths(filename) if filename.present?\n\n # Doesn't exist the translation for current locale, but it does in another\n if found_locale.present? && found_locale.to_s != self.locale.to_s\n # We try to generate the filename replacing the '/existing_locale/' section\n # in path for the new_locale\n filename = find_or_create_origin_filename(filename, found_locale)\n end\n if filename\n filenames << filename\n end\n end\n #\n # Normal app mode, the translation will be dumped together to /config/locales/#{locale}.yml to keep\n # in sync with the original source of the translation\n #\n create_empty_translations_file(application_mode_file_path) if !File.exists?(application_mode_file_path)\n filenames << application_mode_file_path\n #\n # Path to the backup file of the current translation request/transaction\n #\n filenames << log_file_path\n\n filenames\n end",
"def check_file_extname(path, extnames)\n case extnames\n when Array\n raise \"Extension is not #{extnames}: #{path}\" unless extnames.include?(File.extname(path))\n when File.extname(path)\n true\n else\n raise \"Extension is not #{extnames}: #{path}\"\n end\n end",
"def language_image_exists?( filename )\n return ((!filename.blank?) and FileTest.exists?(\"#{RAILS_ROOT}/public/#{filename}\"))\n end",
"def file_correct?(file_path)\n raise 'ERROR: Is your file path correct ?' unless File.exist?(file_path)\n end",
"def _valid_file?(name)\n @cache_valid ||= {}\n @cache_valid[name.to_sym] ||= !_config_files(name).empty?\n end",
"def in_path?\n config.paths.any? do |path_spec|\n path_spec === file\n end\n end",
"def exists?(name)\r\n \t!template_paths(name).empty?\r\n end",
"def has_file?(filename)\n self.files.detect {|f| f[:name] == filename }.present?\n end",
"def formatted?(path)\n MARKUPS.values.any? { |exts| exts.include?(File.extname(path)) }\n end",
"def test_identify_language_from_filename\n filename = 'one.fp'\n femp = Locale.new('femp', 'fp', 'fpt')\n curriculum.add(femp, %w(one two))\n assert_equal 'femp', curriculum.identify_language('femp.fp')\n end",
"def locale_of(filename)\n locale = (filename =~ extension_regex ? $1 : nil)\n locale ? locale.gsub(/^\\./, '').to_sym : nil\n end",
"def contains?(locale, name)\r\n self[locale].has_key?(name.to_s)\r\n end",
"def file_exist?(file_path)\n File.exist?(file_path)\n end",
"def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end",
"def loaded?(language_name = nil)\n if language_name\n self.loaded_languages.include? language_name\n else\n not self.loaded_languages.blank?\n end\n end",
"def exist?(name)\n File.exist?(path(name))\n end",
"def transition_exist?(filename)\n test_file_existence(filename, Transitions_Path, @transition_data)\n end",
"def is_file?(path)\n ::File.file? abspath(path)\n end",
"def load_file(file_name)\n @loadOK = false \n begin\n @template = File.read(file_name)\n @loadOK = true \n rescue => ex\n @template = ex.to_s \n @loadOK = false \n end\n return @loadOK\n end",
"def user_path?(file); end",
"def file?(path)\n eval(FILE_CHECK, binding, __FILE__, FILE_CHECK_LINE)\n nil\nend",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def file_exists?(file_path)\n File.exist? @site.in_source_dir(file_path)\n end",
"def site_uses_translated_builds(path)\n\n is_remote = opensdg_is_path_remote(path)\n endpoints = get_endpoints()\n # For a quick test, we just use 'meta'.\n meta = endpoints['meta']\n endpoint = is_remote ? path + '/' + meta : File.join(path, fix_path(meta))\n\n begin\n json_file = is_remote ? open(endpoint) : File.open(endpoint)\n rescue StandardError => e\n # If we didn't find an untranslated 'meta', we assume translated builds.\n return true\n end\n\n # Other wise assume untranslated builds.\n return false\n end",
"def check_file(filenames)\n filenames.select{ |f| File.exists?(f) }.first\n end",
"def check_template_exists(template_path)\n unless File.exist?(template_path)\n puts \"The template #{template_path} does not exist. Are you sure you use the right template name? The template name does not require the extension.\".color(:red)\n exit 1\n end\n end",
"def file?\n original_filename.present?\n end",
"def skim_file?(path)\n skim_files.include?(path)\n end",
"def file_exists?\n File.exists?(@filename)\n end",
"def _match_available_locales_only\n lambda do\n locale = remaining_path.split(\"/\").reject(&:empty?).first.to_s\n if ::R18n.available_locales.map(&:code).map(&:downcase).include?(locale.downcase)\n @captures.push(locale)\n @remaining_path = remaining_path.sub(\"/#{locale}\", \"\")\n end\n end\n end",
"def file_exists?(paths, file)\n paths.any? do |path|\n Find.find(path)\n .map { |path_file| Shellwords.escape(path_file) }\n .include?(file)\n end\n end",
"def haml_existance_check(path_name, lang_choice)\n if Dir[path_name].any?\n user_input(path_name, lang_choice)\n return 0\n else\n $flag = 2\n if lang_choice == 1\n puts 'No HAML files found in the entered directory.'\n else\n puts 'Aucun fichier HAML trouvé dans le répertoire entré.'\n end\n return -1\n end\n end",
"def filenames_for_current_locale; end",
"def exists?\n File.exists?(filename)\n end",
"def check_template_exists(template_path)\n unless File.exist?(template_path)\n puts \"The template #{template_path} does not exist. Are you sure you use the right template name? The template name does not require the extension.\".color(:red)\n exit 1\n end\n end",
"def file_exists?(file)\n File.exists?(file)\n end",
"def file_matches_criteria?(full_path)\n full_path.file? && proper_ext?(full_path) &&\n !LokaliseRails.skip_file_export.call(full_path)\n end",
"def locale_content?(base_filename_or_identifier, kind)\n base_filename_or_identifier =~ locale_exclude_regex(kind) ? false : true\n end",
"def translated?\n texts = errors.values.flatten.map(&:message)\n texts.select { |text| text.start_with?(\"translation missing\") }.empty?\n end",
"def exists?(path)\n files.include?(path)\n end",
"def has_file?(filename)\n\t\t!self.files.detect(filename).nil?\n\tend",
"def template?(name, format)\n glob = dir.join(\"#{name}.#{format}.*\")\n Dir[glob].first\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def file_exists?\r\n File.file?(full_path)\r\n end",
"def include?(file)\n @file_list.include?(file.basename)\n end",
"def is_globed_path_valid(globed_path)\n # UTF-8 - keep only files with names in\n return true if @non_utf8_paths[globed_path]\n check_utf_8_encoding_file = globed_path.clone\n unless check_utf_8_encoding_file.force_encoding(\"UTF-8\").valid_encoding?\n Log.warning(\"Non UTF-8 file name '#{check_utf_8_encoding_file}', skipping.\")\n @non_utf8_paths[globed_path] = true\n # TODO(bbfsdev): Remove line below and redundant clones of string after\n # those lines are not a GC problem.\n check_utf_8_encoding_file = nil\n return false\n end\n\n true\n end",
"def file_name_exist?(name)\n return true if !name.blank?\n errors.add(:name, \"Nazwa nie moze byc pusta!\")\n false\n end",
"def valid_file_path?(path)\n path && File.exist?(path) && File.readable?(path)\n end",
"def exist?(path)\n ::File.exist?(prefixed(path))\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/db/\\w+?/database.yml$|\n return false\n end\n return true\n end",
"def file_exists?(file)\n File.file? file\n end",
"def valid_file?(file)\n case file\n when 'exclude.exclude', 'include.include',\n 'include_exclude.exclude', 'include_exclude.include',\n 'env_exclude.env.exclude', 'env_include.env.include',\n 'include_env_exclude.include', 'include_env_exclude.env.exclude',\n 'include_exclude_env_include.exclude',\n 'include_exclude_env_exclude.include',\n 'include_env_include_env_exclude.env.exclude',\n 'exclude_env_include.exclude',\n 'exclude_env_include.env.include',\n /^include_env_include\\..*include$/,\n /^include_exclude_env_include\\..*include$/,\n /^include_exclude_env_exclude\\..*exclude$/,\n /^include_env_include_env_exclude\\..*include$/,\n /^exclude_env_exclude\\..*exclude$/,\n /^env_include_env_exclude\\.env\\./,\n /^exclude_env_include_env_exclude\\.(env\\.|exclude$)/,\n /^include_exclude_env_include_env_exclude\\./,\n /^env_symbol\\..*include$/\n return true\n when /^default\\./, /^exclude\\./, /^include\\./,\n /^env_exclude\\./, /^env_include\\./, /^include_env_include\\./,\n /^include_env_exclude\\./, /^include_exclude_env_include\\./,\n /^include_exclude_env_exclude\\./, /^exclude_env_include\\./,\n /^include_env_include_env_exclude\\./, /^exclude_env_exclude\\./,\n /^env_include_env_exclude\\./, /^exclude_env_include_env_exclude/,\n /^env_symbol\\./\n return false\n end\n\n # Raise an error if the file was not handled by existing logic.\n raise \"Invalid file (#{file}) specified in #{__method__}.\"\n end",
"def matches_filename?(filename)\r\n basename = File.basename(filename)\r\n @glob_patterns.any? {|pattern| File.fnmatch pattern, basename.downcase}\r\n end",
"def existing_file?(row)\n existing_files_by_filename.key?(row[\"filename\"])\n end",
"def file_errors_any?\n raise LucarativeAd::Error.file_type unless File.extname(@file) == \".yml\"\n raise LucarativeAd::Error.file_read unless File.exist? @file\n end",
"def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end",
"def has_local_match?(files)\n files.each do |file|\n return true if self.drive_path == file.sub_path\n end\n false\n end",
"def user_file_exist?(file)\n File.exist? user_file_path(file)\n end",
"def checkfile()\n if not File.file?(@file)\n abort(\"File #{@file} does not exist. Aborting...\")\n end\n end",
"def file_exists?(path)\n end",
"def what_language? filename\n test = filename.partition(\".\").last\n case test\n when \"rb\", \"ru\", \"erb\", \"slim\", \"haml\"\n \"Ruby\"\n when \"py\"\n \"Python\"\n when \"java\", \"jsp\", \"jsf\"\n \"Java\"\n when \"cpp\"\n \"C++\"\n when \"m\"\n \"Obj-C\"\n when \"c\"\n \"C\"\n when \"js\", \"coffee\"\n \"Javascript\"\n when \"html\"\n \"Html\"\n when \"cs\"\n \"C#\"\n when \"css\", \"scss\", \"less\"\n \"CSS\"\n when \"php\"\n \"PHP\"\n when \"md\"\n \"Readme\"\n when \"hs\"\n \"Haskell\"\n when \"pm\", \"pl\"\n \"Perl\"\n when \".sh\"\n \"Bash/Shell\"\n else\n \"Other\"\n end\nend",
"def local_file_exists?(full_path)\n File.exists?(full_path)\nend"
] |
[
"0.6395695",
"0.6377267",
"0.61988324",
"0.6192202",
"0.6184694",
"0.6061273",
"0.6058161",
"0.59734136",
"0.596862",
"0.5955389",
"0.5942154",
"0.5930342",
"0.5911605",
"0.59033096",
"0.58174664",
"0.5810139",
"0.5810139",
"0.5794215",
"0.577166",
"0.5768979",
"0.57588035",
"0.5755982",
"0.57542276",
"0.57319176",
"0.5710066",
"0.5695486",
"0.56953543",
"0.5695",
"0.56933355",
"0.56884223",
"0.567894",
"0.56636965",
"0.56623775",
"0.5661479",
"0.5655744",
"0.5653821",
"0.5644098",
"0.56391895",
"0.562816",
"0.56217504",
"0.56052995",
"0.56036013",
"0.559948",
"0.55890286",
"0.55853987",
"0.55840546",
"0.55708694",
"0.55671185",
"0.5562292",
"0.5547694",
"0.55405414",
"0.5533452",
"0.5528302",
"0.55171925",
"0.5514631",
"0.5505247",
"0.55003947",
"0.54967827",
"0.54967827",
"0.548992",
"0.5486951",
"0.54845583",
"0.5481203",
"0.5481136",
"0.5480408",
"0.5476278",
"0.54754233",
"0.54750955",
"0.5474969",
"0.5467492",
"0.5465528",
"0.5457553",
"0.5451825",
"0.5449177",
"0.5439039",
"0.5430828",
"0.54262507",
"0.54256403",
"0.54232675",
"0.5422917",
"0.54197425",
"0.5419503",
"0.5410866",
"0.5404349",
"0.540198",
"0.5392997",
"0.5392881",
"0.5388973",
"0.5381885",
"0.5379621",
"0.53778017",
"0.5362618",
"0.53593844",
"0.53522813",
"0.53502846",
"0.5342352",
"0.53399074",
"0.5338514",
"0.5331669",
"0.5326681"
] |
0.7073991
|
0
|
Select all files from I18n load path that belong to current locale. These files must start with the locale identifier (ie. "en", "ptBR"), followed by an "_" demarcation to separate proceeding text. source://i18n//lib/i18n/backend/lazy_loadable.rb167
|
def filenames_for_current_locale; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def localeList\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\t@locales\n\t\tend",
"def get_files\n self.locales.each do |l|\n self.files[l] = Dir.glob(\"#{self.locale_dir}/*#{l}.#{self.source_format}\")\n\n next if l == self.default_locale\n\n self.files[self.default_locale].each do |original_file|\n locale_file = original_file.gsub(\"#{self.default_locale}.#{self.source_format}\", \"#{l}.#{self.source_format}\")\n\n next if self.files[l].include?(locale_file)\n\n create_locale_file(locale_file, original_file)\n\n self.files[l] << locale_file\n end\n end\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n begin\n require(pathname = path+\"/\"+filename)\n trace :loading, \"Loaded #{pathname}\"\n filename\n rescue LoadError => e\n trace :loading, \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n rescue Exception => e\n $stderr.puts \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n end\n end.compact\n end\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def load_file_path!\n @files = FilepathScanner.call(\n include_paths,\n exclude_path_regexps,\n recursive_scan: recursive_include\n )\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_all\n return if defined?(@loaded_all)\n\n load_env\n\n paths = search_path\n unless paths.nil?\n paths.each do |dir|\n # dir is already an absolute path\n Dir.glob(File.join(dir, '*.rb')).each do |path|\n # exclude dirs that end with .rb\n load_file(path) if File.file?(path)\n end\n end\n end\n\n @loaded_all = true\n end",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def load_translations_and_collect_file_errors(files); end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end",
"def yaml_parts_in_loading_order\n ordered_yaml_parts = []\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.sort_by{|part| File.basename(part, '.yml').split('.').size}.each do |part|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n ordered_yaml_parts\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def discover_locale\n locales = Dir[\"#{locale_dir}/*\"]\n locales.map! { |e| File.basename(e) }\n locales.join(\" \")\n end",
"def load_path\n paths, file = [\"\"], current_file\n paths << File.dirname(file) if file\n paths + LOAD_PATH\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency across platforms\n @load_paths.concat(Dir[\"#{app_path}/*/\"].map(&:chop).sort!)\n end\n end\n \n @load_paths\n end",
"def decide_filenames key\n filenames = []\n # Origin or developer mode, the translations will be applied to the original\n # file where those where setup, including plugin folders\n if self.class.mode == :origin\n filename, found_locale = get_translation_origin_filename(key)\n # If filename is outside rail.root send it to config/locales/external_#{translations_locale_name}.yml\n filename = replace_external_to_application_file_paths(filename) if filename.present?\n\n # Doesn't exist the translation for current locale, but it does in another\n if found_locale.present? && found_locale.to_s != self.locale.to_s\n # We try to generate the filename replacing the '/existing_locale/' section\n # in path for the new_locale\n filename = find_or_create_origin_filename(filename, found_locale)\n end\n if filename\n filenames << filename\n end\n end\n #\n # Normal app mode, the translation will be dumped together to /config/locales/#{locale}.yml to keep\n # in sync with the original source of the translation\n #\n create_empty_translations_file(application_mode_file_path) if !File.exists?(application_mode_file_path)\n filenames << application_mode_file_path\n #\n # Path to the backup file of the current translation request/transaction\n #\n filenames << log_file_path\n\n filenames\n end",
"def default_i18n_with_milkshake\n default_i18n = default_i18n_without_milkshake\n default_i18n.load_path.concat(Milkshake.environment.locale_paths)\n default_i18n.load_path.uniq!\n default_i18n\n end",
"def find_files_for_reload\n paths = [ './', *$LOAD_PATH ].uniq\n [ $0, *$LOADED_FEATURES ].uniq.map do |file|\n next if file =~ /\\.(so|bundle)$/\n yield(find(file, paths))\n end\n end",
"def load_path(match, options={})\n return [] if options[:from]\n\n options = valid_load_options(options)\n\n found = []\n $LOAD_PATH.uniq.each do |path|\n list = Dir.glob(File.join(File.expand_path(path), match))\n list = list.map{ |d| d.chomp('/') }\n # return absolute path unless relative flag\n if options[:relative]\n # the extra '' in File.join adds a '/' to the end of the path\n list = list.map{ |f| f.sub(File.join(path, ''), '') }\n end\n found.concat(list)\n end\n found\n end",
"def all_files\n @all_files ||= load_files\n end",
"def load_current\n Dir.glob(current(\"*.rb\")) do |rb_file|\n require rb_file\n puts \"required #{File.basename(rb_file)}\"\n end\nend",
"def all_languages\n Dir.entries(metadata_path)\n .select { |f| File.directory? File.join(metadata_path, f) }\n .reject { |f| f.start_with?('.') }\n .sort { |x, y| x <=> y }\n end",
"def lookup_parts\n @yaml_parts = ActiveSupport::OrderedHash.new\n @ruby_parts = []\n \n self.lang_file_dirs.each do |lang_file_dir|\n yaml_parts_in_this_dir = Dir.glob(File.join(lang_file_dir, \"#{self.lang_code}*.yml\")).sort\n @yaml_parts[lang_file_dir] = yaml_parts_in_this_dir.collect {|part| File.basename(part)}\n ruby_part_in_this_dir = File.join(lang_file_dir, \"#{self.lang_code}.rb\")\n @ruby_parts << ruby_part_in_this_dir if File.exists?(ruby_part_in_this_dir)\n end\n \n [@yaml_parts, @ruby_parts]\n end",
"def lang_files\n @@languages\n end",
"def load_paths\n @load_paths ||= [\"urls.rb\", \"config/urls.rb\", \"mailers/*.rb\", \"controllers/**/*.rb\", \"controllers.rb\", \"helpers/*.rb\"]\n end",
"def load_imports\n while fn = @pending_imports.shift\n next if @imported.member?(fn)\n ext = File.extname(fn)\n loader = @loaders[ext] || @default_loader\n loader.load(fn)\n @imported << fn\n end\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def require_files\n @load_paths.each do |path|\n Dir[\"#{path}/**/*\"].each do |f|\n require f\n end\n end\n end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def load_resources\n resource_path = File.join(File.dirname(__FILE__), \"resources\")\n Similar.load_all_ruby_files_from_path(resource_path)\n end",
"def load_ruby_files(directory = '.')\n print \"Loading ruby files...\\n\\n\"\n files = `find #{directory} -type f -name '*.rb'`\n files.split(/\\s+/).each do |f|\n begin\n load File.expand_path(f)\n rescue Exception => e\n puts \"failed loading '#{f[/\\b[\\-\\w]+\\/.*rb$/]}': #{e}\"\n end\n end\n puts \"Done\"\nend",
"def each_file\n return unless block_given?\n\n loc_path = LokaliseRails.locales_path\n Dir[\"#{loc_path}/**/*\"].sort.each do |f|\n full_path = Pathname.new f\n\n next unless file_matches_criteria? full_path\n\n relative_path = full_path.relative_path_from Pathname.new(loc_path)\n\n yield full_path, relative_path\n end\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency\n self.class.mixable_app_types.keys.map(&:to_s).sort.each do |type|\n path = \"#{app_path}/#{type}\"\n @load_paths << path if File.directory?(path)\n end\n end\n end\n \n @load_paths\n end",
"def file_dumps\r\n Dir.new(translation_base).entries.select{|x| x['.yml']}\r\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def loadable_constants_for_path(path, bases = autoload_paths)\n path = path.chomp(\".rb\")\n expanded_path = File.expand_path(path)\n paths = []\n\n bases.each do |root|\n expanded_root = File.expand_path(root)\n next unless expanded_path.start_with?(expanded_root)\n\n root_size = expanded_root.size\n next if expanded_path[root_size] != ?/\n\n nesting = expanded_path[(root_size + 1)..-1]\n paths << nesting.camelize unless nesting.blank?\n end\n\n paths.uniq!\n paths\n end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def collect_loaded_features\n @loaded_features = []\n $LOADED_FEATURES.each {|file|\n $LOAD_PATH.each {|dir|\n file_path = File.join(dir, file)\n if File.identical?(file_path, @me)\n next\n end\n if File.file?(file_path)\n @loaded_features << file_path\n next\n end\n }\n }\n end",
"def loaded_languages\n @@cached_language_data.keys\n end",
"def load_files_in(directory_name, options = {})\n get_files_in(directory_name, options).sort.each { |ext| load ext }\n end",
"def loaded_languages\n @@languages.keys\n end",
"def lookup!\n $LOAD_PATH.each do |base|\n Dir[File.join(base, *file_lookup_paths)].each do |path|\n path = path.delete_prefix(\"#{base}/\")\n require path\n rescue Exception\n # No problem\n end\n end\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end",
"def load!(alt_path=nil)\n path = alt_path ? Pathname.new(alt_path) : pathname()\n path.glob('*').each do |file|\n #next if file.to_s.index(/[.]/) # TODO: rejection filter\n name = file.basename #path_to_name(file, path)\n self[name] = get!(file)\n end\n self\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def get_local_files regexp\n Dir[File.join(dir, '*')].select do |path|\n name = File.basename path\n File.file?(path) and name =~ regexp\n end\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def load_packages\n pattern = File.expand_path(File.join(\"..\", \"*.rb\"), File.dirname(__FILE__)) \n Dir[pattern].each {|f| load f}\n end",
"def default_load_paths\n application_load_paths.collect { |lp| File.join(lp, \"widgets\") }\n end",
"def load_paths\n @load_paths ||= Config::LoadPaths.new\n end",
"def lib_files\n @files.select do |file|\n require_paths.any? do |path|\n file.start_with? path\n end\n end\n end",
"def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def load_paths\n [root.join('lib'), root.join('spec')].join(':')\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def find_loadpath(match, options={})\n plugins = []\n #directory = options[:directory] || DIRECTORY\n $LOAD_PATH.uniq.each do |path|\n path = File.expand_path(path)\n #list = Dir.glob(File.join(path, directory, match))\n list = Dir.glob(File.join(path, match))\n list = list.map{ |d| d.chomp('/') }\n plugins.concat(list)\n end\n plugins\n end",
"def _match_available_locales_only\n lambda do\n locale = remaining_path.split(\"/\").reject(&:empty?).first.to_s\n if ::R18n.available_locales.map(&:code).map(&:downcase).include?(locale.downcase)\n @captures.push(locale)\n @remaining_path = remaining_path.sub(\"/#{locale}\", \"\")\n end\n end\n end",
"def load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if !@loaded_paths.include?( expanded_path ) && File.exists?( expanded_path )\n $CLASSPATH << expanded_path\n load_paths << expanded_path\n @loaded_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def includes_load_paths; end",
"def all_files\n Dir.glob(\"#{template_path}/**/*\", File::FNM_DOTMATCH).reject{|path| File.directory?(path) }.sort\n end",
"def all\n load_files = [Rails.root, FfcrmMisc::Engine.root].map{|r| \"#{r}/config/products.yml\"}\n for f in load_files do\n if File.exists?(f)\n return load_from_yaml(f)\n end\n end\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end",
"def templates() = templates_path.glob('**/*.erb')",
"def load_tests (prefix)\n\n dp = File.dirname(__FILE__)\n\n Dir.new(dp).entries.select { |e|\n e.match(/^#{prefix}\\_.*\\.rb$/)\n }.sort.each { |e|\n load(\"#{dp}/#{e}\")\n }\nend",
"def load(*files)\n files.map { |f|\n evaluate(File.read(f).gsub(/\\A#!.*$/, ''), f, 1)\n }.last\n end",
"def loadFiles( reload = false )\n\t\t\t\tfiles().each do |file|\n\t\t\t\t\tfile.load( reload )\n\t\t\t\tend\n\t\t\tend",
"def available_locales\n translations = Dir.glob('config/locales/*').map { |locale| locale.split('/').last.split('.').first }\n locales = []\n translations.each do |t|\n value = (t == 'zh' ? 'zh-CN' : t)\n locales << [LanguageList::LanguageInfo.find(t).name, value]\n end\n locales\n end",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end"
] |
[
"0.70203483",
"0.70203483",
"0.6718164",
"0.666479",
"0.6584111",
"0.65177417",
"0.6438265",
"0.6398446",
"0.6338702",
"0.62744534",
"0.62744534",
"0.62686056",
"0.6265694",
"0.6247467",
"0.62008595",
"0.6171809",
"0.6162883",
"0.6128528",
"0.61251605",
"0.6105777",
"0.60924304",
"0.60924304",
"0.60400265",
"0.59662664",
"0.59166205",
"0.587668",
"0.5860821",
"0.5830667",
"0.5797512",
"0.5783385",
"0.57692647",
"0.5735643",
"0.5730893",
"0.5717764",
"0.5690999",
"0.5690926",
"0.5674254",
"0.56678283",
"0.56544197",
"0.5653817",
"0.5646029",
"0.5639999",
"0.56364876",
"0.5633259",
"0.5624954",
"0.561875",
"0.5600163",
"0.55964464",
"0.5560381",
"0.55440426",
"0.5531861",
"0.5530492",
"0.5529269",
"0.55266595",
"0.55106586",
"0.5507732",
"0.550618",
"0.5479472",
"0.5467723",
"0.5467266",
"0.54515845",
"0.5446537",
"0.54233944",
"0.54156435",
"0.54055953",
"0.5402279",
"0.5402237",
"0.54022163",
"0.53962654",
"0.53922623",
"0.5386009",
"0.5376291",
"0.5373527",
"0.5372671",
"0.53671974",
"0.5365511",
"0.535354",
"0.53208035",
"0.5320609",
"0.5297857",
"0.52974445",
"0.52944833",
"0.5286451",
"0.5262391",
"0.52604514",
"0.52502614",
"0.52479726",
"0.52463406",
"0.52380466",
"0.5221461",
"0.5218892",
"0.5213428",
"0.5210705",
"0.5209412",
"0.52073884",
"0.5202095",
"0.51997644",
"0.5199395",
"0.5190851",
"0.51893616"
] |
0.6213842
|
14
|
Loads each file supplied and asserts that the file only loads translations as expected by the name. The method returns a list of errors corresponding to offending files. source://i18n//lib/i18n/backend/lazy_loadable.rb152
|
def load_translations_and_collect_file_errors(files); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def assert_file_named_correctly!(file, translations); end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_files(options = {})\r\n files = files_newer_than(0).sort_by{|a| number_from_name(a).to_i}\r\n return if files.empty?\r\n log.debug \"files: #{files.inspect}\"\r\n \r\n last_bulk = files.select {|fn| bulk_file?(fn)}.last\r\n if last_bulk\r\n to_load = files[files.index(last_bulk)..-1]\r\n else\r\n to_load = files\r\n end\r\n\r\n counter = 0\r\n TranslationBundle.delete_all if options[:force]\r\n to_load.each {|fn| counter += load_file(fn, options)}\r\n @report << \"no files loaded - they are already in the database\\n\" if counter == 0\r\n counter\r\n end",
"def check_files(paths)\r\n Message::Error.error_puts(\"No files to load\") if paths.nil?\r\n\r\n errors = []\r\n paths.each do |f|\r\n f = \"nil\" if f.nil?\r\n\r\n if Dir.exist?(f)\r\n # Get files in directory\r\n Dir[\"#{f}/*\"].each { |x| Dir.exist?(x) || file_order << x }\r\n next\r\n end\r\n\r\n if File.exist?(f)\r\n file_order << f\r\n next\r\n end\r\n\r\n # Invalid path\r\n errors << File.basename(f)\r\n end\r\n\r\n errors\r\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def check_extnames\r\n errors = []\r\n file_order.each do |f|\r\n self.ext = File.extname(f) if ext.nil?\r\n next if File.extname(f) == ext\r\n\r\n # Multiple extensions\r\n errors << File.basename(f)\r\n end\r\n\r\n errors\r\n end",
"def error_check(paths)\r\n e = check_files(paths)\r\n Message::Error.no_files(e) unless e.empty? && file_order.any?\r\n\r\n file_order.map! { |f| File.absolute_path(f) }\r\n\r\n e = check_extnames\r\n self.ext ||= \"\"\r\n Message::Warning.ext_warn(e, ext) unless e.empty?\r\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def error_message\n @load.each {|f| loadable?(f, true) }\n \"Cyclic dependency prevented loading \\n#{@load.join(\"\\n\")}\"\n end",
"def load_all_from_files\n\t\tload_hash_from_file($searched, $progDir+'searched.txt')\n\t\tload_hash_from_file($downloaded, $progDir+'downloaded.txt')\n\t\tload_array_from_file($toSearch, $progDir+'toSearch.txt')\n\t\tload_array_from_file($toDownload, $progDir+'toDownload.txt')\n\trescue => e\n\t\t$error.save_error_to_file(__method__, e, $specialErrorTxt)\n\tend",
"def load_error; end",
"def load_messages\n @messages_loaded ||= message_loader.load_messages\n end",
"def missing_localizations(org_base='en-US')\n @langs = {}\n @missing_localizations = {}\n @l_files = Dir[File.join( RAILS_ROOT, '/lang/ui', '*.yml')]\n @l_files.each do |file| \n if YAML.load_file(file)\n @langs[File.basename(file, '.*')] = YAML.load_file(file).symbolize_keys \n else\n p \"error with the following file: #{file}, the file might be empty\"\n end\n end\n @base_keys = @langs[org_base]\n unless @base_keys.blank?\n @langs.each_key do |@lang|\n @base_keys.each_key do |key|\n unless @langs[@lang].include?(key)\n @missing_localizations[@lang] ||= {}\n @missing_localizations[@lang] = @missing_localizations[@lang].merge({key.to_sym => @base_keys[key]})\n end\n end\n end\n else\n p \"your #{org_base} file seems empty\"\n end\n @missing_localizations\n end",
"def file_errors_any?\n raise LucarativeAd::Error.file_type unless File.extname(@file) == \".yml\"\n raise LucarativeAd::Error.file_read unless File.exist? @file\n end",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def safe_load(file)\n begin\n load file\n rescue LoadError => ex\n puts \"Error loading rake tasks from '#{file}' but will continue...\"\n puts ex.message\n end\nend",
"def main\n num_errors = 0\n # { <dictionary filename>: [<glob>, ..., <glob>], ... }\n locale_globs = {\n 'en_US': [\n 'config/locales/*.eng.yml',\n 'config/locales/eng.yml'\n ]\n # Disable spellcheck for French and Spanish until we are able to put back special characters\n # 'es_PR': [\n # 'config/locales/spa-pr.yml',\n # 'config/locales/spa.yml'\n # ],\n # 'fr_FR': [\n # 'config/locales/fra.yml'\n # ]\n }\n locale_globs.each do |dict_name, glob|\n Dir.glob(glob).each do|filepath|\n puts \"CHECKING LOCALE: #{filepath} with dictionary #{dict_name}\"\n num_errors += check_locale(dict_name, filepath)\n puts \"\\n\\n\"\n end\n end\n puts \"Found #{num_errors} errors when checking all locale files\"\n exit(1) if num_errors > 0\n end",
"def load(files = T.unsafe(nil), reparse = T.unsafe(nil)); end",
"def load_error=(_arg0); end",
"def yaml_parts_in_loading_order\n ordered_yaml_parts = []\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.sort_by{|part| File.basename(part, '.yml').split('.').size}.each do |part|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n ordered_yaml_parts\n end",
"def check_yaml\n\tnb_error = 0\n\tDir.glob(\"**/*.yml\").each do |file|\n\t\tbegin\n\t\t\tYAML.load_file(file)\n\t\trescue => e\n\t\t\tnb_error += 1\n\t\t\tputs e\n\t\tend\n\tend\n\tif nb_error > 0\n\t\t$errors = true\n\tend\nend",
"def check_locale(dict_name, filepath)\n num_errors = 0\n locale_hash = recursive_parsing(YAML.load_file(filepath))\n\n FFI::Hunspell.dict(dict_name) do |dict|\n customize_dictionary(dict_name, dict)\n locale_hash.each do |key, sentence|\n # Ignore any variables for spell checking.\n sentence.gsub!(/%{\\w+}/, '')\n # Ignore the expected temperature guidance.\n sentence.gsub!('100.4°F/38°C', '')\n # Track if we already printed the YAML path and the sentence.\n already_put_context = false\n words = sentence.scan(/[[:alpha:]\\w'-]+/)\n words.each do |word|\n # Safety check if word is not actually a String.\n next if !word.is_a? String\n # dict.check? returns true if correctly spelled and false if incorrect.\n next if dict.check?(word)\n # Detected an error, so print the error and suggested fixes.\n if !already_put_context\n puts \"\\n\\t#{key}\"\n puts \"\\t#{sentence}\"\n already_put_context = true\n end\n puts \"\\t\\tSPELLING ERROR: #{word}\"\n puts \"\\t\\t\\tSUGGESTIONS: #{dict.suggest(word)}\"\n num_errors += 1\n end\n end\n end\n puts \"\\n\\tFound #{num_errors} errors when checking locale file #{filepath}\"\n num_errors\n end",
"def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end",
"def extract_error_for(path, errors)\n content = File.read(path).strip\n if(content.start_with?('{'))\n errors[:json_load]\n elsif(content.start_with?('<'))\n errors[:xml_load]\n elsif(content.match(/\\.new\\s*(do|\\{)/))\n errors[:struct_load]\n else\n errors[:yaml_load]\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def validate\n @files.each {|fn| check_file fn}\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def load_strings(file_or_url)\n loadStrings(file_or_url).to_a\n end",
"def check_files\n process_files.each do |result|\n URL_TYPES.each do |url_type|\n type = :\"#{url_type}_urls\"\n ivar_name = \"@#{type}\"\n ivar = instance_variable_get(ivar_name)\n\n if ivar.empty?\n instance_variable_set(ivar_name, result[type])\n else\n result[type].each do |url, metadata|\n ivar[url] = [] if ivar[url].nil?\n ivar[url].concat(metadata)\n end\n end\n end\n @failures.concat(result[:failures])\n end\n\n validate_external_urls unless @options[:disable_external]\n\n validate_internal_urls\n end",
"def verify_required_files\n required = REQUIRED_FILES.map{ |f| [f, false] }.to_h\n\n each_zip_entry do |entry|\n if required.key? entry.name\n required[entry.name] = true\n\n if entry.name == \"mod.hcl\"\n load_manifest entry\n end\n end\n end\n\n REQUIRED_FILES.each do |f|\n if required[f] == false\n raise FoobarMod::Package::FormatError.new \"Missing required file '#{f}'\", @mod\n end\n end\n end",
"def load_files(*files)\n dsl = DSL.new(self)\n files.each do |file|\n next unless File.file?(file) # TODO: warn ?\n #begin\n dsl.instance_eval(File.read(file), file)\n #rescue => e\n # raise e if $DEBUG\n # warn e.message\n #end\n end\n end",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def require_files_messily( files )\n while true\n files_remaining = files.length\n return true if files_remaining == 0\n \n files.length.times do\n begin\n file = files.shift\n require file\n @successfully_required << file\n rescue NameError => e\n uninitialized_constant_error( e ) do\n files.push( file )\n end\n end\n end\n \n return false if files.length == files_remaining\n end\n end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def test_load(options={})\n options = test_configuration(options)\n\n tests = options['tests']\n loadpath = options['loadpath']\n requires = options['requires']\n live = options['live']\n exclude = options['exclude']\n\n files = Dir.multiglob_r(*tests) - Dir.multiglob_r(*exclude)\n\n return puts(\"No tests.\") if files.empty?\n\n max = files.collect{ |f| f.size }.max\n list = []\n\n files.each do |f|\n next unless File.file?(f)\n if r = system(\"ruby -I#{loadpath.join(':')} #{f} > /dev/null 2>&1\")\n puts \"%-#{max}s [PASS]\" % [f] #if verbose?\n else\n puts \"%-#{max}s [FAIL]\" % [f] #if verbose?\n list << f\n end\n end\n\n puts \" #{list.size} Load Failures\"\n\n if verbose?\n unless list.empty?\n puts \"\\n-- Load Failures --\\n\"\n list.each do |f|\n print \"* \"\n system \"ruby -I#{loadpath} #{f} 2>&1\"\n #puts\n end\n puts\n end\n end\n end",
"def load_imports\n while fn = @pending_imports.shift\n next if @imported.member?(fn)\n ext = File.extname(fn)\n loader = @loaders[ext] || @default_loader\n loader.load(fn)\n @imported << fn\n end\n end",
"def check_files\n @files.each do |f|\n stat = File.stat f rescue next\n raise RDoc::Error, \"file '#{f}' not readable\" unless stat.readable?\n end\n end",
"def errors\n error_messages = []\n\n [:path].each do |key|\n error_messages << \"include_policy for #{name} is missing key #{key}\" unless source_options[key]\n end\n\n error_messages\n end",
"def load_strings(strings_filename)\n return [{}, {}]\n end",
"def check_files fnames\n fnames.each do |fname|\n AbortIf.abort_unless_file_exists fname\n end\n end",
"def get_not_translated\n language = \"en\"\n language = params[:language] if params[:language]\n lang = []\n @files = {}\n @new_lang = []\n File.read(\"#{Rails.root}/lang/#{language}.rb\").scan(/l.store\\s?[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st|\n st.scan(/[\\'\\\"][^\\'\\\"]+[\\'\\\"]/) do |st2|\n lang << st2.gsub(/[\\'\\\"]/, \"\")\n end\n end\n\n @files_list = Dir.glob(\"#{Rails.root}/app/controllers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/views/**/*.rhtml\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/models/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/app/helpers/*.rb\").collect\n @files_list += Dir.glob(\"#{Rails.root}/lib/**/*.rb\").collect\n for file in @files_list\n File.read(file).scan(/[^\\w\\d]\\_\\([\\'\\\"][^\\'\\\"]+[\\'\\\"]\\)/) do |st|\n st = st.gsub(/.?\\_\\(/, \"\").gsub(/[\\s\\'\\\"\\)\\(]/, \"\")\n @new_lang << st\n @files[st] = file\n end\n end\n\n @new_lang -= lang\n @new_lang = @new_lang.uniq.flatten\n end",
"def validate\n untranslated = self.get_untranslated_keys\n untranslated.each { |key|\n puts \"WARNING: \\\"#{key['id']}\\\" is not translated in #{key['untranslated']} languages\"\n }\n end",
"def load_errors(obj)\n obj.errors.full_messages.each { |m|\n @msg.add(:error, m);\n }\n end",
"def load(*files)\n files.map { |f|\n evaluate(File.read(f).gsub(/\\A#!.*$/, ''), f, 1)\n }.last\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def readFiles\n rError = nil\n\n if (File.exists?(@TasksFileName))\n @LstTasks = nil\n File.open(@TasksFileName, 'r') do |iFile|\n @LstTasks = iFile.readlines.map do |iLine|\n next iLine.strip\n end\n end\n if (File.exists?(@TicketsFileName))\n @LstTickets = nil\n File.open(@TicketsFileName, 'r') do |iFile|\n @LstTickets = iFile.readlines.map do |iLine|\n next iLine.strip\n end\n end\n else\n rError = MissingTicketsFileError.new(\"Missing Tickets file: #{@TicketsFileName}\")\n end\n else\n rError = MissingTasksFileError.new(\"Missing Tasks file: #{@TasksFileName}\")\n end\n\n return rError\n end",
"def validate_file_list_contents\n keys = self.original_file_list.map(&:keys).flatten.uniq.sort\n unless (keys & FILE_LIST_KEYS) == keys\n errors.add(:original_file_list, \" is formatted incorrectly. This must be an array of Hashes with the keys #{FILE_LIST_KEYS.join(', ')}.\" )\n end\n self.original_file_list.each do |file|\n unless StudyFile::STUDY_FILE_TYPES.include?(file['file_type'])\n errors.add(:original_file_list, \" contains a file of an invalid type: #{file['file_type']}\")\n end\n end\n unless match_bundle_type.any?\n errors.add(:original_file_list, \" does not contain a file of the specified bundle type: #{self.bundle_type}\")\n end\n if match_bundle_type.size > 1\n errors.add(:original_file_types, \" contains files of incompatible types: #{match_bundle_type.join(', ')}\")\n end\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def file_load_failed(path, exception)\n description = Formatters::ErrorMapper.file_load_failed(path, exception)\n @error_description = description.for_json\n end",
"def fail_on_unevaluated_resource_collections\n remaining = @collections.collect(&:unresolved_resources).flatten.compact\n if !remaining.empty?\n raise Puppet::ParseError, _(\"Failed to realize virtual resources %{resources}\") % { resources: remaining.join(', ') }\n end\n end",
"def load_file(file_name)\n @loadOK = false \n begin\n @template = File.read(file_name)\n @loadOK = true \n rescue => ex\n @template = ex.to_s \n @loadOK = false \n end\n return @loadOK\n end",
"def file_patterns_errors\n messages = []\n messages << \"The sources did not match any file\" if !@spec.source_files.empty? && @pod.source_files.empty?\n messages << \"The resources did not match any file\" if !@spec.resources.empty? && @pod.resource_files.empty?\n messages << \"The preserve_paths did not match any file\" if !@spec.preserve_paths.empty? && @pod.preserve_files.empty?\n messages << \"The exclude_header_search_paths did not match any file\" if !@spec.exclude_header_search_paths.empty? && @pod.headers_excluded_from_search_paths.empty?\n messages\n end",
"def check_merge\n\tres = ''\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tnb = 0\n\t\tif !file.include? 'convention.rb'\n\t\t\terrors = %w(<<<<< >>>>> ===== binding\\.pry $\\tAnd)\n\t\t\terrors.each do |reg|\n\t\t\t\tnb += File.readlines(file).grep(reg).size\n\t\t\tend\n\t\tend\n\t\tif nb > 0\n\t\t\tres += \"#{file}, \"\n\t\t\t$errors = true\n\t\tend\n\tend\n\n\tif res != ''\n\t\tputs \"Some file seems to be incorrect, with error like <<<<, >>>>, ====, binding.pry...\"\n\t\tputs res\n\tend\nend",
"def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end",
"def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n begin\n require(pathname = path+\"/\"+filename)\n trace :loading, \"Loaded #{pathname}\"\n filename\n rescue LoadError => e\n trace :loading, \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n rescue Exception => e\n $stderr.puts \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n end\n end.compact\n end\n end",
"def load_files(*sources); end",
"def __loading_begin(file)\n level, still_open = @load_table[file]\n warning = [nil]\n warning << \"REPEATED - last at level #{level}\" if level\n warning << 'UNCLOSED' if still_open\n warning = warning.join(' <<<<<<<<<< ')\n @load_level += 1\n @load_table[file] = [@load_level, true]\n $stderr.puts(\"====-> #{__loading_level}#{file}#{warning}\")\n end",
"def validate_input_files\n file_validation = FileValidation.new(input_files)\n raise_error(file_validation.errors) unless file_validation.files_exist? \n raise_error(file_validation.errors) unless file_validation.files_are_ascii?\n true\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def __loading_begin(file)\n level, still_open = @load_table[file]\n warning = [nil]\n warning << \"REPEATED - last at level #{level}\" if level\n warning << 'UNCLOSED' if still_open\n warning = warning.join(' <<<<<<<<<< ')\n @load_level += 1\n @load_table[file] = [@load_level, true]\n __trace { \"====-> #{__loading_level}#{file}#{warning}\" }\nend",
"def seriously_all_of_the_errors\n messages = errors.full_messages.reject { |e| e == \"#{I18n.t('nouns.extension').capitalize} version is invalid\" }\n\n extension_versions.each do |version|\n almost_everything = version.errors.full_messages.reject { |x| x =~ /Tarball can not be/ }\n messages += almost_everything\n end\n\n messages\n end",
"def safe_load(file)\n before_safe_load(file)\n load(file)\n after_safe_load_succeed(file)\n rescue Object => ex\n Log.error(ex)\n after_safe_load_failed(file, ex)\n end",
"def load!(files)\n raise NoConfigFiles if !files || files.empty?\n files.each do |path|\n load path if File.readable?(File.expand_path(path))\n end\n end",
"def validate_master\n log 'Validating master locale file'\n undefined = []\n master.each do |descriptor_set, descriptors|\n descriptors.reject { |k,v| k == 'parent' }.each do |symbol, descriptor|\n unless descriptor[:name]\n undefined << \"Name not defined for #{descriptor_set}\"\n end \n end\n end\n abort undefined if undefined.size > 0\n end",
"def file_checks\n errors = []\n errors << 'There are no entries in the manifest file.' if @current_package.manifest.count == 0\n errors\n end",
"def testget_leveled_file_contentMissingFile\n assert_raise(LoadError) do\n RCodeLeveler.get_leveled_file_content('RequiredFiles/MissingFile')\n end\n end",
"def missing_translations\n @translations.select { |x, v| v.nil? or v.blank? }\n end",
"def __loading(file)\n $stderr.puts(\"====== #{__loading_level}#{file}\")\n end",
"def check_files_array_format\n error_msg = 'has invalid entries. Each entry must be a hash with the keys of name (String), size (Integer), and '\\\n 'generation (String). The following entries are invalid: '\n has_error = false\n self.files.each do |file|\n unless file.keys.map(&:to_s).sort == %w(generation name size)\n error_msg += \"#{file}\"\n end\n end\n if has_error\n errors.add(:files, error_msg)\n end\n end",
"def load_films\n update_films\n rescue => e\n my_msg(\"Fatal error: #{e.class},#{e.message}\", true)\n log_message\n self\n end",
"def load_all\n @internal_loader.load_all(self)\n end",
"def load_dependencies( file_list, force_require=true )\r\n loader = DependencyLoader.new( file_list, force_require )\r\n loader.load_dependencies\r\nend",
"def wrong; require 'unknown_file'; end",
"def load_used_phrases\n\t@used_phrases = load_collection_from_file(@phrase_file_name, {});\nend",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\"\n end\n # puts candidates.inspect\n candidates\n end",
"def each_file\n return unless block_given?\n\n loc_path = LokaliseRails.locales_path\n Dir[\"#{loc_path}/**/*\"].sort.each do |f|\n full_path = Pathname.new f\n\n next unless file_matches_criteria? full_path\n\n relative_path = full_path.relative_path_from Pathname.new(loc_path)\n\n yield full_path, relative_path\n end\n end",
"def test_load_dictionaries\n spellchecker = AlfonsoX::SpellChecker::Main.from_config(\"#{RESOURCES_PATH}/config.yml\")\n assert_equal 6, spellchecker.dictionaries.length\n\n word_list_file_dictionary = spellchecker.dictionaries[3]\n word_list_dictionary = spellchecker.dictionaries[4]\n\n assert word_list_file_dictionary.is_a?(AlfonsoX::SpellChecker::Dictionary::WordListFile)\n assert_equal 59, word_list_file_dictionary.words.length\n assert word_list_dictionary.is_a?(AlfonsoX::SpellChecker::Dictionary::WordList)\n assert_equal 4, word_list_dictionary.words.length\n end",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def fallback_load_path(path)\n retried = false\n begin\n yield\n rescue LoadError\n unless retried\n $: << path\n retried = true\n retry\n end\n raise\n end\nend",
"def valid_translation? translation_file\n raise TranslationFileNotFound, \"Translation file is required\" unless translation_file\n raise TranslationFileNotFound, \"Unable to find Translation File #{translation_file}\" unless File.exists?(translation_file)\n end",
"def process_files\n loaded_files = []\n files.each do |file|\n Async do |task|\n task.async do\n loaded_files << load_file(file[:path], file[:source])\n end\n end\n end\n loaded_files\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def errors\n error_messages = []\n [:git].each do |key|\n error_messages << \"include_policy for #{name} is missing key #{key}\" unless source_options[key]\n end\n\n error_messages\n end",
"def load_file(definition)\n paths = definition.file\n\n paths.each do |path|\n ext = file_module.extname(path).strip.downcase[1..-1]\n parse_method = \"parse_#{ext}\"\n unless respond_to?(parse_method)\n fail \"extension (#{ext}), for (#{definition.key}: #{path}) \" +\n \"is not valid, only yaml and json are supported\"\n end\n\n if file_module.exists?(path)\n config = public_send(parse_method, path)\n unless config.is_a?(Hash)\n fail \"[config #{parse_method}] config must be a hash\"\n end\n config.deep_symbolize_keys!\n return config[definition.key]\n end\n end\n\n list = paths.join(',')\n fail \"none of :#{definition.key} config files exist at (#{list})\"\n end",
"def loaded_resources\n @_loaded_resources ||= []\n end",
"def validate\n @has_validated = true\n\n unless File.exist?(@commits_path)\n @errors.push(\"#{File.basename(@commits_path)}: does not exist\")\n end\n\n unless File.exist?(@data_path)\n @errors.push(\"#{File.basename(@data_path)}: does not exist\")\n end\n\n # Stop as further validations need to read the files.\n return if @errors.any?\n\n begin\n data_file.peek\n rescue StopIteration\n @errors.push(\"#{File.basename(@data_path)}: has no data to import\")\n return\n end\n\n DataValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@data_path)}: #{error}\")\n end\n\n CommitsValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@commits_path)}: #{error}\")\n end\n\n nil\n end",
"def validate_files(cookbooks)\n Array(cookbooks).each do |cookbook|\n path = cookbook.path.to_s\n\n files = Dir.chdir(path) do\n Dir.glob(File.join(\"**\", \"*.rb\")).select do |f|\n f = File.join(path, f)\n parent = Pathname.new(path).dirname.to_s\n f.gsub(parent, \"\") =~ /[[:space:]]/\n end\n end\n\n raise InvalidCookbookFiles.new(cookbook, files) unless files.empty?\n end\n end",
"def load\n @all = [] #contains all template objects\n\n template_dir = Gem.datadir('moo') + '/templates/'\n\n template_files = Dir.entries(template_dir).reject do |t|\n t == '.' || t == '..'\n end\n\n template_files.each do |f|\n path = template_dir + f\n @all << Template.new(path)\n end\n end",
"def __loading(file)\n __trace { \"====== #{__loading_level}#{file}\" }\nend",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\" if Bolt.verbose?\n end\n # puts candidates.inspect\n candidates\n end",
"def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif nb > 0\n\t\tputs \"Error encoding file\"\n\t\t$errors = true\n\tend\nend",
"def file_dumps\r\n Dir.new(translation_base).entries.select{|x| x['.yml']}\r\n end"
] |
[
"0.662972",
"0.662972",
"0.6486297",
"0.6274989",
"0.6266235",
"0.6032316",
"0.59935445",
"0.5818389",
"0.58173627",
"0.58173627",
"0.5807299",
"0.5755714",
"0.57399386",
"0.56895924",
"0.56047267",
"0.5601714",
"0.55890983",
"0.5559645",
"0.5510317",
"0.5499207",
"0.5475547",
"0.54539114",
"0.5440759",
"0.54215705",
"0.5420001",
"0.54113567",
"0.5408301",
"0.54013103",
"0.5399881",
"0.53925574",
"0.5355253",
"0.5331991",
"0.5293903",
"0.5292545",
"0.52911997",
"0.5257961",
"0.52560353",
"0.52511907",
"0.5245303",
"0.5243352",
"0.52337986",
"0.51914805",
"0.51896805",
"0.5181397",
"0.5180445",
"0.51769716",
"0.5142754",
"0.51245576",
"0.5113691",
"0.5111864",
"0.5106505",
"0.51060396",
"0.5105224",
"0.51046866",
"0.509941",
"0.5088322",
"0.50883037",
"0.5087782",
"0.5076576",
"0.5075398",
"0.50700355",
"0.50694376",
"0.5065197",
"0.5065031",
"0.50562704",
"0.5052295",
"0.5051935",
"0.5048504",
"0.5046761",
"0.50309026",
"0.5029525",
"0.501273",
"0.50078225",
"0.5005527",
"0.49913213",
"0.49823347",
"0.49601218",
"0.49595478",
"0.4956003",
"0.49519008",
"0.49515173",
"0.49488342",
"0.4943707",
"0.49423492",
"0.49413717",
"0.49413717",
"0.49413717",
"0.49387053",
"0.49313468",
"0.49308717",
"0.49236324",
"0.49176258",
"0.49168372",
"0.4916458",
"0.49156076",
"0.48902476",
"0.48830655",
"0.48813483",
"0.48806745",
"0.4879822"
] |
0.8011651
|
0
|
Normalizes categories of 0.0 and 1.0 and returns the symbolic version source://i18n//lib/i18n/backend/pluralization.rb89
|
def symbolic_count(count); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def simple_pluralize count, singular, plural=nil\n ((count == 1 || count =~ /^1(\\.0+)?$/) ? singular : (plural || singular.pluralize))\n end",
"def default_pluralizer(count)\n count == 1 ? :one : :other\n end",
"def make_plural\n\t\tsentence_array=Array.new\n\t\tnew_sentence_array=Array.new\n\t\tsentence_array= to_str.split(/ /)\n\t\t\t(0..sentence_array.size-1).each do |cnt|\n\t\t\t\tnew_sentence_array << sentence_array[cnt].strip.downcase.pluralize\n\t\t\tend\n\t\treturn new_sentence_array.join(\" \")\n\tend",
"def pluralize( name )\n warn_nyi( \"support for pluralization guides in pluralize()\" )\n return name.pluralize\n end",
"def pluralize\n p = self[ :plural ]\n p = ! scalar? if p.nil?\n p = 's' if p == false\n p = 'p' if p == true\n p.to_s\n end",
"def plural(input)\n input.dup.en.plural\n end",
"def name_plural() name_singular + 's' end",
"def pluralize\n self[-1] == 's' ? \"#{self}es\" : \"#{self}s\"\n end",
"def simple_tag_type_pluralizer(s)\n case s\n when /o\\Z/ then s.sub(/o\\Z/, \"es\")\n when /y\\Z/ then s.sub(/y\\Z/, \"ies\")\n when /ss\\Z/ then s.sub(/ss\\Z/, \"sses\")\n else\n \"#{s}s\"\n end\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count} \" + if count == 1\n singular\n elsif plural\n plural\n elsif Object.const_defined?(\"Inflector\")\n Inflector.pluralize(singular)\n else\n singular + \"s\"\n end\n end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def pluralize(count = nil)\n if count == 1\n self\n else\n MotionSupport::Inflector.pluralize(self)\n end\n end",
"def is_plural?(value)\n\t(value > 1) || (value < 1)\nend",
"def pluralize(locale, entry, count); end",
"def pluralize_collection collection, noun \n if collection.size == 1 \n \"1 #{noun}\"\n else \n \"#{collection.size} #{noun.pluralize}\"\n end\n end",
"def pluralize amount, singular\n \"#{amount} #{singular}#{amount == 1 ? '' : 's'}\"\n end",
"def pluralize(l_string) #count, singular, plural = nil)\n # map the arguments like in the original pluralize method\n count, singular, plural = l_string.split(',').map{ |arg| arg.strip}\n\n \"#{count} \" + if count == 1 || count == '1'\n singular\n elsif plural\n plural\n elsif Object.const_defined?(\"Inflector\")\n Inflector.pluralize(singular)\n else\n singular + \"s\"\n end\n end",
"def pluralize(word); end",
"def pluralize\n self.class.new Inflector.pluralize(self)\n end",
"def pluralize\n self.class.new Inflector.pluralize(self)\n end",
"def plural(input)\n input>1 ? 's' : ''\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def plural(int, str)\n return \"#{int} #{str.pluralize}\" unless int == 1\n \"#{int} #{str.singularize}\"\n end",
"def pluralize_with_count( count=2 )\n count > 1 ? pluralize_without_count : singularize\n end",
"def class_plural classes\t\n\t\tif classes.is_a? Numeric\n\t\t\tif classes == 1\n\t\t\t\t\"class\"\n\t\t\telsif (classes > 1 || classes == 0)\n\t\t\t\t\"classes\"\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\telse\n\t\t\traise \"You messed up the classes\"\n\t\tend\n\tend",
"def pluralize_category_count\n pluralize(category.articles.count, \"article\")\n end",
"def plural(n)\n n == 1 ? \"#{n} bottle\" : \"#{n} bottles\"\nend",
"def friendly_name_pluralized\n @friendly_name_pluralized ||= self.name.humanize.pluralize\n end",
"def pluralize\n @name.pluralize\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend",
"def pluralize(word)\n result = word.to_s.dup\n\n if word.empty? || inflections.uncountables.include?(result.downcase)\n result\n else\n inflections.plurals.each do |(rule, replacement)| \n break if result.gsub!(rule, replacement)\n end\n result\n end\n end",
"def pluralize(count)\n if custom?\n # todo: make a search from the custom inflector, if doesn't match, simply fallback to @name\n # something like OurInflector.pluralize(@name) || @name\n return @custom_name\n else\n (count == 1 || count =~ /^1([\\.,]0+)?$/) ? \n I18n.t(\"units.#{@yaml}\", :count => 1) : I18n.t(\"units.#{@yaml}\", :count => count)\n end\n end",
"def normalize_count( count, default=2 )\n\t\treturn default if count.nil? # Default to plural\n\t\tif /^(#{PL_count_one})$/i =~ count.to_s ||\n\t\t ( Linguistics::EN.classical? && /^(#{PL_count_zero})$/ =~ count.to_s )\n\t\t\treturn 1\n\t\telse\n\t\t\treturn default\n\t\tend\n\tend",
"def pluralize(num, item)\n if item == :warning && num != 1\n \"#{num} Warnings\"\n else\n \"#{num} #{item.capitalize}\"\n end\n end",
"def pluralizer num, noun\n if num == 1\n \"#{num} #{noun}\"\n else\n \"#{num} #{noun}s\"\n end\nend",
"def pluralizer num, noun\n if num != 1\n \"#{num} #{noun}s\"\n else \"#{num} #{noun}\"\n end\nend",
"def pluralize(n, singular, plural=nil)\n if n == 1 \n \"1 #{singular}\"\n elsif plural\n \"#{n} #{plural}\"\n else\n \"#{n} #{singular}s\"\n end\n end",
"def pluralizer number,noun\n if number <= 0\n \"No #{noun}\"\n elsif number == 1\n \"#{number} #{noun}\" \n else\n \"#{number} #{noun}s\"\n end\nend",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + (count == 1 ? singular : (plural || singular.pluralize))\n end",
"def plural?(num)\n return 'ruby' if num == 1\n return 'rubies' if num > 1\n end",
"def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)\n word = if count == 1 || count.to_s.match?(/^1(\\.0+)?$/)\n singular\n else\n plural || singular.pluralize(locale)\n end\n\n \"#{count || 0} #{word}\"\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\n end",
"def pluralize(bottles, text)\n return text + 's' if bottles != 1\n text\nend",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count || 0} \" + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def test_plural_ruby\n\t\tp = Print.new\n\t\tassert_equal('rubies',p.singular_or_plural(0,'rubies'))\n\tend",
"def pluralize(singularStr, num)\n if num == 1\n return singularStr\n else\n if singularStr[-1] == \"s\" # singularStr[-1] returns last character of string\n return \"#{singularStr}es\"\n else\n return \"#{singularStr}s\"\n end\n end\n end",
"def normalize_count( count, default=2 )\n\t\treturn default if count.nil? # Default to plural\n\t\tif /^(#{PL_count_one})$/i =~ count.to_s ||\n\t\t\t\tLinguistics::classical? &&\n\t\t\t\t/^(#{PL_count_zero})$/ =~ count.to_s\n\t\t\treturn 1\n\t\telse\n\t\t\treturn default\n\t\tend\n\tend",
"def arabic_pluralize(number, singular, double, plural, gender_class='male')\n one = gender_class == 'male' ? 'واحد' : 'واحدة'\n case number\n when 0 then \"لا #{plural}\"\n when 1 then \"#{singular} #{one}\"\n when 2 then \"#{double}\"\n when 3..10 then \"#{number} #{plural}\"\n else \"#{number} #{singular}\"\n end\n end",
"def test_pluralize_one\n assert_equal \"book\", @d.pluralize(\"book\", 1)\n end",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def pluralize_word(count, singular, plural = nil)\n ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end",
"def display_name_pluralize\n I18n.t(self.name, :scope => \"umlaut.service_type_names\", :default => :default, :count => 10)\n end",
"def is_plural?(astring)\n astring.singularize != astring\nend",
"def _plural_name\n @plural_name || begin\n @plural_name = Origen::Componentable.componentable_names(self)[:plural]\n @singleton_name = Origen::Componentable.componentable_names(self)[:singleton]\n end\n end",
"def plural\n\t\tEndings.each { |k, v|\n\t\t\tif name =~ '(.*)' + k + '$'\n\t\t\t\treturn $1.to_s + v\n\t\t\tend\n\t\t}\n\t\treturn \"#{name}s\"\n\tend",
"def pluralizer string, n\n if n == 1 \n puts \"#{n} #{string}\"\n elsif n > 1 || n==0\n puts \"#{n} #{string}s\"\n end\nend",
"def singularize(str)\n Gorillib::Inflector.pluralizations.invert.fetch(str){ str.gsub(/s$/, '') }\n end",
"def pluralizer number,noun\n if number <= 0\n \"No #{noun}\"\n elsif number == 1\n \"#{number} #{noun}\" \n else\n if noun.downcase == 'geese'\n noun = 'goose'\n elsif noun.downcase == 'child'\n noun = 'children'\n elsif noun.downcase == 'person'\n noun = 'people'\n else\n noun = noun.concat('s')\n end\n \"#{number} #{noun}\"\n end\nend",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def declension(singular, plural, count)\n count == 1 ? singular : plural\n end",
"def pluralize_model(klass, options = {})\n t(\"activerecord.models.#{klass.model_name.i18n_key}\", :count => options[:count] || 2)\n end",
"def pluralize\n {'win' => 'wins', 'loss' => 'losses', 'fail' => 'fails'}\n end",
"def pluralize(word)\n return word + \"s\" if pluralize?\n word\nend",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def pluralize(word)\n result = word.to_s.dup\n\n if word.empty? || inflections.uncountables.include?(result.downcase)\n result\n else\n inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result\n end\n end",
"def pluralize(word)\n result = word.to_s.dup\n\n if word.empty? || inflections.uncountables.include?(result.downcase)\n result\n else\n inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result\n end\n end",
"def plural_verb( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word,\n\t\t\tpluralize_special_verb(word, count) ||\n\t\t\tpluralize_general_verb(word, count) )\n\n\t\treturn pre + plural + post\n\tend",
"def pluralize(count, singular, plural_arg=nil, plural: plural_arg, locale: I18n.locale)\n self.class.pluralize(count, singular, plural_arg, plural: plural, locale: locale)\n end",
"def book_plural books\n\t\tif books.is_a? Numeric\n\t\t\tif books == 1\n\t\t\t\t\"book\"\n\t\t\telsif (books > 1 || books == 0)\n\t\t\t\t\"books\"\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\telse\n\t\t\traise \"You messed up the books\"\n\t\tend\n\tend",
"def pluralizer (num, noun)\n return \"#{num} #{noun}\" if num == 1\n return \"#{num} geese\" if noun == \"goose\"\n return \"#{num} sheep\" if noun == \"sheep\"\n return \"#{num} #{noun}s\"\nend",
"def pluralize (amount, item)\n if(amount === 1)\n return amount.to_s + \" \" + item\n end\n if(item.downcase == \"goose\")\n return amount.to_s + \" geese\"\n end\n if(item.downcase == \"child\")\n return amount.to_s + \" children\"\n end\n if(item.downcase == \"sheep\")\n return amount.to_s + \" sheep\"\n end\n return amount.to_s + \" \" + item + \"s\"\nend",
"def toy_plural toys\n\t\tif toys.is_a? Numeric\n\t\t\tif toys == 1\n\t\t\t\t\"toy\"\n\t\t\telsif (toys > 1 || toys == 0)\n\t\t\t\t\"toys\"\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\telse\n\t\t\traise \"You messed up the toys\"\n\t\tend\n\tend",
"def pluralisation_rule\n Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}\n end",
"def pluralizer num,name\n \n if num >= 2\n p \"#{num} #{name}s.\"\n else\n p \"1 #{name}.\"\n end\nend",
"def plural(n, item)\n n == 1 ? \"#{n} #{item}\" : \"#{n} #{item}s\"\nend",
"def set_plural(value_or_index = true, value = true)\n if value_or_index.is_a?(Integer)\n @plural[value_or_index] = value\n else\n @plural.collect! { value_or_index }\n end\n end",
"def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end",
"def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end",
"def pluralizer(num, obj)\n obj.downcase!\n if num > 1\n if obj == \"sheep\"\n return \"#{num} #{obj}\"\n elsif obj == \"goose\"\n return \"#{num} geese\"\n elsif obj == \"child\"\n return \"#{num} children\"\n elsif obj == \"person\"\n return \"#{num} people\"\n elsif obj == \"species\"\n return \"#{num} #{obj}\"\n else\n return \"#{num} #{obj}s\"\n end\n else\n return \"#{num} #{obj}\"\n end\nend",
"def plural(int, str)\r\n return \"#{int} #{str}s\" unless int == 1\r\n \"#{int} #{str}\"\r\n end",
"def pluralize(n, str)\n \"#{n} #{str + (n == 1 ? \"\" : \"s\")}\"\nend",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def pluralizer(num,noun)\n p noun == \"sheep\" ? \"#{num} #{noun}\" : noun == \"geese\" ? \"#{num} #{noun}\" :\n num == 1 && noun == \"child\" ? \"#{num} #{noun}\" : noun == \"child\" ? \"#{num} #{noun}ren\" :\n noun == \"children\" ? \"#{num} child\" : num == 1 && noun == \"people\" ? \"#{num} person\" :\n num > 1 ? \"#{num} #{noun}s\" : nil\nend",
"def is_plural?(model_name)\n model_hash = content_types.select{|x| x[:name] == model_name}.first\n return model_hash[:plural]\n end",
"def controllerize(s)\n s.pluralize.downcase\n end",
"def pluralization_rules\n if defined?(@pluralization_regex) && @pluralization_regex\n return [@pluralization_regex, @pluralization_hash]\n end\n @pluralization_regex = Regexp.new(\"(\" + @plural_rules.map {|s,p| s}.join(\"|\") + \")$\", \"i\")\n @pluralization_hash = Hash[*@plural_rules.flatten]\n [@pluralization_regex, @pluralization_hash]\n end",
"def plural\n return word if word.to_s.empty?\n\n find_match(Inflection.configuration.plurals[:noun]) ||\n (uncountable? && word) || find_match(Nouns.plurals) || word\n end",
"def pluralizer (num, noun)\n return \"#{num} #{noun}\"\n return \"#{num} geese\" if noun == \"goose\"\n return \"#{num} sheep\" if noun == \"sheep\"\n return \"#{num} #{noun}s\"\nend",
"def pluralize(number_of_bottles)\n if number_of_bottles > 1\n \"#{number_of_bottles} bottles\"\n elsif number_of_bottles == 1\n \"1 bottle\"\n else\n \"No more bottles\"\n end\nend",
"def plural_without_count(count, word)\n count == 1 ? word : word.pluralize\n end",
"def declension(singular, plural, count)\n if count == 1\n singular\n else\n plural\n end\n end",
"def pluralize(string)\n if string[-1] == 'y'\n \"#{string[0..(string.length - 2)]}ies\"\n else\n \"#{string}s\"\n end\n end",
"def test_plural_fake_ruby\n\t\tp = Print.new\n\t\tassert_equal('fake rubies',p.singular_or_plural(0,'fake'))\n\tend",
"def pluralize(count, word)\n \"#{word}#{'s' unless count.to_f == 1}\"\n end",
"def human_model name=nil, pluralize=false\n s = model(name).human_name\n s = s.pluralize if pluralize && pluralize != 1\n s\n end",
"def plural?\n self == self.pluralize\n end",
"def pluralize(word, locale = :en)\n Geode::FastInflector.pluralize(word, locale)\n end",
"def pluralize_key\n ActiveSupport::Inflector.pluralize(key)\n end"
] |
[
"0.68241817",
"0.6746467",
"0.64894277",
"0.64882284",
"0.64794225",
"0.64554673",
"0.63860613",
"0.6365204",
"0.6301192",
"0.629816",
"0.6266324",
"0.6265869",
"0.6261882",
"0.6247847",
"0.62098503",
"0.6201506",
"0.6188937",
"0.6185592",
"0.6183827",
"0.6183827",
"0.612485",
"0.610999",
"0.6108375",
"0.6108375",
"0.6108375",
"0.60785604",
"0.60633796",
"0.6046463",
"0.6038093",
"0.6033975",
"0.600705",
"0.6004994",
"0.6004726",
"0.598749",
"0.59691215",
"0.5965886",
"0.5962884",
"0.5961144",
"0.59588957",
"0.595315",
"0.5941658",
"0.5935225",
"0.59340715",
"0.5933072",
"0.5932564",
"0.5929022",
"0.5929022",
"0.592845",
"0.5927108",
"0.59242535",
"0.5916019",
"0.58986384",
"0.58976805",
"0.5897673",
"0.5886051",
"0.58760595",
"0.58590263",
"0.5852001",
"0.5845991",
"0.5834115",
"0.5830774",
"0.5828814",
"0.58091277",
"0.5793624",
"0.5773468",
"0.5758105",
"0.57448584",
"0.57435775",
"0.57435775",
"0.57393867",
"0.5732233",
"0.5729802",
"0.5721401",
"0.5715542",
"0.5703982",
"0.569995",
"0.5692865",
"0.5681768",
"0.56781185",
"0.5677546",
"0.5677546",
"0.5676796",
"0.56672484",
"0.56569135",
"0.5656462",
"0.5643983",
"0.56357795",
"0.56332034",
"0.56293267",
"0.5622411",
"0.5621808",
"0.561917",
"0.56112295",
"0.5602542",
"0.55956906",
"0.5595525",
"0.5594384",
"0.5586378",
"0.5579213",
"0.55751073",
"0.5574233"
] |
0.0
|
-1
|
Get available locales from the translations hash source://i18n//lib/i18n/backend/simple.rb49
|
def available_locales; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def translated_locales\n self.i18n.keys\n end",
"def available_locales\n translation_model.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def locales\n get(\"locales\")[\"locales\"]\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def translated_locales\r\n all.distinct(\"locale\").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)\r\n end",
"def locales\n map(&:locale)\n end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def locale\n @locales = Ramaze::Tool::Localize.languages.map{ |lang|\n [\n Ramaze::Tool::Localize.localize('locale_menu_descrition', lang),\n Ramaze::Tool::Localize.localize('locale_name', lang),\n lang\n ]\n }\n end",
"def available_locales\n translations = Dir.glob('config/locales/*').map { |locale| locale.split('/').last.split('.').first }\n locales = []\n translations.each do |t|\n value = (t == 'zh' ? 'zh-CN' : t)\n locales << [LanguageList::LanguageInfo.find(t).name, value]\n end\n locales\n end",
"def available_locales_set; end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def all_locales\n locales = slugged_attributes\n .map { |attr| send(\"#{attr}_translations\").keys if respond_to?(\"#{attr}_translations\") }\n .flatten.compact.uniq\n locales = I18n.available_locales if locales.empty?\n locales\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def get_locales\n fall_back = [:ru].to_yaml\n locales = CustomSetting.find_or_create_by_name(\"languages\").value || fall_back\n begin\n locales = YAML::load(locales)\n rescue\n locales = YAML::load(fall_back)\n end\n end",
"def available_locales\n []\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def locales\n locale_counts.keys\n end",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def languages\n translations.map(&:language)\n end",
"def GetLocales params = {}\n\n params = params.merge(path: 'locales.json')\n APICall(params)\n\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def translations\n @translations ||= {}\n end",
"def user_languages_hash\n result = Hash.new\n\n I18n.available_locales.each do |locale|\n result[t(\"languages.#{locale.to_s}\")] = locale.to_s\n end\n \n return result\n end",
"def available_locales\n @available_locales ||= self.languages.published\n end",
"def translations_for_select\n configuration(:translations).collect{ |translation|\n [translation[:language], translation[:language_code]]\n }\n end",
"def index\n @locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)\n end",
"def descriptions\n I18n.available_locales.map {|l| [l, description(l)] }.to_h\n end",
"def locales\n @env.locales\n end",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def lookup_chain = locale(true).lookup",
"def other_locales_with_translations(website)\n all_locales_with_translations(website) - [I18n.locale.to_s]\n end",
"def select_languages_localized\n available_languages.map{ |x| known_languages.assoc(x)}.map{ |y| [y[2],y[0]]}.sort!\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def locales\n locale_sources.compact.downcase.map {|loc| WorldFlags.locale(loc) unless loc.blank? }\n end",
"def locales(website)\n if product_families.size > 0\n @locales ||= product_families.map do |pf|\n pf.find_ultimate_parent.locales(website)\n end.flatten.uniq - locales_where_hidden\n else\n @locales ||= website.list_of_all_locales - locales_where_hidden\n end\n end",
"def matching_locales\n @_matching_locales ||= ::I18n.available_locales.select do |locale|\n locale.to_s.split(\"-\")[0] == language_code\n end\n end",
"def all_published_locales\n translations.where(published: true).map{|x| x.locale}.uniq.sort\n end",
"def index\n @translations = @locale.translations.all(:order => \"raw_key, pluralization_index\")\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def locale_matches\n matches = {}\n I18n.available_locales.map(&:to_s).each do |locale|\n matches[locale] = locale\n matches[locale[0, 2]] = locale if locale.length > 2\n end\n matches\n end",
"def getLangs\r\n result = self.class.get '/getLangs', { query:{ key:@@api_key } }\r\n check_result result\r\n end",
"def available_locales_initialized?; end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def translations\n OneclickRefernet::Translation.where(key: self.code)\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def translations_hash; end",
"def resolve_runtime_locale_values(hsh)\n hsh.each do |key, value|\n if value.is_a?(Hash)\n meta = value[helpers::META[:meta]]\n if meta && (meta.to_h)[helpers::META[:decorators][:runtime_locales]]\n hsh[key] = get_runtime_locale_value(value)\n else\n hsh[key] = resolve_runtime_locale_values(value)\n end\n end\n end\n return hsh\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def for_language(locale)\n translations.select { |word| word.locale == locale }\n end",
"def translations; end",
"def missing_locales\n project.locales.reject do |locale|\n translations.map(&:locale_id).include? locale.id\n end\n end",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def locales\n self.site.locales || []\n end",
"def available_locales=(locales); end",
"def locales\n EnvironmentLocaleMethodsFactory.new(self)\n end",
"def rtl_locales\n %i[ar]\n end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def preferred_locales\n read_attribute(\"preferred_locales\").map(&:to_sym)\n end",
"def suitable_locale_text(texts)\n english = texts.select { |t| english_locales.include? t[\"locale\"] }\n (english + texts).first[\"text\"]\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def init_translations; end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def each_locale(include_default_locale = true, &block)\n current_locale = ::Mongoid::Fields::I18n.locale\n _locales = include_default_locale ? self.locales : (self.locales - [self.default_locale])\n\n _locales.each do |locale|\n ::Mongoid::Fields::I18n.with_locale(locale) do\n yield locale, current_locale.to_s == locale.to_s\n end\n end\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def loaded_languages\n @@languages.keys\n end",
"def locales(locale_type)\n locs = Set.new\n\n each_bathing_water do |bw|\n l = bw[locale_type]\n locs << l if l.is_a?(LdaResource)\n end\n\n locs.to_a.sort_by(&:label)\n end",
"def website_locales\n WebsiteLocale.where(locale: self.code)\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def published_locales\n StoryTranslation.where(:story_id => self.id, :published => true).pluck(:locale).uniq\n end",
"def available_locale_preferences\n [@no_preference] + available_locales\n end",
"def hierarchy_locale_map\n { ar: 'ar-Arab', en: 'en' }\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end"
] |
[
"0.7795505",
"0.7594396",
"0.7231203",
"0.7217417",
"0.7215168",
"0.72047263",
"0.71941084",
"0.7124471",
"0.711734",
"0.70609784",
"0.7049899",
"0.7041021",
"0.7019433",
"0.6969116",
"0.69545597",
"0.6909755",
"0.6909755",
"0.6902939",
"0.68827",
"0.68690604",
"0.68629074",
"0.6811067",
"0.6749421",
"0.6745664",
"0.67064464",
"0.6689373",
"0.6687543",
"0.66790974",
"0.6656525",
"0.6650543",
"0.6608158",
"0.65181667",
"0.6495705",
"0.6485807",
"0.648508",
"0.6465061",
"0.64465445",
"0.64465445",
"0.6439108",
"0.64259636",
"0.6424764",
"0.64157623",
"0.641337",
"0.64063877",
"0.64007664",
"0.63971686",
"0.6379979",
"0.63790596",
"0.63638324",
"0.6356817",
"0.6339081",
"0.6335451",
"0.63271654",
"0.6267265",
"0.6259996",
"0.6245623",
"0.6241829",
"0.6221402",
"0.6184947",
"0.6168362",
"0.61674964",
"0.61556685",
"0.6135783",
"0.61310244",
"0.612117",
"0.6117237",
"0.6115776",
"0.61040515",
"0.6102912",
"0.6102606",
"0.60745776",
"0.60439825",
"0.60436493",
"0.6041124",
"0.6014954",
"0.60089535",
"0.59849477",
"0.5984685",
"0.5968615",
"0.59664464",
"0.5964071",
"0.5959109",
"0.5954403",
"0.5939725",
"0.59288716",
"0.5927797",
"0.59258425",
"0.5923398",
"0.5915768",
"0.58991903",
"0.58969396",
"0.5883745",
"0.5880373",
"0.5872692",
"0.5872449",
"0.5869542",
"0.58651406",
"0.58516645",
"0.585132"
] |
0.6868777
|
21
|
Clean up translations hash and set initialized to false on reload! source://i18n//lib/i18n/backend/simple.rb58
|
def reload!; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reload!\n @initialized = false\n @translations = nil\n super\n end",
"def reset_i18n()\n I18n.backend = I18n::Backend::Simple.new\nend",
"def init_translations; end",
"def clear_translations!\r\n @translation_caches = {}\r\n @stop_merging_translated_attributes = nil\r\n end",
"def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def translations\n @translations ||= {}\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def reload\r\n translated_attribute_names.each { |name| @attributes.delete(name.to_s) }\r\n globalize.reset\r\n super\r\n end",
"def clean_cache_and_translations\n $redis.srem(\"otwtranslation_rules_for_#{language_short}\", display_type)\n\n Otwtranslation::Translation.for_language(language_short)\n .where(\"rules != '#{[].to_yaml}'\").each do |translation|\n if translation.rules.include?(id)\n translation.approved = false\n translation.rules = []\n translation.save!\n end\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def clear_available_locales_set; end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end",
"def untranslated\n find_all do |entry|\n entry.untranslated?\n end\n end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def fillin_translations\n collection_types = Hyrax::CollectionType.all\n collection_types.each do |c|\n next unless c.title =~ /^translation missing/\n oldtitle = c.title\n c.title = I18n.t(c.title.gsub(\"translation missing: en.\", ''))\n c.save\n Rails.logger.debug \"#{oldtitle} changed to #{c.title}\"\n end\n end",
"def translations_hash; end",
"def translations; end",
"def set_stale\n return unless locale == I18n.default_locale.to_s\n\n Translation.where(:key => key).where(Translation.arel_table[:locale].not_eq(locale)).update_all({:stale => true})\n end",
"def save_translations\n return true unless translation_cache\n \n translation_cache.each do |code, attrs|\n switch_language(code) do\n @attributes.update attrs\n update_translation\n end\n end\n true\n end",
"def activate\n\tAVAILABLE_LOCALES.clear.merge!('en-US' => \"English US\", 'mx' =>\"Spanish ES\")\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def use_i18n=(value); end",
"def use_i18n; end",
"def initialize\n self.namespace = \"i18n_languages\"\n self.custom = false\n self.available_locales_only = true\n end",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def empty_column_translation\n @column_translation = {}\n end",
"def delete_translations\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def reset_stats!\r\n @@available_locales = nil\r\n @@enabled_locales = nil\r\n @@language_completion = nil\r\n @@all_translation_info = nil\r\n @@datetime_vars = nil\r\n end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def list\n @@translatable ||= Hash.new\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def available_locales_initialized?; end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def globalize_object(model)\n return unless pol_cfg.multilang?\n pol_cfg.languages.each do |lang|\n next if model.globalize_translations.map(&:locale).include?(lang.to_sym)\n model.globalize_translations.build({ :locale => lang })\n end\n end",
"def initialize_attributes(attributes)\n return unless attributes\n attributes_copy = attributes.dup.delete_if do |k, v|\n if self.class.translations_hash.include?(k)\n self[k] = v\n true\n end\n end\n super attributes_copy\n end",
"def inherited(klass)\n super\n klass.instance_variable_set(:@transforms, transforms.dup)\n klass.instance_variable_set(:@translations_hash, translations_hash.dup)\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def after_save_main_object\n if save_default_translation?\n save_default_translation\n end\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def reset_data\n ExpressTranslate.reset\n puts \"Reset successful!\"\n end",
"def reset_locale(locale = nil, force = false)\n return if explicit_locale? and !force\n @locale = locale\n @territory = nil\n @data_locale = nil\n @locale_config = nil\n @timezone = nil\n @calendar = nil\n @currency = nil\n @info = {}\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def reload_dictionary\n if @short_refresh\n load_dictionary if needs_refresh?\n else\n load_dictionary\n end\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def setup_mass_copy_translations\n end",
"def expire_author_init_chars_cache\n I18n.available_locales.each do |locale|\n Rails.cache.delete(\"author_init_chars_#{I18n.locale}\")\n end\n end",
"def reload!\n @stored_settings &&= nil\n end",
"def update_associations_translated_cache\n result = Array(translatable_options[:translatable_associations]).all? do |association|\n records = send(association)\n case records\n when ActiveRecord::Base\n # If it's a single record\n send(association).translation_complete?\n else\n # If it's a relation\n send(association).translation_incomplete.empty?\n end\n end\n # Save without triggering callbacks\n self.class.update_all({:associations_translated => result}, :id => self.id) if self.class.column_names.include? 'associations_translated'\n end",
"def clear_cached_vars\n @_rendered , @_versions = false , false\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def scoped_variables_for_translations\n @scoped_variables_for_translations ||= {\n :default => '',\n :scope => controller_action_scope }.freeze # frozen to force use of dup, otherwise wrong vars get sent to i18n\n end",
"def silence_errors\n require 'fast_gettext/translation_repository/base'\n translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale')\n end",
"def validate\n untranslated = self.get_untranslated_keys\n untranslated.each { |key|\n puts \"WARNING: \\\"#{key['id']}\\\" is not translated in #{key['untranslated']} languages\"\n }\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.section_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.section_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def initialize_attributes(attributes)\n return unless attributes\n attributes_copy = attributes.dup.delete_if do |k, v|\n if self.class.translations_hash.include?(k)\n self[k] = v\n true\n end\n end\n super attributes_copy\n end",
"def test_remove_xlate\r\n @dict.add_translation(\"book\", \"boek\")\r\n @dict.remove_translation(\"book\")\r\n assert_nil @dict.translate(\"book\")\r\n assert_nil @dict.translate(\"boek\")\r\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def after_initialize\n @loaded = Set.new\n end",
"def shouldReInitialize\n return(false)\n end",
"def update_translations(locale, data)\n set_translations(locale, application.cache_translations(\n locale,\n key,\n data.is_a?(Hash) ? data['translations'] : data\n ))\n end",
"def verificar_locale\n \n end",
"def localize_present?\n false\n end",
"def reload\n @ignored = nil\n ignored\n end",
"def localized?\n false\n end",
"def fill_defaults\n self.suid = Dictionary.next_suid\n dictionary_descriptions.destroy_all\n Language.all.each do |language|\n dictionary_descriptions.build(lang: language.code3)\n end\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def reload!\n @manifests = {}\n @strings_hash = {}\n end",
"def switch_to(text_domain, locale)\n @store[text_domain] ||= {}\n @store[text_domain][locale] ||= {}\n @store[text_domain][locale][\"\"] = false # ignore gettext meta key when translating\n @current = @store[text_domain][locale]\n end",
"def match_locale_and_set_locale\n changed = false\n if I18n.available_locales.map(&:to_s).include?(configuration_params[:locale])\n unless cookies[:locale] == configuration_params[:locale]\n I18n.locale = cookies[:locale] = configuration_params[:locale] \n changed = true\n end\n changed\n end\n end",
"def reset!\n Unleashed::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Unleashed::Default.options[key])\n end\n\n self\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def translation_for(locale)\r\n @translation_caches ||= {}\r\n # Need to temporary switch of merging, because #translations uses\r\n # #attributes method too, to avoid stack level too deep error.\r\n @stop_merging_translated_attributes = true\r\n unless @translation_caches[locale]\r\n _translation = translations.find_by_locale(locale)\r\n _translation ||= translations.build(:locale => locale)\r\n @translation_caches[locale] = _translation\r\n end\r\n @stop_merging_translated_attributes = false\r\n @translation_caches[locale]\r\n end",
"def disable_clear_and_finalize; end",
"def clone\r\n obj = super\r\n return obj unless respond_to?(:translated_attribute_names)\r\n obj.instance_variable_set(:@globalize, nil )\r\n each_locale_and_translated_attribute do |locale, name|\r\n obj.globalize.write(locale, name, globalize.fetch(locale, name) )\r\n end\r\n return obj\r\n end",
"def reload!\n @private_key = nil\n @pem = nil\n nil\n end",
"def cached_translations_for_language(language)\n translations = Tr8n::Config.current_source.valid_translations_for_key_and_language(self.key, language)\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end",
"def translations\n\t\t\tvalues(\"http://scta.info/property/hasTranslation\")\n\t\tend",
"def set_default_values\n self.synced_with_gram = false\n end",
"def set_default_values\n self.synced_with_gram = false\n end",
"def save_translations\n cache.each_translation do |translation|\n next unless translation.value.present?\n translation.id ? translation.save : model.send(\"add_#{association_name.to_s.singularize}\", translation)\n end\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def reset() # :nodoc:\n @frecuencia_jugadas = {\n \"Piedra\" => 1,\n \"Papel\" => 1,\n \"Tijera\" => 1,\n \"Lagarto\" => 1,\n \"Spock\" => 1\n }\n end",
"def create_default_language_entries\n self.all.each {|entry| entry.save_default_translation}\n end",
"def status_translations\n @status_translations ||= Assembla.statuses['ticket_statuses']\nend",
"def translatable\n self._translatable[base_name]\n end",
"def translated\n find_all do |entry|\n entry.translated?\n end\n end"
] |
[
"0.7954132",
"0.70641816",
"0.69595075",
"0.6919442",
"0.6725708",
"0.66081476",
"0.646304",
"0.6453719",
"0.6423782",
"0.6372822",
"0.62522215",
"0.61921304",
"0.61864215",
"0.61251813",
"0.61063397",
"0.602579",
"0.602579",
"0.6025587",
"0.59504515",
"0.59426296",
"0.59093636",
"0.5881708",
"0.58628225",
"0.5848672",
"0.5789111",
"0.5756389",
"0.5731809",
"0.5717846",
"0.57008106",
"0.56866246",
"0.56816506",
"0.56351745",
"0.56304836",
"0.56254756",
"0.5615693",
"0.5601576",
"0.5600196",
"0.55962783",
"0.5575486",
"0.55571413",
"0.5555705",
"0.5489045",
"0.54657745",
"0.54556125",
"0.54334784",
"0.5406275",
"0.54053205",
"0.54047436",
"0.53695804",
"0.53616744",
"0.53495145",
"0.53491485",
"0.53434575",
"0.5326634",
"0.53207916",
"0.53170294",
"0.53117514",
"0.5304366",
"0.5297839",
"0.52943933",
"0.52899534",
"0.5286992",
"0.52799803",
"0.52755916",
"0.52711457",
"0.52687764",
"0.52682006",
"0.52627057",
"0.5242474",
"0.5218893",
"0.5209864",
"0.5197833",
"0.5183744",
"0.5175843",
"0.5175052",
"0.516429",
"0.51633346",
"0.51597625",
"0.51564264",
"0.5156385",
"0.5142012",
"0.5138853",
"0.5138693",
"0.5116037",
"0.5107616",
"0.5106586",
"0.50997686",
"0.5095678",
"0.50852066",
"0.50745064",
"0.50613815",
"0.50612044",
"0.50575846",
"0.50575846",
"0.50535315",
"0.5051594",
"0.50506085",
"0.50500697",
"0.5046891",
"0.5034545",
"0.50332403"
] |
0.0
|
-1
|
Stores translations for the given locale in memory. This uses a deep merge for the translations hash, so existing translations will be overwritten by new ones only at the deepest level of the hash. source://i18n//lib/i18n/backend/simple.rb36
|
def store_translations(locale, data, options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def store_translations(locale, data, options = {})\n locale = locale.to_sym\n translations[locale] ||= {}\n data = data.deep_symbolize_keys\n translations[locale].deep_merge!(data)\n end",
"def store_translations(locale, data)\n flatten_data(locale => data).each do |key, value|\n self[key] = value\n end\n end",
"def store_translations(locale, data)\n data = flatten data\n data.each { |key, data| store_translation(locale, key, data) }\n end",
"def store_translations(locale, data, options = {})\n escape = options.fetch(:escape, true)\n flatten_translations(locale, data, escape, @subtrees).each do |key, value|\n key = \"#{locale}.#{key}\"\n\n case value\n when Hash\n if @subtrees && (old_value = @store[key])\n old_value = ActiveSupport::JSON.decode(old_value)\n value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash)\n end\n when Proc\n raise \"Key-value stores cannot handle procs\"\n end\n\n unless value.is_a?(Symbol)\n if value.is_a?(String)\n @store[key] = value.strip.gsub(/\\<script.*?\\>|\\<\\/script\\>/, '') unless value.blank? # don't store the locale if it is empty\n else\n @store[key] = ActiveSupport::JSON.encode(value)\n end\n end\n end\n end",
"def store_translations(locale, data, options = {})\n raise NotImplementedError\n end",
"def store_translations(locale, data, options = {})\n super\n ActiveRecord::Base.transaction do\n store_item(locale, data)\n end if store_items? && valid_locale?(locale)\n end",
"def store_translations(locale, data, options = {})\n super\n ActiveRecord::Base.transaction do\n store_item(locale, data)\n end if store_items? && valid_locale?(locale)\n end",
"def store_translation(locale, key, text, count=nil)\n if count.nil?\n data = text\n else\n pluralization_index = pluralizer(locale).call(count)\n data = { pluralization_index => text }\n end\n Translation.create_or_update(locale, key, data)\n # merge the stored translation back to the memory collection\n reload!\n end",
"def translation_for(locale)\r\n @translation_caches ||= {}\r\n # Need to temporary switch of merging, because #translations uses\r\n # #attributes method too, to avoid stack level too deep error.\r\n @stop_merging_translated_attributes = true\r\n unless @translation_caches[locale]\r\n _translation = translations.find_by_locale(locale)\r\n _translation ||= translations.build(:locale => locale)\r\n @translation_caches[locale] = _translation\r\n end\r\n @stop_merging_translated_attributes = false\r\n @translation_caches[locale]\r\n end",
"def update_translations(locale, data)\n set_translations(locale, application.cache_translations(\n locale,\n key,\n data.is_a?(Hash) ? data['translations'] : data\n ))\n end",
"def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end",
"def update_translation( key, value, locale )\n \n # lock file\n filename = File::join RAILS_ROOT, \"config/locales\", File::basename( locale + \".yml\" )\n if( File.exists? filename )\n file = File.new( filename, \"r+\")\n else\n file = File.new( filename, \"w+\" ) \n end\n \n file.flock( File::LOCK_EX )\n \n begin \n # read project locale file\n data = YAML.load( file )\n unless data.is_a? Hash \n I18n.load_path << filename\n data = { locale => {} } unless data \n end\n \n tmp = data\n \n # create middle hash keys as needed\n key = locale + \".\" + key\n keys = key.split(/\\./)\n base_key = keys.pop\n \n while tmpkey = keys.shift\n unless tmp[tmpkey].class == Hash\n tmp[tmpkey] = {}\n end\n tmp = tmp[tmpkey]\n end\n \n # update or create value\n tmp[base_key] = value\n \n # save file\n file.truncate( 0 )\n file.rewind\n file.write( data.to_yaml )\n ensure\n # unlock and close file\n file.flock( File::LOCK_UN )\n file.close\n end\n \n I18n.reload!\n \n end",
"def save_translations\n cache.each_translation do |translation|\n next unless translation.value.present?\n translation.id ? translation.save : model.send(\"add_#{association_name.to_s.singularize}\", translation)\n end\n end",
"def save_translations\n cache.each_value do |translation|\n next unless present?(translation.__send__ value_column)\n translation.id ? translation.save : model.send(\"add_#{singularize(association_name)}\", translation)\n end\n end",
"def upsert(locale, key, value) # rubocop:disable Metrics/MethodLength\n I18n.with_locale(locale) do\n # when an array has to be inserted with a default value, it needs to\n # be done like:\n # I18n.t('foo', default: [['bar', 'baz']])\n # because without the double array, array items are treated as fallback keys\n # - then, the last array element is the final fallback; so in this case we\n # don't specify fallback keys and only specify the final fallback, which\n # is the array\n val = value.is_a?(Array) ? [value] : value\n I18n.t(key, default: val)\n\n # this indicates that this translation already exists\n existing_translation =\n Lit::Localization.joins(:locale, :localization_key)\n .find_by('localization_key = ? and locale = ?', key, locale)\n\n return unless existing_translation\n\n if @raw\n existing_translation.update(default_value: value)\n else\n existing_translation.update(translated_value: value, is_changed: true)\n lkey = existing_translation.localization_key\n lkey.update(is_deleted: false) if lkey.is_deleted\n end\n end\n end",
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.translations[\"#{locale}\"] = #{translations_for_locale.to_json};\\n);\n end\n end\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.section_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.section_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.story_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.story_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def switch_to(text_domain, locale)\n @store[text_domain] ||= {}\n @store[text_domain][locale] ||= {}\n @store[text_domain][locale][\"\"] = false # ignore gettext meta key when translating\n @current = @store[text_domain][locale]\n end",
"def use_and_copy_default_locale_translations_if_they_exist(locale, key)\n default_locale_entry = lookup(Locale.default_locale, key)\n return unless default_locale_entry\n\n if default_locale_entry.is_a?(Array)\n default_locale_entry.each_with_index do |entry, index|\n locale.create_translation(key, nil, index) if entry\n end\n else\n locale.create_translation(key, nil) \n end\n\n return default_locale_entry\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def save_translations\n return true unless translation_cache\n \n translation_cache.each do |code, attrs|\n switch_language(code) do\n @attributes.update attrs\n update_translation\n end\n end\n true\n end",
"def update_or_create_all_translations(attributes={})\n missing_locales.each { |locale| translations.build :locale => locale }\n translations.each do |translation|\n attrs = attributes[translation.code]\n unless translation.active? or attrs.nil?\n merger = translation.attributes.merge attrs\n translation.attributes = merger\n end\n translation.save!\n end\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def add locale, key, value\n entry = self[key] ||= Entry.new\n entry[locale] = value\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.infographic_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.infographic_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def globalize_object(model)\n return unless pol_cfg.multilang?\n pol_cfg.languages.each do |lang|\n next if model.globalize_translations.map(&:locale).include?(lang.to_sym)\n model.globalize_translations.build({ :locale => lang })\n end\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def generate\n I18n.backend.load_translations\n translations = wrap(source_translations)\n I18n.backend.store_translations(destination_locale, translations)\n I18n.available_locales += [destination_locale]\n end",
"def translations_hash; end",
"def translations\n @translations ||= {}\n end",
"def export_locale(locale)\n @sections_hash.keys.reduce({}) do |memo, section|\n memo[section.name] = export_section_locale(section, locale)\n memo\n end\n end",
"def export(translations)\n res = LazyHash.build_hash\n\n translations.each do |e|\n LazyHash.add(res, \"#{e.locale}.#{e.key}\", e.value)\n end\n if res.any? && res.keys.size != 1\n raise IndexError, \"Generated hash must have only one root key. Your translation data in database may be corrupted.\"\n end\n res\n end",
"def create_or_update(locale, key, data, pluralization_index=\"\")\n\n locale, key = locale.to_s, key.to_s\n\n # create/update all of the pluralization forms\n if data.is_a? Hash\n data.each do |pluralization_index, text|\n if record = find_by_locale_and_key_and_pluralization_index(locale, key, pluralization_index)\n record.update_attribute(:text, text)\n else\n create :locale => locale, :key => key, :pluralization_index =>pluralization_index.to_s, :text => text\n end\n end\n\n # create/update without pluralization\n else\n if record = find_by_locale_and_key_and_pluralization_index(locale, key, pluralization_index)\n record.update_attribute(:text, data)\n else\n create :locale => locale, :key => key, :text => data, :pluralization_index=>pluralization_index\n end\n end\n\n end",
"def export\n keys = {}\n reset\n db_localizations = {}\n Lit::Localization.find_each do |l|\n db_localizations[l.full_key] = l.get_value\n end\n db_localizations.sort.each do |(l_key, value)|\n current = keys\n yaml_keys = l_key.split('.')\n\n 0.upto(yaml_keys.size - 2) do |i|\n key = yaml_keys[i]\n # Overwrite en.key with en.sub.key\n unless current[key].class == Hash\n current[key] = {}\n end\n current = current[key]\n end\n current[yaml_keys.last] = value\n end\n keys.to_yaml\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def write(locale, name, value)\r\n stash.write(locale, name, value)\r\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def save!\n if self.file =~ LOCALE_INTERPOLATOR\n I18n.available_locales.each do |locale|\n write_file(file_for_locale(locale), self.translations.slice(locale))\n end\n else\n write_file\n end\n end",
"def dump_yaml!\n FileUtils.mkdir_p LOCALE_DIR\n File.open(STANDARD_LOCALE_FILE,'w+') { |f| YAML::dump(@translations, f) } \n end",
"def flatten_translations(locale, data, escape, subtree); end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def transliterate(locale = nil)\n I18n.transliterate(self, ({ locale: locale } if locale))\n end",
"def transform_to_locale(entry, locale)\n # If the backing store already returned a localized entry, nothing to do\n if entry_locale = entry.dig('sys', 'locale')\n unless entry_locale == locale\n raise WCC::Contentful::LocaleMismatchError,\n \"expected #{locale} but was #{entry_locale}\"\n end\n\n return entry\n end\n\n # Transform the store's \"locale=*\" entry into a localized one\n locale ||= default_locale\n\n new_entry = entry.dup\n new_entry['sys'] = entry['sys'].deep_dup\n new_entry['sys']['locale'] = locale\n if entry.key?('fields')\n new_entry['fields'] =\n entry['fields']&.transform_values do |value|\n next if value.nil?\n\n # replace the all-locales value with the localized value\n l = locale\n v = nil\n while l\n v = value[l]\n break if v\n\n l = configuration.locale_fallbacks[l]\n end\n\n v\n end\n end\n\n new_entry\n end",
"def write_to_file keys\n init_translations_and_ignore_app_mode_file_dump if self.class.mode == :origin\n # Hash to capture the files updated on origin mode and the keys for each one\n result = {}\n keys.each do |key, value|\n #\n # Search the files where the translation will be applied to\n decide_filenames(key).each do |filename| \n (result[filename] ||= []) << key\n # Apply the current translation to the filenames\n #\n # It will save a key 'ubiquo.categories.index.title' with a value 'Title'\n # mergin the content of $filename with it\n #\n # Load the file\n hash = YAML.load_file(filename)\n # Morph the translation key\n # from: 'ubiquo.categories.index.title'\n # to: { :ubiquo => {\n # :categories => {\n # :index => {\n # :title => 'Title'\n # }\n # }\n # }\n # }\n # }\n branch_hash = Translate::Keys.to_deep_hash({key => value})\n #\n # Cast all the hash keys to String\n #\n branch_hash = Translate::File.deep_stringify_keys({self.locale => branch_hash})\n #\n # Merge the translation with the content of the file\n #\n #\n hash.deep_merge!(branch_hash)\n #\n # Save to file updated to disk\n Translate::File.new(filename).write(hash)\n end \n end\n result\n end",
"def import(file)\n hash = YAML.load file\n raise ArgumentError, \"the YAML file must contain an unique first key representing the locale\" unless hash.keys.count == 1\n\n lang = hash.keys.first\n\n unless lang.to_s == I18n.locale.to_s\n raise ArgumentError, \"the language doesn't match\"\n end\n\n records = parse_hash(hash.first[1], lang)\n transaction do\n records.each do |x|\n if tr = locale(lang).find_by_key(x.key)\n tr.value = x.value\n tr.save!\n else\n x.save!\n end\n end\n end\n end",
"def process_locale(locale)\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(\"#{locale}_tmp\")\n\n # Remove temporary directory if it exists\n FileUtils.rm_rf output_dir\n\n # Output results to temporary directory\n Dir[templ_dir.join('**/*.yml')].each do |f|\n process_file(\n Pathname.new(f).relative_path_from(templ_dir), # Filename\n locale, # Locale\n \"#{locale}_tmp\" # Output locale \n )\n end\n\n # Override the locales folder\n FileUtils.rm_rf local_dir\n FileUtils.mv output_dir, local_dir\n end",
"def find_main_translations\n find_main_cached.translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n end",
"def add_translation(from, to)\n @dictionary[to] = from\n @dictionary[from] = to\n end",
"def merge_names(locale, data)\n locale = locale.to_sym\n names[locale] ||= {}\n data = deep_symbolize_keys(data)\n \n # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n names[locale].merge!(data, &merger)\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def write_locale(directory, file, strings, plurals, locale, date); end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def +(other)\n other = Locale.new(other) unless other.is_a? Locale\n Locale.new(to_h.merge(other.to_h))\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def write!\n Dir.mkdir @directory unless File.directory? @directory\n\n @locales.each_with_index do |locale, index|\n strings = @strings[locale]\n plurals = @plurals[locale]\n\n l_directory = locale_directory locale, index.zero?\n\n file = @table.to_s.empty? ? @adapter.default_file_name : @table\n\n date = DateTime.now\n\n Dir.mkdir l_directory unless File.directory? l_directory\n\n @adapter.write_locale(l_directory,\n file,\n strings,\n plurals,\n locale,\n date)\n end\n end",
"def translation_for(locale, _options = {})\n translation = translations.find { |t| t.key == attribute && t.locale == locale.to_s }\n translation ||= translations.build(locale: locale, key: attribute)\n translation\n end",
"def init_translations; end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def generate_yaml(locale_name, translations)\n yaml = YamlDocument.new(\"config/locales/translation_#{locale_name}.yml\", locale_name)\n each_value [], translations do |parents, value|\n node = parents.inject(yaml[locale_name]) {|node, parent| node[parent]}\n node.value = value\n end\n yaml\n end",
"def setup_mass_copy_translations\n end",
"def store_translation_from_xlsx_cell locale, key, cell\n value = cell.nil? ? '' : cell\n\n if locale.present? && key.present?\n translation = Translation.find_or_initialize_by locale: locale, key: key\n if translation.value != value\n translation.value = value\n translation.save\n end\n end\n end",
"def []=(locale_name, locale)\n @@locales[locale_name] = locale\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def write(locale, name, value)\r\n #raise 'z' if value.nil? # TODO\r\n self[locale][name.to_s] = value\r\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def clone\r\n obj = super\r\n return obj unless respond_to?(:translated_attribute_names)\r\n obj.instance_variable_set(:@globalize, nil )\r\n each_locale_and_translated_attribute do |locale, name|\r\n obj.globalize.write(locale, name, globalize.fetch(locale, name) )\r\n end\r\n return obj\r\n end",
"def dump\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n delete_all unless Interpret.soft\n\n records = []\n files.each do |f|\n ar = YAML.load_file f\n locale = ar.keys.first\n records += parse_hash(ar.first[1], locale)\n end\n\n # TODO: Replace with activerecord-import bulk inserts\n transaction do\n records.each {|x| x.save(:validate => false)}\n end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def translate(details)\n self.translations = Hash[details.map { |k, v| [k.to_s, v.to_s] }].reverse_merge(translations)\n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def list\n @@translatable ||= Hash.new\n end",
"def create_default_language_entries\n self.all.each {|entry| entry.save_default_translation}\n end",
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore create an empty hash to act as\n # placeholder\n local = {} if local.nil?\n\n # Recursing to traverse hash\n pairs = templ.collect { |k, v| [k, assemble(v, local[k])] }\n Hash[pairs]\n end\n\n def validate(node, path)\n if node.nil?\n puts \"Warning: path #{path} is nil. \"\n return\n end\n\n return unless node.is_a?(Hash)\n\n node.each { |k, v| validate(v, \"#{path}.#{k}\") }\n end\n\n puts \"Processing file #{filename} of locale #{locale}. \"\n\n # Directories\n locales_dir = Rails.root.join('config/locales')\n templ_dir = locales_dir.join('template')\n local_dir = locales_dir.join(locale)\n output_dir = locales_dir.join(output_locale)\n\n # Loading template\n templ_file = templ_dir.join(filename)\n templ = YAML::load_file(templ_file)['template']\n\n # If the topmost level of the template is not 'template'\n if !templ\n puts \"Warning: Template is nil for #{filename}. Aborting for this file. \"\n return\n end\n\n # Loading localized YAML\n local_file = local_dir.join(filename)\n local = File.exists?(local_file) ? YAML::load_file(local_file)[locale] : {}\n\n # Alert for new file creation\n puts \"Warning: Creating new file #{filename} of locale #{locale}. \" unless File.exists?(local_file)\n\n # Assemble localized strings into template file\n assembled = assemble(templ, local)\n\n # Validate to find missed translations\n validate(assembled, locale)\n\n # Output to file\n output_file = output_dir.join(filename)\n FileUtils.mkdir_p output_file.dirname\n content = {locale => assembled}.to_yaml\n File.open(output_file, 'w') { |f| f.write(content) }\n\n end",
"def translation(locale=I18n.default_locale)\n translations.find_by(locale: locale)\n end",
"def translate(details)\n self.translations = Hash[details.map { |k,v| [k.to_s, v.to_s] }].reverse_merge(self.translations)\n end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def translate_all(keys)\n returning ActiveSupport::OrderedHash.new do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.t(key, :default => key_suffix, :locale => locale_name)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation != key_suffix ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.t(key, :default => key, :locale => locale_name)\n oh[key] = existing_translation != key ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def translated_in=(locales)\n self._locales = locales.map(&:to_sym)\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def locale=(loc)\n expected_keys = [:country, :language, :variant]\n begin\n loc.keys.each do |k|\n raise ArgumentError, \"Invalid locale parameter: #{k}\" unless expected_keys.include? k\n end\n rescue => e\n raise e, e.message\n else\n @locale = { :country => loc[:country] || locale[:country], \n :language => loc[:language] || locale[:language], \n :variant => loc[:variant] || locale[:variant]\n }\n end\n end",
"def locale_metas_storage(locale = I18n.locale)\n metas_storage[I18n.locale.to_s]\n end",
"def create_translations\n I18n.available_locales.each do |locale|\n next if locale == I18n.locale\n @micropost.translations.create(locale: locale,\n content: micropost_params[:content])\n end\n end",
"def generate_multilang(site)\n lang = site.data['curr_lang']\n prime_lang = site.config['prime_lang']\n is_localization = prime_lang != lang\n\n Jekyll.logger.info \"Generating translation in '#{lang}'\"\n\n prefix_lang = File.join site.source, \"_langs\", lang\n prefix_prime = File.join site.source, \"_langs\", prime_lang\n\n # Hack to skip processing regular content\n # if we're building a translation.\n if is_localization\n site.static_files = []\n site.pages = []\n end\n\n # prime language pages map url => page\n site.data['primes'] = {}\n # Outer loop over each page of prime_lang and their translations\n site.data['translations'].each do |relpath, locales|\n reldir, name = File.split relpath\n prime_file = File.join(prefix_prime, relpath)\n lang_file = File.join(prefix_lang, relpath)\n\n prime = create_page(site, prime_file, reldir, name, prime_lang, true, !is_localization)\n next unless prime\n\n has_localization = locales.inject({}) { |loc, hl| loc[hl] = true; loc }\n prime.data.merge!(\n 'is_localized' => !locales.empty?,\n 'is_localization' => false,\n 'has_localization' => has_localization)\n\n raise \"Two pages at the same URL #{prime.url}\" if site.data['primes'].key? prime.url\n\n site.data['primes'][prime.url] = prime\n translated_pages = [prime]\n\n # Inner loop over known single page translations from the manifest\n (locales || []).each do |hl|\n hl_file = File.join site.source, \"_langs\", hl, relpath\n page = create_page(site, hl_file, reldir, name, hl, true, hl == lang)\n page.data.merge!('is_localized' => true, 'is_localization' => true)\n translated_pages << page\n end\n\n # Map all the translations for a page on to each other\n translated_pages.each do |page|\n page.data[\"translations\"] = translated_pages\n end\n end\n end"
] |
[
"0.8079555",
"0.7767193",
"0.7732029",
"0.7404124",
"0.7088",
"0.70876396",
"0.70876396",
"0.69401413",
"0.69018346",
"0.6747246",
"0.665445",
"0.64230585",
"0.6250312",
"0.6158846",
"0.61491776",
"0.6114319",
"0.6084317",
"0.6078684",
"0.6046479",
"0.5980826",
"0.5876105",
"0.58757085",
"0.5867449",
"0.5833737",
"0.58329684",
"0.5778365",
"0.5776495",
"0.5768316",
"0.5708263",
"0.5701736",
"0.5695207",
"0.5695123",
"0.5680347",
"0.56369215",
"0.5634631",
"0.56115466",
"0.560943",
"0.55831385",
"0.55742854",
"0.5554356",
"0.5531231",
"0.55284595",
"0.55227435",
"0.54689425",
"0.5464043",
"0.54556215",
"0.54457587",
"0.5444765",
"0.5396761",
"0.53769004",
"0.5373399",
"0.53591716",
"0.52870256",
"0.5258191",
"0.522532",
"0.52169025",
"0.52068883",
"0.520462",
"0.51981115",
"0.5196093",
"0.5186818",
"0.5183945",
"0.51791376",
"0.5176287",
"0.5175442",
"0.5169949",
"0.5157033",
"0.5156623",
"0.51563525",
"0.5132425",
"0.51180094",
"0.5107718",
"0.50897247",
"0.50852174",
"0.5083223",
"0.5082954",
"0.5075828",
"0.5075765",
"0.5071939",
"0.5069901",
"0.5061275",
"0.50569",
"0.50569",
"0.505603",
"0.5052872",
"0.5040497",
"0.5026092",
"0.500961",
"0.50039786",
"0.49996072",
"0.4983939",
"0.49815425",
"0.498122",
"0.4980501",
"0.4975055",
"0.49740955",
"0.4961543",
"0.4956536",
"0.49528036",
"0.49442858"
] |
0.7078084
|
7
|
Looks up a translation from the translations hash. Returns nil if either key is nil, or locale, scope or key do not exist as a key in the nested translations hash. Splits keys or scopes containing dots into multiple keys, i.e. currency.format is regarded the same as %w(currency format). source://i18n//lib/i18n/backend/simple.rb93
|
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def lookup(locale, key, scope = [], separator = nil)\n return unless key\n keys = I18n.send(:normalize_translation_keys, locale, key, scope)\n @moneta[keys.join('.')]\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def get_translation_from_hash(key, hash)\n path = key.split('.')\n last_step = hash\n path.each do |step|\n break if last_step.blank? || !last_step.is_a?(Hash)\n last_step = last_step[step.to_s.to_sym]\n end\n last_step\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def lookup(locale, key, scope = [], options = {})\r\n return '' if translations_blocked\r\n\r\n if ::LinguaFranca.debugging? && available_locales.include?(::LinguaFranca.debugging)\r\n locale = ::LinguaFranca.debugging\r\n end\r\n\r\n result = super(locale, key, scope, options)\r\n\r\n key = key_name(key, scope)\r\n\r\n return result\r\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end",
"def translate(key, options)\n I18n.translate(\"#{BASE_KEY}.#{key}\", options)\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def t(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n translate_or_localize(key, options)\n end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def filter(translations, scopes)\n scopes = scopes.split(\".\") if scopes.is_a?(String)\n scopes = scopes.clone\n scope = scopes.shift\n\n if scope == \"*\"\n results = {}\n translations.each do |scope, translations|\n tmp = scopes.empty? ? translations : filter(translations, scopes)\n results[scope.to_sym] = tmp unless tmp.nil?\n end\n return results\n elsif translations.has_key?(scope.to_sym)\n return {scope.to_sym => scopes.empty? ? translations[scope.to_sym] : filter(translations[scope.to_sym], scopes)}\n end\n nil\n end",
"def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def [](key)\n key.to_s.split(\".\").inject(@values) { |v, k| v[k] if v }\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def t(key, hash = {})\n if key.start_with?('.')\n I18n.t(\"#{@model_plural_name}.#{key}\", hash)\n else\n I18n.t(key, hash)\n end\n end",
"def t(key, hash = {})\n if key.start_with?('.')\n I18n.t(\"#{@model_plural_name}.#{key}\", hash)\n else\n I18n.t(key, hash)\n end\n end",
"def localized(key, value = nil)\n self[key] = value if value\n\n case self[key]\n when NilClass then nil\n when Proc then instance_eval(&self[key])\n else _(self[key])\n end\n end",
"def translate!(key, **options); end",
"def nested_key(hash, key)\n hash[key] if hash\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def translation_for(locale, _options = {})\n translation = translations.find { |t| t.key == attribute && t.locale == locale.to_s }\n translation ||= translations.build(locale: locale, key: attribute)\n translation\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}.#{key}\", :scope => [:devise, :mailer], :default => key)\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def use_and_copy_default_locale_translations_if_they_exist(locale, key)\n default_locale_entry = lookup(Locale.default_locale, key)\n return unless default_locale_entry\n\n if default_locale_entry.is_a?(Array)\n default_locale_entry.each_with_index do |entry, index|\n locale.create_translation(key, nil, index) if entry\n end\n else\n locale.create_translation(key, nil) \n end\n\n return default_locale_entry\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def get(key, options = EMPTY_HASH)\n return unless key\n\n result = t.(key, locale: options.fetch(:locale, default_locale))\n\n if result.is_a?(Hash)\n text = result[:text]\n meta = result.dup.tap { |h| h.delete(:text) }\n else\n text = result\n meta = EMPTY_HASH.dup\n end\n\n {\n text: text,\n meta: meta\n }\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def getValue(hash, key)\n key.to_s.split('.').inject(hash) { |h, k| h[k] unless h.nil? }\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def human(options = {})\n return @human if i18n_keys.empty? || i18n_scope.empty?\n\n key, *defaults = i18n_keys\n defaults << options[:default] if options[:default]\n defaults << MISSING_TRANSLATION\n\n translation = I18n.translate(key, scope: i18n_scope, count: 1, **options, default: defaults)\n translation = @human if translation == MISSING_TRANSLATION\n translation\n end",
"def localize(key, options = {})\n I18n.localize(key, options.merge(:locale => self.locale))\n end",
"def th(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n options.each {|k,v| options[k] = h(v) if v.is_a?(String) }\n translate_or_localize(key, options)\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def translate(key)\n read(key.to_s)\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def one_translation_per_lang_per_key\n translation_exists = Translation.exists?(\n lang: self.lang,\n translator_id: self.translator.id,\n translator_type: self.translator.class.name,\n translation_key_id: self.key.id\n )\n\n unless translation_exists\n true\n else\n false\n self.errors.add(:lang, I18n.t('.one_translation_per_lang_per_key'))\n end\n end",
"def add_key i18n_prj, input, select_from_translations\n v, quote = input.unquote\n\n if select_from_translations\n items = i18n_prj.potential_i18n_keys v\n if items.empty?\n TextMate::UI.tool_tip \"Can not find tranlation key\"\n else\n k = TextMate::UI.request_item \\\n :title => \"Select Translation Key\",\n :prompt => 'Select Translation Key',\n :items => items\n if !k\n TextMate::UI.tool_tip \"Canceled\"\n end\n end\n return input if !k\n else # new translation if needed\n v.gsub! '.', ''\n k = v[0..0].downcase + v[1..-1].underscore\n full_k = \"#{i18n_prj.key_prefix}.#{k}\"\n if i18n_prj.no_translation(full_k)\n new_k = TextMate::UI.request_string \\\n :default => full_k,\n :title => \"New Translation Key\"\n return input if new_k.nil? or new_k.empty?\n if new_k != full_k\n full_k = new_k\n k = new_k\n else\n k = '.' + k\n end\n insert_translation i18n_prj.en_yml_path, full_k, v\n else\n TextMate::UI.tool_tip \"Translation key '#{full_k}' exists\"\n k = '.' + k\n end\n end\n\n # snippet\n file_type = i18n_prj.file_type\n if quote or file_type == 'rb'\n %Q|t(#{k.inspect})|\n else\n case file_type\n when 'slim'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n when 'haml'; quote ? %Q|t(#{k.inspect})| : %Q|= t(#{k.inspect})|\n else %Q|<%= t #{k.inspect} %>|\n end\n end\nend",
"def translate key = nil, retries: nil, timeout: nil\n require \"gcloud/translate\"\n Gcloud.translate key, retries: (retries || @retries),\n timeout: (timeout || @timeout)\n end",
"def t(hash, key)\n key.split('.').inject(hash) { |r, seg| r[seg] if r }\n end",
"def get(key)\n subkeys = key.split('.')\n lastkey = subkeys.pop\n subhash = subkeys.inject(@config) do |hash, k|\n hash[k]\n end\n return nil if subhash.nil?\n\n subhash.key?(lastkey) ? subhash[lastkey] : nil\n end",
"def pagy_t(key, opts = {})\n Pagy::I18n.translate(@pagy_locale ||= nil, key, opts)\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.section_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.section_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.infographic_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.infographic_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def parse_value(v, locale)\n new_value = nil\n case v\n when Symbol then\n lk = @localization_key_object_cache[v.to_s] || \\\n Lit::LocalizationKey.where(localization_key: v.to_s).first\n if lk\n loca = Lit::Localization.active.where(locale_id: locale.id).\n where(localization_key_id: lk.id).first\n new_value = loca.translation if loca && loca.translation.present?\n end\n when String then\n new_value = v\n when Hash then\n new_value = nil\n when Proc then\n new_value = nil # was v.call - requires more love\n else\n new_value = v.to_s\n end\n new_value\n end",
"def normalize_key(key, options = nil)\n str_key = expanded_key(key)\n raise(ArgumentError, \"key cannot be blank\") if !str_key || str_key.empty?\n\n namespace_key str_key, options\n end",
"def translate_options(keys, scope)\n keys.map{|k| [t(k, :scope => scope), k]}\n end",
"def nested_params_for(key, params)\n params.detect { |p| p.is_a?(Hash) }.try(:[], key.to_sym)\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def at(key_chain)\n result = key_chain.split(\".\").inject(self) { |result, key| result = result ? result[key] : nil }\n end",
"def key_has_value?(key, locale = base_locale)\n t(locale_data(locale)[locale], key).present?\n end",
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def translation(locale=I18n.default_locale)\n translations.find_by(locale: locale)\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def with_translation(locale, build_if_missing=true)\n @local_translations ||= {}\n if @local_translations[locale].blank?\n x = self.story_translations.where(:locale => locale).first\n if x.blank? && build_if_missing\n x = self.story_translations.build(locale: locale)\n end\n\n @local_translations[locale] = x\n end\n return @local_translations[locale]\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subject\", :scope => [:devise, :mailer, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def lookup(key, default, scope, order_override, resolution_type)\n @backends ||= {}\n answer = nil\n\n Config[:backends].each do |backend|\n if constants.include?(\"#{backend.capitalize}_backend\")\n @backends[backend] ||= Backend.const_get(\"#{backend.capitalize}_backend\").new\n answer = @backends[backend].lookup(key, scope, order_override, resolution_type)\n\n break if answer\n end\n end\n\n answer = resolve_answer(answer, resolution_type) || parse_string(default, scope)\n\n return default if answer == empty_answer(resolution_type)\n return answer\n end",
"def normalized_key(name, serializer)\n # serializer && serializer.localized? ? \"#{name}.#{::I18n.locale}\" : name\n serializer&.localized? ? \"#{name}.#{::Mongoid::Fields::I18n.locale}\" : name\n end",
"def [](key, &block)\n if has_key?(key)\n old_bracket(key, &block)\n else\n # Look up aliases in reverse, to find the most recent one\n # Does not allow (obvious) recursion\n aliias = filing.translator.aliases.reverse.detect do |a|\n a[:alias] == key && a[:row].match(row_type) && a[:alias] != a[:for]\n end\n # Pass the key this alias references back to this function\n aliias ? old_bracket(aliias[:for], &block) : nil\n end\n end",
"def normalized_key(name, serializer)\n serializer && serializer.localized? ? \"#{name}.#{::I18n.locale}\" : name\n end",
"def translate_with_consistent_case( key, options = {} )\n lower_requested = options.delete( :case ) != \"upper\"\n translation = I18n.t( key, **options )\n en = I18n.t( key, **options.merge( locale: \"en\" ) )\n default_is_lower = en == en.downcase\n lower_requested_and_default_is_lower = lower_requested && default_is_lower\n upper_requested_and_default_is_upper = !lower_requested && !default_is_lower\n if lower_requested_and_default_is_lower || upper_requested_and_default_is_upper\n return translation\n end\n\n I18n.t( \"#{key}_\", **options )\n end",
"def translator_for(t_key, template = nil, parameters = nil)\n o_translator = translators[t_key]\n if template\n translator = Translator.new(template,\n :parameters => parameters)\n if o_translator\n o_translator.flagged.each do |i|\n translator.flag_ref(i)\n end\n end\n translators[t_key] = translator\n o_translator = translator\n else\n unless o_translator\n o_translator = Translator.new({},\n :parameters => {})\n end\n end\n o_translator\n end",
"def translate_json prefix, src\n json = JSON.parse src\n json.each do |translation_json|\n qualified_key = join_keys prefix, translation_json[\"value\"]\n translations.add locale, qualified_key, translation_json[\"name\"]\n end\n end",
"def find_first_valid_translation_for_language(language, token_values)\n translation = find_first_valid_translation(language, token_values)\n return [language, translation] if translation\n\n if Tr8n::Config.enable_fallback_languages?\n # recursevily go into the fallback language and look there\n # no need to go to the default language - there obviously won't be any translations for it\n # unless you really won't to keep the keys in the text, and translate the default language\n if language.fallback_language and not language.fallback_language.default?\n return find_first_valid_translation_for_language(language.fallback_language, token_values)\n end\n end \n \n [language, nil]\n end",
"def escape_translation_key(key, scope=nil, separator=nil)\n scope ? \"#{scope}#{separator || I18n.default_separator}\\\"#{key}\\\"\" : \"\\\"#{key}\\\"\"\n end",
"def unescape_translation_key_without_scope(key, separator=nil)\n unescape_translation_key(key, separator)[1]\n end",
"def lookup(key, scope)\n compiler = scope.compiler\n _override_loaders(compiler) do\n MeepLookupAdapter.adapt(compiler) do |adapter|\n adapter.set_global_hiera_config_path(config_path)\n end\n\n invocation = Puppet::Pops::Lookup::Invocation.new(\n scope, Puppet::Pops::EMPTY_HASH, Puppet::Pops::EMPTY_HASH, true, MeepLookupAdapter)\n Puppet::Pops::Lookup.lookup(key, nil, nil, true, nil, invocation)\n end\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def translation_for(locale)\r\n @translation_caches ||= {}\r\n # Need to temporary switch of merging, because #translations uses\r\n # #attributes method too, to avoid stack level too deep error.\r\n @stop_merging_translated_attributes = true\r\n unless @translation_caches[locale]\r\n _translation = translations.find_by_locale(locale)\r\n _translation ||= translations.build(:locale => locale)\r\n @translation_caches[locale] = _translation\r\n end\r\n @stop_merging_translated_attributes = false\r\n @translation_caches[locale]\r\n end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.context.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.context || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.context\n valid_translations << {:label => translation.label, :context => translation.context.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def field_label *i18n_keys\n first, *rest = i18n_keys.compact\n\n t(first, default: rest)\n end"
] |
[
"0.76751006",
"0.707611",
"0.67588884",
"0.66506654",
"0.6601622",
"0.64001673",
"0.63686395",
"0.6267941",
"0.6219027",
"0.6099977",
"0.60696435",
"0.60575545",
"0.5892969",
"0.5819957",
"0.58131915",
"0.5810905",
"0.58023244",
"0.5532237",
"0.5487296",
"0.5477236",
"0.53488696",
"0.5341006",
"0.53216124",
"0.52653974",
"0.5238496",
"0.52361125",
"0.52181864",
"0.5200485",
"0.5200485",
"0.51961315",
"0.51961315",
"0.51724094",
"0.51661134",
"0.5139752",
"0.5119306",
"0.51149184",
"0.50807303",
"0.50807303",
"0.50791484",
"0.50789595",
"0.5060571",
"0.50426555",
"0.50348383",
"0.5033843",
"0.50304884",
"0.5023944",
"0.50154364",
"0.49909818",
"0.49826878",
"0.49729663",
"0.49720323",
"0.49667972",
"0.49546742",
"0.49391592",
"0.49266985",
"0.49183464",
"0.49165636",
"0.49094003",
"0.49072254",
"0.4905909",
"0.49044704",
"0.49021506",
"0.4896538",
"0.48766115",
"0.48549697",
"0.48505962",
"0.48474666",
"0.47910002",
"0.47683504",
"0.47483188",
"0.4731815",
"0.47151038",
"0.47112083",
"0.46899545",
"0.468908",
"0.46841422",
"0.46779418",
"0.46712065",
"0.46585855",
"0.46583435",
"0.46456861",
"0.4624968",
"0.46175626",
"0.46118858",
"0.46104518",
"0.46079355",
"0.46042356",
"0.46003056",
"0.459887",
"0.45843837",
"0.4579873",
"0.45662543",
"0.4564363",
"0.45613983",
"0.45555148",
"0.45485327",
"0.45466495",
"0.4546359",
"0.45400333",
"0.4524914"
] |
0.5802403
|
16
|
Add transliteration rules to the approximations hash. source://i18n//lib/i18n/backend/transliterator.rb100
|
def add(hash); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def customize_fr_dictionary(dict)\n dict.add('Alert')\n dict.add('ltr')\n dict.add('org')\n dict.add('Other')\n dict.add('Sara')\n dict.add('saraalert')\n end",
"def translate(text,dictonary)\nend",
"def apply_locale; end",
"def lookup_chain = locale(true).lookup",
"def translations_hash; end",
"def customize_es_pr_dictionary(dict)\n dict.add('Alert')\n dict.add('Fahrenheit')\n dict.add('infórmeles')\n dict.add('intentemoslo')\n dict.add('ltr')\n dict.add('org')\n dict.add('oxímetro')\n dict.add('recordándole')\n dict.add('Sara')\n dict.add('saraalert')\n end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def translate(settings); end",
"def translate_utf8 text, index\n @dict.each { |word| \n key, eng = word[0], word[1][TABLE[index]] \n text.gsub!(key, eng)\n }\n text\n end",
"def replace_with_translation_keys(model_errors)\n return model_errors if internationalized?\n deep_translation_replace(model_errors)\n end",
"def test_localize_from_hash\n hash = {\n \"en\" => {\"é\" => \"ee\"}\n }\n Stringex::Unidecoder.localize_from hash\n assert_equal \"ee\", \"é\".to_ascii\n end",
"def translations; end",
"def transliterate(locale = nil)\n I18n.transliterate(self, ({ locale: locale } if locale))\n end",
"def translate(details)\n self.translations = Hash[details.map { |k, v| [k.to_s, v.to_s] }].reverse_merge(translations)\n end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def init_translations; end",
"def translate_external(facets, options)\n facets_string = \"[\" + facets.map {|facet| \":#{facet}\"}.join(\", \") + \"]\"\n class_eval <<-HERE\n @@facet_options = {}\n attr_writer :fully_loaded\n def fully_loaded?; @fully_loaded; end\n @@globalize_facets = #{facets_string}\n @@preload_facets ||= @@globalize_facets\n class << self\n\n def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end\n\n def globalize_facets\n @@globalize_facets\n end\n\n def globalize_facets_hash\n @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|\n hash[facet.to_s] = true; hash\n }\n end\n\n def untranslated_fields\n @@untranslated_fields ||=\n column_names.map {|cn| cn.intern } - globalize_facets\n end\n\n def preload_facets; @@preload_facets; end\n def postload_facets\n @@postload_facets ||= @@globalize_facets - @@preload_facets\n end\n alias_method :globalize_old_find_every, :find_every unless\n respond_to? :globalize_old_find_every\n end\n alias_method :globalize_old_reload, :reload\n alias_method :globalize_old_destroy, :destroy\n alias_method :globalize_old_create_or_update, :create_or_update\n alias_method :globalize_old_update, :update\n\n include Globalize::DbTranslate::TranslateObjectMethods\n extend Globalize::DbTranslate::TranslateClassMethods\n\n HERE\n\n facets.each do |facet|\n bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s\n class_eval <<-HERE\n @@facet_options[:#{facet}] ||= {}\n @@facet_options[:#{facet}][:bidi] = #{bidi}\n\n def #{facet}\n if not_original_language\n raise WrongLanguageError.new(@original_language, Locale.language)\n end\n load_other_translations if\n !fully_loaded? && !self.class.preload_facets.include?(:#{facet})\n result = read_attribute(:#{facet})\n return nil if result.nil?\n result.direction = #{facet}_is_base? ?\n (Locale.base_language ? Locale.base_language.direction : nil) :\n (@original_language ? @original_language.direction : nil)\n\n # insert bidi embedding characters, if necessary\n if @@facet_options[:#{facet}][:bidi] &&\n Locale.language && Locale.language.direction && result.direction\n if Locale.language.direction == 'ltr' && result.direction == 'rtl'\n bidi_str = \"\\xe2\\x80\\xab\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'\n bidi_str = \"\\xe2\\x80\\xaa\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n end\n end\n\n return result\n end\n\n def #{facet}=(arg)\n raise WrongLanguageError.new(@original_language, Locale.language) if\n not_original_language\n write_attribute(:#{facet}, arg)\n end\n\n def #{facet}_is_base?\n self['#{facet}_not_base'].nil?\n end\n HERE\n end\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def translate!(key, **options); end",
"def translate(details)\n self.translations = Hash[details.map { |k,v| [k.to_s, v.to_s] }].reverse_merge(self.translations)\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def pluralization_rules\n if defined?(@pluralization_regex) && @pluralization_regex\n return [@pluralization_regex, @pluralization_hash]\n end\n @pluralization_regex = Regexp.new(\"(\" + @plural_rules.map {|s,p| s}.join(\"|\") + \")$\", \"i\")\n @pluralization_hash = Hash[*@plural_rules.flatten]\n [@pluralization_regex, @pluralization_hash]\n end",
"def substitution_dict\n dict = {}\n\n # X__[]\n @states.each_with_index do |s, i|\n dict[s] = var :\"X__[#{i}]\"\n end\n\n # XL__[]\n size = @states_i_f.size\n @states_i_f[0...-size/2].each_with_index do |sl, i|\n dict[sl] = var :\"XL__[#{i}]\"\n end\n\n # XR__[]\n @states_i_f[(size/2)..-1].each_with_index do |sr, i|\n dict[sr] = var :\"XR__[#{i}]\"\n end\n\n # L__[]\n @lambdas.each_with_index do |l, i|\n dict[l] = var :\"L__[#{i}]\"\n end\n\n # LL__[]\n size = @lambdas_i_f.size\n @lambdas_i_f[0...-size/2].each_with_index do |ll, i|\n dict[ll] = var :\"LL__[#{i}]\"\n end\n\n # LR__[]\n @lambdas_i_f[(size/2)..-1].each_with_index do |lr, i|\n dict[lr] = var :\"LR__[#{i}]\"\n end\n \n # U__[]\n @controls.each_with_index do |c,i|\n dict[c] = var :\"U__[#{i}]\"\n end\n \n # OMEGA__[]\n @omegas.each_with_index do |o, i|\n dict[o] = var :\"OMEGA__[#{i}]\"\n end\n\n # P__[]\n @params.each_with_index do |p, i|\n dict[p] = var :\"P__[#{i}]\"\n end\n\n # V__[]\n @nu.each_with_index do |n, i|\n dict[n] = var :\"V__[#{i}]\"\n end\n\n # ModelPars[]\n @aux_params.each_with_index do |(p, _), i|\n dict[p] = var :\"ModelPars[#{i}]\"\n end\n\n return dict\n end",
"def translate\n translate_matches\n add_meta_charset\n set_encoding\n end",
"def translate text\n split_arr = text.split(\" \")\n split_arr_trans = split_arr.map { |word| \n (@@found_dict.key? word) ? @@found_dict[word] : (@@found_dict[word]=process_word(word); @@found_dict[word])\n }\n return split_arr_trans.join(\" \")\n end",
"def lang(orig); end",
"def translate(*args, **opts); end",
"def add_v1_translations dictionary\n\n ['eligibility', 'accommodation', 'purpose'].each do |trans_type|\n\n trans = dictionary.keys.select { |key| key.to_s.match(/^#{trans_type}_/) }\n trans.each do |tran|\n new_key = tran.sub(\"#{trans_type}_\", \"\")\n dictionary[new_key] = dictionary[tran]\n end\n end\n\n dictionary\n\n end",
"def test_multi_xlate\r\n assert @dict.empty?\r\n @dict.add_translation(\"book\", \"boek\")\r\n assert !@dict.empty?\r\n assert_equal \"book\", @dict.translate(\"boek\")\r\n assert_equal \"boek\", @dict.translate(\"book\")\r\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def translate\n @new_phrase = []\n words\n @phrase.each do |word|\n @new_phrase << changer(word)\n end\n end",
"def build_variant_replacements(variant_words)\n # first check if the number of words in a given set is not 7\n # (meaning doesn't include all source/target for each locale + source)\n invalid_variant_words = variant_words.select { |words| words.count != 7 }\n unless invalid_variant_words.empty?\n pp \"Found Invalid Variants: #{invalid_variant_words}\"\n raise Exception.new(\"Found Invalid Variants: #{invalid_variant_words.count}\")\n end\n locale_words = { 'en-GB' => [], 'en-CA' => [], 'en-AU' => [], }\n variant_words.each do |source, gb_source, gb_target, ca_source, ca_target, au_source, au_target|\n puts \"A single row below:\"\n puts \"#{source}, #{gb_source}, #{gb_target}, #{ca_source}, #{ca_target}, #{au_source}, #{au_target}\"\n locale_words['en-GB'] << { origin: source, source: gb_source, target: gb_target }\n # puts locale_words['en-GB']\n locale_words['en-CA'] << { origin: source, source: ca_source, target: ca_target }\n pp locale_words\n # puts locale_words['en-CA']\n locale_words['en-AU'] << { origin: source, source: au_source, target: au_target }\n # puts locale_words['en-AU']\n end\n locale_words\nend",
"def translate_all(keys)\n returning ActiveSupport::OrderedHash.new do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.t(key, :default => key_suffix, :locale => locale_name)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation != key_suffix ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.t(key, :default => key, :locale => locale_name)\n oh[key] = existing_translation != key ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def test_accents\r\n @dict.add_translation(\"book\", \"böek\")\r\n assert !@dict.empty?\r\n assert_equal \"book\", @dict.translate(\"böek\")\r\n end",
"def translated_legs(locale=I18n.default_locale)\n OTPTranslator.new(locale).translate_legs(legs)\n end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def use_i18n; end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.context.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.context || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.context\n valid_translations << {:label => translation.label, :context => translation.context.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def interpoltype()\n return :linear\n end",
"def interpolation_patterns; end",
"def find_all_valid_translations(translations)\n if translations.empty?\n return {:id => self.id, :key => self.key, :label => self.label, :original => true}\n end\n \n # if the first translation does not depend on any of the context rules\n # use it... we don't care about the rest of the rules.\n if translations.first.rules_hash.blank?\n return {:id => self.id, :key => self.key, :label => translations.first.label}\n end\n \n # build a context hash for every kind of context rules combinations\n # only the first one in the list should be used\n context_hash_matches = {}\n valid_translations = []\n translations.each do |translation|\n context_key = translation.rules_hash || \"\"\n next if context_hash_matches[context_key]\n context_hash_matches[context_key] = true\n if translation.rules_definitions\n valid_translations << {:label => translation.label, :context => translation.rules_definitions.dup}\n else\n valid_translations << {:label => translation.label}\n end\n end\n\n # always add the default one at the end, so if none of the rules matched, use the english one\n valid_translations << {:label => self.label} unless context_hash_matches[\"\"]\n {:id => self.id, :key => self.key, :labels => valid_translations}\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def translate_internal(facets, options)\n facets_string = \"[\" + facets.map {|facet| \":#{facet}\"}.join(\", \") + \"]\"\n class_eval %{\n @@facet_options = {}\n @@globalize_facets = #{facets_string}\n\n class << self\n\n def globalize_facets\n @@globalize_facets\n end\n\n\n #Returns the localized column name of the supplied attribute for the\n #current locale\n #\n #Useful when you have to build up sql by hand or for AR::Base::find conditions\n #\n # e.g. Product.find(:all , :conditions = [\"\\#{Product.localized_facet(:name)} = ?\", name])\n #\n # Note: <i>Used when Globalize::DbTranslate.keep_translations_in_model is true</i>\n def localized_facet(facet)\n unless Locale.base?\n \"\\#{facet}_\\#{Locale.language.code}\"\n else\n facet.to_s\n end\n end\n\n alias_method :globalize_old_method_missing, :method_missing unless\n respond_to? :globalize_old_method_missing\n end\n\n def globalize_facets_hash\n @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|\n hash[facet.to_s] = true; hash\n }\n end\n\n def non_localized_fields\n @@non_localized_fields ||=\n column_names.map {|cn| cn.intern } - globalize_facets\n end\n\n #Is field translated?\n #Returns true if translated\n #Warning! Depends on Locale.switch_locale\n def translated?(facet, locale_code = nil)\n localized_method = \"\\#{facet}_\\#{Locale.language.code}\"\n\n Locale.switch_locale(locale_code) do\n localized_method = \"\\#{facet}_\\#{Locale.language.code}\"\n end if locale_code\n\n value = send(localized_method.to_sym) if respond_to?(localized_method.to_sym)\n return !value.nil?\n end\n\n extend Globalize::DbTranslate::InternalStorageClassMethods\n }\n\n facets.each do |facet|\n bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s\n class_eval %{\n\n #Handle facet-specific options (.e.g a bidirectional setting)\n @@facet_options[:#{facet}] ||= {}\n @@facet_options[:#{facet}][:bidi] = #{bidi}\n\n #Accessor that proxies to the right accessor for the current locale\n def #{facet}\n value = nil\n unless Locale.base?\n localized_method = \"#{facet}_\\#{Locale.language.code}\"\n value = send(localized_method.to_sym) if respond_to?(localized_method.to_sym)\n value = value ? value : read_attribute(:#{facet}) if #{options[:base_as_default]}\n else\n value = read_attribute(:#{facet})\n end\n value.nil? ? nil : add_bidi(value, :#{facet})\n end\n\n #Accessor before typecasting that proxies to the right accessor for the current locale\n def #{facet}_before_type_cast\n unless Locale.base?\n localized_method = \"#{facet}_\\#{Locale.language.code}_before_type_cast\"\n value = send(localized_method.to_sym) if respond_to?(localized_method.to_sym)\n value = value ? value : read_attribute_before_type_cast('#{facet}') if #{options[:base_as_default]}\n return value\n else\n value = read_attribute_before_type_cast('#{facet}')\n end\n value.nil? ? nil : add_bidi(value, :#{facet})\n end\n\n #Write to appropriate localized attribute\n def #{facet}=(value)\n unless Locale.base?\n localized_method = \"#{facet}_\\#{Locale.language.code}\"\n write_attribute(localized_method.to_sym, value) if respond_to?(localized_method.to_sym)\n else\n write_attribute(:#{facet}, value)\n end\n end\n\n #Is field translated?\n #Returns true if untranslated\n def #{facet}_is_base?\n localized_method = \"#{facet}_\\#{Locale.language.code}\"\n value = send(localized_method.to_sym) if respond_to?(localized_method.to_sym)\n return value.nil?\n end\n\n #Read base language attribute directly\n def _#{facet}\n value = read_attribute(:#{facet})\n value.nil? ? nil : add_bidi(value, :#{facet})\n end\n\n #Read base language attribute directly without typecasting\n def _#{facet}_before_type_cast\n read_attribute_before_type_cast('#{facet}')\n end\n\n #Write base language attribute directly\n def _#{facet}=(value)\n write_attribute(:#{facet}, value)\n end\n\n def add_bidi(value, facet)\n return value unless Locale.active?\n value.direction = self.send(\"\\#{facet}_is_base?\") ?\n (Locale.base_language ? Locale.base_language.direction : nil) :\n (Locale.active ? Locale.language.direction : nil)\n\n # insert bidi embedding characters, if necessary\n if @@facet_options[facet][:bidi] &&\n Locale.language && Locale.language.direction && value.direction\n if Locale.language.direction == 'ltr' && value.direction == 'rtl'\n bidi_str = \"\\xe2\\x80\\xab\" + value + \"\\xe2\\x80\\xac\"\n bidi_str.direction = value.direction\n return bidi_str\n elsif Locale.language.direction == 'rtl' && value.direction == 'ltr'\n bidi_str = \"\\xe2\\x80\\xaa\" + value + \"\\xe2\\x80\\xac\"\n bidi_str.direction = value.direction\n return bidi_str\n end\n end\n return value\n end\n\n protected :add_bidi\n }\n end\n end",
"def keystroke_translations\n @keystroke_translations ||= begin\n hash = { \"\\n\" => \"return\",\n \"\\\\\" => \"\\\\\\\\\",\n \"\\\"\" => \"\\\\\\\"\" }\n hash.default_proc = proc { |hash,key| hash[key] = \"\\\"#{key}\\\"\" }\n hash\n end\n end",
"def texts_translated\n @texts_translated ||= tokens_translated.map do |group|\n group.map { |value, type| type == :text ? value : fix_ascii(value) }.join\n end\n end",
"def find_replacement_translations(locale, variant_words, translations)\n pp \"Processing #{locale} strings\"\n unchanged = []\n to_be_replaced = []\n variant_words.each do |dict|\n current = dict[:source]\n origin = dict[:origin]\n replacement = dict[:target]\n # keeping a tally of how many will not change due to both current\n # and replacement being the same\n if current == replacement\n unchanged << { current: current, replacement: replacement }\n next\n end\n if current == '--'\n t = translations.where('copy LIKE ?', \"%#{origin}%\")\n puts \"#{t.count} strings found in #{locale} for #{origin}\"\n else\n t = translations.where('copy LIKE ?', \"%#{current}%\")\n puts \"#{t.count} strings found in #{locale} for #{current}\"\n end\n # t = translations.where(source_copy: source)\n # count = t.count\n # t = t.concat(fuzzy_match)\n unless (t.nil? or t.empty?) && current[0] != replacement[0]\n # pp \"#{current[0]} matched #{replacement[0]}\"\n t.each do |row|\n # exact match with word boundaries around the word\n # this will prevent words being part of ids/classes\n # and it will also prevent words like \"Unenroll\"\n # it's looking for \"enroll\"\n unless row.copy.match(/#{current}\\b/)\n next\n end\n if current[0] == replacement[0]\n pp \"#{current} will be replaced with #{replacement}\"\n end\n rep = {\n locale: locale,\n source: row.source_copy,\n current: row.copy,\n replacement: row.copy && row.copy.gsub(current, replacement),\n id: row.id,\n word: replacement,\n }\n if rep[:current] != rep[:replacement]\n puts \"Current and replacmeent match: #{rep[:current]} == #{rep[:replacement]}\"\n begin\n if rep[:replacement].strip_html_tags == rep[:replacement]\n to_be_replaced << rep\n else\n pp \"Stripped #{rep[:replacement]} and didn't add to list\"\n end\n end\n end\n end\n end\n end\n puts \"Ignoring: #{unchanged.size} strings\"\n puts \"Changing: #{to_be_replaced.size} strings\"\n to_be_replaced\nend",
"def prefix_solve\n return @prefix_soln unless @prefix_soln.nil?\n\n @prefix_soln = {}\n soln.each_key { |key| @prefix_soln[ToHTML::add_prefix(key)] = soln[key] }\n @prefix_soln\n end",
"def italy\n # super doesn't call #new_start on MRI, so each method has to be\n # individually overridden.\n if_period(super) {|p,dt| dt.localize(p) }\n end",
"def search_conditions_as_hash(locale)\n [\n { :value => I18n.t(\"advanced_searches.text_search_field.all_words\", locale: locale), :key => \"all_words\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.one_word\", locale: locale), :key => \"one_word\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.exact\", locale: locale), :key => \"exact\"}\n ]\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def process_trans(data, trans_table)\n\t\tnewentry = data.downcase.gsub(/[^a-z0-9\\s'\\.,;-]/i, '')\n\t\twords = newentry.split(\" \")\n\n\t\tprev = \"\"\n\t\twords.each do |word|\n\t\t\tif prev == \"\" then \n\t\t\t\tnext\n\t\t\tend\n\t\t\t# store trans probs\n\t\t\tif !trans_table.has_key?(prev) then\n\t\t\t\ttrans_table[prev] = Hash.new\n\t\t\tend\n\t\t\tif !trans_table[prev].has_key?(word) then\n\t\t\t\ttrans_table[prev][word] = 1\n\t\t\telse\n\t\t\t\ttrans_table[prev][word] += 1\n\t\t\tend\n\t\t\tprev = word\n\t\tend\n\tend",
"def label_translation; end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def tokens_translated\n @tokens_translated ||= tokens.dup.tap do |tokens|\n text_tokens_translated.each do |index, value|\n group_index, index = index.split(\"_\")\n tokens[group_index.to_i][index.to_i][0] =\n restore_spacing(tokens[group_index.to_i][index.to_i][0], value)\n end\n end\n end",
"def add_translation(from, to)\n @dictionary[to] = from\n @dictionary[from] = to\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def interpolated_markup\n visualization.markup.tap do |markup|\n interpolation_values.each do |k,v|\n markup.gsub!(\"__#{k.upcase}__\", v.to_s)\n end\n end\n end",
"def translations\n @translations ||= {}\n end",
"def apply_config_interpolations(item, units:, **)\n if item.is_a?(Hash)\n item.transform_values { |v| send(__method__, v, units: units) }\n elsif item.is_a?(Array)\n item.map { |v| send(__method__, v, units: units) }\n elsif item.is_a?(String) && item.include?('%{')\n item.gsub(SPRINTF_NAMED_REFERENCE) { |s| units[$1&.to_sym] || s }\n else\n item\n end\n end",
"def customize_en_us_dictionary(dict)\n dict.add('admin')\n dict.add('admin_authenticator')\n dict.add('apps')\n dict.add('Authy')\n dict.add('cancelled')\n dict.add('captcha')\n dict.add('code_verifier')\n dict.add('COVID-19')\n dict.add('HTTPS')\n dict.add('ltr')\n dict.add('OAuth')\n dict.add('OAuth2')\n dict.add('org')\n dict.add('pkce')\n dict.add('pre-authorization')\n dict.add('resource_owner_authenticator')\n dict.add('resource_owner_from_credentials')\n dict.add('S256')\n dict.add('saraalert')\n dict.add('SMS')\n dict.add('SSL')\n dict.add('UID')\n dict.add('unconfigured')\n dict.add('uri')\n dict.add('urls')\n dict.add('webpage')\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def localize(object, **options); end",
"def localize(object, **options); end",
"def test_bidirectional_xlate\n assert @dict.empty?\n @dict.add_translation(\"book\", \"boek\")\n assert !@dict.empty?\n assert_equal \"book\", @dict.translate(\"boek\")\n assert_equal \"boek\", @dict.translate(\"book\")\n end",
"def translate_pattern(key, language = :en)\n case key\n when :search\n language.eql?(:sv) ? 'Du sökte efter %%searchphrase%% %%page%% %%sep%% %%sitename%%' : 'You searched for %%searchphrase%% %%page%% %%sep%% %%sitename%%'\n when :not_found\n language.eql?(:sv) ? 'Sidan kunde inte hittas %%sep%% %%sitename%%' : 'Page Not Found %%sep%% %%sitename%%'\n when :author\n language.eql?(:sv) ? '%%name%%, Författare %%sitename%% %%page%%' : '%%name%%, Author at %%sitename%% %%page%%'\n when :term\n language.eql?(:sv) ? '%%term_title%% Arkiv %%page%% %%sep%% %%sitename%%' : '%%term_title%% Archives %%page%% %%sep%% %%sitename%%'\n end\n end",
"def add_translation(first, second)\r\n @dictionary[second] = first\r\n @dictionary[first] = second\r\n end",
"def inline_translations_for(language)\n translations_for(language, -50).sort_by{|t| t.precedence}\n end",
"def each_locale_and_translated_attribute\r\n used_locales.each do |locale|\r\n translated_attribute_names.each do |name|\r\n yield locale, name\r\n end\r\n end\r\n end",
"def translation_hash\n Hash[ opts.select{ |k, v| v.is_a? String }.sort_by{ |k, v| [ translation_order( k ), k ] } ]\n end",
"def reformat_languages(languages)\r\n new_languages_hash = {}\r\n \r\n languages.each do |style_key, language_val|\r\n language_val.each do |language_key, type_val|\r\n type_val.each do |type_key, string_val|\r\n \t#new_languages_hash[language_key] ||= {}\r\n \tif new_languages_hash[language_key].nil?\r\n \t\tnew_languages_hash[language_key] = {}\r\n \tend\r\n \tnew_languages_hash[language_key][:style] ||= []\r\n \tnew_languages_hash[language_key][:style] << style_key\r\n \tif new_languages_hash[language_key][type_key].nil?\r\n \t\tnew_languages_hash[language_key][type_key] = string_val\r\n \tend \r\n end\r\n end\r\n end\r\n new_languages_hash\r\nend",
"def i18n_options\n default_i18n_options.merge(event_interpolations).transform_values do |value|\n if value.is_a?(String)\n decidim_html_escape(value)\n else\n value\n end\n end\n end",
"def initialize\n @max_repetitions = 100\n @transitions = {\n :start => {\n :symbol => proc {|g,t| g.rule=t; g.start_symbol=t.data; :equals },\n :newline => proc { :start },\n :comment => proc { :start },\n :space => proc { :start }\n },\n :equals => {\n :equals => proc { :elements },\n :eq_slash => proc {|g,t| g.retype=:incremental; :elements },\n :comment => proc { :equals }, \n :space => proc { :equals } \n },\n :elements => {\n :symbol => proc {|g,t| g.tok=t; :elements },\n :literal => proc {|g,t| g.tok=t; :elements },\n :_digit => proc {|g,t| g.ranges(t,['0'..'9']); :elements },\n :_hexdig => proc {|g,t| g.ranges(t,['0'..'9','A'..'F']); :elements },\n :_bit => proc {|g,t| g.ranges(t,['0'..'1']); :elements },\n :_alpha => proc {|g,t| g.ranges(t,['A'..'Z','a'..'z']); :elements },\n :_char => proc {|g,t| g.ranges(t,[0x01..0x7F]); :elements },\n :_vchar => proc {|g,t| g.ranges(t,[0x21..0x7E]); :elements }, \n :_octet => proc {|g,t| g.ranges(t,[0x00..0xFF]); :elements },\n :_ctl => proc {|g,t| g.ranges(t,[0x00..0x1F,0x7F..0x7F]); :elements },\n :_wsp => proc {|g,t| g.ranges(t,[' '..' ',\"\\t\"..\"\\t\"]); :elements }, \n :_cr => proc {|g,t| g.entity=\"\\r\"; :elements },\n :_lf => proc {|g,t| g.entity=\"\\n\"; :elements },\n :_crlf => proc {|g,t| g.entity=\"\\r\\n\"; :elements },\n :_sp => proc {|g,t| g.entity=\" \"; :elements },\n :_dquote => proc {|g,t| g.entity=%Q(\"); :elements },\n :_htab => proc {|g,t| g.entity=\"\\t\"; :elements },\n :entity_dec => proc {|g,t| g.entity=t.data.to_i.chr; :dot },\n :entity_hex => proc {|g,t| g.entity=t.data.hex.chr; :dot },\n :entity_bin => proc {|g,t| g.entity=bin2chr(t.data); :dot },\n :range_hex => proc {|g,t| g.rng(t) {|v| v.hex.chr}; :elements },\n :range_dec => proc {|g,t| g.rng(t) {|v| v.to_i.chr}; :elements },\n :range_bin => proc {|g,t| g.rng(t) {|v| bin2chr v}; :elements },\n :slash => proc {|g,t| g.alt; :elements },\n :newline => proc {|g,t| :next_rule },\n :seq_begin => proc {|g,t| g.group=t; :elements },\n :seq_end => proc {|g,t| g.store=t; :elements }, \n :opt_begin => proc {|g,t| g.opt=t; :elements },\n :opt_end => proc {|g,t| g.store=t; :elements }, \n :comment => proc { :elements }, \n :space => proc { :elements },\n :number => proc {|g,t| g.repeat=t.data; :rpt_1 },\n :asterisk => proc { |g,t| g.repeat=0; :rpt_2 },\n :eof => proc { |g,t| g.retype=:eof; g.store=t; :stop } \n },\n :dot => {\n :dot => proc { :elements },\n :entity_dec => proc {|g,t| g.entity=t.data.to_i.chr; :dot },\n :entity_hex => proc {|g,t| g.entity=t.data.hex.chr; :dot }, \n :entity_bin => proc {|g,t| g.entity=bin2chr(t.data); :dot },\n :space => proc { :elements },\n :eof => proc { |g,t| g.retype=:eof; g.store=t; :stop },\n :comment => proc { :elements }, \n },\n :rpt_1 => {\n :number => proc {|g,t| g.repeat=t.data; :rpt_1 },\n :asterisk => proc { :rpt_2 },\n :symbol => proc {|g,t| g.tok=t; :elements },\n :literal => proc {|g,t| g.tok=t; :elements },\n :_digit => proc {|g,t| g.ranges(t,['0'..'9']); :elements },\n :_hexdig => proc {|g,t| g.ranges(t,['0'..'9','A'..'F']); :elements },\n :_bit => proc {|g,t| g.ranges(t,['0'..'1']); :elements },\n :_alpha => proc {|g,t| g.ranges(t,['A'..'Z','a'..'z']); :elements },\n :_char => proc {|g,t| g.ranges(t,[0x01..0x7F]); :elements },\n :_vchar => proc {|g,t| g.ranges(t,[0x21..0x7E]); :elements },\n :_octet => proc {|g,t| g.ranges(t,[0x00..0xFF]); :elements },\n :_ctl => proc {|g,t| g.ranges(t,[0x00..0x1F,0x7F..0x7F]); :elements },\n :_wsp => proc {|g,t| g.ranges(t,[' '..' ','\\t'..'\\t']); :elements },\n :_cr => proc {|g,t| g.entity=\"\\r\"; :elements },\n :_lf => proc {|g,t| g.entity=\"\\n\"; :elements },\n :_crlf => proc {|g,t| g.entity=\"\\r\\n\"; :elements },\n :_sp => proc {|g,t| g.entity=\" \"; :elements },\n :_htab => proc {|g,t| g.entity=\"\\t\"; :elements },\n :_dquote => proc {|g,t| g.entity=%Q(\"); :elements }, \n :seq_begin => proc {|g,t| g.group=t; :elements },\n :space => proc { :rpt_1 },\n :entity_dec => proc {|g,t| g.entity=t.data.to_i.chr; :dot },\n :entity_hex => proc {|g,t| g.entity=t.data.hex.chr; :dot },\n :entity_bin => proc {|g,t| g.entity=bin2chr(t.data); :dot },\n :range_hex => proc {|g,t| g.rng(t) {|v| v.hex.chr}; :elements; },\n :range_dec => proc {|g,t| g.rng(t) {|v| v.to_i.chr}; :elements },\n :range_bin => proc {|g,t| g.rng(t) {|v| bin2chr v}; :elements }\n },\n :rpt_2 => {\n :number => proc {|g,t| g.repeat=t.data; :elements },\n :space => proc { :rpt_2 },\n },\n :next_rule => {\n :symbol => proc {|g,t| g.store=t; g.rule=t; :equals },\n :comment => proc { :next_rule }, \n :space => proc { :elements },\n :newline => proc { :next_rule },\n :eof => proc { |g,t| g.retype=:eof; g.store=t; :stop }\n },\n }\n\n end",
"def translatable\n self._translatable[base_name]\n end"
] |
[
"0.5835699",
"0.5835699",
"0.5835699",
"0.575385",
"0.57177186",
"0.57145286",
"0.56272817",
"0.56239116",
"0.557654",
"0.5574478",
"0.5574478",
"0.5574478",
"0.5573385",
"0.5447518",
"0.539471",
"0.5385845",
"0.5378572",
"0.53784126",
"0.5372482",
"0.5355296",
"0.5355296",
"0.5355296",
"0.5343258",
"0.5300746",
"0.5297419",
"0.5295239",
"0.5287418",
"0.5278895",
"0.5225396",
"0.5217131",
"0.5217131",
"0.5212818",
"0.5209018",
"0.5199911",
"0.51963973",
"0.5183613",
"0.5166995",
"0.51509434",
"0.514282",
"0.5131553",
"0.51305974",
"0.5123569",
"0.5112226",
"0.5073274",
"0.5066021",
"0.50636655",
"0.50632757",
"0.50632757",
"0.50632757",
"0.50632757",
"0.50558",
"0.5042477",
"0.5037164",
"0.5022173",
"0.5001908",
"0.49987787",
"0.4983727",
"0.49773467",
"0.4960565",
"0.4954382",
"0.49456725",
"0.49381977",
"0.49365717",
"0.49347258",
"0.49282098",
"0.49241766",
"0.49176544",
"0.49145943",
"0.4911356",
"0.49068442",
"0.48918882",
"0.48912984",
"0.48912984",
"0.48912984",
"0.48772928",
"0.48658544",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48483586",
"0.48459592",
"0.48454893",
"0.48323932",
"0.48221493",
"0.48195192",
"0.48141482",
"0.48141482",
"0.48139843",
"0.4811763",
"0.48089892",
"0.48077947",
"0.48005018",
"0.47964728",
"0.47900027",
"0.47866848",
"0.47822642",
"0.47821665"
] |
0.0
|
-1
|
Gets I18n configuration object. source://i18n//lib/i18n.rb56
|
def config; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_locale\n I18n.locale = session[:i18n] || I18n.default_locale || :en\n end",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def use_i18n; end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def initialize\n self.namespace = \"i18n_languages\"\n self.custom = false\n self.available_locales_only = true\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def config\n @config ||= YAML.load_file @options[:config_file]\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def configuration\n Configuration::get\n end",
"def configuration\n Configuration::get\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def translated_locales\n self.i18n.keys\n end",
"def config\n @config ||= load_config\n end",
"def config\n App.instance.load_project_config\n App.instance.config\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def config\n PrcLib.runtime_fail 'No config object loaded.' unless @config\n @config\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def configuration\n Ablerc::Configuration.instance\n end",
"def config\n @config ||= YAML.load_file(@config_file_path)\n end",
"def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def config\n @config ||= YAML.load File.read(@config_file)\n end",
"def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end",
"def js_i18n\n @js_i18n ||= self.class.netzke_ancestors.inject({}) do |r, klass|\n hsh = klass.client_class_config.translated_properties.inject({}) { |h, t| h.merge(t => I18n.t(\"#{klass.i18n_id}.#{t}\")) }\n r.merge(hsh)\n end\n end",
"def config\n @config ||= YAML::load_file(File.join(@cwd, \"config\", \"settings.yml\"))\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n elsif !self.org.nil?\n return self.org.get_locale\n else\n return nil\n end\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @config ||= read_config\n end",
"def i18n(locale)\n selected_locale = self.i18ns.select{|i18n| i18n.locale_id == locale.id }\n return selected_locale.first if selected_locale.any?\n\n self.i18ns.first\n end",
"def config\n\t\t\t@config ||= begin\n\t\t\t\tfile = File.join(self.location, \"config.yaml\")\n\t\t\t\tif File.exists?(file)\n\t\t\t\t\tYAML::load_file(file)\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def default_i18n_with_milkshake\n default_i18n = default_i18n_without_milkshake\n default_i18n.load_path.concat(Milkshake.environment.locale_paths)\n default_i18n.load_path.uniq!\n default_i18n\n end",
"def translations\n @translations ||= {}\n end",
"def get_locales\n fall_back = [:ru].to_yaml\n locales = CustomSetting.find_or_create_by_name(\"languages\").value || fall_back\n begin\n locales = YAML::load(locales)\n rescue\n locales = YAML::load(fall_back)\n end\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def current_language\n @@current_language\n end",
"def configuration\n @configuration ||= case configuration_path.split(\"/\").last\n when \"database.yml\" then database_yml_config\n when \"mongoid.yml\" then mongoid_yml_config\n end\n end",
"def read_configuration\n\t\t@config = YAML.load_file(\"config.yml\")\n\t\treturn @config\n\tend",
"def config_get(id)\n Configuration.get(id)\n end",
"def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end",
"def config\n if Config.config.nil? or Config.config.empty?\n begin\n Config.config = Configuration.load_config(Config.config_file,\n Config.config_options)\n rescue Errno::ENOENT\n Config.config = {}\n end\n end\n\n return Config.config\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end",
"def available_languages\n AppConfig.available_languages\n end",
"def config\n @config ||= Config.new\n end",
"def config\n @config ||= Config.new\n end",
"def configuration\n notifier.configuration\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\n @config ||= Configuration.new\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def yml_config\n return @yml_config if @yml_config\n\n require 'yaml'\n data = File.open(options[:config_path]).read\n\n require 'erb'\n data = ERB.new(data).result(binding)\n\n @yml_config ||= YAML.load(data)\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def config(lang=nil)\n if lang\n lang_config_hash[lang] || read_config\n else\n read_config\n end\n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def use_i18n=(value); end",
"def config\n @options[:config]\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def message_language\n return @message_language\n end",
"def load_config\n @log.debug \"loading validator-specific configuration\"\n config = Autosign::Config.new\n\n if config.settings.to_hash[self.name].nil?\n @log.warn \"Unable to load validator-specific configuration\"\n @log.warn \"Cannot load configuration section named '#{self.name}'\"\n return {}\n else\n @log.debug \"Set validator-specific settings from config file: \" + config.settings.to_hash[self.name].to_s\n return config.settings.to_hash[self.name]\n end\n end",
"def language_obj\n @language_obj ||= begin\n lookup = self.language_code || self.language_str\n LanguageList::LanguageInfo.find( lookup.dup ) if lookup\n end\n end",
"def context\n config.file? ? YAML.load_file(config) : {}\n end",
"def context\n config.file? ? YAML.load_file(config) : {}\n end",
"def _config\n Lita.config.handlers.lbcfg\n end",
"def get_locale(locale = nil)\n locale || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def configuration\n @configuration ||= begin\n config = {}\n\n if protoc_options[:configuration]\n require \"yaml\"\n\n config = YAML.load_file protoc_options[:configuration]\n config.merge! config\n end\n\n config\n end\n end",
"def config\n configuration\n end",
"def get_locale_from_session\n if (session && session[:language])\n logger.debug \"*** Language from Session '#{session[:language]}'\"\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def get_locale_from_session\n if (session && session[:language])\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def base_config\n if engine_config.config\n ::HamlLint::ConfigurationLoader.load_file(engine_config.config)\n else\n ::HamlLint::ConfigurationLoader.load_applicable_config\n end\n end",
"def config\n @config ||= @module_config || {}\n end",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def config\n @config ||= @module_config || {}\n end",
"def lang_id\n static_module.lang_id\n end",
"def config\n config_yml['PAYMENT']\n end",
"def configuration\n @configuration ||= Configuration.new()\n end",
"def config\n ensure_config_exists\n @config ||= (YAML.load_file(config_file) || {})\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def language_name(lang)\n TranslationCenter::CONFIG['lang'][lang.to_s]['name']\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end"
] |
[
"0.63729435",
"0.62221944",
"0.6167822",
"0.59829676",
"0.5938354",
"0.5818081",
"0.5735795",
"0.5706033",
"0.5695791",
"0.5681474",
"0.5661287",
"0.5645338",
"0.56435734",
"0.56435734",
"0.56031936",
"0.5598879",
"0.5597194",
"0.5586421",
"0.55640906",
"0.55640906",
"0.5553383",
"0.55285615",
"0.55208904",
"0.5511716",
"0.55057365",
"0.55036706",
"0.548952",
"0.54764867",
"0.5456283",
"0.5433973",
"0.54172355",
"0.54098755",
"0.54089373",
"0.54089373",
"0.5398668",
"0.5388851",
"0.5376484",
"0.5376337",
"0.5370223",
"0.53624654",
"0.5353986",
"0.53525907",
"0.53495246",
"0.53443617",
"0.534103",
"0.53284234",
"0.5325797",
"0.53190076",
"0.5314331",
"0.53135467",
"0.5297963",
"0.5297963",
"0.5278321",
"0.527639",
"0.527639",
"0.527639",
"0.527639",
"0.527639",
"0.527639",
"0.5275514",
"0.5272031",
"0.5271255",
"0.5266909",
"0.52642554",
"0.52615327",
"0.5259444",
"0.52560544",
"0.5242288",
"0.52369094",
"0.5231477",
"0.52216554",
"0.5212333",
"0.5212333",
"0.52075464",
"0.51978886",
"0.51949036",
"0.51949036",
"0.51898247",
"0.51881987",
"0.5176094",
"0.51712406",
"0.5167937",
"0.5167749",
"0.516186",
"0.51579124",
"0.5146153",
"0.5144154",
"0.51368934",
"0.51364684",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51341045",
"0.51324433",
"0.5126508"
] |
0.0
|
-1
|
Sets I18n configuration object. source://i18n//lib/i18n.rb61
|
def config=(value); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def use_i18n=(value); end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def initialize\n self.namespace = \"i18n_languages\"\n self.custom = false\n self.available_locales_only = true\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def use_i18n; end",
"def setup\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def set_application(app)\n self.application = app\n translations.values.each do |locale_translations|\n locale_translations.each do |translation|\n translation.translation_key = self\n translation.language = self.application.language(translation.locale)\n end\n end\n self\n end",
"def configure(&block)\n block.call @locale\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def set_language\n @lecture.update(locale: I18n.default_locale.to_s)\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n I18n.locale = extract_locale || session[:locale] || I18n.default_locale\n session[:locale] = I18n.locale\n end",
"def set_user_language\n I18n.locale = 'es-VE'\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def initialize(object_name, object, template, options, proc)\n super\n # set_language_if_valid options.delete(:lang)\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def update_config(config)\n\n config['languages'] ||= []\n config['language_default'] ||= config['languages'].first;\n\n # set the default value of `i18ndir` to `_i18n`\n config['i18ndir'] ||= \"_i18n\";\n\n %w[languages language_default].each do |opt|\n self.send(\"#{opt}=\", config[opt])\n end\n end",
"def set_locale\n if params[:controller] == \"rails_admin/main\"\n I18n.locale = :en\n else\n I18n.locale = :ru\n end\n end",
"def set_locale\n I18n.locale = :pl\n end",
"def set_locale\n I18n.locale = current_user.try(:locale) || I18n.default_locale\n end",
"def default_locale=(locale); end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n if params[:locale]\n I18n.locale = session[:locale] = params[:locale] || I18n.default_locale\n else\n I18n.locale = session[:locale] || I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = if user_signed_in?\n current_user.language.to_sym\n else\n I18n.default_locale\n end\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def setup_default_locale\n locale = config.dig(\"locale\").split(\"- \").last\n\n application nil do\n <<~CONFS\n # Default i18n locale\n config.i18n.default_locale = :#{locale}\n\n CONFS\n end\n\n template \"templates/default_locale.tt\", \"config/locales/#{locale}.yml\" if locale != \"en\"\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def set_locale\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tLOG.debug(fname) {\">>>>\"}\n\t\t#puts \"set_locale:params[:locale]=#{params[:locale]}\"\n\t\tif params[:locale]\n\t\t\tI18n.locale = params[:locale]\n\t\t\tsession[:lng] = I18n.locale\n\t\telse\n\t\t\tunless @current_user.nil?\n\t\t\t\t#puts \"set_locale:@current_user=#{@current_user} lng=#{@current_user.language}\"\n\t\t\t\tI18n.locale = @current_user.language\n\t\t\telse\n\t\t\t\tif session[:lng]\n\t\t\t\t\tI18n.locale = session[:lng]\n\t\t\t\telse\n\t\t\t\t\tI18n.locale = PlmServices.get_property(:LOCAL_DEFAULT)\n\t\t\t\t\tsession[:lng] = I18n.locale\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tLOG.debug(fname) {\"<<<<session=#{session}\"}\n\tend",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n if request.subdomain == 'en'\n I18n.locale = request.subdomain\n else\n I18n.locale = params[:locale] || I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = access_control.user.locale\n end",
"def set_locale\n if cookies[:locale].nil?\n if signed_in?\n I18n.locale = cookies[:locale] = current_user.language\n end\n #if not signed in, the locale will be the default (en)\n else\n I18n.locale = cookies[:locale]\n end\n end",
"def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end",
"def initialize\r\n\r\n I18n.exception_handler = I18n::LinguaFrancaMissingTranslation.new\r\n unless File.exist?(I18n.config.info_file)\r\n dir = File.dirname(I18n.config.info_file)\r\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\r\n File.open(I18n.config.info_file, 'w+')\r\n end\r\n\r\n # throw an exception if we're missing the pluralizations rules file\r\n throw Exception(\"Lingua Franca: Missing Pluralization File #{I18n.config.languages_file}\") unless File.exist?(I18n.config.languages_file)\r\n \r\n super\r\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end",
"def set_default_language\n I18n.locale = :ja\n end",
"def set_locale\n I18n.locale = cookies[:locale] || params[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n if user_signed_in?\n I18n.locale = current_user.language.to_sym\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def init_translations; end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = 'en'\n\n # if params[:locale].present? || session[:locale].present?\n # session[:locale] = params[:locale] if params[:locale].present?\n # I18n.locale = session[:locale]\n # else\n # logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n # I18n.locale = extract_locale_from_accept_language_header\n # logger.debug \"* Locale set to '#{I18n.locale}'\"\n # end\n end",
"def set_locale\n if params[:locale].nil?\n if session[:locale].nil?\n I18n.locale = :ar\n else\n I18n.locale = session[:locale]\n end\n else\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n end\n end",
"def set_locale\n # session[:locale] = params[:locale] if params[:locale]\n # session[:locale] = \"zh\" if session[:locale].blank?\n # session[:locale] = \"zh\"\n # I18n.locale = session[:locale] || I18n.default_locale\n I18n.locale = 'zh'\n end"
] |
[
"0.6981374",
"0.65649277",
"0.65131193",
"0.6511873",
"0.6372405",
"0.6367812",
"0.6367812",
"0.6366951",
"0.6360399",
"0.63399667",
"0.63041973",
"0.6289104",
"0.6288381",
"0.62868583",
"0.6217682",
"0.61952424",
"0.61271507",
"0.607679",
"0.60690695",
"0.60079885",
"0.59980094",
"0.59925926",
"0.5970564",
"0.59672564",
"0.59582955",
"0.59567684",
"0.59423804",
"0.59316134",
"0.59230494",
"0.5916913",
"0.5909531",
"0.5906625",
"0.5906625",
"0.5886753",
"0.5886753",
"0.5886753",
"0.5886753",
"0.5883595",
"0.5877221",
"0.5854032",
"0.5844747",
"0.58307767",
"0.5825866",
"0.58191574",
"0.57959867",
"0.57929164",
"0.57534724",
"0.5751229",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.57456774",
"0.5741642",
"0.5740594",
"0.5740594",
"0.5738188",
"0.5724271",
"0.5724271",
"0.5691685",
"0.5657245",
"0.5653586",
"0.56528974",
"0.5652677",
"0.56504184",
"0.5624114",
"0.56109643",
"0.55873364",
"0.55741197",
"0.5568224",
"0.55608964",
"0.55510384",
"0.555088",
"0.55503017",
"0.55422205",
"0.5540394",
"0.5536738",
"0.5525737",
"0.5516114",
"0.54931074",
"0.548702",
"0.5472184",
"0.5469531",
"0.5463969",
"0.5463882",
"0.5458335",
"0.5456201",
"0.545614",
"0.54463685",
"0.54220486",
"0.54113925",
"0.5408733"
] |
0.0
|
-1
|
Tells the backend to load translations now. Used in situations like the Rails production environment. Backends can implement whatever strategy is useful. source://i18n//lib/i18n.rb90
|
def eager_load!; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def use_i18n; end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def init_translations; end",
"def translations; end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def use_i18n=(value); end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def reset_i18n()\n I18n.backend = I18n::Backend::Simple.new\nend",
"def generate\n I18n.backend.load_translations\n translations = wrap(source_translations)\n I18n.backend.store_translations(destination_locale, translations)\n I18n.available_locales += [destination_locale]\n end",
"def translations\n @translations ||= {}\n end",
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def translatable\n self._translatable[base_name]\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def on_load_language; load_language('lang/login'); end",
"def show\n if Delayed::Job.any?\n @lang_update_status = :running\n else\n @lang_update_status ||= :default\n end\n @path_langu = request.path.starts_with? '/langu'\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def set_gettext_locale_db\n params[:locale] ||= User.current.try(:locale)\n end",
"def language_server; end",
"def load_language(lang)\n puts \"Loading current translations for language #{lang}\"\n system(\n 'curl -X GET ' \\\n \"'https://translation.io/api/v1/segments.json?target_language=#{lang}' \" \\\n \"-H 'x-api-key: #{$API_KEY}' > ,full-list\"\n )\n current_translations_file_contents = File.read(',full-list')\n current_translations_json = JSON.parse(current_translations_file_contents)\n\n if current_translations_json.key?('errors')\n puts 'Error:'\n puts current_translations_json['errors']\n exit 1\n end\n\n # Initialize hash in CURRENT_TRANSLATIONS for this new language\n $CURRENT_TRANSLATIONS[lang] = {}\n\n # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment\n # information that translations.io provides:\n # id, key, target_language, target, etc.\n current_translations_json['segments'].each do |segment|\n # Work around bug in Rubocop\n if segment['target_language'] != lang\n STDERR.puts \"Error: Expected language #{lang} in segment #{segment}\"\n exit 1\n end\n $CURRENT_TRANSLATIONS[lang][segment['key']] = segment\n end\nend",
"def locale_backend; end",
"def create_translations\n end",
"def translate(settings); end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def version_language_ready_to_publish translation_language\n # 2\n\n translations = Translation.version_language_ready_to_publish(calmapp_version, translation_language)\n end",
"def initialize\n self.namespace = \"i18n_languages\"\n self.custom = false\n self.available_locales_only = true\n end",
"def init_translations_and_ignore_app_mode_file_dump\n # Get the current yaml file list sorted\n files = (I18n.load_path + Dir.glob(File.join(\"config\", \"locales\", \"**\",\"*.{rb,yml}\"))).uniq.sort\n # Avoid application mode file paths\n files -= I18n.available_locales.map{|l| application_mode_file_path(l)}\n files -= I18n.available_locales.map{|l| File.join(\"config\", \"locales\", \"#{l}.yml\")}\n # Load the new translation file list\n I18n.load_path = files\n # Reset I18n to track the updated file list\n I18n.reload!\n I18n.backend.send(:init_translations)\n end",
"def translations\n collection = Collection.new\n\n # add all translations from the database to the collection\n collection.add(find_database_translations(@texts)) if @use_db\n\n # request translations for all texts that aren't in the database\n untranslated = untranslated(collection)\n if untranslated.present?\n provider_translations = find_provider_translations(untranslated)\n save_database_translations(provider_translations)\n collection.add(provider_translations)\n end\n\n # puts collection.description\n collection\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def get_po\r\n\r\n send_file(\"#{Rails.root}/po/#{params[:locale]}/#{APP_SID}.po\",\r\n :filename => \"#{APP_SID}.po\",\r\n :type => \"text/x-gettext-translation\")\r\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def show_translation\n @translations = load_translations( @locale, @base_locale )\n render :partial => \"i18n_ui/translation_body\", :locals => { :key => params[:key], :tr => @translations[params[:key]]}, :layout => nil\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def apply_locale; end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def translate( string_to_translate )\n @@dc_strings ||= LanguageHandler.new( 'dynamiccomponents.strings' )\n @@dc_strings.GetString( string_to_translate )\n end",
"def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def available_locales_initialized?; end",
"def current_language=(new_lang)\n if loaded_languages.include? new_lang.to_sym\n @@current_language = new_lang.to_sym\n else\n raise LangFileNotLoaded.new(new_lang, loaded_languages)\n end\n end",
"def current_language=(new_lang)\n if loaded_languages.include? new_lang.to_sym\n @@current_language = new_lang.to_sym\n else\n raise LangFileNotLoaded.new(new_lang, loaded_languages)\n end\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def set_best_locale\n if ( RAILS_ENV == 'test' )\n code = 'en'\n else\n code = Translation.reconcile_user_data_with_http_request_language(\n request,\n logged_in? ? current_user : nil\n )\n end\n\n Translation.set_best_locale( code )\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def fetch\n update_attributes(application.api_client.get(\n \"language/#{locale}/definition\", {},\n {\n cache_key: self.class.cache_key(locale)\n }\n ))\n rescue Tml::Exception => ex\n Tml.logger.error(\"Failed to load language: #{ex}\")\n self\n end",
"def new\n respond_with(new_i18n_key)\n end",
"def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end",
"def translation\n @translation ||= name.underscore.split('/').last\n end",
"def verificar_locale\n \n end",
"def store_language\n self.language ||= I18n.locale.to_s\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def set_website_locale\n app_locales = %w(es ca)\n I18n.locale = params[:lang] if app_locales.include?(params[:lang])\n end",
"def cached_translations_for_language(language)\n if Tr8n::RequestContext.current_source\n translations = Tr8n::RequestContext.current_source.valid_translations_for_key_and_language(self.key, language)\n end\n\n # pp \"found #{translations.count} cached translations for #{self.label}\" if translations\n translations || valid_translations_for_language(language)\n end",
"def setup_mass_copy_translations\n end",
"def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def load_i18n\n res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))\n end",
"def set_language_from\n session[:lang_from] = params[:lang].to_sym\n I18n.locale = session[:lang_from]\n render nothing: true\n end",
"def language_client; end",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def load\n reload_rh_texts unless PSDK_CONFIG.release?\n lang = ($pokemon_party ? $pokemon_party.options.language : default_lang)\n unless lang && Available_Langs.include?(lang)\n log_error \"Unsupported language code (#{lang}).\\nSupported language code are : #{Available_Langs.join(', ')}\"\n lang = Available_Langs.first\n log_info \"Fallback language code : #{lang}\"\n end\n @lang = lang\n @dialogs.clear\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def label_translation; end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def update_translations(locale, data)\n set_translations(locale, application.cache_translations(\n locale,\n key,\n data.is_a?(Hash) ? data['translations'] : data\n ))\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate_external(facets, options)\n facets_string = \"[\" + facets.map {|facet| \":#{facet}\"}.join(\", \") + \"]\"\n class_eval <<-HERE\n @@facet_options = {}\n attr_writer :fully_loaded\n def fully_loaded?; @fully_loaded; end\n @@globalize_facets = #{facets_string}\n @@preload_facets ||= @@globalize_facets\n class << self\n\n def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end\n\n def globalize_facets\n @@globalize_facets\n end\n\n def globalize_facets_hash\n @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|\n hash[facet.to_s] = true; hash\n }\n end\n\n def untranslated_fields\n @@untranslated_fields ||=\n column_names.map {|cn| cn.intern } - globalize_facets\n end\n\n def preload_facets; @@preload_facets; end\n def postload_facets\n @@postload_facets ||= @@globalize_facets - @@preload_facets\n end\n alias_method :globalize_old_find_every, :find_every unless\n respond_to? :globalize_old_find_every\n end\n alias_method :globalize_old_reload, :reload\n alias_method :globalize_old_destroy, :destroy\n alias_method :globalize_old_create_or_update, :create_or_update\n alias_method :globalize_old_update, :update\n\n include Globalize::DbTranslate::TranslateObjectMethods\n extend Globalize::DbTranslate::TranslateClassMethods\n\n HERE\n\n facets.each do |facet|\n bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s\n class_eval <<-HERE\n @@facet_options[:#{facet}] ||= {}\n @@facet_options[:#{facet}][:bidi] = #{bidi}\n\n def #{facet}\n if not_original_language\n raise WrongLanguageError.new(@original_language, Locale.language)\n end\n load_other_translations if\n !fully_loaded? && !self.class.preload_facets.include?(:#{facet})\n result = read_attribute(:#{facet})\n return nil if result.nil?\n result.direction = #{facet}_is_base? ?\n (Locale.base_language ? Locale.base_language.direction : nil) :\n (@original_language ? @original_language.direction : nil)\n\n # insert bidi embedding characters, if necessary\n if @@facet_options[:#{facet}][:bidi] &&\n Locale.language && Locale.language.direction && result.direction\n if Locale.language.direction == 'ltr' && result.direction == 'rtl'\n bidi_str = \"\\xe2\\x80\\xab\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'\n bidi_str = \"\\xe2\\x80\\xaa\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n end\n end\n\n return result\n end\n\n def #{facet}=(arg)\n raise WrongLanguageError.new(@original_language, Locale.language) if\n not_original_language\n write_attribute(:#{facet}, arg)\n end\n\n def #{facet}_is_base?\n self['#{facet}_not_base'].nil?\n end\n HERE\n end\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end"
] |
[
"0.7476398",
"0.738462",
"0.72456765",
"0.7151758",
"0.7151758",
"0.7107111",
"0.70435876",
"0.6864971",
"0.68643826",
"0.67471796",
"0.6738159",
"0.65648824",
"0.65023535",
"0.6496432",
"0.6455962",
"0.6387617",
"0.63376004",
"0.6294993",
"0.6273274",
"0.6262533",
"0.62249136",
"0.6159368",
"0.6145541",
"0.61280775",
"0.6122648",
"0.61213356",
"0.6091546",
"0.6082452",
"0.6079674",
"0.6062339",
"0.6019357",
"0.6019357",
"0.6017676",
"0.6013836",
"0.60045344",
"0.5993217",
"0.59872013",
"0.59803104",
"0.59741575",
"0.59734565",
"0.59393436",
"0.5932894",
"0.59221554",
"0.59211004",
"0.5898935",
"0.58984494",
"0.58876866",
"0.58675605",
"0.5856298",
"0.5842514",
"0.5840471",
"0.5821773",
"0.5813956",
"0.5811641",
"0.5802853",
"0.5801152",
"0.579978",
"0.5798282",
"0.57943004",
"0.5793441",
"0.5784482",
"0.5760396",
"0.5756319",
"0.5752966",
"0.5746521",
"0.5744727",
"0.57324755",
"0.5726822",
"0.57235265",
"0.5719269",
"0.5719269",
"0.57083124",
"0.569932",
"0.56985414",
"0.56922984",
"0.56891024",
"0.5676822",
"0.5663241",
"0.56612",
"0.5661104",
"0.5659427",
"0.5658265",
"0.5649909",
"0.5635314",
"0.5626983",
"0.5616344",
"0.56155825",
"0.5613081",
"0.5612544",
"0.5611396",
"0.56097347",
"0.5609593",
"0.56085646",
"0.5603226",
"0.56029373",
"0.5601409",
"0.5600493",
"0.560028",
"0.5586678",
"0.55839646",
"0.5580038"
] |
0.0
|
-1
|
Raises an InvalidLocale exception when the passed locale is not available. source://i18n//lib/i18n.rb349
|
def enforce_available_locales!(locale); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(locale)\n LOCALES.include?(locale) or raise BadLocale\n @locale = locale\n end",
"def valid_locale?(locale)\n FastGettext.available_locales.include?(locale)\n end",
"def locale_in_context(locale)\n return @locale if @locale && @locale.code == locale.to_s\n #Locale.find_by_code(locale.to_s) rescue nil && (raise InvalidLocale.new(locale))\n locale = Locale.find_by_code(locale.to_s)\n raise InvalidLocale.new(locale) unless locale\n locale\n end",
"def verify_locale(locale)\n site_locales.include?(locale.to_s) ? locale : preferred_default_locale\n end",
"def verify_locale(locale)\n (site_locales.include? locale.to_s) ? locale : preferred_default_locale\n end",
"def locale_available?(locale); end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def valid_locale?\n unless I18n.available_locales.detect {|alc| alc == I18n.locale }\n redirect_to root_with_locale_url(:locale => I18n.default_locale)\n return false\n end\n true\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def read_locale\n raise \"Override me\"\n end",
"def verificar_locale\n \n end",
"def locale=(_arg0); end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def check_availability(locale)\n if ['en', 'es'].include? locale.to_s\n locale\n else\n false\n end\n end",
"def permit_locale(locale)\n stripped_locale = locale&.strip\n I18n.config.available_locales_set.include?(stripped_locale) ? stripped_locale : nil\n end",
"def locale=(locale); end",
"def available_locales_initialized?; end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def handle_locale\n return if request.headers['Accept-Language'].nil?\n\n I18n.locale = case request.headers['Accept-Language'].downcase\n when 'ru' || 'russian'\n :ru\n when 'en' || 'english'\n :en\n else\n I18n.default_locale\n end\n end",
"def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language? ||\n params[:locale].presence == ::I18n.default_locale.to_s\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end",
"def apply_locale; end",
"def valid_locale?(locale_str)\n @loaded_locales.any? { |loc| loc.short == locale_str }\n end",
"def from_i18n_locale(locale)\n I18n.with_locale(locale) { Locale.new(locale, I18n.t('.display_name'), I18n.t('.database_encoding')) }\n end",
"def enforce_no_locale\n redirect_permanently_to additional_params.merge(locale: nil)\n end",
"def enforce_no_locale\n redirect_permanently_to additional_params.merge(locale: nil)\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def locale_from_params\n params[:locale] if (params[:locale] && ['en', 'se'].include?(params[:locale]))\n end",
"def filter_locale(locale, only_available_locales)\n return nil if locale.blank?\n if only_available_locales\n (defined?(available_locales) && available_locales.include?(locale)) ? locale : nil\n else\n locale\n end\n end",
"def locale_backend; end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def set_locale\n end",
"def payment_compatible_locale(locale)\n locale = locale.to_s.split(\"-\").first\n if [\"fr\", \"en\", \"es\", \"it\", \"pt\", \"de\", \"nl\", \"fi\"].include?(locale)\n return locale\n else\n return \"en\"\n end\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def correct_locale\n (locales.select{|loc|loc.locale == I18n.locale.to_s}.first || locales.first)\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def with_locale(tmp_locale = T.unsafe(nil)); end",
"def language_cannot_be_changed\n if ! language_was.nil? && language_changed?\n errors.add(:language, I18n.t('messages.project_info.errors.language_changed'))\n end\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language?\n end",
"def default_locale; end",
"def has_available_locale? locale\n available_locales.include?(locale.to_sym)\n end",
"def with_locale(tmp_locale = T.unsafe(nil), &block); end",
"def __with_locale__(locale, &block)\n yield\n end",
"def default_locale=(locale); end",
"def check_not_source_locale\n if rfc5646_locale == source_glossary_entry.source_rfc5646_locale\n errors.add(:rfc5646_locale, :cant_equal_source_locale)\n return false\n end\n return true\n end",
"def locale=(value); end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def another_locale\n I18n.available_locales.map(&:to_sym).select {|locale| locale != I18n.locale.to_sym }.first\n end",
"def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end",
"def system\n locale_from_env || default_locale\n end",
"def set_locale(locale)\n # Parse the HTTP GET header for languages and create an array\n # from them\n locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])\n\n # If we passed in a locale param, put it at the front of the\n # locales array\n if ((locale.is_a? String) && !(locale.empty?))\n locales.insert(0, locale)\n end\n\n # R18N locale setter\n ::R18n.thread_set do\n if Settings[:DEFAULT_LOCALE]\n ::R18n::I18n.default = Settings[:DEFAULT_LOCALE]\n end\n \n ::R18n::I18n.new(locales, ::R18n.default_places,\n :off_filters => :untranslated, :on_filters => :untranslated_html)\n end\n \n begin\n # We depend on lang-locale, not just lang code.\n # If we get a 2 letter lang code, dupe it so that\n # de becomes de-de\n # unless it's en, then we want en-us\n # or ja then we want ja-jp\n if (locales[0].length == 2)\n case locales[0].downcase\n when \"en\"\n return \"en-us\"\n when \"ja\"\n return \"ja-jp\"\n else\n return \"#{locales[0].downcase}-#{locales[0].downcase}\"\n end\n else\n return locales[0].downcase\n end\n rescue\n return Settings[:DEFAULT_LOCALE]\n end\n end",
"def locale_enabled?(locale)\r\n locale.to_s == I18n.default_locale.to_s || (get_language_completion(locale) || -1) >= I18n.config.language_threshold\r\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_locale\n \tI18n.locale = params[:locale] if params[:locale].present? \n end",
"def available_locales; end",
"def available_locales; end",
"def one_locale_must_have_translations\n if (preferred_locales & configatron.full_locales).empty?\n errors.add(:preferred_locales_str, :one_must_have_translations, locales: configatron.full_locales.join(\",\"))\n end\n end",
"def locale=(value)\n super(value.blank? ? nil : value)\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def validate!\n if local_site.default_locale != remote_site.default_locale && remote_site.edited?\n raise \"Your Wagon site locale (#{local_site.default_locale}) is not the same as the one in the back-office (#{remote_site.default_locale}).\"\n end\n\n if local_site.locales != remote_site.locales\n instrument :warning, message: \"Your Wagon site locales (#{local_site.locales.join(', ')}) are not the same as the ones in the back-office (#{remote_site.locales.join(', ')}).\"\n end\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def prevent_base_locale_from_changing\n errors.add(:base_rfc5646_locale, :readonly) if base_rfc5646_locale_changed?\n end",
"def get_matching_ui_locale(locale)\n lang = locale[0,2].downcase\n\n # Check with exact matching\n if Globalite.ui_locales.values.include?(local_case(locale))\n local_case(locale)\n end\n\n # Check on the language only\n Globalite.ui_locales.values.each do |value|\n value.to_s =~ /#{lang}-*/ ? value : nil\n end\n end",
"def with_locale(locale, &block)\n previous_locale = I18n.locale\n I18n.locale = locale if locale\n \n yield\n \n I18n.locale = previous_locale\n end",
"def locale_from_http_header\n language = request.env['HTTP_ACCEPT_LANGUAGE']\n unless language.blank?\n http_locale = language.scan(/^[a-z]{2}-[A-Z]{2}/)\n unless http_locale.blank?\n http_locale = http_locale.first\n else\n http_locale = language.scan(/^[a-z]{2}/).first\n end\n end\n end",
"def set_locale \n locale = params[:locale]\n locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\n I18n.locale = (locale && I18n.available_locales.include?(locale.to_sym)) ? locale : I18n.default_locale\n end",
"def locale=(loc)\n expected_keys = [:country, :language, :variant]\n begin\n loc.keys.each do |k|\n raise ArgumentError, \"Invalid locale parameter: #{k}\" unless expected_keys.include? k\n end\n rescue => e\n raise e, e.message\n else\n @locale = { :country => loc[:country] || locale[:country], \n :language => loc[:language] || locale[:language], \n :variant => loc[:variant] || locale[:variant]\n }\n end\n end",
"def detect_locale_from(source)\n case source\n when :params\n params[:locale]\n when :session\n logger.debug \"Session: #{session.inspect}\"\n session[:locale]\n when :cookie\n cookies[:locale]\n when :domain\n parse_host_and_port_for_locale[0]\n when :header\n request.env['HTTP_ACCEPT_LANGUAGE']\n when :default\n default_locale\n else\n raise \"unknown source\"\n end\n end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end"
] |
[
"0.68707335",
"0.63898605",
"0.6340171",
"0.6323789",
"0.629247",
"0.60979164",
"0.60438544",
"0.60401165",
"0.6038137",
"0.6037172",
"0.59767675",
"0.5975047",
"0.59715027",
"0.58499944",
"0.58274907",
"0.5803372",
"0.57953465",
"0.57890517",
"0.5786042",
"0.57789034",
"0.5759224",
"0.57547814",
"0.57303244",
"0.5724803",
"0.569084",
"0.5636732",
"0.5635401",
"0.5624148",
"0.5618257",
"0.5618257",
"0.5618257",
"0.5618257",
"0.5618257",
"0.5618257",
"0.5618257",
"0.561588",
"0.5588587",
"0.55870545",
"0.5578849",
"0.5576578",
"0.5576578",
"0.55653405",
"0.55553967",
"0.55440265",
"0.55264044",
"0.55172884",
"0.550078",
"0.5494651",
"0.54901755",
"0.54898405",
"0.54883724",
"0.5461571",
"0.5460658",
"0.54593915",
"0.5457533",
"0.54560447",
"0.5440712",
"0.5437137",
"0.5422392",
"0.5420268",
"0.5419128",
"0.5411322",
"0.54076195",
"0.5397684",
"0.5395345",
"0.5392663",
"0.53920144",
"0.53847486",
"0.53836405",
"0.5369447",
"0.5367642",
"0.53635067",
"0.53618336",
"0.5352719",
"0.5352719",
"0.5344326",
"0.53422177",
"0.5338858",
"0.5338858",
"0.53111655",
"0.52888924",
"0.5287028",
"0.52869797",
"0.52860874",
"0.5283008",
"0.52800107",
"0.5270935",
"0.5270763",
"0.5269695",
"0.5266777",
"0.52471304",
"0.52465844",
"0.52444714",
"0.5243422",
"0.5240361",
"0.5240361",
"0.5239323",
"0.52373546",
"0.52373546",
"0.5206413"
] |
0.720186
|
0
|
Returns true if a translation exists for a given key, otherwise returns false.
|
def exists?(key, _locale = T.unsafe(nil), locale: T.unsafe(nil), **options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_exist?(key)\n FastGettext.key_exist?(key)\n rescue Errno::ENOENT => error\n Yast.y2warning(\"File not found when translating '#{key}' on textdomain #{@my_textdomain}'. \"\\\n \"Error: #{error}. Backtrace: #{error.backtrace}\")\n false\n end",
"def one_translation_per_lang_per_key\n translation_exists = Translation.exists?(\n lang: self.lang,\n translator_id: self.translator.id,\n translator_type: self.translator.class.name,\n translation_key_id: self.key.id\n )\n\n unless translation_exists\n true\n else\n false\n self.errors.add(:lang, I18n.t('.one_translation_per_lang_per_key'))\n end\n end",
"def has_key?( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && contains_key( key )\n end",
"def exists(key)\n mon_synchronize do\n perform [\"exists\", key], proc: T_BOOL\n end\n end",
"def exists(key)\n mon_synchronize do\n perform [\"exists\", key], :proc => T_BOOL\n end\n end",
"def contains?(key)\n @key_data.has_key?(key)\n end",
"def key_has_value?(key, locale = base_locale)\n t(locale_data(locale)[locale], key).present?\n end",
"def exists?(key)\n unimplemented\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def key?(key, options)\n I18n.exists?(key, options.fetch(:locale, default_locale)) ||\n I18n.exists?(key, I18n.default_locale)\n end",
"def has_key?(key)\n keys.include?(key)\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def has_key?(key)\n return self.fetch(key) ? true : false\n end",
"def trans_exists?(trans)\n @wordlist.values.include?(trans)\n end",
"def exists(key)\n call(key, [:exists, key], transform: Redis::Boolify, read: true)\n end",
"def i18n_set?(key)\n I18n.t key, raise: true\n rescue StandardError\n false\n end",
"def has_key?(key); end",
"def has_key?(key); end",
"def exists?(key)\n key.present? && manager.key?(key)\n end",
"def key?(key)\n lookup_map.key?(key.to_sym)\n end",
"def has_key?(key)\n return to_h().has_key?(key)\n end",
"def has_key?(key)\n any? {|mod| mod.name == key}\n end",
"def exists?(key)\n @data.has_key?(key) && @data[key].valid?(self)\n end",
"def has_key?(key)\n @hash.has_key?(key)\n end",
"def exist?(key)\n with_client do |client|\n !client.exists(build_key(key)).zero?\n end\n end",
"def exist?(key)\n !@store.select { |i| i[:key] == build_key(key) }.empty?\n end",
"def exist?(key)\n !find(key).nil?\n end",
"def has_key?(key)\n !get(key).nil?\n end",
"def has_key?(key)\n !get(key).nil?\n end",
"def has_key? key; key? key; end",
"def include?(key)\n has_key?(key)\n end",
"def include?(key)\n @hash.has_key?(key.to_s)\n end",
"def exist?(key)\n\n end",
"def has_key?(key)\n @table.get(key) != nil\n end",
"def include?(key)\n # Ensure a Ruby true is returned\n item_exists(key) == true\n end",
"def exist? _key\n store.transaction(:read_only) do |s|\n s.roots.any? { |r| r.to_sym == _key.to_sym }\n end\n end",
"def exists?(namespace, key)\n exists = File.exist?(make_path(namespace, key))\n settings.logger.info(\"Queried #{make_key(namespace, key)}, found: #{exists}\")\n exists\n end",
"def has_key?(key)\n @h.has_key?(key.to_sym)\n end",
"def exist?(key)\n store.key?(key)\n end",
"def exists?\n retrieve\n true\n rescue Error::NoSuchKey\n false\n end",
"def has_key?(key)\n @cache.has_key?(key)\n end",
"def has?(key)\n value = self[key]\n boolean_typecast(key, value)\n end",
"def has?(key)\n [cache, values].any? { |store| store.keys.include?(key.to_sym) }\n end",
"def exists?(key)\n @redis.exists(prefix(key))\n end",
"def has?(key)\n @properties.has_key?(key)\n end",
"def has_key?(key)\n @map.has_key?(key.to_sym)\n end",
"def contains?(key)\n not get(key).nil?\n end",
"def exist?(key, options = {})\n invoke(:exist?, key) do |store|\n store.exists(namespaced_key(key, merged_options(options)))\n end\n end",
"def key?(key)\n timeout_retry(3, 3){\n write \"EXISTS #{key}\\r\\n\"\n integer_reply == 1\n }\n end",
"def has_key?(key)\n @db.each_key do\n\t|k|\n\treturn true if k == key\n end\n end",
"def has_key?(key)\n @stored[key] && !@stored[key].empty? ? true : false\n end",
"def i18n_set?(key, params = {})\n I18n.t key, params, :raise => true rescue false\n end",
"def contains?(key)\n position = search(key)\n (key <=> @keys[position]) == 0\n end",
"def key_value?(key, locale = base_locale)\n !t(key, locale).nil?\n end",
"def translator_missing?\n !yaml.key?(\"translator\")\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def key?(key)\n keys.include?(key) || keys.map(&:to_s).include?(key)\n end",
"def has_key?(key)\n dummy = Pair.new(key,nil)\n return @tree.get(dummy)\n end",
"def has_key?(key)\n !find_node(key).nil?\n end",
"def key?(key)\n config.resolver.key?(_container, key)\n end",
"def contains?(key)\n @semaphore.synchronize {\n @key_data.has_key?(key)\n }\n end",
"def exists?(key)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def key?(key)\n return false if key.nil?\n return true if self.class.mutable? && mutations.key?(key)\n\n respond_to?(key) || fallback_data.key?(key)\n end",
"def has_key?(key)\n !!fetch(key)\n rescue ContextMiss\n false\n end",
"def has_key?(key)\n @configuration.has_key?(key.to_sym)\n end",
"def key?(key)\n configuration.key?(key)\n end",
"def is_key_exist(key)\r\n (@redis.exists key) ? true : false \r\n end",
"def exist?(key)\n raise NotImplementedError\n end",
"def key?(key, *args)\n messages.key?(key, *args)\n end",
"def exist?(key)\n instrument :exist, key: key do |payload|\n id = map_key_to_id(key)\n answer = id.present?\n\n payload[:exist] = answer\n answer\n end\n end",
"def include_key?(key)\n\t\t\ttrue\n\t\tend",
"def has?(key)\n respond_to? key\n end",
"def has_key(rsa)\n refresh_keys if @keys.nil?\n return false if @keys.empty?\n\n # loop through arrays checking against 'key'\n @keys.each do |key|\n return true if key[\"key\"] == rsa\n end\n\n return false # key not found\n end",
"def key?(key)\n @configuration.key?(key)\n end",
"def has_key?(key)\n super(convert_key(key))\n end",
"def key?(key)\n !self[key].nil?\n end",
"def exists?(key)\n # Use recommended binary-returning method create [with this redis-rb commit](https://github.com/redis/redis-rb/commit/bf42fc9e0db4a1719d9b1ecc65aeb20425d44427).\n return Lit.redis.exists?(key) if Lit.redis.respond_to?(:exists?)\n\n # Fall back with older gem\n Lit.redis.exists(key)\n end",
"def has_key(hash, key)\n\thash.has_key? key\nend",
"def has_key?(key)\n super(convert_key(key))\n end",
"def contains?(locale, name)\r\n self[locale].has_key?(name.to_s)\r\n end",
"def exists?(key)\n s3_object(key).exists?\n end",
"def has_key?(p0) end",
"def has_key? key\n @lock.read_sync{ @data.has_key? key }\n end",
"def has_key?(key)\n local?(key) || (!@parent.nil? && @parent.key?(key))\n end",
"def plist_key_exists?(key, file, opts={})\n plist_read(key, file, opts) != nil\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def exist?(key)\n jiak.client.exist?(jiak.bucket,key)\n end",
"def key?(key, options = {})\n load(key, options) != nil\n end",
"def has_key?(key)\n params.keys.include?(key)\n end",
"def has_key? k\n @values.has_key?(k)\n end",
"def lookup_key(translations, key)\n translations[key]\n end",
"def in?(key)\n return true if get(key)\n false\n end",
"def has_key? key\n (self.class.order + @order).include? key\n end",
"def exist(key)\n check_return_code(\n Lib.memcached_exist(@struct, key),\n key\n )\n end",
"def include?(key)\n self.each_key.any? { |k|\n k.casecmp?(key)\n }\n end",
"def include?(key)\n @item.key?(key)\n end",
"def include?(key)\n @item.key?(key)\n end",
"def exists?(key, bucket = nil)\n about(key, bucket)\n true\n rescue NoSuchKey\n false\n end",
"def exist?(key)\n File.exist?(cache_path(key))\n end"
] |
[
"0.7618886",
"0.72968954",
"0.72556454",
"0.7175665",
"0.7140171",
"0.7086438",
"0.70421803",
"0.7025646",
"0.70164347",
"0.70164347",
"0.699866",
"0.6966423",
"0.69571394",
"0.69490457",
"0.6946193",
"0.6940823",
"0.6920112",
"0.691393",
"0.691393",
"0.6891443",
"0.68899125",
"0.6883573",
"0.68636847",
"0.68632156",
"0.6845894",
"0.68156797",
"0.6813763",
"0.67990065",
"0.6798886",
"0.6798886",
"0.6789307",
"0.67717314",
"0.6757477",
"0.6752965",
"0.672173",
"0.6720507",
"0.6710108",
"0.6691746",
"0.6690828",
"0.66781473",
"0.6676719",
"0.6671999",
"0.66688824",
"0.6652402",
"0.6624359",
"0.6623361",
"0.6622244",
"0.6613623",
"0.66109836",
"0.65915537",
"0.6589017",
"0.6579198",
"0.6571249",
"0.65628004",
"0.6560124",
"0.6540474",
"0.6538835",
"0.6538835",
"0.6530069",
"0.6528474",
"0.6505553",
"0.6497764",
"0.6486005",
"0.64794123",
"0.6456451",
"0.64441514",
"0.6441302",
"0.6434079",
"0.64338595",
"0.64205503",
"0.64123046",
"0.6398823",
"0.6398293",
"0.6396043",
"0.63879144",
"0.6378278",
"0.6373054",
"0.6358994",
"0.6349773",
"0.6345044",
"0.63410676",
"0.63404006",
"0.63304245",
"0.63181794",
"0.63177955",
"0.63146156",
"0.63020253",
"0.63014895",
"0.6294179",
"0.6289137",
"0.6286797",
"0.6272784",
"0.626481",
"0.6263526",
"0.6261632",
"0.6242714",
"0.6235172",
"0.6235172",
"0.62343276",
"0.6220791"
] |
0.6431996
|
69
|
Localizes certain objects, such as dates and numbers to local formatting.
|
def l(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def localize(object, **options); end",
"def localize(object, **options); end",
"def localize(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end",
"def localize(object, **options)\n I18n.localize(object, **options)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize\n helpers.localize\n end",
"def localize(locale, object, format = :default)\n raise ArgumentError, \"Object must be a Date, DateTime or Time object. #{object.inspect} given.\" unless object.respond_to?(:strftime)\n \n type = object.respond_to?(:sec) ? 'time' : 'date'\n format = translate(locale, \"#{type}.formats.#{format.to_s}\") unless format.to_s.index('%') # lookup keyed formats unless a custom format is passed\n\n format.gsub!(/%a/, translate(locale, :\"date.abbr_day_names\")[object.wday]) \n format.gsub!(/%A/, translate(locale, :\"date.day_names\")[object.wday])\n format.gsub!(/%b/, translate(locale, :\"date.abbr_month_names\")[object.mon])\n format.gsub!(/%B/, translate(locale, :\"date.month_names\")[object.mon])\n format.gsub!(/%p/, translate(locale, :\"time.#{object.hour < 12 ? :am : :pm}\")) if object.respond_to? :hour\n \n object.strftime(format)\n end",
"def apply_locale; end",
"def localize(object, options = {})\n # Fall back to the default localize behavior if the :force_default_behavior is true\n return original_localize(object, options) if options.delete(:force_default_behavior)\n\n localized_values = []\n\n available_locales.each do |locale|\n options_copy = options.merge(locale: locale)\n\n localized_values << original_localize(object, options_copy)\n end\n\n localized_values.max\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def localize(time, opts)\n time.strftime(opts[:format])\n end",
"def localise(args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n object = args.last.respond_to?(:available_in_locale?) ? args.pop : nil\n options[:locale] ||= (defined?(params) && params[:locale] || I18n.locale)\n if (options[:locale].to_s == \"en\") || (object && !object.available_in_locale?(options[:locale]))\n options.delete(:locale)\n end\n args.push(object) if object\n args.push(options)\n args\n end",
"def set_locale\n end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def localize(field)\n if klass.fields[field.to_s].try(:localized?)\n field = \"#{field}.#{::I18n.locale}\".to_sym\n end\n field\n end",
"def localize(key, options = {})\n I18n.localize(key, options.merge(:locale => self.locale))\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def formatta_locale(format)\n if defined? I18n\n I18n.l self, format: format\n else\n formattazione = strftime format\n formattazione\n .gsub(/January/i, \"Gennaio\")\n .gsub(/February/i, \"Febbraio\")\n .gsub(/March/i, \"Marzo\")\n .gsub(/April/i, \"Aprile\")\n .gsub(/May/i, \"Maggio\")\n .gsub(/June/i, \"Giugno\")\n .gsub(/July/i, \"Luglio\")\n .gsub(/August/i, \"Agosto\")\n .gsub(/September/i, \"Settembre\")\n .gsub(/October/i, \"Ottobre\")\n .gsub(/November/i, \"Novembre\")\n .gsub(/December/i, \"Dicembre\")\n end\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def serialize(object)\n { ::I18n.locale.to_s => object.try(:to_s) }\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def mongoize(object)\n { ::I18n.locale.to_s => type.mongoize(object) }\n end",
"def strftime(date)\n tmpdate=date.dup\n LocalizationSimplified::localize_strftime(tmpdate, self)\n old_strftime(tmpdate)\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def _calc_locale(_l)\n _l = (_l || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale).to_s\n \"_#{_l}\"\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def locale=(value); end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def locale=(_arg0); end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def italy\n # super doesn't call #new_start on MRI, so each method has to be\n # individually overridden.\n if_period(super) {|p,dt| dt.localize(p) }\n end",
"def default_locale; end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def humanize(lang = :en)\n t = object.strftime(\"%r\")\n if has_timezone?\n t += if self.tz == 'Z'\n \" UTC\"\n else\n \" #{self.tz}\"\n end\n end\n t\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def locale=(locale); end",
"def translated_month_names; end",
"def localized_names\n @localized_names ||= []\n end",
"def localized_date(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def set_locale\n I18n.locale = params[:locale] if params[:locale].present?\n # \"en\"\n # params[:locale] if params[:locale].present?\n # current_user.locale\n # request.subdomain\n # request.env[\"HTTP_ACCEPT_LANGUAGE\"]\n # request.remote_ip\n end",
"def normalize_locale\n return unless @locale\n alias_for = config.data.resolve_alias(locale)\n @locale = Locale.parse(alias_for) if alias_for and alias_for != locale\n \n normalized = {\n territory: territory.known? ? territory.code : nil,\n # todo: script etc\n }\n\n normalized.delete_if { |key, value| @locale[key] == value }\n reset_locale(@locale.with(**normalized)) if normalized.any?\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def local_strftime(string)\n @time.getlocal.strftime(string)\n end",
"def canonicalize!\n @string = @object.strftime(FORMAT) + self.tz.to_s if self.valid?\n self\n end",
"def localize_default_attributes\n _title, _slug = self.title, self.slug\n\n self.site.each_locale(false) do |locale, _|\n self.title, self.slug = _title, _slug\n end\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def humanize(lang = :en)\n d = object.strftime(\"%A, %d %B %Y\")\n if has_timezone?\n d += if self.tz == 'Z'\n \" UTC\"\n else\n \" #{self.tz}\"\n end\n end\n d\n end",
"def localized(scope, attribute, default)\n self.class.localized scope, attribute, default, object.class.name.downcase\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def use_us_formats\n self.current_date_format = :us\n end",
"def localize_present?\n false\n end",
"def apply_local_r_converters(obj)\n apply_converters(r_converters, obj)\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def globalize_object(model)\n return unless pol_cfg.multilang?\n pol_cfg.languages.each do |lang|\n next if model.globalize_translations.map(&:locale).include?(lang.to_sym)\n model.globalize_translations.build({ :locale => lang })\n end\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def humanize(lang = :en)\n d = object.strftime(\"%A, %d %B %Y\")\n if timezone?\n d += if @zone == '+00:00'\n \" UTC\"\n else\n \" #{@zone}\"\n end\n end\n d\n end",
"def locale_backend; end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end",
"def humanize(lang = :en)\n t = object.strftime(\"%r\")\n if timezone?\n z = @zone == '+00:00' ? \"UTC\" : @zone\n t += \" #{z}\"\n end\n t\n end",
"def with_locale(tmp_locale = T.unsafe(nil)); end"
] |
[
"0.7576494",
"0.7576494",
"0.7558256",
"0.7387076",
"0.7198532",
"0.7198532",
"0.7198532",
"0.7197788",
"0.7187726",
"0.7187726",
"0.7186084",
"0.7020376",
"0.6825264",
"0.6587345",
"0.65222496",
"0.6291261",
"0.62178284",
"0.6076371",
"0.60617816",
"0.59505117",
"0.59505117",
"0.59505117",
"0.59505117",
"0.59505117",
"0.59505117",
"0.59505117",
"0.59306324",
"0.5909189",
"0.58695376",
"0.5858685",
"0.5851811",
"0.5768479",
"0.5759557",
"0.5751379",
"0.57346743",
"0.57340485",
"0.5695658",
"0.56882507",
"0.5665091",
"0.5653965",
"0.5645091",
"0.5645091",
"0.56177276",
"0.5611623",
"0.5599593",
"0.5599382",
"0.55612934",
"0.5548037",
"0.5548037",
"0.5540836",
"0.5536878",
"0.55245525",
"0.55193955",
"0.5518644",
"0.54926527",
"0.54855555",
"0.54732364",
"0.5470205",
"0.5462736",
"0.54494756",
"0.54384345",
"0.5427016",
"0.542629",
"0.5423901",
"0.54178727",
"0.5413454",
"0.5412986",
"0.5411149",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.5400154",
"0.53993636",
"0.5386071",
"0.53852403",
"0.5380589",
"0.53758335",
"0.53690255",
"0.5366692",
"0.53632027",
"0.5360155",
"0.5360155",
"0.5351893",
"0.5351893",
"0.5351649",
"0.5341341",
"0.53411233",
"0.53358495",
"0.53193295",
"0.5304426"
] |
0.5809348
|
31
|
Returns true when the passed locale, which can be either a String or a Symbol, is in the list of available locales. Returns false otherwise.
|
def locale_available?(locale); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_locale? locale\n locales.include?(locale.to_sym)\n end",
"def has_available_locale? locale\n available_locales.include?(locale.to_sym)\n end",
"def check_availability(locale)\n if ['en', 'es'].include? locale.to_s\n locale\n else\n false\n end\n end",
"def valid_locale?(locale)\n FastGettext.available_locales.include?(locale)\n end",
"def locale_enabled?(locale)\r\n locale.to_s == I18n.default_locale.to_s || (get_language_completion(locale) || -1) >= I18n.config.language_threshold\r\n end",
"def has_locale?(locale)\n @locales.has_key?(locale.to_s)\n end",
"def valid_locale?(locale_str)\n @loaded_locales.any? { |loc| loc.short == locale_str }\n end",
"def in_locale?(locale)\n\t\tin_locale = false\n\t\tif locale == :ka && Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\telsif locale != :ka && !Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\tend\n\t\treturn in_locale\n\tend",
"def in_locale?(locale)\n\t\tin_locale = false\n\t\tif locale == :ka && Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\telsif locale != :ka && !Utf8Converter.is_geo?(self.explaination)\n\t\t\tin_locale = true\n\t\tend\n\t\treturn in_locale\n\tend",
"def supported_language?(locale)\n self.supported_languages.include?(locale.to_s)\n end",
"def valid_locale?\n unless I18n.available_locales.detect {|alc| alc == I18n.locale }\n redirect_to root_with_locale_url(:locale => I18n.default_locale)\n return false\n end\n true\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language?\n end",
"def locale_prefix_not_allowed?\n params[:locale].present? && !multi_language? ||\n params[:locale].presence == ::I18n.default_locale.to_s\n end",
"def contains?(locale, name)\r\n self[locale].has_key?(name.to_s)\r\n end",
"def fully_translated?\n locale_counts.all? do |locale_code, _|\n fully_translated_in?(locale_code)\n end\n end",
"def verify_locale(locale)\n (site_locales.include? locale.to_s) ? locale : preferred_default_locale\n end",
"def verify_locale(locale)\n site_locales.include?(locale.to_s) ? locale : preferred_default_locale\n end",
"def is_point_in_locale?(point, locale)\n for i in 1..6\n route = locale.send(\"route_#{i}\")\n \n if !route.nil? && route.points_on_route.include?(point.id.to_s)\n return true\n end\n \n end\n \n return false\n end",
"def explicit_locale? = @explicit_locale",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def permit_locale(locale)\n stripped_locale = locale&.strip\n I18n.config.available_locales_set.include?(stripped_locale) ? stripped_locale : nil\n end",
"def key_has_value?(key, locale = base_locale)\n t(locale_data(locale)[locale], key).present?\n end",
"def localized?\n self.locales.size > 1\n end",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def exclude_locale_from_options?(locale)\n if !(session['geo_usa']) && locale.to_s.match?(/\\-US/i)\n return true # Hide en-US if we're not in the US\n elsif !!(session['geo_usa']) && [\"en\", \"en-asia\"].include?(locale.to_s)\n return true # Hide en, en-asia if we are in the US\n end\n return false\n end",
"def enforce_available_locales!(locale); end",
"def country_is?(country_symbol)\n return false if country.blank?\n country_values = COUNTRY_ABBREVIATIONS[country_symbol]\n (country_values && country_values.include?(country.downcase)) ? true : false\n end",
"def key_value?(key, locale = base_locale)\n !t(key, locale).nil?\n end",
"def get_matching_ui_locale(locale)\n lang = locale[0,2].downcase\n\n # Check with exact matching\n if Globalite.ui_locales.values.include?(local_case(locale))\n local_case(locale)\n end\n\n # Check on the language only\n Globalite.ui_locales.values.each do |value|\n value.to_s =~ /#{lang}-*/ ? value : nil\n end\n end",
"def localize_present?\n options[:localize] == :present\n end",
"def supported?(language)\n if Languages.key?(language) || Languages.value?(language.upcase)\n true\n else\n false\n end\n end",
"def matches?\n symbol = @actual.is_a?(Symbol)\n actual = symbol ? @actual.to_s : @actual\n values = symbol ? @values.map { |v| v.is_a?(Symbol) ? v.to_s : v } : @values\n\n values.each do |value|\n return false unless actual.include?(value)\n end\n\n true\n end",
"def available_locales_initialized?; end",
"def exists?(key, _locale = T.unsafe(nil), locale: T.unsafe(nil), **options); end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def match_locale_and_set_locale\n changed = false\n if I18n.available_locales.map(&:to_s).include?(configuration_params[:locale])\n unless cookies[:locale] == configuration_params[:locale]\n I18n.locale = cookies[:locale] = configuration_params[:locale] \n changed = true\n end\n changed\n end\n end",
"def locales_are_valid\n preferred_locales.each do |l|\n errors.add(:preferred_locales_str, :invalid_code, code: l) unless ISO_639.find(l.to_s)\n end\n end",
"def valid_symbol?(symbol)\n return false if [].include?(symbol)\n true\n end",
"def key?(key, options)\n I18n.exists?(key, options.fetch(:locale, default_locale)) ||\n I18n.exists?(key, I18n.default_locale)\n end",
"def defines? currency\n currencies.include?(country_map[currency] ? country_map[currency] : currency)\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def fully_translated_in?(locale_code)\n (locale_counts[locale_code] || -1) >= phrase_count\n end",
"def valid_language?(language)\n %w(de en).include?(language)\nend",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def filter_locale(locale, only_available_locales)\n return nil if locale.blank?\n if only_available_locales\n (defined?(available_locales) && available_locales.include?(locale)) ? locale : nil\n else\n locale\n end\n end",
"def matching_locales\n @_matching_locales ||= ::I18n.available_locales.select do |locale|\n locale.to_s.split(\"-\")[0] == language_code\n end\n end",
"def payment_compatible_locale(locale)\n locale = locale.to_s.split(\"-\").first\n if [\"fr\", \"en\", \"es\", \"it\", \"pt\", \"de\", \"nl\", \"fi\"].include?(locale)\n return locale\n else\n return \"en\"\n end\n end",
"def locale_in_context(locale)\n return @locale if @locale && @locale.code == locale.to_s\n #Locale.find_by_code(locale.to_s) rescue nil && (raise InvalidLocale.new(locale))\n locale = Locale.find_by_code(locale.to_s)\n raise InvalidLocale.new(locale) unless locale\n locale\n end",
"def valid?\n ENUM.include? @type.downcase.to_sym\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def locale_matches\n matches = {}\n I18n.available_locales.map(&:to_s).each do |locale|\n matches[locale] = locale\n matches[locale[0, 2]] = locale if locale.length > 2\n end\n matches\n end",
"def localized?\n true\n end",
"def default_language?\n return true unless params[:locale]\n\n params[:locale].to_s == I18n.default_locale.to_s\n end",
"def localize_present?\n false\n end",
"def is_rtl_locale\n I18n.locale.to_s.eql?(\"he\")\n end",
"def matches?(candidates)\n candidates.any? && candidates.all? { |l| @languages.include?(l.name) }\n end",
"def valid?\n invalid_strings = %w[ab cd pq xy]\n invalid_strings.each do |x|\n return false if include?(x)\n end\n\n true\n end",
"def valid?(key)\n MENUS.keys.map(&:to_sym).include?(key.to_sym)\n end",
"def valid?\n language_validator = EnumAttributeValidator.new('String', [\"ar\", \"en\"])\n return false unless language_validator.valid?(@language)\n return false if !@card_token.nil? && @card_token !~ Regexp.new(/^[0-9]{8}$/)\n return false if !@ptlf.nil? && @ptlf.to_s.length > 45\n true && super\n end",
"def normalize_locales\n self.preferred_locales = preferred_locales.map { |l| l.to_s.downcase.gsub(/[^a-z]/, \"\")[0,2] }\n true\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def locale_from_params\n params[:locale] if (params[:locale] && ['en', 'se'].include?(params[:locale]))\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def available_locales; end",
"def available_locales; end",
"def hash_is_for_pluralization?(hash, locale)\n plural_keys = I18n.t('i18n.plural.keys', locale: locale)\n raise missing_pluralisations_message(locale) unless plural_keys.is_a?(Array)\n ((hash.keys.map(&:to_s) - plural_keys.map(&:to_s)) - ['zero']).empty?\n end",
"def isValid?\n if @Valid.nil?\n params = []\n joins = ''\n where = ''\n\n if not @Locales.empty?\n joins += ' LEFT JOIN `Locales` AS L ON TN.Locale = L.ID'\n where = 'L.Name COLLATE NOCASE IN (' + Array.new(@Locales.count, '?').join(',') + ') AND '\n params += @Locales\n end\n\n sql = \"SELECT 1 FROM `TimezoneNames` TN #{joins} WHERE #{where}TN.NameLowercase = ? COLLATE NOCASE LIMIT 1\"\n params << @Timezone.downcase\n\n @Valid = Data::Storage.getStatement(sql).execute(*params).count > 0\n end\n @Valid\n end",
"def arabic?\r\n self =~ ARABIC_REGEXP\r\n end",
"def available_locales_set; end",
"def symbols?\n sort == ::SYMBOLS\n end",
"def probably_mailing_list?\n !!short_name.match(/\\-/)\n end",
"def available_for_order?(_order)\n true\n end",
"def _is_in(token, list)\n return false unless list\n list.include?(token[1])\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def accepts?(countries)\n return false if done?\n\n @possibles.any? do |ops_modifiers, count|\n all_ops_modifiers_qualify?(countries, ops_modifiers, count)\n end\n end",
"def searchable_in_registry?\n # Use blacklist instead of whitelist; almost all MO names are searchable\n !unsearchable_in_registry?\n end",
"def languages?(candidate)\n raise ArgumentError, 'candidate must have a :languages key' unless candidate.has_key?(:languages)\n candidate[:languages].any? { |language| REQUIRED_LANGUAGES.include? language } ? true : false\nend",
"def role?(role_sym)\n \n self.master_user_types.pluck(:name).include?(role_sym) ? true : false\n end",
"def _match_available_locales_only\n lambda do\n locale = remaining_path.split(\"/\").reject(&:empty?).first.to_s\n if ::R18n.available_locales.map(&:code).map(&:downcase).include?(locale.downcase)\n @captures.push(locale)\n @remaining_path = remaining_path.sub(\"/#{locale}\", \"\")\n end\n end\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def localized_strings?\n @lstrings ||= entry[:localized] && entry[:filename] =~ /strings.js$/\n end",
"def is_currency(token)\n _is_in(token, @currency_tags)\n end",
"def is_one_of?(*syms)\n syms.flatten.include?(to_sym)\n end",
"def localized?\n false\n end",
"def check_not_source_locale\n if rfc5646_locale == source_glossary_entry.source_rfc5646_locale\n errors.add(:rfc5646_locale, :cant_equal_source_locale)\n return false\n end\n return true\n end",
"def valid?\n payment_method_validator = EnumAttributeValidator.new('String', [\"Cheque\", \"Electronically\", \"Manual\"])\n return false unless payment_method_validator.valid?(@payment_method)\n true\n end",
"def locale(locale, &block)\n scope :locale => locale, &block\n end",
"def should_cache?(key_with_locale, options, had_key)\n if had_key\n return false unless options[:default] && !options[:default].is_a?(Array)\n end\n\n _, key_without_locale = ::Lit::Cache.split_key(key_with_locale)\n return false if is_ignored_key(key_without_locale)\n\n true\n end",
"def isValid?\n if @Valid.nil?\n params = []\n joins = ''\n where = ''\n\n if not @Locales.empty?\n joins += ' LEFT JOIN `Locales` AS L ON RI.Locale = L.ID'\n where = 'L.Name COLLATE NOCASE IN (' + Array.new(@Locales.count, '?').join(',') + ') AND '\n params += @Locales\n end\n\n sql = \"SELECT 1 FROM `RailsI18N` RI #{joins} WHERE #{where}RI.`NameLowercase` = ? LIMIT 1\"\n params << @Name.downcase\n\n @Valid = Data::Storage.getStatement(sql).execute(*params).count > 0\n end\n @Valid\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end",
"def one_locale_must_have_translations\n if (preferred_locales & configatron.full_locales).empty?\n errors.add(:preferred_locales_str, :one_must_have_translations, locales: configatron.full_locales.join(\",\"))\n end\n end",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def valid?\n promo_level_validator = EnumAttributeValidator.new('String', ['Standard', 'StandardPP', 'Elite', 'ElitePP', 'PremiumPlus'])\n return false unless promo_level_validator.valid?(@promo_level)\n listing_type_validator = EnumAttributeValidator.new('String', ['Sale', 'Rent', 'Share', 'Sold', 'NewHomes'])\n return false unless listing_type_validator.valid?(@listing_type)\n true\n end",
"def available_in?(region)\n available_regions.include?(region)\n end",
"def valid_order?(order)\n valid_orders.include? order.to_s\n end"
] |
[
"0.80649173",
"0.7921756",
"0.78618103",
"0.7635542",
"0.7378551",
"0.73482186",
"0.73356074",
"0.7039958",
"0.7039958",
"0.67875314",
"0.63923645",
"0.6376659",
"0.63715035",
"0.631821",
"0.6147968",
"0.6133758",
"0.6127884",
"0.6125635",
"0.60624176",
"0.60459256",
"0.59774214",
"0.58770764",
"0.58386415",
"0.58267605",
"0.5797671",
"0.5750536",
"0.5731759",
"0.5703302",
"0.5679635",
"0.5660383",
"0.55904424",
"0.5585965",
"0.5571325",
"0.5558542",
"0.5553132",
"0.5534863",
"0.5534641",
"0.5533582",
"0.5519666",
"0.551287",
"0.5508784",
"0.5508548",
"0.5503716",
"0.5502922",
"0.5453936",
"0.545151",
"0.5436121",
"0.5416959",
"0.5410821",
"0.541009",
"0.53913325",
"0.5380204",
"0.5361173",
"0.5347336",
"0.53082633",
"0.52824974",
"0.52609783",
"0.52548766",
"0.5239485",
"0.5236902",
"0.5220265",
"0.52179855",
"0.52179855",
"0.5189486",
"0.51862526",
"0.51665384",
"0.51665384",
"0.5155045",
"0.5143169",
"0.51393586",
"0.51354384",
"0.51326746",
"0.5117204",
"0.5116516",
"0.511235",
"0.5105449",
"0.5100278",
"0.5090782",
"0.50864357",
"0.5073128",
"0.5067",
"0.5066569",
"0.5066569",
"0.506511",
"0.5062122",
"0.5047921",
"0.5046949",
"0.5038955",
"0.5028583",
"0.50167775",
"0.5016169",
"0.5010759",
"0.5008226",
"0.50069606",
"0.49929678",
"0.4982466",
"0.49768382",
"0.49692178",
"0.49622238",
"0.49606395"
] |
0.77475053
|
3
|
Localizes certain objects, such as dates and numbers to local formatting.
|
def localize(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def localize(object, **options); end",
"def localize(object, **options); end",
"def localize(object, **options)\n I18n.localize(object, **options)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize\n helpers.localize\n end",
"def localize(locale, object, format = :default)\n raise ArgumentError, \"Object must be a Date, DateTime or Time object. #{object.inspect} given.\" unless object.respond_to?(:strftime)\n \n type = object.respond_to?(:sec) ? 'time' : 'date'\n format = translate(locale, \"#{type}.formats.#{format.to_s}\") unless format.to_s.index('%') # lookup keyed formats unless a custom format is passed\n\n format.gsub!(/%a/, translate(locale, :\"date.abbr_day_names\")[object.wday]) \n format.gsub!(/%A/, translate(locale, :\"date.day_names\")[object.wday])\n format.gsub!(/%b/, translate(locale, :\"date.abbr_month_names\")[object.mon])\n format.gsub!(/%B/, translate(locale, :\"date.month_names\")[object.mon])\n format.gsub!(/%p/, translate(locale, :\"time.#{object.hour < 12 ? :am : :pm}\")) if object.respond_to? :hour\n \n object.strftime(format)\n end",
"def apply_locale; end",
"def localize(object, options = {})\n # Fall back to the default localize behavior if the :force_default_behavior is true\n return original_localize(object, options) if options.delete(:force_default_behavior)\n\n localized_values = []\n\n available_locales.each do |locale|\n options_copy = options.merge(locale: locale)\n\n localized_values << original_localize(object, options_copy)\n end\n\n localized_values.max\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def localize(time, opts)\n time.strftime(opts[:format])\n end",
"def localise(args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n object = args.last.respond_to?(:available_in_locale?) ? args.pop : nil\n options[:locale] ||= (defined?(params) && params[:locale] || I18n.locale)\n if (options[:locale].to_s == \"en\") || (object && !object.available_in_locale?(options[:locale]))\n options.delete(:locale)\n end\n args.push(object) if object\n args.push(options)\n args\n end",
"def set_locale\n end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def localize(field)\n if klass.fields[field.to_s].try(:localized?)\n field = \"#{field}.#{::I18n.locale}\".to_sym\n end\n field\n end",
"def localize(key, options = {})\n I18n.localize(key, options.merge(:locale => self.locale))\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def formatta_locale(format)\n if defined? I18n\n I18n.l self, format: format\n else\n formattazione = strftime format\n formattazione\n .gsub(/January/i, \"Gennaio\")\n .gsub(/February/i, \"Febbraio\")\n .gsub(/March/i, \"Marzo\")\n .gsub(/April/i, \"Aprile\")\n .gsub(/May/i, \"Maggio\")\n .gsub(/June/i, \"Giugno\")\n .gsub(/July/i, \"Luglio\")\n .gsub(/August/i, \"Agosto\")\n .gsub(/September/i, \"Settembre\")\n .gsub(/October/i, \"Ottobre\")\n .gsub(/November/i, \"Novembre\")\n .gsub(/December/i, \"Dicembre\")\n end\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def l(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end",
"def serialize(object)\n { ::I18n.locale.to_s => object.try(:to_s) }\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def mongoize(object)\n { ::I18n.locale.to_s => type.mongoize(object) }\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def strftime(date)\n tmpdate=date.dup\n LocalizationSimplified::localize_strftime(tmpdate, self)\n old_strftime(tmpdate)\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def _calc_locale(_l)\n _l = (_l || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale).to_s\n \"_#{_l}\"\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def locale=(value); end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def locale=(_arg0); end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def italy\n # super doesn't call #new_start on MRI, so each method has to be\n # individually overridden.\n if_period(super) {|p,dt| dt.localize(p) }\n end",
"def default_locale; end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def humanize(lang = :en)\n t = object.strftime(\"%r\")\n if has_timezone?\n t += if self.tz == 'Z'\n \" UTC\"\n else\n \" #{self.tz}\"\n end\n end\n t\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def locale=(locale); end",
"def translated_month_names; end",
"def localized_names\n @localized_names ||= []\n end",
"def localized_date(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def set_locale\n I18n.locale = params[:locale] if params[:locale].present?\n # \"en\"\n # params[:locale] if params[:locale].present?\n # current_user.locale\n # request.subdomain\n # request.env[\"HTTP_ACCEPT_LANGUAGE\"]\n # request.remote_ip\n end",
"def normalize_locale\n return unless @locale\n alias_for = config.data.resolve_alias(locale)\n @locale = Locale.parse(alias_for) if alias_for and alias_for != locale\n \n normalized = {\n territory: territory.known? ? territory.code : nil,\n # todo: script etc\n }\n\n normalized.delete_if { |key, value| @locale[key] == value }\n reset_locale(@locale.with(**normalized)) if normalized.any?\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def local_strftime(string)\n @time.getlocal.strftime(string)\n end",
"def canonicalize!\n @string = @object.strftime(FORMAT) + self.tz.to_s if self.valid?\n self\n end",
"def localize_default_attributes\n _title, _slug = self.title, self.slug\n\n self.site.each_locale(false) do |locale, _|\n self.title, self.slug = _title, _slug\n end\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def humanize(lang = :en)\n d = object.strftime(\"%A, %d %B %Y\")\n if has_timezone?\n d += if self.tz == 'Z'\n \" UTC\"\n else\n \" #{self.tz}\"\n end\n end\n d\n end",
"def localized(scope, attribute, default)\n self.class.localized scope, attribute, default, object.class.name.downcase\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def use_us_formats\n self.current_date_format = :us\n end",
"def localize_present?\n false\n end",
"def apply_local_r_converters(obj)\n apply_converters(r_converters, obj)\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def globalize_object(model)\n return unless pol_cfg.multilang?\n pol_cfg.languages.each do |lang|\n next if model.globalize_translations.map(&:locale).include?(lang.to_sym)\n model.globalize_translations.build({ :locale => lang })\n end\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def humanize(lang = :en)\n d = object.strftime(\"%A, %d %B %Y\")\n if timezone?\n d += if @zone == '+00:00'\n \" UTC\"\n else\n \" #{@zone}\"\n end\n end\n d\n end",
"def locale_backend; end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end",
"def humanize(lang = :en)\n t = object.strftime(\"%r\")\n if timezone?\n z = @zone == '+00:00' ? \"UTC\" : @zone\n t += \" #{z}\"\n end\n t\n end",
"def with_locale(tmp_locale = T.unsafe(nil)); end"
] |
[
"0.75768316",
"0.75768316",
"0.7388077",
"0.7198687",
"0.7198687",
"0.7198687",
"0.71979046",
"0.7187928",
"0.7187928",
"0.7186119",
"0.7021551",
"0.68252957",
"0.6588167",
"0.65228957",
"0.62908906",
"0.62176716",
"0.60762066",
"0.60624653",
"0.59500843",
"0.59500843",
"0.59500843",
"0.59500843",
"0.59500843",
"0.59500843",
"0.59500843",
"0.59313047",
"0.5909657",
"0.5870045",
"0.585842",
"0.5852378",
"0.58100474",
"0.5768959",
"0.5759063",
"0.57516897",
"0.5733987",
"0.5733719",
"0.56941974",
"0.568869",
"0.56654054",
"0.56543505",
"0.5645442",
"0.5645442",
"0.56173795",
"0.56119937",
"0.559937",
"0.5598893",
"0.5562217",
"0.55484414",
"0.55484414",
"0.55408347",
"0.5536918",
"0.55244154",
"0.5519757",
"0.55186665",
"0.5492927",
"0.54850864",
"0.5472812",
"0.5469334",
"0.54625875",
"0.5449981",
"0.54385805",
"0.5427647",
"0.54251534",
"0.54228896",
"0.5417767",
"0.54137105",
"0.54133683",
"0.5412344",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.54004467",
"0.5399401",
"0.53863555",
"0.53858566",
"0.53809786",
"0.53754",
"0.5368735",
"0.5366867",
"0.53638405",
"0.5360501",
"0.5360501",
"0.53520566",
"0.53520566",
"0.53519523",
"0.53415865",
"0.5341207",
"0.5336824",
"0.5319717",
"0.53040975"
] |
0.7558665
|
2
|
Merges the given locale, key and scope into a single array of keys. Splits keys that contain dots into multiple keys. Makes sure all keys are Symbols. source://i18n//lib/i18n.rb332
|
def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def translate_options(keys, scope)\n keys.map{|k| [t(k, :scope => scope), k]}\n end",
"def lookup(locale, key, scope = [], separator = nil)\n return unless key\n keys = I18n.send(:normalize_translation_keys, locale, key, scope)\n @moneta[keys.join('.')]\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def expand_keys(key)\n key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, k|\n keys << [keys.last, k].compact.join(FLATTEN_SEPARATOR)\n end\n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def translate(locale, key, options = {})\n new_key = normalize_flat_keys(locale, key, options[:scope], options[:separator])\n content = super\n store_translations(locale, DynamicCopy.convert_to_hash(new_key, content), :escape => false) unless store[\"#{locale}.#{new_key}\"]\n content.respond_to?(:html_safe) ? content.html_safe : content\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def scope_names\n keys.map { |k| k.to_s }\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def composite_keys \n Hash.new.tap do |hash|\n SPREE_MODULES.each do |mod|\n hash.merge! get_translation_keys(\"spree_#{mod}\")\n end\n end\n end",
"def merge_names(locale, data)\n locale = locale.to_sym\n names[locale] ||= {}\n data = deep_symbolize_keys(data)\n \n # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n names[locale].merge!(data, &merger)\n end",
"def expand_key( key )\n ek = case key\n when Array\n key\n when /\\./\n key.split(\".\")\n else\n [ key ]\n end\n ek.select { |k| k.to_s.strip.length > 0 }\n end",
"def composite_keys \n api_keys = get_translation_keys \"spree_api\"\n auth_keys = get_translation_keys \"spree_auth\"\n core_keys = get_translation_keys \"spree_core\"\n dash_keys = get_translation_keys \"spree_dash\"\n promo_keys = get_translation_keys \"spree_promo\"\n\n api_keys.merge(auth_keys).merge(core_keys).merge(dash_keys).merge(promo_keys)\nend",
"def join_keys *segments\n segments.map(&:to_s).select(&:present?).join(\".\")\n end",
"def normalize\n inject({}) do |hash, kv|\n k, v = kv\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n hash[k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join] = v\n hash\n end\n end",
"def slice(*keys) = Locale.new(deconstruct_keys(keys.map(&:to_sym)))",
"def prepare_key(key, options)\n complete_key = key\n\n # if a scope is passed in options then build the full key\n complete_key = options[:scope].present? ? \"#{options[:scope].to_s}.#{complete_key}\" : complete_key\n\n # add the correct count suffix\n if options[:count].present? && options[:count] == 1\n complete_key = \"#{complete_key}.one\"\n elsif options[:count].present? && options[:count] != 1\n complete_key = \"#{complete_key}.other\"\n end\n complete_key\n end",
"def with_namespaces_key_for(keys = EMPTY_ARRAY)\n [*namespaces, *keys].join('_').upcase\n end",
"def with_namespaces_key_for(keys = EMPTY_ARRAY)\n [*namespaces, *keys].join('_').upcase\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def load_translations( locale, base_locale=\"en\", type=\"all\", scope=\"\" )\n \n @files ||= load_files\n @languages = @files[:translations].keys.sort {|x,y| x.to_s <=> y.to_s }\n \n # Convert hash to scope string\n global = scopize( @files[:globals] )\n base = scopize( @files[:translations][base_locale.to_sym] )\n dest = scopize( @files[:translations][locale.to_sym] )\n translation = {}\n \n reg = Regexp.new( '^' + Regexp.escape( scope ))\n \n # Process all keys from all locales\n global.keys.each do |key| \n if((type == \"all\") or (type==\"untranslated\" and dest[key].nil?) or (type == \"translated\" and not ( dest[key].nil? )))\n if scope.empty? or key.match( reg )\n case base[key]\n when Hash\n value_type = \"hash\"\n when Array\n value_type = \"array\"\n when TrueClass, FalseClass\n value_type = \"bool\"\n else\n value_type = \"string\"\n end\n \n translation[key] = { \n :base => base[key].nil? ? \"Not translated in base [#{base_locale}]\" : base[key],\n :value => dest[key],\n :type => value_type,\n }\n end\n end\n end\n \n return translation\n end",
"def reconstruct flat_hash\n flat_hash.inject({}) do |result, (key, value)|\n # Build the nested hash for a single key/value pair\n hash = key.split(\".\").reverse.inject(value) do |r, e|\n { e => r }\n end\n\n result.deep_merge(hash)\n end\nend",
"def normalize\n @parameters.inject({}) do |hash, (k, v)|\n v = v.is_a?(Array) ? v.join(',') : v.to_s\n k = k.to_s.split('_').map {|w| w[0, 1] = w[0, 1].upcase; w }.join\n hash[k] = v\n\n hash\n end\n end",
"def escape_translation_key(key, scope=nil, separator=nil)\n scope ? \"#{scope}#{separator || I18n.default_separator}\\\"#{key}\\\"\" : \"\\\"#{key}\\\"\"\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def normalize_language_keys(options)\n (LOCALISED_VERSION_VALUES.keys + LOCALISED_APP_VALUES.keys).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n current.keys.each do |language|\n current[language.to_s] = current.delete(language)\n end\n end\n\n options\n end",
"def normalize_language_keys(options)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n current = options[key]\n next unless current && current.kind_of?(Hash)\n\n current.keys.each do |language|\n current[language.to_s] = current.delete(language)\n end\n end\n\n options\n end",
"def translate_all(keys)\n translator = I27r::Translator.new locale_name.sub(/\\-.*/, '')\n\n ActiveSupport::OrderedHash.new.tap do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n Rails.logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.backend.send(:lookup, locale_name, key_suffix, key_prefix)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.backend.send(:lookup, locale_name, key)\n oh[key] = existing_translation ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def pluralized_array_from_hash(hash, singular_key, plural_key); end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def keystroke_translations\n @keystroke_translations ||= begin\n hash = { \"\\n\" => \"return\",\n \"\\\\\" => \"\\\\\\\\\",\n \"\\\"\" => \"\\\\\\\"\" }\n hash.default_proc = proc { |hash,key| hash[key] = \"\\\"#{key}\\\"\" }\n hash\n end\n end",
"def with_prefixes_namespaces_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *namespaces, *keys].join('_').upcase\n end",
"def with_prefixes_namespaces_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *namespaces, *keys].join('_').upcase\n end",
"def scope_to_hash(keys_case=:undescore)\n\t\tend",
"def environment_item prefix, key, value\n {Oaf::Util.prepare_key(prefix, key) => Oaf::Util.flatten(value)}\n end",
"def keys_to_sym clean: false\n self.inject({}){|memo,(k,v)| memo[clean ? k.to_s.to_clean_sym : k.to_s.to_sym] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_sym(clean:clean) : v); memo}\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def keys_for(key = EMPTY_STRING)\n key.split(NAMESPACE_PATTERN)\n end",
"def keys_for(key = EMPTY_STRING)\n key.split(NAMESPACE_PATTERN)\n end",
"def to_flat include_key=true\n if include_key.is_a? Proc\n sort_key = include_key.call(self)\n elsif include_key && respond_to?(:key)\n sort_key = [self.class.resource_name, key].flatten.join(\"-\")\n else\n sort_key = self.class.resource_name\n end\n [sort_key, *to_a.map(&:to_flat)]\n end",
"def normalize_abbreviation_key(key); end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end",
"def [](key)\n key.to_s.split(\".\").inject(@values) { |v, k| v[k] if v }\n end",
"def search_conditions_as_hash(locale)\n [\n { :value => I18n.t(\"advanced_searches.text_search_field.all_words\", locale: locale), :key => \"all_words\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.one_word\", locale: locale), :key => \"one_word\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.exact\", locale: locale), :key => \"exact\"}\n ]\n end",
"def normalize_keys(hash)\n hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)|\n new_hash[key.parameterize(separator: \"_\")] = value\n new_hash\n end\n end",
"def _cache_key(*keys)\n # monkey patch to avoid SystemStackError: stack level too deep \n if keys.to_s.include?(\"i18n_transliterate_rule\")\n keys.to_s\n else\n keys.map(&:to_s).join(\" \").parameterize.underscore \n end \n end",
"def dot_key_values(hash)\n hash.map{|k,v| \n \"#{k}=\\\"#{ v.to_s.gsub(/\"/, \"''\" ).gsub(\"\\n\",' ') }\\\"\" \n }.join(', ') rescue \"boh1235: #{$!}\"\n end",
"def lookup(locale, key, scope = [], options = {})\r\n return '' if translations_blocked\r\n\r\n if ::LinguaFranca.debugging? && available_locales.include?(::LinguaFranca.debugging)\r\n locale = ::LinguaFranca.debugging\r\n end\r\n\r\n result = super(locale, key, scope, options)\r\n\r\n key = key_name(key, scope)\r\n\r\n return result\r\n end",
"def get_count_keys(locale, key)\r\n empty_translations = {}\r\n store_empty_translations = false\r\n count_keys = I18n.t!('i18n.plural.keys', :locale => locale).inject({}) do |result, plural_key|\r\n full_key = \"#{key}.#{plural_key}\"\r\n value = get_translate(locale, full_key)\r\n if value\r\n store_empty_translations = true\r\n result.merge plural_key.to_s => value\r\n else\r\n empty_translations.merge! full_key => \"\"\r\n result\r\n end\r\n end\r\n if store_empty_translations && empty_translations.present?\r\n I18n.backend.store_translations locale, empty_translations, :escape => false\r\n end\r\n count_keys\r\n rescue\r\n {}\r\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def format_keys(resource)\n resource.keys.reduce({}) do |memo, key|\n value = resource[key]\n\n formatted_key = Ubw::Util.snakify(key)\n formatted_key << '?' if !!value == value # Add a ? to the key if value is a Boolean\n\n memo[formatted_key] = value\n\n memo\n end\n end",
"def filter(translations, scopes)\n scopes = scopes.split(\".\") if scopes.is_a?(String)\n scopes = scopes.clone\n scope = scopes.shift\n\n if scope == \"*\"\n results = {}\n translations.each do |scope, translations|\n tmp = scopes.empty? ? translations : filter(translations, scopes)\n results[scope.to_sym] = tmp unless tmp.nil?\n end\n return results\n elsif translations.has_key?(scope.to_sym)\n return {scope.to_sym => scopes.empty? ? translations[scope.to_sym] : filter(translations[scope.to_sym], scopes)}\n end\n nil\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def possible_namespaces\n namespaces = []\n key = @key.to_s\n while (index = key.rindex('_'))\n key = key[0, index]\n namespaces << key.to_sym\n end\n namespaces\n end",
"def inject_facet(facet, key)\n case key\n when Symbol, String\n facet[key.to_sym] = {}\n when Hash\n facet.deep_merge! key\n when Array\n key.each { |k| inject_facet(facet, k) }\n end\n facet\n end",
"def translate_all(keys)\n returning ActiveSupport::OrderedHash.new do |oh|\n # fix the order first(for multi thread translating)\n keys.each do |key|\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n key_prefix.inject(oh) {|h, k| h[k] ||= ActiveSupport::OrderedHash.new}[key_suffix] = nil\n else\n oh[key] = nil\n end\n end\n threads = []\n keys.each do |key|\n threads << Thread.new do\n logger.debug \"translating #{key} ...\"\n Thread.pass\n if key.to_s.include? '.'\n key_prefix, key_suffix = key.to_s.split('.')[0...-1], key.to_s.split('.')[-1]\n existing_translation = I18n.t(key, :default => key_suffix, :locale => locale_name)\n key_prefix.inject(oh) {|h, k| h[k]}[key_suffix] = existing_translation != key_suffix ? existing_translation : translator.translate(key_suffix)\n else\n existing_translation = I18n.t(key, :default => key, :locale => locale_name)\n oh[key] = existing_translation != key ? existing_translation : translator.translate(key)\n end\n end\n end\n threads.each {|t| t.join}\n end\n end",
"def group_keys(include_all = false)\n keys = @group.entries(include_all).collect {|e| e.key }\n unless @group.key.blank?\n keys.collect! {|k| k.gsub(@group.key + '.', '') }\n end\n keys\n end",
"def keys(key)\n Array(@nesting) + Array(key)\n end",
"def i18n_keys(attr = nil, model = nil)\n values = { type: self.class.type_name, value: to_s }\n list_from = :i18n_type_scopes\n\n if attr && model\n values[:attr] = attr\n values[:model] = model.model_name.i18n_key\n list_from = :i18n_scopes\n end\n\n Torque::PostgreSQL.config.enum.send(list_from).map do |key|\n (key % values).to_sym\n end\n end",
"def buffer_key(key, opts)\n # covert keys to strings, as sorting a Hash with Symbol keys fails on\n # Ruby 1.8.x.\n opts = opts.inject({}) do |result, (k, v)|\n result[k.to_s] = v\n result\n end\n \"#{key.to_s}:#{opts.sort.flatten.join(':')}\"\n end",
"def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def expanded_key(key) # :nodoc:\n return validate_key(key.cache_key.to_s) if key.respond_to?(:cache_key)\n\n case key\n when Array\n if key.size > 1\n key = key.collect{|element| expanded_key(element)}\n else\n key = key.first\n end\n when Hash\n key = key.sort_by { |k,_| k.to_s }.collect{|k,v| \"#{k}=#{v}\"}\n end\n\n validate_key(key.respond_to?(:to_param) ? key.to_param : key)\n end",
"def normalize_keys(keys, pressed_keys = [], memo = [])\n case keys\n when Array\n raise ArgumentError, \"empty keys passed\" if keys.empty?\n\n pressed_keys.push([])\n memo += combine_strings(keys).map do |key|\n normalize_keys(key, pressed_keys, memo)\n end\n pressed_keys.pop\n memo.flatten.compact\n when Symbol\n key = keys.to_s.downcase\n\n if MODIFIERS.keys.include?(key)\n pressed_keys.last.push(key)\n nil\n else\n key = KEYS.fetch(KEYS_MAPPING[key.to_sym] || key.to_sym)\n key[:modifiers] = pressed_keys.flatten.map { |k| MODIFIERS[k] }.reduce(0, :|)\n to_options(key)\n end\n when String\n raise ArgumentError, \"empty keys passed\" if keys.empty?\n\n pressed = pressed_keys.flatten\n keys.each_char.map do |char|\n key = KEYS[char] || {}\n\n if pressed.empty?\n key = key.merge(text: char, unmodifiedText: char)\n [to_options(key)]\n else\n text = pressed == [\"shift\"] ? char.upcase : char\n key = key.merge(\n text: text,\n unmodifiedText: text,\n isKeypad: key[\"location\"] == 3,\n modifiers: pressed.map { |k| MODIFIERS[k] }.reduce(0, :|)\n )\n\n modifiers = pressed.map { |k| to_options(KEYS.fetch(KEYS_MAPPING[k.to_sym])) }\n modifiers + [to_options(key)]\n end.flatten\n end\n else\n raise ArgumentError, \"unexpected argument\"\n end\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def with_prefixes_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *keys].join('_').upcase\n end",
"def with_prefixes_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *keys].join('_').upcase\n end",
"def normalize_key(key, options = nil)\n str_key = expanded_key(key)\n raise(ArgumentError, \"key cannot be blank\") if !str_key || str_key.empty?\n\n namespace_key str_key, options\n end",
"def export\n keys = {}\n reset\n db_localizations = {}\n Lit::Localization.find_each do |l|\n db_localizations[l.full_key] = l.get_value\n end\n db_localizations.sort.each do |(l_key, value)|\n current = keys\n yaml_keys = l_key.split('.')\n\n 0.upto(yaml_keys.size - 2) do |i|\n key = yaml_keys[i]\n # Overwrite en.key with en.sub.key\n unless current[key].class == Hash\n current[key] = {}\n end\n current = current[key]\n end\n current[yaml_keys.last] = value\n end\n keys.to_yaml\n end",
"def stringify_keys\n inject({}) do |options, (key, value)|\n options[(key.to_s rescue key) || key] = value\n options\n end\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def namespaced(key)\n return [@namespace, key].join(':')\n end",
"def namespaced(key)\n return [@namespace, key].join(':')\n end",
"def keys\n return full_path.to_s.split('.') if full_path\n return [key.to_s] unless path&.present?\n\n [path, key].compact.join('.').split('.')\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def key_name_groups\n KEY_NAME_GROUPS.map { |kn| const_get kn }\n end",
"def dot_key_array\n return ['label', 'label and hint','message','message error', 'message info','message success','message warning','model','model and menu','action', 'lookup']\n end",
"def convert_keys_to_symbols_recursive(obj)\n if obj.is_a?(Hash)\n if var_name = mangled_mustache_variable?(obj)\n return \"{{#{var_name}}}\"\n end\n obj.keys.inject({}) do |h, k| \n # Complication due to fact that keys can be misformed, such as due to yaml parsing of form port: {{port}}\n if k.respond_to?(:to_sym)\n h.merge(k.to_sym => convert_keys_to_symbols_recursive(obj[k]))\n else\n Log.error_pp([\"Unexpected hash key:\",k])\n h.merge(k => convert_keys_to_symbols_recursive(obj[k]))\n end\n end\n elsif obj.is_a?(Array)\n obj.map { |el| convert_keys_to_symbols_recursive(el) }\n else\n obj\n end\n end",
"def rubyize_keys\n transform_keys do |key|\n key\n .to_s\n .gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n .gsub(/([a-z\\d])([A-Z])/, '\\1_\\2')\n .downcase\n .to_sym\n end\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def join_keys(hash, parent_keys = [])\n hash.inject([]) do |keys, (key, value)|\n full_key = parent_keys + [key]\n if value.is_a?(Hash)\n keys += join_keys(value, full_key)\n elsif !value.nil?\n keys << [full_key.join('.'), parse_value(value)]\n end\n keys\n end\n end",
"def entry_keys(include_all = true)\n keys = @group.entries(include_all).collect {|e| e.key }\n unless @group.key.blank?\n keys.collect! {|k| k.gsub(@group.key + '.', '') }\n end\n keys\n end",
"def to_dotted_args args\n args.map do |k,v|\n if v.is_a?(Hash)\n to_dotted_args(v).map do |s|\n [k,s].join(\".\")\n end\n else\n \"#{k}=#{v}\"\n end\n end.flatten\n end",
"def symbolize_keys\r\n inject({}) do |options, (key, value)|\r\n options[(key.to_sym rescue key) || key] = value\r\n options\r\n end\r\n end",
"def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end",
"def symbolize_keys_rec\n if is_a?(Hash)\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = (value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value\n options\n end\n elsif is_a?(Array)\n inject([]) do |options, value|\n options << ((value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value)\n options\n end\n else\n raise Exception.new(\"Can't do that!\")\n end\n end",
"def localize(key, options = {})\n I18n.localize(key, options.merge(:locale => self.locale))\n end",
"def key_for(key)\n key_parts = []\n key_parts << @namespace if @namespace && @namespace.length > 0\n \n # Gracefully handles arrays passed here as well, due to the flatten\n key_parts << key\n key_parts.flatten.join ':'\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end"
] |
[
"0.7766871",
"0.72663033",
"0.72663033",
"0.7161529",
"0.6404735",
"0.6251713",
"0.6175191",
"0.5956065",
"0.5935087",
"0.56829524",
"0.5657044",
"0.55625105",
"0.5553841",
"0.55200654",
"0.5452371",
"0.5416747",
"0.539464",
"0.5330687",
"0.53244793",
"0.53172946",
"0.5278677",
"0.5259505",
"0.5185642",
"0.5185642",
"0.51680267",
"0.51680267",
"0.51630056",
"0.5120903",
"0.50906044",
"0.50893086",
"0.5073267",
"0.5072876",
"0.5068973",
"0.50544965",
"0.5036589",
"0.5033214",
"0.49886522",
"0.49886355",
"0.49886355",
"0.4971927",
"0.49647424",
"0.4950083",
"0.49463648",
"0.49374184",
"0.49374184",
"0.49200326",
"0.49065262",
"0.49006924",
"0.4893309",
"0.4891216",
"0.48895893",
"0.48773172",
"0.48754972",
"0.4868737",
"0.48615766",
"0.48583734",
"0.48580617",
"0.48564446",
"0.48537904",
"0.48102394",
"0.48080412",
"0.48040086",
"0.47993183",
"0.47982338",
"0.47971922",
"0.47933146",
"0.47890815",
"0.4784373",
"0.47804952",
"0.47673208",
"0.47663486",
"0.47657514",
"0.47657514",
"0.47655743",
"0.47654024",
"0.4760087",
"0.47517338",
"0.47517338",
"0.47517338",
"0.4750464",
"0.4750074",
"0.4750074",
"0.47339797",
"0.47339797",
"0.47337827",
"0.47215748",
"0.47165167",
"0.47145438",
"0.4693412",
"0.46855962",
"0.4680862",
"0.46700045",
"0.46586013",
"0.465199",
"0.46483502",
"0.46480703",
"0.4647112",
"0.46414143",
"0.46391553",
"0.46354765"
] |
0.7111197
|
4
|
Tells the backend to reload translations. Used in situations like the Rails development environment. Backends can implement whatever strategy is useful. source://i18n//lib/i18n.rb82
|
def reload!; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def use_i18n; end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def translations; end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def init_translations; end",
"def reset_i18n()\n I18n.backend = I18n::Backend::Simple.new\nend",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def reload!\n @initialized = false\n @translations = nil\n super\n end",
"def use_i18n=(value); end",
"def reload\n @@languages.each do |lang_code, lang_file|\n lang_file.reload\n end\n end",
"def get_translations\n I18n.translate(:foo) # Need to do this to force I18n init\n I18n.backend.send(:translations)\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def update_translations(locale, data)\n set_translations(locale, application.cache_translations(\n locale,\n key,\n data.is_a?(Hash) ? data['translations'] : data\n ))\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def set_locale\n set_I18n_locale(params[:locale]) # Merken in Client_Info_Cache\n\n respond_to do |format|\n format.js {render :js => \"window.location.reload();\" } # Reload der Sganzen Seite\n end\n end",
"def operate_switch_language(code)\n #callback(:before_switch_language)\n @translation_cache = {} if @translation_cache.nil?\n facet_names = self.class.globalize_facets\n @translation_cache[language_code] = @attributes.dup.delete_if {|key, value| !facet_names.include? key.to_sym}\n Locale.switch(code) do\n set_original_language\n if @translation_cache.include? code\n @attributes.update @translation_cache[code]\n elsif @original_language == Locale.base_language and !@new_record\n reload\n elsif !@new_record\n trs = ModelTranslation.find(:all, \n :conditions => [ \"table_name = ? AND item_id = ? AND language_id = ? AND \" +\n \"facet IN (#{[ '?' ] * facet_names.size * ', '})\", self.class.table_name,\n self.id, @original_language.id ] + facet_names.map {|facet| facet.to_s} )\n trs ||= []\n trs.each do |tr|\n attr = tr.text || base[tr.facet.to_s]\n write_attribute( tr.facet, attr )\n end\n end\n \n operate_switch_language_on_associations(code)\n \n #callback(:after_switch_language)\n end\n end",
"def translate(settings); end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def reload_rh_texts\n langs = Dir[\"Data/Text/Dialogs/#{CSV_BASE}.*.dat\"].collect { |i| i.match(/[0-9]+\\.([a-z]+)\\.dat$/).captures[0] }\n if langs.empty? ||\n File.mtime(\"Data/Text/Dialogs/#{CSV_BASE}.#{langs.first}.dat\") < File.mtime(\"Data/Text/#{langs.first}.dat\")\n langs << GamePlay::Load::DEFAULT_GAME_LANGUAGE if langs.empty?\n log_debug('Updating Text files')\n filename = 'plugins/text2csv' # Just to avoid the warning\n require filename\n Available_Langs.clear\n Available_Langs.concat(langs)\n log_debug('Compiling Text files')\n compile\n end\n end",
"def translations\n @translations ||= {}\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def generate\n I18n.backend.load_translations\n translations = wrap(source_translations)\n I18n.backend.store_translations(destination_locale, translations)\n I18n.available_locales += [destination_locale]\n end",
"def translatable\n self._translatable[base_name]\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def set_locale\n end",
"def language_server; end",
"def set_gettext_locale_db\n params[:locale] ||= User.current.try(:locale)\n end",
"def show\n if Delayed::Job.any?\n @lang_update_status = :running\n else\n @lang_update_status ||= :default\n end\n @path_langu = request.path.starts_with? '/langu'\n end",
"def update\r\n\r\n data = params.except(:action, :controller, :options)\r\n options = params[:options]\r\n translations = GetPomo::PoFile.parse(File.read(\"#{Rails.root}/po/#{options[\"locale\"]}/#{APP_SID}.po\"))\r\n\r\n # Find translation\r\n\r\n @locale = translations.find { |t| t.comment == data[\"comment\"] }\r\n index = translations.find_index(@locale)\r\n\r\n # Edit translation\r\n\r\n @locale.msgid = data[\"msgid\"]\r\n @locale.msgstr = data[\"msgstr\"]\r\n @locale.comment = data[\"comment\"]\r\n if data.has_key?(\"fuzzy\") and data[\"fuzzy\"] == \"on\"\r\n @locale.comment += \", fuzzy\\n\" if @locale.fuzzy?.nil?\r\n else\r\n @locale.comment.slice! \", fuzzy\\n\" unless @locale.fuzzy?.nil?\r\n end\r\n\r\n # Replace translation\r\n\r\n translations[index] = @locale\r\n\r\n # Create delayed job to rewrite the PO file asynchronously\r\n\r\n Delayed::Job.enqueue WritePo.new(options[\"locale\"], GetPomo::PoFile.to_text(translations))\r\n render :json => @locale\r\n end",
"def change_lang\n eng = :en\n jap = :ja\n if I18n.locale == eng\n params[:locale] = :ja\n I18n.locale = :ja\n elsif I18n.locale == jap\n params[:locale] = :en\n I18n.locale = :en\n end\n end",
"def on_fallback(_original_locale, _fallback_locale, _key, _options); end",
"def switch_to(text_domain, locale)\n @store[text_domain] ||= {}\n @store[text_domain][locale] ||= {}\n @store[text_domain][locale][\"\"] = false # ignore gettext meta key when translating\n @current = @store[text_domain][locale]\n end",
"def translation\r\n translation_for(Mongoid::Globalize.locale)\r\n end",
"def show_translation\n @translations = load_translations( @locale, @base_locale )\n render :partial => \"i18n_ui/translation_body\", :locals => { :key => params[:key], :tr => @translations[params[:key]]}, :layout => nil\n end",
"def locale_backend; end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def apply_locale; end",
"def index\n @translations = TRANSLATION_STORE\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def old_translation\n id = params[:id].to_s\n str = TranslationString::Version.find(id)\n render(text: str.text)\n end",
"def save_translations\n return true unless translation_cache\n \n translation_cache.each do |code, attrs|\n switch_language(code) do\n @attributes.update attrs\n update_translation\n end\n end\n true\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def translate_external(facets, options)\n facets_string = \"[\" + facets.map {|facet| \":#{facet}\"}.join(\", \") + \"]\"\n class_eval <<-HERE\n @@facet_options = {}\n attr_writer :fully_loaded\n def fully_loaded?; @fully_loaded; end\n @@globalize_facets = #{facets_string}\n @@preload_facets ||= @@globalize_facets\n class << self\n\n def sqlite?; defined?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) and connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter); end\n\n def globalize_facets\n @@globalize_facets\n end\n\n def globalize_facets_hash\n @@globalize_facets_hash ||= globalize_facets.inject({}) {|hash, facet|\n hash[facet.to_s] = true; hash\n }\n end\n\n def untranslated_fields\n @@untranslated_fields ||=\n column_names.map {|cn| cn.intern } - globalize_facets\n end\n\n def preload_facets; @@preload_facets; end\n def postload_facets\n @@postload_facets ||= @@globalize_facets - @@preload_facets\n end\n alias_method :globalize_old_find_every, :find_every unless\n respond_to? :globalize_old_find_every\n end\n alias_method :globalize_old_reload, :reload\n alias_method :globalize_old_destroy, :destroy\n alias_method :globalize_old_create_or_update, :create_or_update\n alias_method :globalize_old_update, :update\n\n include Globalize::DbTranslate::TranslateObjectMethods\n extend Globalize::DbTranslate::TranslateClassMethods\n\n HERE\n\n facets.each do |facet|\n bidi = (!(options[facet] && !options[facet][:bidi_embed])).to_s\n class_eval <<-HERE\n @@facet_options[:#{facet}] ||= {}\n @@facet_options[:#{facet}][:bidi] = #{bidi}\n\n def #{facet}\n if not_original_language\n raise WrongLanguageError.new(@original_language, Locale.language)\n end\n load_other_translations if\n !fully_loaded? && !self.class.preload_facets.include?(:#{facet})\n result = read_attribute(:#{facet})\n return nil if result.nil?\n result.direction = #{facet}_is_base? ?\n (Locale.base_language ? Locale.base_language.direction : nil) :\n (@original_language ? @original_language.direction : nil)\n\n # insert bidi embedding characters, if necessary\n if @@facet_options[:#{facet}][:bidi] &&\n Locale.language && Locale.language.direction && result.direction\n if Locale.language.direction == 'ltr' && result.direction == 'rtl'\n bidi_str = \"\\xe2\\x80\\xab\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n elsif Locale.language.direction == 'rtl' && result.direction == 'ltr'\n bidi_str = \"\\xe2\\x80\\xaa\" + result + \"\\xe2\\x80\\xac\"\n bidi_str.direction = result.direction\n return bidi_str\n end\n end\n\n return result\n end\n\n def #{facet}=(arg)\n raise WrongLanguageError.new(@original_language, Locale.language) if\n not_original_language\n write_attribute(:#{facet}, arg)\n end\n\n def #{facet}_is_base?\n self['#{facet}_not_base'].nil?\n end\n HERE\n end\n end",
"def on_load_language; load_language('lang/login'); end",
"def fillin_translations\n collection_types = Hyrax::CollectionType.all\n collection_types.each do |c|\n next unless c.title =~ /^translation missing/\n oldtitle = c.title\n c.title = I18n.t(c.title.gsub(\"translation missing: en.\", ''))\n c.save\n Rails.logger.debug \"#{oldtitle} changed to #{c.title}\"\n end\n end",
"def test_gettext_support\n ### FIXME: how to set \"en\" as gettext's default language?\n\n t = MyTestCell.new(@controller)\n c = render_cell_state(t, :view_with_explicit_english_translation)\n\n # the view \"view_with_explicit_english_translation_en\" exists, check if\n # gettext/rails found it:\n if Object.const_defined?(:GetText)\n assert_selekt c, \"#defaultTranslation\", 0\n assert_selekt c, \"#explicitEnglishTranslation\"\n else\n assert_selekt c, \"#defaultTranslation\"\n end\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def set_website_locale\n app_locales = %w(es ca)\n I18n.locale = params[:lang] if app_locales.include?(params[:lang])\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def update\n files = Dir[Rails.root.join(\"config\", \"locales\", \"*.yml\").to_s]\n\n @languages = {}\n files.each do |f|\n ar = YAML.load_file f\n lang = ar.keys.first\n if @languages.has_key?(lang.to_s)\n @languages[lang.to_s] = @languages[lang.to_s].deep_merge(ar.first[1])\n else\n @languages[lang.to_s] = ar.first[1]\n end\n end\n\n sync(@languages[I18n.default_locale.to_s])\n end",
"def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end",
"def activate\n\tAVAILABLE_LOCALES.clear.merge!('en-US' => \"English US\", 'mx' =>\"Spanish ES\")\n end",
"def current_language=(new_lang)\n if loaded_languages.include? new_lang.to_sym\n @@current_language = new_lang.to_sym\n else\n raise LangFileNotLoaded.new(new_lang, loaded_languages)\n end\n end",
"def current_language=(new_lang)\n if loaded_languages.include? new_lang.to_sym\n @@current_language = new_lang.to_sym\n else\n raise LangFileNotLoaded.new(new_lang, loaded_languages)\n end\n end",
"def set_locale\n if params[:controller] == \"rails_admin/main\"\n I18n.locale = :en\n else\n I18n.locale = :ru\n end\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def translated_legs(locale=I18n.default_locale)\n OTPTranslator.new(locale).translate_legs(legs)\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def original_to_translation(language, original)\n\t\t\t\t\t\tload_cache(language)\n\t\t\t\t\t\treturn @o2t[language.to_sym][original.to_s]\n\t\t\t\t\tend",
"def set_language_from\n session[:lang_from] = params[:lang].to_sym\n I18n.locale = session[:lang_from]\n render nothing: true\n end",
"def index\n @translations = @locale.translations.all(:order => \"raw_key, pluralization_index\")\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def reload\r\n translated_attribute_names.each { |name| @attributes.delete(name.to_s) }\r\n globalize.reset\r\n super\r\n end",
"def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend"
] |
[
"0.70088494",
"0.68589634",
"0.6840616",
"0.68170846",
"0.6731393",
"0.6637949",
"0.6619912",
"0.65739566",
"0.65739566",
"0.6521624",
"0.6493551",
"0.6387629",
"0.634272",
"0.63236946",
"0.6250576",
"0.62379646",
"0.6229648",
"0.6199509",
"0.6189279",
"0.61372334",
"0.6073666",
"0.6033724",
"0.60148335",
"0.60103124",
"0.60013086",
"0.5976807",
"0.5965293",
"0.59181434",
"0.59150076",
"0.5896469",
"0.58577603",
"0.5780258",
"0.577152",
"0.5770686",
"0.5754861",
"0.5729999",
"0.57185465",
"0.571463",
"0.5710354",
"0.56845134",
"0.5666955",
"0.5657828",
"0.564384",
"0.5639912",
"0.56383246",
"0.5626514",
"0.56211334",
"0.5618151",
"0.5611073",
"0.5599708",
"0.55921763",
"0.55818033",
"0.5578087",
"0.55773586",
"0.55748665",
"0.5574499",
"0.5573843",
"0.556448",
"0.5563216",
"0.55622196",
"0.5558395",
"0.5543045",
"0.5538372",
"0.5535728",
"0.5525787",
"0.55170065",
"0.55151874",
"0.55122197",
"0.550907",
"0.550907",
"0.5498981",
"0.5497317",
"0.5495615",
"0.5489389",
"0.54889876",
"0.54849887",
"0.5475905",
"0.54746056",
"0.54708564",
"0.54708564",
"0.5470065",
"0.5466582",
"0.5466582",
"0.54589325",
"0.545729",
"0.54539555",
"0.54535544",
"0.5452404",
"0.5450972",
"0.5448077",
"0.54426247",
"0.54351234",
"0.54235095",
"0.54224676",
"0.54224676",
"0.54224676",
"0.54224676",
"0.54224676",
"0.54224676",
"0.54224676",
"0.54224676"
] |
0.0
|
-1
|
Wrapper for translate that adds :raise => true. With this option, if no translation is found, it will raise I18n::MissingTranslationData source://i18n//lib/i18n.rb229
|
def t!(key, **options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def t(key, options = {})\n options[:raise] = true\n translate(key, options)\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def translate(input_text, src_lang, target_lang)\n raise \"Not Implemented. Class #{self.class.name} doesn't implement translate\"\n end",
"def translate(*args, **opts); end",
"def translate(item)\n @progress.setMainStatusAndLogIt('Translating')\n text = get_original_text(item)\n return nil if text.empty?\n\n translated = ms_translate(text)\n super(item, translated) unless translated.nil? || translated.empty?\n end",
"def translate!(key, **options); end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def translated_msg(translate, message, src_lang, target_lang)\n return message unless translate \n use_src = nil \n if (src_lang.nil? || src_lang.empty?)\n # We don't need to infer again and again\n begin\n @inferred_src_lang ||= infer_languages.first\n rescue StandardError => e \n raise LangDetectionFailureException.new(\"Failed to infer language due to #{e.message}\")\n end\n use_src = @inferred_src_lang\n else\n use_src = src_lang\n end\n return message if use_src.eql?(target_lang)\n @translator.translate(message, use_src, target_lang)\n end",
"def translate key = nil, retries: nil, timeout: nil\n require \"gcloud/translate\"\n Gcloud.translate key, retries: (retries || @retries),\n timeout: (timeout || @timeout)\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def translate_exception(e, message)\n case e.message\n when /violation of FOREIGN KEY constraint/\n InvalidForeignKey.new(message, e)\n when /violation of PRIMARY or UNIQUE KEY constraint/\n RecordNotUnique.new(message, e)\n else\n super\n end\n end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def i18n_set?(key, params = {})\n I18n.t key, params, :raise => true rescue false\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def silence_errors\n require 'fast_gettext/translation_repository/base'\n translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale')\n end",
"def translate!(text, *languages)\n languages = Translations.keys unless languages.any?\n languages = languages.flatten.map!(&:to_sym)\n languages.delete :en # remove :en translation from everywhere\n languages.push :en # to push it as the last one\n languages.each do |lang|\n Translations[lang] && Translations[lang].call(text)\n end\n text\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def translate_exception(e)\n exception_translator.register_exception e\n end",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def translate(settings); end",
"def translate!( *args )\n super( *args )\n reset_positions_inside\n end",
"def translate(message)\n @messages[message] || message\n end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def translated?\n texts = errors.values.flatten.map(&:message)\n texts.select { |text| text.start_with?(\"translation missing\") }.empty?\n end",
"def translate(text:, from: nil, to:, **opts) # rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength\n raise NotImplementedError\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end",
"def translate(text, options = {})\n response = google_api_call(text,\"#{SERVICE}#{@from}%7C#{@to}#{TEXT_PAR}\",TranslationResponse)\n translation = options[:html] ? response.translation : CGI.unescapeHTML(response.translation)\n translation # return value\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def translations; end",
"def translate(klass, key, value)\n if defined?(I18n)\n super\n else\n value ? value.to_s.humanize.downcase : 'nil'\n end\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def translation_target\n super\n end",
"def translation_text_presence\n present = false\n translations.each {|t| present = true if !t.text.blank?}\n unless present\n errors.add 'translations.text', I18n.t(\n 'models.phrase.attributes.translations.min_amount',\n default: 'needs at least one translation'\n )\n end\n end",
"def command_translate\n command :translate do |c|\n c.syntax = 'budik translate [options]'\n c.summary = @str_translate.summary\n c.description = @str_translate.description\n c.action { |args, _opts| Command.new(:translate, args) }\n end\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate(details)\n self.translations = Hash[details.map { |k, v| [k.to_s, v.to_s] }].reverse_merge(translations)\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def i18n_set?(key)\n I18n.t key, raise: true\n rescue StandardError\n false\n end",
"def translator_missing?\n !yaml.key?(\"translator\")\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def translate(src_lang, target_lang, output_file)\n # Check if a non empty output file is present and error out to avoid\n # the danger or overwriting some important file !!\n if File.exists?(output_file) && File.size(output_file) > 0\n raise InvalidInputException.new(\"Output file #{output_file} is not empty.\")\n else\n # Just open the file in writable mode and close it just to ensure that\n # we can write the output file\n File.open(output_file, \"w\") {|f|\n }\n end\n # Check if the file is writable ?\n unless File.writable?(output_file)\n raise InvalidInputException.new(\"Output file #{output_file} not writable.\")\n end\n # Further checks can be done only in caption specific implementations\n # or translation engine specific implementation\n end",
"def translate(details)\n self.translations = Hash[details.map { |k,v| [k.to_s, v.to_s] }].reverse_merge(self.translations)\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def translate(response)\n end",
"def set_translator(translator)\n if translator && !(translator.is_a? Translator)\n raise InvalidInputException.new(\"Argument is not an instance of Translator\")\n end\n end",
"def t(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n translate_or_localize(key, options)\n end",
"def test_gettext_support\n ### FIXME: how to set \"en\" as gettext's default language?\n\n t = MyTestCell.new(@controller)\n c = render_cell_state(t, :view_with_explicit_english_translation)\n\n # the view \"view_with_explicit_english_translation_en\" exists, check if\n # gettext/rails found it:\n if Object.const_defined?(:GetText)\n assert_selekt c, \"#defaultTranslation\", 0\n assert_selekt c, \"#explicitEnglishTranslation\"\n else\n assert_selekt c, \"#defaultTranslation\"\n end\n end",
"def translate(text:, from: nil, to:, **opts)\n provider.translate(text: text, from: from, to: to, **opts)\n end",
"def translate(key, options)\n I18n.translate(\"#{BASE_KEY}.#{key}\", options)\n end",
"def translate(overwrite_user_edited_translations = false, translate_to = nil)\n translate_to ||= MuckContents.configuration.translate_to\n return if translate_to.blank?\n \n title_translations = Babelphish::Translator.multiple_translate(self.title, translate_to, self.locale)\n body_translations = Babelphish::Translator.multiple_translate(self.body, translate_to, self.locale)\n existing_translations = {}\n self.content_translations.each do |translation|\n existing_translations[translation.locale] = translation\n end\n \n translate_to.each do |language|\n if translation = existing_translations[language]\n if !translation.user_edited || overwrite_user_edited_translations\n translation.update_attributes!(:title => title_translations[language],\n :body => body_translations[language])\n end\n else\n self.content_translations.create!(:title => title_translations[language],\n :body => body_translations[language],\n :locale => language)\n end\n end\n end",
"def set_translation(locale, translation, value)\n SimpleTranslationEngine.set_translation(locale, \"alert_#{self.id}_#{translation}\", value)\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def propagate_dependent_option_with_shared_translations record\n # if this model is not translatable, act normally\n yield && return unless record.class.is_translatable?\n\n if should_propagate_dependent_option? record\n klass.translating_relations do\n yield\n end\n end\n update_foreign_keys_to_point_another_translation record if record.translations.exists?\n end",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def translate_boolean(boolean)\n I18n.translate!(boolean)\n rescue I18n::MissingTranslationData\n boolean.to_s\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def init_translations; end",
"def translate_google\n set_params\n result = send_translate_google_api( params[:value], params[:locale], params[:base_locale] )\n \n unless result.nil?\n render :text => result\n else\n render :text => \"error translating\"\n end\n end",
"def translate(*args)\n key = args.shift\n if xlated = @map[key]\n if xlated.is_a?(String)\n args.empty? ? xlated : sprintf(xlated, *args)\n else\n xlated.call(*args)\n end\n else\n return key\n end\n end",
"def is_translated?(moonrune)\n begin\n if moonrune.translation_check != moonrune\n return true\n else\n return false\n end\n rescue \n p \"something went awry with is_translated?\"\n return false\n end\nend",
"def assert_no_missing_translations(msg = \"\")\n assert_select \"span[class=translation_missing]\", false, \"Missing translation #{msg}\"\n end",
"def translate_exception(exception, message) #:nodoc:\r\n return super unless exception.respond_to?(:errno)\r\n case exception.errno\r\n when 2121\r\n if exception.sql !~ /^SELECT/i then\r\n raise ActiveRecord::ActiveRecordError.new(message)\r\n else\r\n super\r\n end\r\n when 7076\r\n raise InvalidForeignKey.new(message, exception)\r\n when 7057\r\n raise RecordNotUnique.new(message, exception)\r\n else\r\n super\r\n end\r\n super\r\n end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def translate(x, y = 0)\n transform[:translate] = [x, y]\n end",
"def message_for(key,options={})\n handwritten_message || I18n.translate(key, {:scope => 'activerecord.errors.messages'}.merge(options))\n end",
"def valid_translation? translation_file\n raise TranslationFileNotFound, \"Translation file is required\" unless translation_file\n raise TranslationFileNotFound, \"Unable to find Translation File #{translation_file}\" unless File.exists?(translation_file)\n end",
"def translate\n api = ENV['API']\n url = 'https://translation.googleapis.com/language/translate/v2?key='\n target_language = self.phrasebook.language.abbr\n input = self.phrase.input\n # byebug\n\n request = HTTParty.get(url + api + '&q=' + input + '&source=en' + '&target=' + target_language)\n response = JSON.parse(request.body)\n translation = response['data']['translations'][0]['translatedText']\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def translated\n find_all do |entry|\n entry.translated?\n end\n end",
"def translated?(name)\r\n self.class.translated?(name)\r\n end",
"def label_translation; end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def myDeepl_translate(text, source_lang, target_lang)\n begin\n source = source_lang.to_s.upcase\n target = target_lang.to_s.upcase\n ret = DeepL.translate(text, source, target).to_s\n ret.chomp!(\".\") # Українська translation has often a dot in the end\n ret.sub!(/\"/, \"\") # Українська translation has sometimes double quote in the beginning\n ret.sub!(/。/, \"\") # one time seen, 日本語 translation added japanese dot in the end\n # puts \"translate #{source} \\”#{text}\\\" -> #{target} \\\"#{ret}\\\"\"\n return ret\n rescue DeepL::Exceptions::Error => exc\n puts \"DeepL translation failed #{exc.class} #{exc.message}\"\n end\n return nil\n end"
] |
[
"0.66068226",
"0.6571936",
"0.6490723",
"0.61729616",
"0.60273767",
"0.5949705",
"0.5937595",
"0.59009826",
"0.589076",
"0.5889784",
"0.5804128",
"0.57450473",
"0.57219005",
"0.57057226",
"0.5641733",
"0.55808485",
"0.55714333",
"0.5516033",
"0.5516033",
"0.55033755",
"0.5482996",
"0.54788834",
"0.5460443",
"0.5457013",
"0.5430759",
"0.54235137",
"0.5415121",
"0.53747296",
"0.5362707",
"0.53568405",
"0.5350081",
"0.5338316",
"0.5318373",
"0.53162545",
"0.52857053",
"0.5284101",
"0.52504086",
"0.52492404",
"0.52362114",
"0.52362114",
"0.5228266",
"0.52271277",
"0.52245986",
"0.52145255",
"0.5207049",
"0.5202155",
"0.51961064",
"0.51905525",
"0.51547444",
"0.513904",
"0.5135757",
"0.5135757",
"0.5135757",
"0.5135757",
"0.5135757",
"0.5135757",
"0.5135757",
"0.5135757",
"0.51237255",
"0.51089525",
"0.5091328",
"0.5073408",
"0.50640064",
"0.5039812",
"0.5030417",
"0.50246936",
"0.5016784",
"0.50159407",
"0.49971578",
"0.4984536",
"0.4983676",
"0.4970691",
"0.4967534",
"0.496646",
"0.4965791",
"0.49603638",
"0.49574065",
"0.4948464",
"0.49476027",
"0.49456346",
"0.49442297",
"0.49426755",
"0.49398518",
"0.49272418",
"0.49139044",
"0.49136603",
"0.49074888",
"0.4896579",
"0.48929617",
"0.4890589",
"0.4885715",
"0.48821056",
"0.48796064",
"0.48778382",
"0.48622856",
"0.48589334",
"0.4856847",
"0.4854536",
"0.48496732",
"0.4841467",
"0.48347646"
] |
0.0
|
-1
|
Wrapper for translate that adds :raise => true. With this option, if no translation is found, it will raise I18n::MissingTranslationData source://i18n//lib/i18n.rb229
|
def translate!(key, **options); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def t(key, options = {})\n options[:raise] = true\n translate(key, options)\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def translate!(key, options = {}, &block)\n I18n.translate!(*object_scoped_i18n_options(key, options.dup), &block)\n end",
"def translate_with_fallbacks opts, locale = nil\n locale ||= default_locale\n\n opts.each.with_index do |(key, vars), index|\n next unless I18n.exists?(key, locale) || index == opts.count - 1\n\n return I18n.translate(key, vars)\n end # each\n end",
"def translate(input_text, src_lang, target_lang)\n raise \"Not Implemented. Class #{self.class.name} doesn't implement translate\"\n end",
"def translate(*args, **opts); end",
"def translate(item)\n @progress.setMainStatusAndLogIt('Translating')\n text = get_original_text(item)\n return nil if text.empty?\n\n translated = ms_translate(text)\n super(item, translated) unless translated.nil? || translated.empty?\n end",
"def translate\n self.translations.destroy\n\n if auto_translate\n google_translate\n bing_translate\n end\n end",
"def translated_msg(translate, message, src_lang, target_lang)\n return message unless translate \n use_src = nil \n if (src_lang.nil? || src_lang.empty?)\n # We don't need to infer again and again\n begin\n @inferred_src_lang ||= infer_languages.first\n rescue StandardError => e \n raise LangDetectionFailureException.new(\"Failed to infer language due to #{e.message}\")\n end\n use_src = @inferred_src_lang\n else\n use_src = src_lang\n end\n return message if use_src.eql?(target_lang)\n @translator.translate(message, use_src, target_lang)\n end",
"def translate key = nil, retries: nil, timeout: nil\n require \"gcloud/translate\"\n Gcloud.translate key, retries: (retries || @retries),\n timeout: (timeout || @timeout)\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def translate_exception(e, message)\n case e.message\n when /violation of FOREIGN KEY constraint/\n InvalidForeignKey.new(message, e)\n when /violation of PRIMARY or UNIQUE KEY constraint/\n RecordNotUnique.new(message, e)\n else\n super\n end\n end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def i18n_set?(key, params = {})\n I18n.t key, params, :raise => true rescue false\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def silence_errors\n require 'fast_gettext/translation_repository/base'\n translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale')\n end",
"def translate!(text, *languages)\n languages = Translations.keys unless languages.any?\n languages = languages.flatten.map!(&:to_sym)\n languages.delete :en # remove :en translation from everywhere\n languages.push :en # to push it as the last one\n languages.each do |lang|\n Translations[lang] && Translations[lang].call(text)\n end\n text\n end",
"def translate(key, **options)\n return key.map { |k| translate(k, **options) } if key.is_a?(Array)\n key = key&.to_s unless key.is_a?(Symbol)\n\n alternatives = if options.key?(:default)\n options[:default].is_a?(Array) ? options.delete(:default).compact : [options.delete(:default)]\n end\n\n options[:raise] = true if options[:raise].nil? && TranslationHelper.raise_on_missing_translations\n default = MISSING_TRANSLATION\n\n translation = while key || alternatives.present?\n if alternatives.blank? && !options[:raise].nil?\n default = NO_DEFAULT # let I18n handle missing translation\n end\n\n key = scope_key_by_partial(key)\n\n translated = ActiveSupport::HtmlSafeTranslation.translate(key, **options, default: default)\n\n break translated unless translated == MISSING_TRANSLATION\n\n if alternatives.present? && !alternatives.first.is_a?(Symbol)\n break alternatives.first && I18n.translate(nil, **options, default: alternatives)\n end\n\n first_key ||= key\n key = alternatives&.shift\n end\n\n if key.nil? && !first_key.nil?\n translation = missing_translation(first_key, options)\n key = first_key\n end\n\n block_given? ? yield(translation, key) : translation\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def translate_exception(e)\n exception_translator.register_exception e\n end",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def translate(settings); end",
"def translate!( *args )\n super( *args )\n reset_positions_inside\n end",
"def translate(message)\n @messages[message] || message\n end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def translate key, opts = {}\n opts = { :locale => default_locale }.update(opts)\n\n I18n.translate(key, opts)\n end",
"def translated?\n texts = errors.values.flatten.map(&:message)\n texts.select { |text| text.start_with?(\"translation missing\") }.empty?\n end",
"def translate(text:, from: nil, to:, **opts) # rubocop:disable Lint/UnusedMethodArgument, Metrics/LineLength\n raise NotImplementedError\n end",
"def translate(*args)\n # Fall back to the default translate behavior if the :force_default_behavior is true\n force_current_locale = args.last.is_a?(Hash) ? args.pop.delete(:force_default_behavior) : false\n return original_translate(*args) if force_current_locale\n\n translations = []\n\n available_locales.each do |locale|\n args_copy = args.dup\n\n if args_copy.last.is_a?(Hash)\n args_copy.last.merge!(locale: locale)\n else\n args_copy << {locale: locale}\n end\n\n translations << original_translate(*args_copy)\n end\n\n translations.max\n end",
"def translate(text, options = {})\n response = google_api_call(text,\"#{SERVICE}#{@from}%7C#{@to}#{TEXT_PAR}\",TranslationResponse)\n translation = options[:html] ? response.translation : CGI.unescapeHTML(response.translation)\n translation # return value\n end",
"def ct(key, language = nil)\n language = language || I18n.locale\n r = {flag: false, key: key, translation: \"\", locale: language.to_sym}\n hooks_run(\"on_translation\", r)\n return r[:translation] if r[:flag]\n translate(\"common.#{key}\", locale: language)\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def i18n_set? key\n I18n.t key, :raise => true rescue false\n end",
"def translate_or_localize(key, options = {})\n [Date, DateTime, Time].include?(key.class) ? I18n.localize(key, options) : I18n.translate(key, options)\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def translations; end",
"def translate(klass, key, value)\n if defined?(I18n)\n super\n else\n value ? value.to_s.humanize.downcase : 'nil'\n end\n end",
"def translate(locale, key, options = {})\n options[:lit_default_copy] = options[:default].dup if can_dup_default(options)\n content = super(locale, key, options)\n\n if on_rails_6_1_or_higher?\n @untranslated_key = key if key.present? && options[:default].instance_of?(Object)\n\n if key.nil? && options[:lit_default_copy].present?\n update_default_localization(locale, options)\n end\n end\n\n if Lit.all_translations_are_html_safe && content.respond_to?(:html_safe)\n content.html_safe\n else\n content\n end\n end",
"def with_locales_if_translated(with_locales = nil, &block)\n if instance.respond_to?(:translated_locales) && instance.translated?(:\"#{name}_file_name\")\n # TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)\n with_locales = instance.translated_locales if with_locales.nil?\n Globalize.with_locales([*with_locales]) { yield }\n else\n yield\n end\n end",
"def translation_target\n super\n end",
"def translation_text_presence\n present = false\n translations.each {|t| present = true if !t.text.blank?}\n unless present\n errors.add 'translations.text', I18n.t(\n 'models.phrase.attributes.translations.min_amount',\n default: 'needs at least one translation'\n )\n end\n end",
"def command_translate\n command :translate do |c|\n c.syntax = 'budik translate [options]'\n c.summary = @str_translate.summary\n c.description = @str_translate.description\n c.action { |args, _opts| Command.new(:translate, args) }\n end\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate(details)\n self.translations = Hash[details.map { |k, v| [k.to_s, v.to_s] }].reverse_merge(translations)\n end",
"def localize_x(object, options = {})\n if options.has_key?(:locale) && !options[:locale].is_a?(Array)\n localize(object, options)\n else\n begin\n handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise\n if object.is_a?(Array)\n if handling\n options[handling] = true\n end\n object.map { |k| localize_x(k, options) }\n else\n backend = config.backend\n locales = if options.has_key?(:locale) && options[:locale].is_a?(Array)\n options.delete(:locale)\n else\n config.locale_array\n end\n format = options.delete(:format) || :default\n\n # we need to drop :default from the options, or we won't find a translation if a later\n # locale has one and the first does not\n\n default = options.delete(:default)\n options[:raise] = true\n\n seen = {}\n\n locales.each do |lloc|\n aloc = lloc.to_s.split('-')\n while aloc.length > 0\n l = aloc.join('-')\n unless seen.has_key?(l)\n seen[l] = true\n begin\n return backend.localize(l, object, format, options)\n rescue\n end\n end\n aloc.pop\n end\n end\n\n # if we made it here, there is no translation\n\n if default\n default\n else\n raise I18n::MissingTranslationData.new(locales, object, options)\n end\n end\n rescue I18n::ArgumentError => exception\n handle_exception(handling, exception, locale, object, options)\n end\n end\n end",
"def i18n_set?(key)\n I18n.t key, raise: true\n rescue StandardError\n false\n end",
"def translator_missing?\n !yaml.key?(\"translator\")\n end",
"def translate(s)\n old_i18n_locale = I18n.locale\n \n [ current_locale, base ].uniq.each do |locale|\n current_scope.each(s) do |scope|\n next unless value = translate_via_i18n(locale, scope)\n\n log_translation s, locale, scope, value\n \n #\n # reformat: if target format is html, convert the value into text.\n return Localite::Format.send(current_format, value)\n end\n end\n\n src = caller[1]\n if src =~ /^([^:]+:[^:]+):/\n src = $1\n end\n logger.warn \"[#{current_locale}] Could not translate #{current_scope.first(s).inspect}; from #{src}\"\n\n record_missing current_locale, current_scope.first(s)\n raise Missing, [current_locale, s]\n ensure\n I18n.locale = old_i18n_locale\n end",
"def translate(src_lang, target_lang, output_file)\n # Check if a non empty output file is present and error out to avoid\n # the danger or overwriting some important file !!\n if File.exists?(output_file) && File.size(output_file) > 0\n raise InvalidInputException.new(\"Output file #{output_file} is not empty.\")\n else\n # Just open the file in writable mode and close it just to ensure that\n # we can write the output file\n File.open(output_file, \"w\") {|f|\n }\n end\n # Check if the file is writable ?\n unless File.writable?(output_file)\n raise InvalidInputException.new(\"Output file #{output_file} not writable.\")\n end\n # Further checks can be done only in caption specific implementations\n # or translation engine specific implementation\n end",
"def translate(details)\n self.translations = Hash[details.map { |k,v| [k.to_s, v.to_s] }].reverse_merge(self.translations)\n end",
"def translation_for(locale)\n success = true\n tries ||= 3\n translation = self.translations.detect{ |t| t.locale == locale }\n return translation if translation\n return nil if self.new_record\n request = Net::HTTP::Get.new(\"/api/projects/#{Connection.api_key}/terms/#{self.id}/locales/#{locale}/translations.yaml\")\n WebTranslateIt::Util.add_fields(request)\n begin\n response = Util.handle_response(Connection.http_connection.request(request), true, true)\n array = YAML.load(response)\n return nil if array.empty?\n translations = []\n array.each do |translation|\n term_translation = WebTranslateIt::TermTranslation.new(translation)\n translations.push(term_translation)\n end\n return translations\n \n rescue Timeout::Error\n puts \"Request timeout. Will retry in 5 seconds.\"\n if (tries -= 1) > 0\n sleep(5)\n retry\n else\n success = false\n end\n end\n success\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def translate(key, options = {})\n I18n.t(key, options.merge(locale: @answer.questionnaire.language))\n end",
"def translate(response)\n end",
"def set_translator(translator)\n if translator && !(translator.is_a? Translator)\n raise InvalidInputException.new(\"Argument is not an instance of Translator\")\n end\n end",
"def t(key, options = {}, &block)\n options.merge!(block_to_hash(options, &block)) if block_given?\n translate_or_localize(key, options)\n end",
"def test_gettext_support\n ### FIXME: how to set \"en\" as gettext's default language?\n\n t = MyTestCell.new(@controller)\n c = render_cell_state(t, :view_with_explicit_english_translation)\n\n # the view \"view_with_explicit_english_translation_en\" exists, check if\n # gettext/rails found it:\n if Object.const_defined?(:GetText)\n assert_selekt c, \"#defaultTranslation\", 0\n assert_selekt c, \"#explicitEnglishTranslation\"\n else\n assert_selekt c, \"#defaultTranslation\"\n end\n end",
"def translate(key, options)\n I18n.translate(\"#{BASE_KEY}.#{key}\", options)\n end",
"def translate(text:, from: nil, to:, **opts)\n provider.translate(text: text, from: from, to: to, **opts)\n end",
"def translate(overwrite_user_edited_translations = false, translate_to = nil)\n translate_to ||= MuckContents.configuration.translate_to\n return if translate_to.blank?\n \n title_translations = Babelphish::Translator.multiple_translate(self.title, translate_to, self.locale)\n body_translations = Babelphish::Translator.multiple_translate(self.body, translate_to, self.locale)\n existing_translations = {}\n self.content_translations.each do |translation|\n existing_translations[translation.locale] = translation\n end\n \n translate_to.each do |language|\n if translation = existing_translations[language]\n if !translation.user_edited || overwrite_user_edited_translations\n translation.update_attributes!(:title => title_translations[language],\n :body => body_translations[language])\n end\n else\n self.content_translations.create!(:title => title_translations[language],\n :body => body_translations[language],\n :locale => language)\n end\n end\n end",
"def set_translation(locale, translation, value)\n SimpleTranslationEngine.set_translation(locale, \"alert_#{self.id}_#{translation}\", value)\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def propagate_dependent_option_with_shared_translations record\n # if this model is not translatable, act normally\n yield && return unless record.class.is_translatable?\n\n if should_propagate_dependent_option? record\n klass.translating_relations do\n yield\n end\n end\n update_foreign_keys_to_point_another_translation record if record.translations.exists?\n end",
"def translate_boolean(boolean)\n I18n.translate!(boolean)\n rescue I18n::MissingTranslationData\n boolean.to_s\n end",
"def translate(input, options = {})\n locale = options['locale'] || self.current_locale\n scope = options.delete('scope')\n key = scope.present? ? \"#{scope.gsub('.', '_')}_#{input}\" : input\n\n key = \"#{key}_#{pluralize_prefix(options['count'])}\" if options['count']\n\n values = find_values_by_key(key)\n\n # FIXME: important to check if the returned value is nil (instead of nil + false)\n # false being reserved for an existing key but without provided translation)\n if (translation = values[locale.to_s]).present?\n _translate(translation, options)\n elsif output = I18n.t(input, scope: scope&.split('.'), locale: locale, default: nil)\n output\n else\n Locomotive::Common::Logger.warn \"Missing translation '#{input}' for the '#{locale}' locale\".yellow\n ActiveSupport::Notifications.instrument('steam.missing_translation', input: input, locale: locale)\n input\n end\n end",
"def translate(keyword, language)\n if LOCALES[language.to_sym].nil?\n translations = LOCALES[:en]\n else\n translations = LOCALES[language.to_sym]\n end\n return translations[keyword]\nend",
"def init_translations; end",
"def translate_google\n set_params\n result = send_translate_google_api( params[:value], params[:locale], params[:base_locale] )\n \n unless result.nil?\n render :text => result\n else\n render :text => \"error translating\"\n end\n end",
"def is_translated?(moonrune)\n begin\n if moonrune.translation_check != moonrune\n return true\n else\n return false\n end\n rescue \n p \"something went awry with is_translated?\"\n return false\n end\nend",
"def translate(*args)\n key = args.shift\n if xlated = @map[key]\n if xlated.is_a?(String)\n args.empty? ? xlated : sprintf(xlated, *args)\n else\n xlated.call(*args)\n end\n else\n return key\n end\n end",
"def assert_no_missing_translations(msg = \"\")\n assert_select \"span[class=translation_missing]\", false, \"Missing translation #{msg}\"\n end",
"def translate_exception(exception, message) #:nodoc:\r\n return super unless exception.respond_to?(:errno)\r\n case exception.errno\r\n when 2121\r\n if exception.sql !~ /^SELECT/i then\r\n raise ActiveRecord::ActiveRecordError.new(message)\r\n else\r\n super\r\n end\r\n when 7076\r\n raise InvalidForeignKey.new(message, exception)\r\n when 7057\r\n raise RecordNotUnique.new(message, exception)\r\n else\r\n super\r\n end\r\n super\r\n end",
"def translate_default(key, value)\n translated[key] = value\n end",
"def translate(x, y = 0)\n transform[:translate] = [x, y]\n end",
"def message_for(key,options={})\n handwritten_message || I18n.translate(key, {:scope => 'activerecord.errors.messages'}.merge(options))\n end",
"def valid_translation? translation_file\n raise TranslationFileNotFound, \"Translation file is required\" unless translation_file\n raise TranslationFileNotFound, \"Unable to find Translation File #{translation_file}\" unless File.exists?(translation_file)\n end",
"def translate\n api = ENV['API']\n url = 'https://translation.googleapis.com/language/translate/v2?key='\n target_language = self.phrasebook.language.abbr\n input = self.phrase.input\n # byebug\n\n request = HTTParty.get(url + api + '&q=' + input + '&source=en' + '&target=' + target_language)\n response = JSON.parse(request.body)\n translation = response['data']['translations'][0]['translatedText']\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def store_original_as_translation\n unless self.original_text.nil?\n self.translations << self.original_text\n end\n end",
"def translated\n find_all do |entry|\n entry.translated?\n end\n end",
"def translated?(name)\r\n self.class.translated?(name)\r\n end",
"def label_translation; end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def myDeepl_translate(text, source_lang, target_lang)\n begin\n source = source_lang.to_s.upcase\n target = target_lang.to_s.upcase\n ret = DeepL.translate(text, source, target).to_s\n ret.chomp!(\".\") # Українська translation has often a dot in the end\n ret.sub!(/\"/, \"\") # Українська translation has sometimes double quote in the beginning\n ret.sub!(/。/, \"\") # one time seen, 日本語 translation added japanese dot in the end\n # puts \"translate #{source} \\”#{text}\\\" -> #{target} \\\"#{ret}\\\"\"\n return ret\n rescue DeepL::Exceptions::Error => exc\n puts \"DeepL translation failed #{exc.class} #{exc.message}\"\n end\n return nil\n end"
] |
[
"0.66070175",
"0.65727067",
"0.6490433",
"0.6172325",
"0.6025658",
"0.5947924",
"0.5936465",
"0.5898825",
"0.58887774",
"0.5802334",
"0.5742642",
"0.5720782",
"0.57044584",
"0.5639981",
"0.5580546",
"0.557122",
"0.5514886",
"0.5514886",
"0.55027807",
"0.54809695",
"0.54789954",
"0.5459034",
"0.54563177",
"0.542936",
"0.54235625",
"0.5412969",
"0.53722215",
"0.5360898",
"0.535382",
"0.53479385",
"0.5337893",
"0.5316709",
"0.53152776",
"0.52843785",
"0.52829945",
"0.5248548",
"0.5248216",
"0.5235904",
"0.5235904",
"0.52285737",
"0.52285004",
"0.522339",
"0.52131",
"0.5205213",
"0.520168",
"0.519372",
"0.5188674",
"0.515259",
"0.51360357",
"0.5133573",
"0.5133573",
"0.5133573",
"0.5133573",
"0.5133573",
"0.5133573",
"0.5133573",
"0.5133573",
"0.51231045",
"0.51067144",
"0.5091274",
"0.5072904",
"0.50631857",
"0.50377584",
"0.5029908",
"0.5022062",
"0.5016633",
"0.50147814",
"0.49941123",
"0.4983594",
"0.4983298",
"0.4970301",
"0.49663386",
"0.49653",
"0.4962744",
"0.4957651",
"0.49557966",
"0.49486738",
"0.49470896",
"0.49432907",
"0.49408937",
"0.49405003",
"0.4938358",
"0.49266547",
"0.4912988",
"0.49126825",
"0.4908104",
"0.4896636",
"0.48904824",
"0.48883158",
"0.48858717",
"0.4879952",
"0.48774034",
"0.48763716",
"0.48608658",
"0.4856656",
"0.48545277",
"0.48523036",
"0.4848835",
"0.48394603",
"0.48338664"
] |
0.5888501
|
9
|
Executes block with given I18n.locale set. source://i18n//lib/i18n.rb315
|
def with_locale(tmp_locale = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def __with_locale__(locale, &block)\n yield\n end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def with_locale(locale, &block)\n previous_locale = I18n.locale\n I18n.locale = locale if locale\n \n yield\n \n I18n.locale = previous_locale\n end",
"def configure(&block)\n block.call @locale\n end",
"def with_user_locale\n raise \"No block given\" unless block_given?\n begin\n tmp_locale = I18n.locale\n I18n.locale = profile.language\n yield\n ensure\n I18n.locale = tmp_locale\n end\n end",
"def with_locale(locale, &block)\n old_locale = I18n.locale\n I18n.locale = locale\n yield(locale)\n I18n.locale = old_locale\n end",
"def each_locale(include_default_locale = true, &block)\n current_locale = ::Mongoid::Fields::I18n.locale\n _locales = include_default_locale ? self.locales : (self.locales - [self.default_locale])\n\n _locales.each do |locale|\n ::Mongoid::Fields::I18n.with_locale(locale) do\n yield locale, current_locale.to_s == locale.to_s\n end\n end\n end",
"def locale(locale, &block)\n scope :locale => locale, &block\n end",
"def with_locale(tmp_locale = nil)\n if tmp_locale\n current_locale = locale\n self.locale = tmp_locale\n end\n yield\n ensure\n self.locale = current_locale if tmp_locale\n end",
"def with_locale(tmp_locale = T.unsafe(nil), &block); end",
"def each_locale(&block)\n self.mounting_point.locales.each do |locale|\n Locomotive::Mounter.with_locale(locale) do\n block.call(locale)\n end\n end\n end",
"def with_default_locale(&block)\n ::Mongoid::Fields::I18n.with_locale(self.default_locale) do\n yield\n end\n end",
"def set_locale\n end",
"def locale locale, &block\n def self.it_should_be_translated(selector, translation)\n it \"#{selector} should have translation #{translation}\" do\n response.should have_tag(selector, translation)\n end\n end\n def self.it_should_not_have_missing_translations\n it \"should have everything translated\" do\n response.body.should_not =~ /translation missing|translation_missing/\n end\n end\n \n contexted = context \"with locale #{locale}\", &block\n \n contexted.class_eval <<-BODY\n before(:all) do\n @old_locale = I18n.locale\n I18n.locale = locale\n end\n after(:all) do\n I18n.locale = @old_locale\n end\n BODY\nend",
"def locale=(locale); end",
"def with_given_locale(attributes, &block)\r\n attributes.symbolize_keys! if attributes.respond_to?(:symbolize_keys!)\r\n if locale = attributes.try(:delete, :locale)\r\n Mongoid::Globalize.with_locale(locale, &block)\r\n else\r\n yield\r\n end\r\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def render_with_locale(item)\n if item.data[\"locale\"]\n previous_locale = locale\n self.locale = item.data[\"locale\"]\n yield\n self.locale = previous_locale\n else\n yield\n end\n end",
"def initialize(locale, &blk)\n @locale = locale\n configure &blk if block_given?\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def route_eval(&block)\n if options.auto_locale\n if params[:locale]\n I18n.locale = params[:locale].to_sym rescue options.locale\n end\n end\n super(&block)\n end",
"def apply_locale; end",
"def each\n each_locale { |locale| yield Translation.new(self, locale) }\n end",
"def default_locale=(locale); end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale\n \n #raise \"params[:locale] = #{params[:locale].present?}\"\n #raise \"params[:locale] = #{params[:locale].blank?}\"\n # Se non ho assegnato il parametro :locale allora gli passo la lingua impostata sul browser \n # (per testare usa Google chrome Extension: Locale Switcher)\n params[:locale] = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').scan(/[a-z]{2}/).first if params[:locale].blank?\n #raise \"params[:locale] = #{params[:locale]}\"\n\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n \tI18n.locale = params[:locale] if params[:locale].present? \n end",
"def transliterate(locale = nil)\n I18n.transliterate(self, ({ locale: locale } if locale))\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def set_locale_from_options_inline\n <<-EOL\nif options[:locale]\n #{\"Mobility.enforce_available_locales!(options[:locale])\" if I18n.enforce_available_locales}\n locale = options[:locale].to_sym\n options[:locale] &&= !!locale\nelse\n locale = Mobility.locale\nend\nEOL\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def locale=(value); end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale(locale)\n # Parse the HTTP GET header for languages and create an array\n # from them\n locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])\n\n # If we passed in a locale param, put it at the front of the\n # locales array\n if ((locale.is_a? String) && !(locale.empty?))\n locales.insert(0, locale)\n end\n\n # R18N locale setter\n ::R18n.thread_set do\n if Settings[:DEFAULT_LOCALE]\n ::R18n::I18n.default = Settings[:DEFAULT_LOCALE]\n end\n \n ::R18n::I18n.new(locales, ::R18n.default_places,\n :off_filters => :untranslated, :on_filters => :untranslated_html)\n end\n \n begin\n # We depend on lang-locale, not just lang code.\n # If we get a 2 letter lang code, dupe it so that\n # de becomes de-de\n # unless it's en, then we want en-us\n # or ja then we want ja-jp\n if (locales[0].length == 2)\n case locales[0].downcase\n when \"en\"\n return \"en-us\"\n when \"ja\"\n return \"ja-jp\"\n else\n return \"#{locales[0].downcase}-#{locales[0].downcase}\"\n end\n else\n return locales[0].downcase\n end\n rescue\n return Settings[:DEFAULT_LOCALE]\n end\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def set_locale\n I18n.locale = extract_locale_from_accept_language_header || I18n.default_locale\n # I18n.locale = params[:locale] if params[:locale].present?\n end",
"def set_locale\n I18n.locale = params[:locale] if params[:locale].present?\n # \"en\"\n # params[:locale] if params[:locale].present?\n # current_user.locale\n # request.subdomain\n # request.env[\"HTTP_ACCEPT_LANGUAGE\"]\n # request.remote_ip\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def verificar_locale\n \n end",
"def locale=(_arg0); end",
"def set_locale\n # Get the current path and request method (useful in the layout for changing the language)\n @current_path = request.env['PATH_INFO']\n @request_method = request.env['REQUEST_METHOD']\n\n # Try to get the locale from the parameters, from the session, and then from the navigator\n if params[:user_locale]\n # Store the locale in the session\n Locale.code = params[:user_locale][:code]\n session[:locale] = Locale.code\n elsif session[:locale]\n Locale.code = session[:locale]\n else\n Locale.code = local_case(get_valid_lang_from_accept_header)\n end\n\n logger.debug \"[globalite] Locale set to #{Locale.code}\"\n # render the page\n yield\n\n # reset the locale to its default value\n Locale.reset!\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale \n locale = params[:locale]\n locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\n I18n.locale = (locale && I18n.available_locales.include?(locale.to_sym)) ? locale : I18n.default_locale\n end",
"def set_locale\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = params[:locale] || locale_from_header || I18n.default_locale\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def set_locale\n# logger.debug \"* Locale currently is '#{I18n.locale}', params[:locale] = '#{params[:locale] }'\"\n# logger.debug \"* cookies[:locale] = '#{cookies[:locale] }', HTTP_ACCEPT_LANGUAGE: '#{request.env[\"HTTP_ACCEPT_LANGUAGE\"] }'\"\n accept_locales = LOCALES.keys # See config/application.rb for accepted LOCALES\n\n locale = params[:locale] if accept_locales.include?( params[:locale] )\n if locale.nil? # Use the cookie only when set or enabled\n locale = cookies[:locale] if accept_locales.include?( cookies[:locale] )\n else # Store the chosen locale when it changes\n cookies[:locale] = locale\n end\n\n current_locale = locale || I18n.default_locale # This covers also the default case when cookies are not enabled\n unless current_locale.nil?\n I18n.locale = to_safe_sym( current_locale, accept_locales )\n logger.debug \"* Locale is now set to '#{I18n.locale}'\"\n end\n end",
"def set_locale\n# logger.debug \"* Locale currently is '#{I18n.locale}', params[:locale] = '#{params[:locale] }'\"\n# logger.debug \"* cookies[:locale] = '#{cookies[:locale] }', HTTP_ACCEPT_LANGUAGE: '#{request.env[\"HTTP_ACCEPT_LANGUAGE\"] }'\"\n accept_locales = LOCALES.keys # See config/application.rb for accepted LOCALES\n\n locale = params[:locale] if accept_locales.include?( params[:locale] )\n if locale.nil? # Use the cookie only when set or enabled\n locale = cookies[:locale] if accept_locales.include?( cookies[:locale] )\n else # Store the chosen locale when it changes\n cookies[:locale] = locale\n end\n\n current_locale = locale || I18n.default_locale # This covers also the default case when cookies are not enabled\n unless current_locale.nil?\n I18n.locale = to_safe_sym( current_locale, accept_locales )\n logger.debug \"* Locale is now set to '#{I18n.locale}'\"\n end\n end",
"def set_gettext_locale_db\n params[:locale] ||= User.current.try(:locale)\n end",
"def set_locale\n #logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n #logger.debug request.env['HTTP_ACCEPT_LANGUAGE']\n\n if session[:default_locale] != nil\n I18n.locale = (session[:default_locale]).to_sym\n mapping_locale_to_area\n return\n end\n\n logger.debug \"'#{I18n.locale}'\"\n\n I18n.locale = extract_locale_from_accept_language_header\n\n logger.debug \"'#{I18n.locale}'\"\n\n if I18n.locale == :\"zh\"\n \n logger.debug env['HTTP_ACCEPT_LANGUAGE'][3]\n # Ealin: 84 == 'T' (特別處理: zh_TW)\n if env['HTTP_ACCEPT_LANGUAGE'][3] == 84 || env['HTTP_ACCEPT_LANGUAGE'][3] == 116 || \\\n env['HTTP_ACCEPT_LANGUAGE'][3] == 'T' || env['HTTP_ACCEPT_LANGUAGE'][3] == 't'\n\n #\n # Ealin: 避免繁體與簡體可能混淆, 將繁體的locale name設為zh_tw\n #\n I18n.locale = :zh_tw\n end\n end\n\n # save mapped area to session[:default_area]\n mapping_locale_to_area\n \n #logger.debug I18n.locale.length\n #logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def use_i18n=(value); end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def set_locale\n I18n.locale = :pl\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_locale\n I18n.locale = access_control.user.locale\n end"
] |
[
"0.79622006",
"0.7961856",
"0.7892074",
"0.7621341",
"0.7596587",
"0.75914526",
"0.7283137",
"0.71972877",
"0.7119325",
"0.7088867",
"0.7074945",
"0.7056728",
"0.6884442",
"0.6812741",
"0.6811464",
"0.67295754",
"0.6712164",
"0.67107445",
"0.66648245",
"0.6662093",
"0.6662093",
"0.6641635",
"0.6621292",
"0.6616561",
"0.6609853",
"0.6541118",
"0.6531957",
"0.6501889",
"0.6499266",
"0.64722",
"0.6454365",
"0.6445538",
"0.64057696",
"0.6401174",
"0.6396664",
"0.63851815",
"0.6379606",
"0.63751835",
"0.63737005",
"0.6370725",
"0.6367954",
"0.63592446",
"0.63523155",
"0.6349133",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63403594",
"0.63343215",
"0.6333905",
"0.6323255",
"0.6322526",
"0.6317655",
"0.63093555",
"0.63093555",
"0.6276791",
"0.6273567",
"0.6261111",
"0.6261111",
"0.6252548",
"0.6252548",
"0.6252548",
"0.6252548",
"0.6248215",
"0.6247861",
"0.6218451",
"0.62167764",
"0.6193849",
"0.618532",
"0.6177778",
"0.6177455",
"0.61540586",
"0.6152783",
"0.6095691",
"0.6093673",
"0.60580987",
"0.60567313",
"0.60416853",
"0.60416853",
"0.60353804",
"0.6033129",
"0.6017174",
"0.601317",
"0.601317",
"0.60012025",
"0.599628",
"0.5990835",
"0.5988631",
"0.5980276",
"0.59722924",
"0.59722745"
] |
0.0
|
-1
|
Sets the available locales. source://i18n//lib/i18n/config.rb57
|
def available_locales=(locales); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def translated_in=(locales)\n self._locales = locales.map(&:to_sym)\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def available_locales_set; end",
"def enabled_locales=(values)\n languages = values.reject{|x| x.blank?}\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def enabled_locales=(values)\n languages = values.reject { |x| x.blank? }\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def setup\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def available_locales; end",
"def available_locales; end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def locales\n EnvironmentLocaleMethodsFactory.new(self)\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def set_locale\n if params[:controller] == \"rails_admin/main\"\n I18n.locale = :en\n else\n I18n.locale = :ru\n end\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def configure(&block)\n block.call @locale\n end",
"def set_locale\n I18n.locale = :pl\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n locales = ['en', 'en-AU']\n begin\n # Try to auto-detect it\n if request.headers['Accept-Language']\n browser_language = request.headers['Accept-Language'].split(',')[0] \n browser_language = browser_language.split('-')[0] + '-' + browser_language.split('-')[1].upcase\n session[:locale] = browser_language\n end\n session[:locale] = params[:locale] if params[:locale]\n session[:locale] = 'en-AU' if session[:locale] == 'en-GB'\n I18n.locale = locales.include?(session[:locale]) ? session[:locale] : I18n.default_locale\n rescue\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def default_locale=(locale); end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def locales\n @env.locales\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale \n locale = params[:locale]\n locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\n I18n.locale = (locale && I18n.available_locales.include?(locale.to_sym)) ? locale : I18n.default_locale\n end",
"def locale\n @locales = Ramaze::Tool::Localize.languages.map{ |lang|\n [\n Ramaze::Tool::Localize.localize('locale_menu_descrition', lang),\n Ramaze::Tool::Localize.localize('locale_name', lang),\n lang\n ]\n }\n end",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def set_locale\n \n #raise \"params[:locale] = #{params[:locale].present?}\"\n #raise \"params[:locale] = #{params[:locale].blank?}\"\n # Se non ho assegnato il parametro :locale allora gli passo la lingua impostata sul browser \n # (per testare usa Google chrome Extension: Locale Switcher)\n params[:locale] = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').scan(/[a-z]{2}/).first if params[:locale].blank?\n #raise \"params[:locale] = #{params[:locale]}\"\n\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def set_locale\n if params[:locale]\n I18n.locale = session[:locale] = params[:locale] || I18n.default_locale\n else\n I18n.locale = session[:locale] || I18n.default_locale\n end\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_locale\n I18n.locale = current_user.try(:locale) || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n if logged_in?\n if !current_user.shainmaster.setting.nil?\n if !current_user.shainmaster.setting.local.nil? && current_user.shainmaster.setting.local != ''\n I18n.locale = current_user.shainmaster.setting.local\n end\n end\n end\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def set_locale\n #logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n #logger.debug request.env['HTTP_ACCEPT_LANGUAGE']\n\n if session[:default_locale] != nil\n I18n.locale = (session[:default_locale]).to_sym\n mapping_locale_to_area\n return\n end\n\n logger.debug \"'#{I18n.locale}'\"\n\n I18n.locale = extract_locale_from_accept_language_header\n\n logger.debug \"'#{I18n.locale}'\"\n\n if I18n.locale == :\"zh\"\n \n logger.debug env['HTTP_ACCEPT_LANGUAGE'][3]\n # Ealin: 84 == 'T' (特別處理: zh_TW)\n if env['HTTP_ACCEPT_LANGUAGE'][3] == 84 || env['HTTP_ACCEPT_LANGUAGE'][3] == 116 || \\\n env['HTTP_ACCEPT_LANGUAGE'][3] == 'T' || env['HTTP_ACCEPT_LANGUAGE'][3] == 't'\n\n #\n # Ealin: 避免繁體與簡體可能混淆, 將繁體的locale name設為zh_tw\n #\n I18n.locale = :zh_tw\n end\n end\n\n # save mapped area to session[:default_area]\n mapping_locale_to_area\n \n #logger.debug I18n.locale.length\n #logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n rxp = Regexp.new('[a-zA-Z]{2}')\n user_locale = cookies[:locale] || params[:locale]\n user_locale = user_locale.present? ? user_locale.scan(rxp) : 'en'\n # Check, is this locale available for using.\n # Please note: this needed for disable invalid locale warning.\n available = I18n.available_locales.include?(user_locale[0].to_sym)\n I18n.locale = available ? user_locale[0] : 'en'\n end",
"def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n #Rails.application.routes.default_url_options[:locale]= I18n.locale \n end",
"def locale_array=(locale_array)\n config.locale_array = locale_array\n end",
"def set_user_language\n I18n.locale = 'es-VE'\n end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end"
] |
[
"0.68784225",
"0.68308413",
"0.6816556",
"0.6816556",
"0.67949677",
"0.67649126",
"0.67481863",
"0.6700948",
"0.66904336",
"0.66848886",
"0.66686445",
"0.6661873",
"0.6633606",
"0.6608253",
"0.6598595",
"0.65736765",
"0.65610206",
"0.65610206",
"0.65610206",
"0.65610206",
"0.6553939",
"0.6530013",
"0.65299004",
"0.6528493",
"0.6527111",
"0.6523195",
"0.6523195",
"0.6522852",
"0.65056854",
"0.65048605",
"0.65048605",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.6499975",
"0.64979875",
"0.6492521",
"0.6492042",
"0.64860576",
"0.64860576",
"0.6473107",
"0.647216",
"0.644705",
"0.6441209",
"0.64225525",
"0.64225525",
"0.6403384",
"0.640274",
"0.64025897",
"0.6377619",
"0.63666284",
"0.63489085",
"0.63182354",
"0.63170075",
"0.62924606",
"0.6278596",
"0.6263942",
"0.62481433",
"0.6236921",
"0.6225065",
"0.6224282",
"0.6224125",
"0.62226504",
"0.62219554",
"0.6211663",
"0.6187614",
"0.6170653",
"0.61690414",
"0.6168141",
"0.6149977",
"0.61492866",
"0.6145257",
"0.6142454",
"0.6142319",
"0.612967",
"0.6119682",
"0.61196095",
"0.6114129",
"0.61122227",
"0.6111516",
"0.6108567",
"0.61042804",
"0.6097075",
"0.60891366",
"0.6087659",
"0.6074828",
"0.6071294",
"0.607004",
"0.60593444",
"0.6057362"
] |
0.75680006
|
0
|
Returns true if the available_locales have been initialized
|
def available_locales_initialized?; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def available_locales\n @available_locales ||= self.languages.published\n end",
"def localized?\n self.locales.size > 1\n end",
"def locale_available?(locale); end",
"def available_locales_set; end",
"def available_locales; end",
"def available_locales; end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def has_available_locale? locale\n available_locales.include?(locale.to_sym)\n end",
"def fully_translated?\n locale_counts.all? do |locale_code, _|\n fully_translated_in?(locale_code)\n end\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def available_locales\n []\n end",
"def initialized?\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n @initialized || false\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def initialized?\n !!@initialized\n end",
"def available_locales=(locales); end",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def initialized?\n @state == STATE_INITIALIZED\n end",
"def localized?\n @localized ||= (self.languages_count > 1)\n end",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def localized?\n true\n end",
"def localize_present?\n options[:localize] == :present\n end",
"def valid_locale?(locale_str)\n @loaded_locales.any? { |loc| loc.short == locale_str }\n end",
"def valid_locale?(locale)\n FastGettext.available_locales.include?(locale)\n end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def initialized\n @initialized ||= false\n end",
"def initialized?\n !(version.zero?)\n end",
"def available_locales\n translation_model.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def check_availability(locale)\n if ['en', 'es'].include? locale.to_s\n locale\n else\n false\n end\n end",
"def has_locale? locale\n locales.include?(locale.to_sym)\n end",
"def valid_locale?\n unless I18n.available_locales.detect {|alc| alc == I18n.locale }\n redirect_to root_with_locale_url(:locale => I18n.default_locale)\n return false\n end\n true\n end",
"def init?\n @init\n end",
"def available?\n if @available_rooms.length > 0\n return true\n end\n end",
"def localized?\n false\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def available_locale_preferences\n [@no_preference] + available_locales\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def init?\n status == :init\n end",
"def localized?\n self.entries_custom_fields.where(localized: true).count > 0\n end",
"def all_members_available?\n @rs.members.each do |member|\n machine = @machine.env.machine(member[:host], @machine.provider_name)\n return false if !member_available?(machine)\n end\n true\n end",
"def available?\n true\n end",
"def rooms_available?\n return @available_rooms.length > 0\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def enforce_available_locales!(locale); end",
"def locale_enabled?(locale)\r\n locale.to_s == I18n.default_locale.to_s || (get_language_completion(locale) || -1) >= I18n.config.language_threshold\r\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def _ready?\n true\n end",
"def missing_translation?\n @translations.any? { |x, v| v.nil? or v.blank? }\n end",
"def initted?\n @initted\n end",
"def initted?\n @initted\n end",
"def initialized?\n defined?(@state) && @state\n end",
"def initialized\n @initialized\n end",
"def clear_available_locales_set; end",
"def has_locale?(locale)\n @locales.has_key?(locale.to_s)\n end",
"def initialized?\n !!get_main_hub\n end",
"def initialized?\n server.present? && username.present? && api_token.present?\n end",
"def initiative_started?\n find_init.present?\n end",
"def matching_locales\n @_matching_locales ||= ::I18n.available_locales.select do |locale|\n locale.to_s.split(\"-\")[0] == language_code\n end\n end",
"def check_locales!\n default_locale = self.mounting_point.default_locale.to_s\n locales = self.site.locales.map(&:to_s)\n remote_locales = self.remote_site['locales']\n message = nil\n\n unless locales.all? { |l| remote_locales.include?(l) }\n message = \"Your site locales (#{locales.join(', ')}) do not match exactly the ones of your target (#{remote_locales.join(', ')})\"\n end\n\n if default_locale != remote_locales.first\n message = \"Your default site locale (#{default_locale.inspect}) is not the same as the one of your target (#{remote_locales.first.inspect})\"\n end\n\n if message\n self.output_resource_op self.site\n self.output_resource_op_status self.site, :error, message\n raise Mounter::WriterException.new('Use the force option in order to force your locale settings.')\n end\n end",
"def initialized?\n !@data.nil?\n end",
"def localized_strings?\n @lstrings ||= entry[:localized] && entry[:filename] =~ /strings.js$/\n end",
"def explicit_locale? = @explicit_locale",
"def localize_present?\n false\n end",
"def agent_available?\n @free_agents.count > 0\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def locales_are_valid\n preferred_locales.each do |l|\n errors.add(:preferred_locales_str, :invalid_code, code: l) unless ISO_639.find(l.to_s)\n end\n end",
"def languages?(candidate)\n raise ArgumentError, 'candidate must have a :languages key' unless candidate.has_key?(:languages)\n candidate[:languages].any? { |language| REQUIRED_LANGUAGES.include? language } ? true : false\nend",
"def fully_translated_in?(locale_code)\n (locale_counts[locale_code] || -1) >= phrase_count\n end",
"def loaded?\n true\n end",
"def loaded?\n !@all.nil?\n end",
"def one_locale_must_have_translations\n if (preferred_locales & configatron.full_locales).empty?\n errors.add(:preferred_locales_str, :one_must_have_translations, locales: configatron.full_locales.join(\",\"))\n end\n end",
"def has_language?\n !language.nil?\n end",
"def available?\n true\n end",
"def loaded?\n self.load_error = nil\n\n return true if loaded\n\n load_validations_pass?\n end",
"def isValid?\n if @Valid.nil?\n params = []\n joins = ''\n where = ''\n\n if not @Locales.empty?\n joins += ' LEFT JOIN `Locales` AS L ON RI.Locale = L.ID'\n where = 'L.Name COLLATE NOCASE IN (' + Array.new(@Locales.count, '?').join(',') + ') AND '\n params += @Locales\n end\n\n sql = \"SELECT 1 FROM `RailsI18N` RI #{joins} WHERE #{where}RI.`NameLowercase` = ? LIMIT 1\"\n params << @Name.downcase\n\n @Valid = Data::Storage.getStatement(sql).execute(*params).count > 0\n end\n @Valid\n end",
"def manga_available?\n return false if licensed?\n !@chapters.empty?\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def installable?\n uninstallable_reasons.empty?\n end",
"def candidates_exist_for_all_uninstalled?\n packages_missing_candidates.empty?\n end",
"def available?\n false\n end",
"def loaded?\n @loaded ||= false\n end",
"def initialized?\r\n if ENV[\"RAILS_ENV\"] == \"test\" || !User.table_exists? || $setup_disabled \r\n return false\r\n else \r\n $tmp_env = ENV[\"RAILS_ENV\"] || \"development\"\r\n return true\r\n end \r\n end",
"def is_module_options_ready?(mod)\n mod.options.each_pair do |option_name, option|\n return false if option.required && option.default.nil? && mod.datastore[option_name].blank?\n end\n\n true\n end"
] |
[
"0.73823977",
"0.7142856",
"0.7131945",
"0.71311575",
"0.68821996",
"0.6841551",
"0.6841551",
"0.68159914",
"0.67886496",
"0.6757621",
"0.6686077",
"0.6673215",
"0.66670877",
"0.66355133",
"0.662808",
"0.662808",
"0.6620581",
"0.6618938",
"0.6594498",
"0.6477159",
"0.6403219",
"0.6378061",
"0.63390034",
"0.6333228",
"0.63187414",
"0.6257402",
"0.6229908",
"0.62199044",
"0.6204829",
"0.6165111",
"0.6138486",
"0.61340624",
"0.61094654",
"0.61032045",
"0.60546577",
"0.60204804",
"0.5999697",
"0.5986835",
"0.5986396",
"0.5956276",
"0.5938446",
"0.59365267",
"0.59356236",
"0.59356236",
"0.5929901",
"0.5910628",
"0.589399",
"0.5889116",
"0.5887771",
"0.5884613",
"0.58836484",
"0.5881583",
"0.5879161",
"0.58745986",
"0.58619946",
"0.5858429",
"0.5856487",
"0.5856487",
"0.5854714",
"0.58312935",
"0.58185554",
"0.5808083",
"0.5801356",
"0.5796748",
"0.5788612",
"0.578856",
"0.5786653",
"0.5780479",
"0.5775219",
"0.57749975",
"0.5770842",
"0.5755352",
"0.57402676",
"0.5739877",
"0.57371044",
"0.5725053",
"0.57155555",
"0.56965166",
"0.56750727",
"0.5669856",
"0.5667693",
"0.56441724",
"0.56425995",
"0.5634667",
"0.56331635",
"0.5623628",
"0.5623628",
"0.5623419",
"0.5621525",
"0.5621525",
"0.5621525",
"0.5621525",
"0.5621525",
"0.5621525",
"0.5616005",
"0.560923",
"0.5605723",
"0.5586233",
"0.5585571",
"0.5583322"
] |
0.8490245
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.