Bilingual with two columns

Comments

56 comments

  • Ninh

    Hi Rainer,

    danke fuer Ihr Support.

    Calculation note : 

    " Script syntax error: Unexpected token ILLEGAL."

    May be the formula has typo but i can't find it: 

    var sen = @all of table field in sentences;
    var ord = @all of order number in sentences;
    var rows = [];
    for( var i = 0; i < sen.length; i++){
    senArr = sen[i].split("\n"),
    for(var j = 2; j < senArr.length; j++){
    senOrd = senArr[j] + " | " + ord[i];
    rows.push(senOrd);
    }};
    var rows = rows.sort( function (a,b) {
    a = a.split(" | ")[1];
    b = b.split(" | ")[1];
    return a-b
    }).join("\n).
    "No. | First Letter | Word |  Sentence Order \n" +
    "--- | --- | --- | --- \n" +
    rows

    Please help me to correct it.

    =============================

    Other hand,

    In some article there are some number, ex: 2.017 years, 67.48$, 4.7 kg

    With formula: b = str.replace(/(<([^>]+)>)|\*|\n|\r/ig,"").replace(/!/g,"!.").replace(/\?/g,"?.").replace(/([.?])\s*(?=[A-Z0-9'"])/g, "$1|").split("|");

    Each break line is created if after number and dot (.) is blank character, as:

    2

    017 years

    4

    7 kg

    How don’t break line of text if after number and dot (.) are not blank character?

    Schones Wochenende fuer mein Hero :)

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Ninh,

    indeed there are 2 typos:

    1. Replace in this line the comma by a semicolon
    Correct line:

    senArr = sen[i].split("\n");

    2. In this line remove the dot behind the last bracket
    Correct line:

    }).join("\n)

     

     

    0
    Comment actions Permalink
  • Ninh

    Thank Rainer,

    i fixed these 2 typo, but calculation still " Script syntax error: Unexpected token ILLEGAL."

    maybe there is other typo?

    This formula

    ========

    var sen = @All of Vocabulary list;
    var ord = @All of Ordernumber;
    var rows = [];
    for( var i = 0; i < sen.length; i++){
    senArr = sen[i].split("\n");
    for(var j = 2; j < senArr.length; j++){
    senOrd = senArr[j] + " | " + ord[i];
    rows.push(senOrd);
    }};
    var rows = rows.sort( function (a,b) {
    a = a.split(" | ")[1];
    b = b.split(" | ")[1];
    return a-b
    }).join("\n)
    "No. | First Letter | Word | Sentence Order \n" +
    "--- | --- | --- | --- \n" +
    rows

    ========

    thanks

    0
    Comment actions Permalink
  • Rainer Grabowski

    Can't see a typo. Please share a screenshot of the calculation field where I can see the error notification.

    For your other question: In some article there are some number, ex: 2.017 years, 67.48$, 4.7 kg

    I've changed the whole formula, the for-loop shouldn't be necessary anymore. Please try this.

    @text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/")

    If that doesn't work please create a text which covers all possible scenarios. 

    Rainer

    0
    Comment actions Permalink
  • Ninh

    Please see my screenshot:

    0
    Comment actions Permalink
  • Rainer Grabowski

    .join("\n")

    0
    Comment actions Permalink
  • Ninh

    Great Rainer.

    the new calculation without "for statement" works well

    You are legend

    0
    Comment actions Permalink
  • Ninh

    Dear Rainer, das Ergebnis ist:

    In table, row sort by sentence order.

    Can sort by No. and First Letter of Word, ex:

    No.         First Letter       Word            Sentence Order

    1            A                         and                     10

    2            D                        during                  1

    ....

    Danke im Voraus

    0
    Comment actions Permalink
  • Ninh

    Hi Rainer,

    new Formula is brillante but the last sentence don't work: not change from dot to  // character

    Formula: 

    @1A_Original English.replace(/(<([^>]+)>)|\*|_/g,"").replace(/!/g,"!.").replace(/\?/g,"?.").replace(/[\u201C]/g,'"').replace(/([\.?])\s*(?=\s.?([^a-z0-9'" ]))/g,"//\n").replace(/\.([^.]*)$1/, "$1/")

    please see attachment image

    of the country test. => of the country test //

    0
    Comment actions Permalink
  • Rainer Grabowski

    Cause you don't use the code I've provided in my last but one posting. Take and it will work.

    0
    Comment actions Permalink
  • Rainer Grabowski

    For the table:

    var sen = @all of table field in sentences;
    var ord = @all of order number in sentences;
    var rows = [];
    for( var i = 0; i < sen.length; i++){
    senArr = sen[i].split("\n");
    for(var j = 2; j < senArr.length; j++){
    rows.push(senArr[j] + " | " + ord[i];);
    }};
    var rowsSort = rows.sort( function (a,b) {
    a = a.split("|")[1].trim();
    b = b.split("|")[1].trim();
    return a-b
    });
    var rows = [];
    for(var i = 0; i < rowsSort.length; i++){
    rows.push(rowsSort[i].replace(/\[.*?\]/,"[" + i + "]"));
    };
    "No. | First Letter | Word | Sentence Order \n" +
    "--- | --- | --- | --- \n" +
    rows.join("\n")
    0
    Comment actions Permalink
  • Ninh

    Danke Rainer,

    Sie sind richtig.

    That is my fail, Sorry.

    1. Can i  replace number (USA: dot) to number (Deutschland: comma). Ex: 100.5 kg USA => 100,5 kg DL,  in article?

    2. Numbered list: 1. or 2. or 10. to 1, 2, or 10, 

    Can use together with the formula: 

    @text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/")

    Thanks

    0
    Comment actions Permalink
  • Ninh

    and the table of above the formula:

    1. Order of columns: deviation on the left and column (No.): No data (please see ímage)

    2. some first rows has no data

    3. First letter is not in A-Z order

    Danke im Voraus

    0
    Comment actions Permalink
  • Rainer Grabowski

    Can i  replace number (USA: dot) to number (Deutschland: comma). Ex: 100.5 kg USA => 100,5 kg DL,  in article?

    Add .replace(/USA/g,"DL") at the end. 

    For the table:I need to see the code of the table in Sentences and a screenshot how this table looks like in an item. And also the code from words from the fields where the Sentences tables get their data.

    0
    Comment actions Permalink
  • Ninh

    Danke Rainer,

    i tested with 2 number : dot and comma. But no effort, please see image

    wish: dot => comma

    Coding

    many thanks

    0
    Comment actions Permalink
  • Ninh

    And the formula for this calculation field (vocabulary list)

    Danke

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    ok, I see, that was a misunderstanding :) I've thought you want to to remove the string "USA" by the string "DL", but you mean the number formatting. Forget my last .replace() and delete it. 

    This one should do what you want:

    .replace(/(\d),(\d{3})/g,"$1X_X$2").replace(/(\d)\.(\d)/g,"$1,$2").replace(/X_X/g,".")

    But this replaces also the dots by commas in a text like: "As mentioned in chapter 1.1 and chapter 2.2. this ... ".

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    And the formula for this calculation field (vocabulary list)

    I've meant the other vocabulary list (the one you get in var sen)

    0
    Comment actions Permalink
  • Ninh

    Danke great Rainer,

    good result from new calculation:

    @text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/").replace(/(\d),(\d{3})/g,"$1X_X$2").replace(/(\d)\.(\d)/g,"$1,$2").replace(/X_X/g,".")

    please see before and after in image

    1. Number: 1.405 (before) => 1,405 (after): correct. But 5,987 (before) => 5.987 (after): incorrect => with comma (before) don't need change to dot. That mean; only one way to change number formating: from comma to dot

    2. in chapter: More 1 digit are correct, ex: 1.2 or 3,1 or 4.0   but only one digit ex: 2. are incorrect

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Ninh,

    the new calculation does exactly what you wanted and what you've asked for: Transfer US number format to German number format.

    1000 separator US = comma, German = dot
    Decimal separator US = dot, German = comma.

    1.405 (US) == 1 decimal 405
    5,987 (US) == five thousand nine hundred eighty-seven

    1,405 (German) = 1 decimal 405
    5.987 (German) == five thousand nine hundred eighty-seven

    1.405 (before) => 1,405 (after): correct AND 5,987 (before) => 5.987 (after): CORRECT

    The issue with list number 2. isn't caused by the new code, but by the older part which removes dot by / line break. In this case in the original text between 2 and dot is a backslash, this backslash escapes the dot (you can google for "escape markdown").
    You can try .replace(/\\/g,"") but this doesn't work for all cases, depends on how the backslash was entered in the original text.

    Rainer

    0
    Comment actions Permalink
  • Ninh

    Hi great Rainer,

    You are diamond :)

    Number formating of DL is total different with USA  :)

    -------------------------------------------------------------

    About calculation Vocabulary list in App article:

    i use calculation with your help:

    // Vocabulary list = table field in Sentence

    // Số thứ tự câu ở Source = number in sentence

    var sen = @All of Vocabulary list;
    var ord = @All of Số thứ tự câu ở Source;
    var link= "https://podio.com/.../example/items/";
    var ID = @All of Example ID Link with nulls;
    var rows = [];
    for ( var i = 0; i < sen.length; i++){
    senArr = sen[i].split("\n");
    for(var j = 2; j < senArr.length; j++){
    if (senArr[j]+""!="") {
    rows.push(senArr[j] +"["+ ord[i]+ '](' + link + ID[i] + ')|');
    }
    }};
    var rowsSort = rows.sort( function (a,b) {
    a = a.split("|")[1].trim();
    b = b.split("|")[1].trim();
    return a-b;
    });
    var rows1 = [];

    for(var i = 0; i < rowsSort.length; i++){
    rows1.push(rowsSort[i].replace(/\#.*?\./g,(i+1)));
    };


    "|No. | First Letter | Word | Sentence Order |\n" +
    "|--- | --- | --- | ---| \n" +
    rows1.join("\n")

    =============

     

    And result: 

    all data display good. But only one issue: First Letter do not sort A-Z

    Please check and correct it if any.

    Danke shone.

    Schonest Wochenende

    Hope is last for this long topic with your help 

    0
    Comment actions Permalink
  • Rainer Grabowski

    In var rowsSort change the return line to:

    return ((a < b) ? -1 : ((a > b) ? 1 : 0))

    Rainer

    0
    Comment actions Permalink
  • Ninh

    thank you Rainer

    i was changed:

    var rowsSort = rows.sort( function (a,b) {
    a = a.split("|")[1].trim();
    b = b.split("|")[1].trim();
    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
    });

    and first letter still don't display A-Z

    Please help

    thanks

    0
    Comment actions Permalink
  • Ninh

    Dear Rainer,

    ich habe noch eine Frage.

    Changing: from ". to ". 

    and i use formula: replace("."",'".\n')

    Calculation note: script syntax error unexpected string

    ============

    Example:

    thank you

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    and i use formula: replace("."",'".\n')

    Don't understand what you want to achieve. Opening and closing quotation marks must be the same, eiter ' ', or " ". If you want to replace " it's  '"' (single double single).

     and first letter still don't display A-Z

    for me it works. There must be something in your linked letter formula which isn't correct. You can check that by entering

    rows[0]

    as last line, It should look like:

    n1 | [A](https://podio.com.....) | word  | n2

    n1 = some No., n2 = some sentence order No.

    0
    Comment actions Permalink
  • Ninh

    thank you for your help

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk