Class: Rosette::Tms::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/rosette/tms/repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(configurator) ⇒ Repository

Creates a new instance of this repository.

Parameters:

  • configurator (Object)

    The implementation-specific configuration object for this repository.


11
12
# File 'lib/rosette/tms/repository.rb', line 11

def initialize(configurator)
end

Instance Method Details

#checksum_for(locale, commit_id) ⇒ String

Calculates a single unique value for the phrases and translations associated with a given commit id. Often this is calculated using a one-way hash like MD5 or SHA1. Checksum values can be compared to determine when translations for the given commit id have changed.

Parameters:

  • locale (Locale)

    The locale to calculate the checksum for.

  • commit_id (String)

    The commit id that contains the phrases and translations to calculate the checksum for.

Returns:

  • (String)

    the calculated checksum value

Raises:

  • (NotImplementedError)

69
70
71
72
# File 'lib/rosette/tms/repository.rb', line 69

def checksum_for(locale, commit_id)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#finalize(commit_id) ⇒ Object

Signals the repository to perform any cleanup tasks that may be required for the given commit once it's been fully processed.

Parameters:

  • commit_id (String)

Raises:

  • (NotImplementedError)

88
89
90
91
# File 'lib/rosette/tms/repository.rb', line 88

def finalize(commit_id)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#lookup_translation(locale, phrase) ⇒ String

Retrieves a single translation for the given phrase.

Parameters:

  • locale (Locale)

    The locale of the translation to retrieve.

  • phrase (Phrase)

    The phrase to retrieve the translation for.

Returns:

  • (String)

    the translation or nil of one cannot be found.

Raises:

  • (NotImplementedError)

32
33
34
35
# File 'lib/rosette/tms/repository.rb', line 32

def lookup_translation(locale, phrase)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#lookup_translations(locale, phrases) ⇒ Array<String>

Retrieves a list of translations for the given phrases.

Parameters:

  • locale (Locale)

    The locale of the translations to retrieve.

  • phrases (Array<Phrase>)

    The list of phrases to retrieve translations for.

Returns:

  • (Array<String>)

    an array of translations (note that the array contains strings, not [Translation] instances). The array may also contain nil entries where translations could not be found.

Raises:

  • (NotImplementedError)

22
23
24
25
# File 'lib/rosette/tms/repository.rb', line 22

def lookup_translations(locale, phrases)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#status(commit_id) ⇒ TranslationStatus

Collects and calculates status information for the phrases contained in the given commit as well as their translations per locale.

Parameters:

  • commit_id (String)

    The commit id to calculate the status for.

Returns:

  • (TranslationStatus)

Raises:

  • (NotImplementedError)

79
80
81
82
# File 'lib/rosette/tms/repository.rb', line 79

def status(commit_id)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#store_phrase(phrase, commit_id) ⇒ void

This method returns an undefined value.

Publishes a phrase in the repository. For web-based translation management systems, this probably means uploading the phrase over HTTP.

Parameters:

  • phrase (Phrase)

    The phrase to store.

  • commit_id (String)

    The commit id to associate the phrase with.

Raises:

  • (NotImplementedError)

55
56
57
58
# File 'lib/rosette/tms/repository.rb', line 55

def store_phrase(phrase, commit_id)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end

#store_phrases(phrases, commit_id) ⇒ void

This method returns an undefined value.

Publishes a list of phrases in the repository. For web-based translation management systems, this probably means uploading phrases to be translated over HTTP.

Parameters:

  • phrases (Array<Phrase>)

    The list of phrases to store.

  • commit_id (String)

    The commit id to associate the phrases with.

Raises:

  • (NotImplementedError)

44
45
46
47
# File 'lib/rosette/tms/repository.rb', line 44

def store_phrases(phrases, commit_id)
  raise NotImplementedError,
    'expected to be implemented in derived classes'
end