Translation support

Goals

  • to make a really simple and usable support for text in many laguages in Aida web applications
  • easy user interface for professional translators
  • in-place translation of the text directly on the web pages
  • smooth migration of the existing text in apps to the multilingual one
  • translations stored in class methods of Apps, for easier version control and distribution

Multilingual text in apps

  • default: e addText: 'Bonjour'
  • multilingual: e addText: #fr->'Bonjour'
  • example in WebDemoApp>>viewCalendar, where the header is written multilingual:
    • e addTextH1: #en->'Date input with Javascript Calendar example'.
    • See also class side of WebDemo, protocol translations, for instance for Spanish translation:
    • esViewCalendar
          ^#(
          ('Date input with Javascript Calendar example'->'Ejemplo de entrada de fecha con un calendario javascript')
          )

Implementation

  • WebText
    • #isMultilingual, if text is actually an association #lang->text
    • #printHTMLPage - if multilangual, translated text is retrieved with translator help from class side of an App this text belongs to.
    • protocol translation
    • #prepareForTranslation - when session is in translation mode, object WebText is replaced with WebInplaceEditableText widget (in WebApplication>>printWebView:on: at once for text in a whole page)
  • WebElement
    • #prepareForTranslation  looks down recursivelly in subelement hierarchy for WebTexts, which are then replaced with WebInplaceEditableTexts
  • WebApplication
    • #printWebView:on: replaces all multilingual text with inline editable text in a page, if session is in translation mode.
  • WebSession
    • session modes, #inTranslationMode, for now if #inAdminMode or #inDevMode
  • WebTranslator
    • offers a translation support to web apps. Apps on class side hold translations of the text. WebTranslator is then called by executing app to find a proper translation for each text.
    • AIDASite>>translator gets the one translator per site
    • translator's #translate:to:for:on: is called indirectly from WebText>>printHTMLPage, that is, just before a text is streamed to the web browser.
    • translator gets translations from a class side of App on which this webpage was composed.
  • WebTranslDict
    • is a dictionary holding the last level in WebTranslator cache. Special dictionary is needed to catch the changes when doing translations by translation tools and storing them back to appropriate class translation methods.
    • #at:put: is called by WebInlineEditableText widget after the text change is posted. See WebText>>#prepareForTranslation, how the aspect of this widget is prepared to achieve that.
  • text is stored in class methods in UTF-8 encoding. Encoding happens in WebTranslator>>writeBackPairs.., decoding while read in cache in WebTranslator>>pairsForLang:...