Module: ExtractI18n
- Defined in:
- lib/extract_i18n.rb,
lib/extract_i18n/cli.rb,
lib/extract_i18n/version.rb,
lib/extract_i18n/source_change.rb,
lib/extract_i18n/file_processor.rb,
lib/extract_i18n/html_extractor/match.rb,
lib/extract_i18n/slimkeyfy/whitespacer.rb,
lib/extract_i18n/slimkeyfy/slim_transformer.rb,
lib/extract_i18n/html_extractor/erb_document.rb,
lib/extract_i18n/html_extractor/two_way_regexp.rb,
lib/extract_i18n/html_extractor/match/base_match.rb,
lib/extract_i18n/html_extractor/match/node_match.rb,
lib/extract_i18n/html_extractor/match/attribute_match.rb,
lib/extract_i18n/html_extractor/match/plain_text_match.rb,
lib/extract_i18n/html_extractor/match/erb_directive_match.rb
Defined Under Namespace
Modules: Adapters, HTMLExtractor, Slimkeyfy Classes: CLI, FileProcessor, SourceChange
Constant Summary collapse
- VERSION =
"0.8.1"
Class Attribute Summary collapse
-
.html_fields_with_plaintext ⇒ Object
Returns the value of attribute html_fields_with_plaintext.
-
.ignore_functions ⇒ Object
Returns the value of attribute ignore_functions.
-
.ignore_hash_keys ⇒ Object
Returns the value of attribute ignore_hash_keys.
-
.ignorelist ⇒ Object
Returns the value of attribute ignorelist.
-
.strip_path ⇒ Object
Returns the value of attribute strip_path.
Class Method Summary collapse
Class Attribute Details
.html_fields_with_plaintext ⇒ Object
Returns the value of attribute html_fields_with_plaintext.
14 15 16 |
# File 'lib/extract_i18n.rb', line 14 def html_fields_with_plaintext @html_fields_with_plaintext end |
.ignore_functions ⇒ Object
Returns the value of attribute ignore_functions.
14 15 16 |
# File 'lib/extract_i18n.rb', line 14 def ignore_functions @ignore_functions end |
.ignore_hash_keys ⇒ Object
Returns the value of attribute ignore_hash_keys.
14 15 16 |
# File 'lib/extract_i18n.rb', line 14 def ignore_hash_keys @ignore_hash_keys end |
.ignorelist ⇒ Object
Returns the value of attribute ignorelist.
14 15 16 |
# File 'lib/extract_i18n.rb', line 14 def ignorelist @ignorelist end |
.strip_path ⇒ Object
Returns the value of attribute strip_path.
14 15 16 |
# File 'lib/extract_i18n.rb', line 14 def strip_path @strip_path end |
Class Method Details
.file_key(path) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/extract_i18n.rb', line 49 def self.file_key(path) path.gsub(strip_path, ''). gsub(%r{^/|/$}, ''). # remove leading and trailing slashes gsub(/\.[a-z\.]+$/, ''). # remove file extension gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'). # convert camelcase to underscore gsub(/([a-z\d])([A-Z])/, '\1_\2'). gsub('/_', '.'). gsub('/', '.'). tr("-", "_").downcase end |
.ignore?(string) ⇒ Boolean
38 39 40 |
# File 'lib/extract_i18n.rb', line 38 def self.ignore?(string) ExtractI18n.ignorelist.any? { |item| string.to_s[item] } end |
.key(string, length: 25) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/extract_i18n.rb', line 42 def self.key(string, length: 25) string.strip. unicode_normalize(:nfkd).gsub(/(\p{Letter})\p{Mark}+/, '\\1'). gsub(/\W+/, '_').downcase[0..length]. gsub(/_+$|^_+/, '') end |