Silverstripe 3: Links in translation string

I want to add a link around some text in a string which is translatable.

I am using silverstripe 3 and fluent and have my 2 language files set up and working.

I want to add a string on a page which can be translated but I also want part of the string to contain a hyperlink.

e.g.

EN - 'This is a link'
Second languauge - 'This is a link'

with a hyperlink on the word "link"

I have searched and tried all solutions I can find but with no success. Someone please help, how can I achieve this?

  • nav-link change color on carousel-item transition

    I have a carousel from Bootstrap 4 which includes three images. I want to change the nav-links color to red when the third carousel image is active and remove red color when the first and second images are active. Is there anyway to do this?

    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
          <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
          <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
          <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner" id="c-1">
          <div class="carousel-item active">
            <img id="c-1" class="d-block w-100 si" data-color='light' src="https://mrdp2rbn.portal.ir/themes/custom-2fc4/userfiles/e02825.jpg" alt="First slide">
          </div>
          <div class="carousel-item">
            <img id="c-2" class="d-block w-100 si" src="https://mrdp2rbn.portal.ir/themes/custom-2fc4/userfiles/decaa4.jpeg" alt="Second slide">
          </div>
          <div class="carousel-item c-3">
            <img id="" class="d-block w-100 c-3 si" src="https://mrdp2rbn.portal.ir/themes/custom-2fc4/userfiles/a7a145.jpg" alt="Third slide">
          </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    
  • Reference a Google Sheet hyperlink when sending email via Google Script

    I am using Google Script to send emails to an email list. One field of the email list includes a hyperlink that is customized for each recipient. So I need to be able to include this customized hyperlink found in Google Sheets as part of my email.

    function sendEmails() {
    
        // Set the spreadsheet file we are sending from: 
        var sheetname = SpreadsheetApp.openById('<google sheet url>');  
    
        // Set the sheet we are sending from:
        var sheet = sheetname.getSheetByName('Send Emails');
    
        // Set the first row of data in the list:
        var startRow = 2;
    
        // Set the number of rows of data in the list:
        var numRows = 2; 
    
        // Fetch the range of cells desired, using formula {first row}, {first column}, {number of rows}, {number of columns}:
        var dataRange = sheet.getRange(startRow, 8, numRows, 3);
    
        // Loop through each row in the range set defined above, sending an email based on the values in each row:
        var data = dataRange.getValues();
        for (i in data) {
          var row = data[i];
          var emailAddress = row[0]; // First column identified by [0]
          var subject = row[1]; // Second column identified by [1]
          var html = row[2] + "<a href=" + row[3] + "> click here </a>";  // Third column identified by [2] and fourth by [3]
          GmailApp.sendEmail(emailAddress, subject, 'unused but required text',{htmlBody: html});
        }
    
        Browser.msgBox(numRows + ' emails were sent successfully.');
    }
    

    (In this fourth column referenced by [3] I have the customized hyperlink in each row.)

    So most of this code works just fine and does generate a link but the link URL that generates in the email is "http://undefined/". So it's not grabbing the hyperlink URL from the column referenced by [3] for some reason; it's substituting "undefined"

  • Silverstripe 3: Use variables in translation files

    I have created a custom email for account validation when a user signs up to my website but I can't get the confirmation link to render in the email.

    I have 2 translation files and all the content in the email is translatable. I have added a hyperlink to a part of the string in the translation which is working fine and showing a link however when I try to use one of my variables in the anchor tag href it does not show the link, rather just keep the variable name in place.

    Is there some way I can escape this variable or use it as the href attribute for my link in my translation files?

  • Silverstripe 4: Configuring Fluent to make Widget fields translatable

    I'm setting up an SS project and want to add url based locales (/en, /gb, etc) using the silverstripe-fluent addon (https://github.com/tractorcow-farm/silverstripe-fluent). I've successfully installed it and can add locales using cms but the translatable fields only work for main content. How do i make other widgets and dataobjects translatable too?

    I've tried making it work for Widgets by following the github docs and doing the following listed below.

    mysite.yml

    Silverstripe\SiteConfig\SiteConfig:
      extensions:
        - TCM\SiteConfig\Extensions\LdaUrlExtension
        - TractorCow\Fluent\Extension\FluentExtension
    SiteTree:
      extensions:
        - TractorCow\Fluent\Extension\FluentFilteredExtension
    Widget:
      extensions:
        - TractorCow\Fluent\Extension\FluentVersionedExtension
      translate:
        - HTMLTitle
        - HTMLContent
    ContentWidget:
      extensions:
        - TractorCow\Fluent\Extension\FluentVersionedExtension
      translate:
        - HTMLTitle
        - HTMLContent
    Page:
      translate:
        - 'Heading'
        - 'Description'
    ---
    Name: myfluentconfig
    ---
    TractorCow\Fluent\Extension\FluentDirectorExtension:
      disable_default_prefix: false
    ---
    Name: fluentfieldconfig
    ---
    TractorCow\Fluent\Extension\FluentExtension:
      field_include:
        - Varchar(100)
        - DBHTMLText
        - HTMLTitle
        - HTMLContent
    

    PHP in widget.php or contentwidget.php

    private static $db = array(
            'HTMLTitle'       => 'HTMLVarchar',
            'HTMLContent'     => 'HTMLText',
            'PreviewBgImg'    => 'HTMLText',
            'TextPosition'    => 'Varchar(6)',
            'TextColour'      => 'Varchar(5)',
            'BackgroundColour' => 'Varchar(5)'
        );
    
    private static $translate = [
            'HTMLTitle',
            'HTMLText',
            'HTMLContent'
        ];
    

    I expected these to make my content widget fields also translatable but unfortunately widget content is still the same for all locales.

    I've also made sure to do dev/build?flush=all and manually even cleared contents of silverstripe-cache folder.

    Any help would be appreciated. Thank you.

  • Translate a picture

    I don’t know in which language is it and what it says. I tried with google translate but it doesn’t chinese, Korean or Japanese. Can someone tell me what it says and in which language?

    enter image description here

  • Oracle TRANSLATE function not working on ORDER BY

    I want to use TRANSLATE on my Oracle ORDER BY to sort a column as A,a,B,b...Z,z instead of A-Z, a-z.

    If I apply TRANSLATE in my SELECT and then ORDER BY that column it works fine. Coding TRANSLATE on the ORDER BY appears to have no affect.

    SELECT a1,  
           translate(a1,
                     'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz',
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') AS sort_col
    FROM (SELECT * 
            FROM (SELECT 'A' AS a1 FROM dual UNION 
                  SELECT 'a' AS a1 FROM dual UNION
                  SELECT 'B' AS a1 FROM dual UNION
                  SELECT '#' AS a1 FROM dual UNION
                  SELECT '0' AS a1 FROM dual ) )
    --ORDER BY 2 
    ORDER BY TRANSLATE(1,
                      'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz',
                      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
    

    The output order should be #,0,A,a,B