Skip to content

Commit

Permalink
Merge pull request #1144 from ferrisoxide/fix-1102
Browse files Browse the repository at this point in the history
Support for hash arguments in i18n. Fixes #1102
  • Loading branch information
CloCkWeRX authored Aug 6, 2023
2 parents c11b44a + 4c68ecd commit 844ea33
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fat_free_crm/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def t(*args)
if args.size == 1
super(args.first, default: args.first.to_s)
elsif args.second.is_a?(Hash)
super(*args)
super(args.first, **args.second)
elsif args.second.is_a?(Integer)
super(args.first, count: args.second)
else
Expand Down
24 changes: 24 additions & 0 deletions spec/lib/fat_free_crm/i18n.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe 'I18n.t()' do

class TestController < ActionController::Base
include FatFreeCRM::I18n
end

let(:entity_string) { 'entities' }
let(:hidden_count) { 10 }
let(:test_controller) { TestController.new }

it 'should translate hash arguments' do
expect(test_controller.t(:not_showing_hidden_entities, entity: entity_string, count: hidden_count))
.to eq("Not showing 10 hidden entities.")
end
end

0 comments on commit 844ea33

Please sign in to comment.