Search the web and translate text in Project Siena

 

In a Project Siena app, you can search the web by using BingSearch and translate text by using BingTranslate. For a general overview of Project Siena and links to resources such as sample apps, video tutorials, and forums, see Project Siena.

Prerequisites

Configure your app for BingSearch

  1. Open Project Siena, and then press Alt-D to open a list of data sources.

  2. Click BingSearch, and then click Connect.

  3. In the Existing Sources pane, click Service Configuration under BingSearch, and then type or paste your primary key in the Primary Account Key box.

  4. Click Apply, and then press Esc to return to the design workspace.

Show news items

  1. Press Alt-V to open a list of controls, click Web in that list, and then click Bing News Search.

    Composite control to search for news using Bing

  2. Press F5, type one or more search terms in the box, and then click a result.

    The gallery shows news items about the term or terms that you specified and then opens the original webpage of the result that you clicked.

  3. In Project Siena, press Esc to return to the design workspace.

     

  4. (optional) Filter the news items by date:

    1. Press Ctrl-A to select all the controls you added, drag them to the center of the screen, and add an input-text control.

    2. (optional) Set the Default property of the control you just added to "mm/dd/yyyy" (including the quotation marks).

      For information about how to set a property, see Create your first app with Project Siena.

    3. Set the Items property of the gallery to this function:

      Filter(BingSearch!News(Text1!Text), DateValue(Date)>=DateValue(Text2!Text))

      If you added one or more input-text control before you built this function, they'll have different names than what this example shows. In that case, change Text1 to the name of the search box, and change Text2 to the name of the box that will contain a date.

    4. Press F5, and type a date in the text box on the left.

      The gallery shows only those news items that were posted on or after the date that you specified.

      Composite control for BingNews filtered by date in input-text control

Translate text

  1. Open Project Siena, press Alt-V to open a list of controls, click Web in that list, and then click Bing Translator.

  2. Press F5, click a language in the Translate to list, and then type one or more words in the box on the left.

    The box on the right translates the text that you typed into the language you specified.

    Type on the left, choose a language, and see the translation on the right

  3. Press Esc or click the Back button to return to the design workspace.

  4. (optional) Translate multiple lines of text:

    1. Click the input-text control on the left, click Design if it appears near the bottom of the screen, click More, and then click Options.

    2. In the list of modes, click Multi-line.

  5. (optional) Translate handwritten text:

    1. Press Alt-V to open a list of controls, click Pen in that list, and then drag the pen control below the other controls.

    2. With the pen control still selected, click Design if it appears near the bottom of the screen, click Options, and then set the Show Controls property to true.

    3. Click the input-text control on the left, click Data if it appears in the lower-left corner, and then set the Default property to Pen1!RecognizedText.

    4. Press F5, and then write a word in the pen control with your mouse or your finger.

      The box on the left converts your written text into typed text, and the box on the right translates it into the language you specified.

      An input-text box, a list, a label, and a pen element

    5. Press Esc or click the Back button to return to the design workspace.

  6. (optional) Hear translation:

    1. Add an audio control, and set its Media property to this function:

      BingTranslator!Speak(Label3!Text, Dropdown1!Selected!Value)

    2. Press F5, and then click the play button.

      The audio player speaks the translated text.

    3. Press Esc or click the Back button to return to the design workspace.

  7. (optional) Translate text from another source:

    1. Press Alt-V, click Web, and then click Bing News Search.

    2. Click Label3 (the box that shows the translated text), click Data if it appears in the lower-left corner, and then set the Text property of that label to this function:

      BingTranslator!Translate(Gallery1!Selected!Description, Dropdown1!Selected!Value)

    3. (optional) Delete Text1, and widen Label3.

      UI in which you can search for and translate news items