Class: Translatomatic::ResourceFile::Properties

Inherits:
Base
  • Object
show all
Defined in:
lib/translatomatic/resource_file/properties.rb

Overview

Properties resource file

Instance Attribute Summary

Attributes inherited from Base

#locale, #options, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

enabled?, #get, #get_context, #initialize, key_value?, #locale_path, #properties, #properties=, #save, #sentences, #set, #to_s, #type

Methods included from PathUtils

#detect_path_locale, #modify_path_locale

Constructor Details

This class inherits a constructor from Translatomatic::ResourceFile::Base

Class Method Details

.extensionsArray<String>

Returns File extensions supported by this resource file.

Returns:

  • (Array<String>)

    File extensions supported by this resource file



11
12
13
# File 'lib/translatomatic/resource_file/properties.rb', line 11

def self.extensions
  %w[properties]
end

.preferred_locale_separatorString

Returns Preferred character to use to separate the locale from the file basename.

Returns:

  • (String)

    Preferred character to use to separate the locale from the file basename



21
22
23
# File 'lib/translatomatic/resource_file/properties.rb', line 21

def self.preferred_locale_separator
  '_'
end

.supports_variable_interpolation?boolean

Returns true if this resource file supports variable interpolation.

Returns:

  • (boolean)

    true if this resource file supports variable interpolation



16
17
18
# File 'lib/translatomatic/resource_file/properties.rb', line 16

def self.supports_variable_interpolation?
  true
end

Instance Method Details

#create_variable(name) ⇒ String

Create an interpolated variable string.

Parameters:

  • name (String)

    The variable name

Returns:

  • (String)

    A string representing the interpolated variable, or nil if this resource file doesn’t support variable interpolation.



26
27
28
# File 'lib/translatomatic/resource_file/properties.rb', line 26

def create_variable(name)
  "{#{name}}"
end

#variable_regexRegexp

Returns A regexp used to match interpolated variables.

Returns:

  • (Regexp)

    A regexp used to match interpolated variables



31
32
33
# File 'lib/translatomatic/resource_file/properties.rb', line 31

def variable_regex
  /\{.*?\}/
end