From 9be3d4a311b5bf583eec5d39986176cc40c112f2 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 26 Aug 2009 17:18:55 +0200 Subject: [PATCH] set encoding to utf-8 on all files --- lib/i18n.rb | 2 ++ lib/i18n/backend/base.rb | 11 +++++++---- lib/i18n/backend/cache.rb | 2 ++ lib/i18n/backend/chain.rb | 2 ++ lib/i18n/backend/fallbacks.rb | 2 ++ lib/i18n/backend/gettext.rb | 2 ++ lib/i18n/backend/pluralization.rb | 2 ++ lib/i18n/backend/simple.rb | 2 ++ lib/i18n/exceptions.rb | 2 ++ lib/i18n/gettext.rb | 2 ++ lib/i18n/helpers/gettext.rb | 2 ++ lib/i18n/locale/fallbacks.rb | 2 ++ lib/i18n/locale/tag.rb | 2 ++ lib/i18n/locale/tag/parents.rb | 2 ++ lib/i18n/locale/tag/rfc4646.rb | 2 ++ lib/i18n/locale/tag/simple.rb | 2 ++ lib/i18n/string.rb | 2 ++ test/all.rb | 2 ++ test/api/basics.rb | 2 ++ test/api/interpolation.rb | 2 ++ test/api/lambda.rb | 2 ++ test/api/link.rb | 2 ++ test/api/localization/date.rb | 2 ++ test/api/localization/date_time.rb | 2 ++ test/api/localization/lambda.rb | 2 ++ test/api/localization/time.rb | 2 ++ test/api/pluralization.rb | 2 ++ test/api/translation.rb | 2 ++ test/backend/cache/cache_test.rb | 2 ++ test/backend/chain/api_test.rb | 2 ++ test/backend/chain/chain_test.rb | 2 ++ test/backend/fallbacks/api_test.rb | 2 ++ test/backend/fallbacks/fallbacks_test.rb | 2 ++ test/backend/pluralization/api_test.rb | 2 ++ test/backend/pluralization/pluralization_test.rb | 2 ++ test/backend/simple/all.rb | 2 ++ test/backend/simple/api_test.rb | 1 + test/backend/simple/lookup_test.rb | 1 + test/backend/simple/setup.rb | 2 ++ test/backend/simple/translations_test.rb | 1 + test/fixtures/locales/en.rb | 2 ++ test/fixtures/locales/plurals.rb | 2 ++ test/gettext/api_test.rb | 2 ++ test/gettext/backend_test.rb | 2 ++ test/i18n_exceptions_test.rb | 2 ++ test/i18n_load_path_test.rb | 1 + test/i18n_test.rb | 2 ++ test/locale/fallbacks_test.rb | 2 ++ test/locale/tag/rfc4646_test.rb | 2 ++ test/locale/tag/simple_test.rb | 2 ++ test/string_test.rb | 2 ++ test/test_helper.rb | 1 + test/with_options.rb | 2 ++ 53 files changed, 106 insertions(+), 4 deletions(-) diff --git a/lib/i18n.rb b/lib/i18n.rb index 11401da7..c3c3f439 100755 --- a/lib/i18n.rb +++ b/lib/i18n.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + # Authors:: Matt Aimonetti (http://railsontherun.com/), # Sven Fuchs (http://www.artweb-design.de), # Joshua Harvey (http://www.workingwithrails.com/person/759-joshua-harvey), diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index 0fa092ac..8e9566af 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'yaml' module I18n @@ -102,11 +104,12 @@ def lookup(locale, key, scope = [], separator = nil) return unless key init_translations unless initialized? keys = I18n.send(:normalize_translation_keys, locale, key, scope, separator) - keys.inject(translations) do |result, k| - if (x = result[k.to_sym]).nil? - return nil + keys.inject(translations) do |result, key| + key = key.to_sym + if result.respond_to?(:has_key?) and result.has_key?(key) + result[key] else - x + return nil end end end diff --git a/lib/i18n/backend/cache.rb b/lib/i18n/backend/cache.rb index 91cf6550..1de9013b 100644 --- a/lib/i18n/backend/cache.rb +++ b/lib/i18n/backend/cache.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + # This module allows you to easily cache all responses from the backend - thus # speeding up the I18n aspects of your application quite a bit. # diff --git a/lib/i18n/backend/chain.rb b/lib/i18n/backend/chain.rb index 34b0e279..6f212ccf 100644 --- a/lib/i18n/backend/chain.rb +++ b/lib/i18n/backend/chain.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module I18n module Backend # Backend that chains multiple other backends and checks each of them when diff --git a/lib/i18n/backend/fallbacks.rb b/lib/i18n/backend/fallbacks.rb index 87574daa..7b8883de 100644 --- a/lib/i18n/backend/fallbacks.rb +++ b/lib/i18n/backend/fallbacks.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/locale/fallbacks' # I18n locale fallbacks are useful when you want your application to use diff --git a/lib/i18n/backend/gettext.rb b/lib/i18n/backend/gettext.rb index f5e72fdd..6400a0d9 100644 --- a/lib/i18n/backend/gettext.rb +++ b/lib/i18n/backend/gettext.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/gettext' require File.expand_path(File.dirname(__FILE__) + '/../../../vendor/po_parser.rb') diff --git a/lib/i18n/backend/pluralization.rb b/lib/i18n/backend/pluralization.rb index 30d9e691..92a6989c 100644 --- a/lib/i18n/backend/pluralization.rb +++ b/lib/i18n/backend/pluralization.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + # I18n locale fallbacks are useful when you want your application to use # translations from other locales when translations for the current locale are # missing. E.g. you might want to use :en translations when translations in diff --git a/lib/i18n/backend/simple.rb b/lib/i18n/backend/simple.rb index 417b48ba..5875935f 100644 --- a/lib/i18n/backend/simple.rb +++ b/lib/i18n/backend/simple.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/backend/base' # Stub class for the Simple backend. The actual implementation is provided by diff --git a/lib/i18n/exceptions.rb b/lib/i18n/exceptions.rb index 7acc037a..d8aee59b 100644 --- a/lib/i18n/exceptions.rb +++ b/lib/i18n/exceptions.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + class KeyError < IndexError def initialize(message = nil) super(message || "key not found") diff --git a/lib/i18n/gettext.rb b/lib/i18n/gettext.rb index 7556ad65..fd37ace1 100644 --- a/lib/i18n/gettext.rb +++ b/lib/i18n/gettext.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module I18n module Gettext PLURAL_SEPARATOR = "\001" diff --git a/lib/i18n/helpers/gettext.rb b/lib/i18n/helpers/gettext.rb index 70ca6e38..13bbf574 100644 --- a/lib/i18n/helpers/gettext.rb +++ b/lib/i18n/helpers/gettext.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module I18n module Helpers # Implements classical Gettext style accessors. To use this include the diff --git a/lib/i18n/locale/fallbacks.rb b/lib/i18n/locale/fallbacks.rb index ff1410bb..1a3008f5 100644 --- a/lib/i18n/locale/fallbacks.rb +++ b/lib/i18n/locale/fallbacks.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/locale/tag' # Locale Fallbacks diff --git a/lib/i18n/locale/tag.rb b/lib/i18n/locale/tag.rb index bf50b23d..74940143 100644 --- a/lib/i18n/locale/tag.rb +++ b/lib/i18n/locale/tag.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/locale/tag/simple' require 'i18n/locale/tag/rfc4646' diff --git a/lib/i18n/locale/tag/parents.rb b/lib/i18n/locale/tag/parents.rb index 41dc0b94..c81fc28d 100644 --- a/lib/i18n/locale/tag/parents.rb +++ b/lib/i18n/locale/tag/parents.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module I18n module Locale module Tag diff --git a/lib/i18n/locale/tag/rfc4646.rb b/lib/i18n/locale/tag/rfc4646.rb index dd62dfec..1c1c149f 100644 --- a/lib/i18n/locale/tag/rfc4646.rb +++ b/lib/i18n/locale/tag/rfc4646.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + # RFC 4646/47 compliant Locale tag implementation that parses locale tags to # subtags such as language, script, region, variant etc. # diff --git a/lib/i18n/locale/tag/simple.rb b/lib/i18n/locale/tag/simple.rb index ce30b659..f9393e54 100644 --- a/lib/i18n/locale/tag/simple.rb +++ b/lib/i18n/locale/tag/simple.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'i18n/locale/tag/parents' # Simple Locale tag implementation that computes subtags by simply splitting diff --git a/lib/i18n/string.rb b/lib/i18n/string.rb index d459c03d..dbcd6192 100644 --- a/lib/i18n/string.rb +++ b/lib/i18n/string.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + =begin heavily based on Masao Mutoh's gettext String interpolation extension http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb diff --git a/test/all.rb b/test/all.rb index df7398e8..1a8e4668 100644 --- a/test/all.rb +++ b/test/all.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + Dir[File.dirname(__FILE__) + '/**/*_test.rb'].sort.each do |file| require file end diff --git a/test/api/basics.rb b/test/api/basics.rb index 5009ab50..ac95c0d9 100644 --- a/test/api/basics.rb +++ b/test/api/basics.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/interpolation.rb b/test/api/interpolation.rb index 0275ab23..4f4013cb 100644 --- a/test/api/interpolation.rb +++ b/test/api/interpolation.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/lambda.rb b/test/api/lambda.rb index 4558d234..e626ee0c 100644 --- a/test/api/lambda.rb +++ b/test/api/lambda.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/link.rb b/test/api/link.rb index 898b4c72..b3f8b4c5 100644 --- a/test/api/link.rb +++ b/test/api/link.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/localization/date.rb b/test/api/localization/date.rb index a8c00f3f..c0c6bd46 100644 --- a/test/api/localization/date.rb +++ b/test/api/localization/date.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/localization/date_time.rb b/test/api/localization/date_time.rb index 18cb5d48..4203ebc8 100644 --- a/test/api/localization/date_time.rb +++ b/test/api/localization/date_time.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/localization/lambda.rb b/test/api/localization/lambda.rb index e6d3c4e6..bc853c70 100644 --- a/test/api/localization/lambda.rb +++ b/test/api/localization/lambda.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/localization/time.rb b/test/api/localization/time.rb index 4ca13719..e8ed4d6a 100644 --- a/test/api/localization/time.rb +++ b/test/api/localization/time.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/pluralization.rb b/test/api/pluralization.rb index a06d0b01..43be97bf 100644 --- a/test/api/pluralization.rb +++ b/test/api/pluralization.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/api/translation.rb b/test/api/translation.rb index 855c5da2..a1ffd230 100644 --- a/test/api/translation.rb +++ b/test/api/translation.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Api diff --git a/test/backend/cache/cache_test.rb b/test/backend/cache/cache_test.rb index 672fb06f..19dfedb2 100644 --- a/test/backend/cache/cache_test.rb +++ b/test/backend/cache/cache_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/cache' require 'activesupport' diff --git a/test/backend/chain/api_test.rb b/test/backend/chain/api_test.rb index 784dfe0e..279eae37 100644 --- a/test/backend/chain/api_test.rb +++ b/test/backend/chain/api_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/chain' diff --git a/test/backend/chain/chain_test.rb b/test/backend/chain/chain_test.rb index be4b1fd6..0e0e7a10 100644 --- a/test/backend/chain/chain_test.rb +++ b/test/backend/chain/chain_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/chain' diff --git a/test/backend/fallbacks/api_test.rb b/test/backend/fallbacks/api_test.rb index 746aafad..2eaf26d6 100644 --- a/test/backend/fallbacks/api_test.rb +++ b/test/backend/fallbacks/api_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/fallbacks' diff --git a/test/backend/fallbacks/fallbacks_test.rb b/test/backend/fallbacks/fallbacks_test.rb index f557e1d8..49db203c 100644 --- a/test/backend/fallbacks/fallbacks_test.rb +++ b/test/backend/fallbacks/fallbacks_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/fallbacks' diff --git a/test/backend/pluralization/api_test.rb b/test/backend/pluralization/api_test.rb index f11cf1a6..a567c711 100644 --- a/test/backend/pluralization/api_test.rb +++ b/test/backend/pluralization/api_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/pluralization' diff --git a/test/backend/pluralization/pluralization_test.rb b/test/backend/pluralization/pluralization_test.rb index 1ba31e3e..237e330d 100644 --- a/test/backend/pluralization/pluralization_test.rb +++ b/test/backend/pluralization/pluralization_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') require 'i18n/backend/pluralization' diff --git a/test/backend/simple/all.rb b/test/backend/simple/all.rb index 4847457f..09a5afac 100644 --- a/test/backend/simple/all.rb +++ b/test/backend/simple/all.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + Dir[File.dirname(__FILE__) + '/*_test.rb'].each do |file| require file end diff --git a/test/backend/simple/api_test.rb b/test/backend/simple/api_test.rb index 6c2f2efb..6d459aa8 100644 --- a/test/backend/simple/api_test.rb +++ b/test/backend/simple/api_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') class I18nSimpleBackendApiBasicsTest < Test::Unit::TestCase diff --git a/test/backend/simple/lookup_test.rb b/test/backend/simple/lookup_test.rb index efffa811..1a362c93 100644 --- a/test/backend/simple/lookup_test.rb +++ b/test/backend/simple/lookup_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') class I18nSimpleBackendLookupTest < Test::Unit::TestCase diff --git a/test/backend/simple/setup.rb b/test/backend/simple/setup.rb index ab18e166..7cc38240 100644 --- a/test/backend/simple/setup.rb +++ b/test/backend/simple/setup.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + module Tests module Backend module Simple diff --git a/test/backend/simple/translations_test.rb b/test/backend/simple/translations_test.rb index 95eaf458..c170d0a5 100644 --- a/test/backend/simple/translations_test.rb +++ b/test/backend/simple/translations_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase diff --git a/test/fixtures/locales/en.rb b/test/fixtures/locales/en.rb index c6e3c5ad..e847d104 100644 --- a/test/fixtures/locales/en.rb +++ b/test/fixtures/locales/en.rb @@ -1 +1,3 @@ +# encoding: utf-8 + { :en => { :fuh => { :bah => "bas" } } } \ No newline at end of file diff --git a/test/fixtures/locales/plurals.rb b/test/fixtures/locales/plurals.rb index 816b5417..ac0d3d5b 100644 --- a/test/fixtures/locales/plurals.rb +++ b/test/fixtures/locales/plurals.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + { :af => { :i18n => { :pluralize => lambda { |n| n == 1 ? :one : :other } } }, :am => { :i18n => { :pluralize => lambda { |n| (0..1).include?(n) ? :one : :other } } }, diff --git a/test/gettext/api_test.rb b/test/gettext/api_test.rb index aa94b6b1..8feff9c5 100644 --- a/test/gettext/api_test.rb +++ b/test/gettext/api_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require 'i18n/backend/gettext' require 'i18n/helpers/gettext' diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index bcb4ba33..07966fdb 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require 'i18n/backend/gettext' require 'i18n/helpers/gettext' diff --git a/test/i18n_exceptions_test.rb b/test/i18n_exceptions_test.rb index 21594ecc..3991769b 100644 --- a/test/i18n_exceptions_test.rb +++ b/test/i18n_exceptions_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/test_helper') class I18nExceptionsTest < Test::Unit::TestCase diff --git a/test/i18n_load_path_test.rb b/test/i18n_load_path_test.rb index 6b492e33..e17b6b5b 100644 --- a/test/i18n_load_path_test.rb +++ b/test/i18n_load_path_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/test_helper') class I18nLoadPathTest < Test::Unit::TestCase diff --git a/test/i18n_test.rb b/test/i18n_test.rb index cfd6ab70..268c3094 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/test_helper') class I18nTest < Test::Unit::TestCase diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index a59e20e0..9720e1c4 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.dirname(__FILE__) + '/../test_helper.rb' require 'i18n/locale/fallbacks' require 'i18n/locale/tag' diff --git a/test/locale/tag/rfc4646_test.rb b/test/locale/tag/rfc4646_test.rb index c3613472..6bd47bb8 100644 --- a/test/locale/tag/rfc4646_test.rb +++ b/test/locale/tag/rfc4646_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.dirname(__FILE__) + '/../../test_helper.rb' require 'i18n/locale/tag' require 'i18n/locale/tag/rfc4646' diff --git a/test/locale/tag/simple_test.rb b/test/locale/tag/simple_test.rb index 73cfa7a1..c3174472 100644 --- a/test/locale/tag/simple_test.rb +++ b/test/locale/tag/simple_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.dirname(__FILE__) + '/../../test_helper.rb' require 'i18n/locale/tag' require 'i18n/locale/tag/simple' diff --git a/test/string_test.rb b/test/string_test.rb index 6e378708..79458ac0 100644 --- a/test/string_test.rb +++ b/test/string_test.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require File.expand_path(File.dirname(__FILE__) + '/test_helper') # thanks to Masao's String extensions these should work the same in diff --git a/test/test_helper.rb b/test/test_helper.rb index 4c517cc5..189c24ae 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + $:.unshift "lib" require 'rubygems' diff --git a/test/with_options.rb b/test/with_options.rb index 8a51443d..a654c730 100644 --- a/test/with_options.rb +++ b/test/with_options.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + # this is only here so we can test I18n works nicely with ActiveSupports # with_options. Maybe we can just remove it?