Class: Translatomatic::ResourceFile::HTML
- Defined in:
- lib/translatomatic/resource_file/html.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.extensions ⇒ Array<String>
File extensions supported by this resource file.
Instance Method Summary collapse
-
#locale_path(locale) ⇒ Pathname
Create a path for the current resource file with a given locale.
-
#save(target = path, options = {}) ⇒ void
Save the resource file.
Methods inherited from XML
Methods inherited from Base
#format, #get, #initialize, #sentences, #set, #to_s, #valid?
Methods included from Util
Constructor Details
This class inherits a constructor from Translatomatic::ResourceFile::XML
Class Method Details
.extensions ⇒ Array<String>
Returns File extensions supported by this resource file.
5 6 7 |
# File 'lib/translatomatic/resource_file/html.rb', line 5 def self.extensions %w{html htm shtml} end |
Instance Method Details
#locale_path(locale) ⇒ Pathname
Create a path for the current resource file with a given locale
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/translatomatic/resource_file/html.rb', line 10 def locale_path(locale) extlist = extension_list if extlist.length >= 2 && loc_idx = find_locale(extlist) # part of the extension is the locale # replace that part with the new locale extlist[loc_idx] = locale.to_s new_extension = extlist.join(".") return strip_extensions.sub_ext("." + new_extension) else # add locale extension ext = path.extname # TODO: need configurable order for locale & ext here? #path.sub_ext("#{ext}." + locale.to_s) path.sub_ext("." + locale.to_s + ext) end end |
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
28 29 30 31 32 33 |
# File 'lib/translatomatic/resource_file/html.rb', line 28 def save(target = path, = {}) if @doc add_created_by unless [:no_created_by] target.write(@doc.to_html) end end |