diff --git a/lib/copycopter_client/i18n_backend.rb b/lib/copycopter_client/i18n_backend.rb index 048a89b..9d8811d 100644 --- a/lib/copycopter_client/i18n_backend.rb +++ b/lib/copycopter_client/i18n_backend.rb @@ -34,7 +34,7 @@ def translate(locale, key, options = {}) # Returns locales availabile for this Copycopter project. # @return [Array] available locales def available_locales - cached_locales = cache.keys.map { |key| key.split('.').first } + cached_locales = cache.keys.map { |key| key.split('.').first.to_sym } (cached_locales + super).uniq.map { |locale| locale.to_sym } end diff --git a/spec/copycopter_client/i18n_backend_spec.rb b/spec/copycopter_client/i18n_backend_spec.rb index 33d6a15..79da142 100644 --- a/spec/copycopter_client/i18n_backend_spec.rb +++ b/spec/copycopter_client/i18n_backend_spec.rb @@ -50,6 +50,14 @@ def build_backend subject.available_locales.should =~ [:en, :es, :fr] end + it "handles symbol locales from i18n gem" do + YAML.stubs(:load_file => { :en => { 'key' => 'value' } }) + I18n.stubs(:load_path => ["test.yml"]) + + cache['en.key'] = '' + + subject.available_locales.should =~ [:en] + end it "queues missing keys with default" do default = 'default value'