Method: Translatomatic::ResourceFile::Base#initialize
- Defined in:
- lib/translatomatic/resource_file/base.rb
#initialize(path, locale = nil) ⇒ Translatomatic::ResourceFile::Base
Create a new resource file. If locale is unspecified, attempts to determine the locale of the file automatically, and if that fails, uses the default locale.
22 23 24 25 26 27 28 |
# File 'lib/translatomatic/resource_file/base.rb', line 22 def initialize(path, locale = nil) @path = path.kind_of?(Pathname) ? path : Pathname.new(path) @locale = Translatomatic::Locale.parse(locale || detect_locale || Translatomatic::Locale.default) raise t("resource.unknown_locale") unless @locale && @locale.language @valid = false @properties = {} end |