Class: Rosette::Core::Commands::TranslationLookupCommand
- Inherits:
-
GitCommand
- Object
- Command
- GitCommand
- Rosette::Core::Commands::TranslationLookupCommand
- Includes:
- WithLocale, WithRef, WithRepoName
- Defined in:
- lib/rosette/core/commands/translations/translation_lookup_command.rb
Overview
Returns the translation for the given phrase and locale combination.
Instance Attribute Summary collapse
-
#key ⇒ String
readonly
The phrase key.
-
#locale ⇒ String
readonly
The locale of the translation to look up.
-
#meta_key ⇒ String
readonly
The phrase meta key.
-
#repo_name ⇒ String
readonly
The name of the repo the phrase (and therefore the translation) belongs to.
Attributes included from WithRef
Attributes inherited from Command
Instance Method Summary collapse
Methods included from WithLocale
Methods included from WithRef
#commit_id, #set_commit_id, #set_ref
Methods included from WithRepoName
Methods inherited from GitCommand
Methods inherited from Command
#initialize, #messages, #valid?, validate, validators
Constructor Details
This class inherits a constructor from Rosette::Core::Commands::Command
Instance Attribute Details
#key ⇒ String (readonly)
Returns the phrase key.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 31 class TranslationLookupCommand < GitCommand attr_reader :key, :meta_key include WithRepoName include WithRef include WithLocale def set_key(key) @key = key self end def () = self end def execute phrase = datastore.lookup_phrase(repo_name, key, , commit_id) repo_config.tms.lookup_translation(locale_obj, phrase) end protected def repo_config configuration.get_repo(repo_name) end def locale_obj repo_config.locales.find { |l| l.code == locale } end end |
#locale ⇒ String (readonly)
Returns the locale of the translation to look up.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 31 class TranslationLookupCommand < GitCommand attr_reader :key, :meta_key include WithRepoName include WithRef include WithLocale def set_key(key) @key = key self end def () = self end def execute phrase = datastore.lookup_phrase(repo_name, key, , commit_id) repo_config.tms.lookup_translation(locale_obj, phrase) end protected def repo_config configuration.get_repo(repo_name) end def locale_obj repo_config.locales.find { |l| l.code == locale } end end |
#meta_key ⇒ String (readonly)
Returns the phrase meta key.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 31 class TranslationLookupCommand < GitCommand attr_reader :key, :meta_key include WithRepoName include WithRef include WithLocale def set_key(key) @key = key self end def () = self end def execute phrase = datastore.lookup_phrase(repo_name, key, , commit_id) repo_config.tms.lookup_translation(locale_obj, phrase) end protected def repo_config configuration.get_repo(repo_name) end def locale_obj repo_config.locales.find { |l| l.code == locale } end end |
#repo_name ⇒ String (readonly)
Returns the name of the repo the phrase (and therefore the translation) belongs to.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 31 class TranslationLookupCommand < GitCommand attr_reader :key, :meta_key include WithRepoName include WithRef include WithLocale def set_key(key) @key = key self end def () = self end def execute phrase = datastore.lookup_phrase(repo_name, key, , commit_id) repo_config.tms.lookup_translation(locale_obj, phrase) end protected def repo_config configuration.get_repo(repo_name) end def locale_obj repo_config.locales.find { |l| l.code == locale } end end |
Instance Method Details
#execute ⇒ Object
48 49 50 51 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 48 def execute phrase = datastore.lookup_phrase(repo_name, key, , commit_id) repo_config.tms.lookup_translation(locale_obj, phrase) end |
#set_key(key) ⇒ Object
38 39 40 41 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 38 def set_key(key) @key = key self end |
#set_meta_key(meta_key) ⇒ Object
43 44 45 46 |
# File 'lib/rosette/core/commands/translations/translation_lookup_command.rb', line 43 def () = self end |