Перевод JSON-файла с помощью Angular Gettext

Другим способом отправки электронной почты из JavaScript является использование directtomx.com следующим образом:

 Email = {
 Send : function (to,from,subject,body,apikey)
    {
        if (apikey == undefined)
        {
            apikey = Email.apikey;
        }
        var nocache= Math.floor((Math.random() * 1000000) + 1);
        var strUrl = "http://directtomx.azurewebsites.net/mx.asmx/Send?";
        strUrl += "apikey=" + apikey;
        strUrl += "&from=" + from;
        strUrl += "&to=" + to;
        strUrl += "&subject=" + encodeURIComponent(subject);
        strUrl += "&body=" + encodeURIComponent(body);
        strUrl += "&cachebuster=" + nocache;
        Email.addScript(strUrl);
    },
    apikey : "",
    addScript : function(src){
            var s = document.createElement( 'link' );
            s.setAttribute( 'rel', 'stylesheet' );
            s.setAttribute( 'type', 'text/xml' );
            s.setAttribute( 'href', src);
            document.body.appendChild( s );
    }
};

Затем вызовите его со своей страницы следующим образом:

 window.onload = function(){
    Email.apikey = "-- Your api key ---";
    Email.Send("to@domain.com","from@domain.com","Sent","Worked!");
 }

0
задан iwillbeawebdeveloper 13 July 2018 в 12:42
поделиться

1 ответ

Обработайте файл HTML самим скриптом во время сборки и сбрасывайте все переводимые сообщения в фиктивный исходный файл с синтаксисом, ожидаемым вашим экстрактором строк, возможно, примерно так:

<translate>I am ...</translate>
<translate>Placing an order</translate>
<translate>E-mailing customer service</translate>
0
ответ дан Guido Flohr 17 August 2018 в 12:50
поделиться
Другие вопросы по тегам:

Похожие вопросы: