In this exercise you'll be providing a TranslationService
where paid members
have some quality assurance.
You have found a magical translation API that is able to fulfill any translation request in a reasonable amount of time, and you want to capitalize on this.
The magical API has a very minimal interface:
api.fetch(text)
fetches the translation of text
, returning two values:
translation
: the actual translationquality
: the quality expressed as a numberIf there is no translation available (because it has not been requested yet), the API throws an error. This also happens if a piece of text is untranslatable.
api.request(text, callback)
requests the translation of text
, calling the
callback
once it's ready, without a value.
The request
API is unstable, which means that sometimes the API will call the
callback
with an error. If that happens, it is okay to re-request.
Because of some previous users being lazy when programming, always requesting a translation, without even checking if the text was already translated, the API returns an error if the text has already been translated and blocks all access completely, forever.
These These are examples of tasks that fit the story of the translation service:
These are recommendations, not rules, for recurring terminology in the instructions (including stub commentary)
TranslationService
, or APIcallback
with an error
All the translation texts are Klingon to English.
The correct translation of 'arlogh Qoylu'pu'?
is How many times has it been heard?.