How to copy-translate-paste certain lines?



  • I want to translate a file xml, I can select the lines (copy to translate) that I want but I can not replace all together (paste)

    Example:
    http://image.ibb.co/b0Ftno/example.jpg

    thanks in advance





  • I want to translate a file xml, I select Specific Rows using Regular expression, but the function in marks “Paste to (Replace) Bookmarked Lines” does not appear… i use the version 6.9.2

    Example:
    http://image.ibb.co/b0Ftno/example.jpg

    thanks in advance



  • @Cacarasa-Parada

    Invoke Replace dialog by pressing ctrl+h, then:

    • Find what zone: Turn on the dispenser.
    • Replace with zone: Quick! Power it now!
    • Action: press Replace button


  • @Scott-Sumner said:

    Turn on the dispenser

    Thank you!! but I do not understand the explanation …



  • @Cacarasa-Parada

    Perhaps it is me that doesn’t understand the question…but since no one else in 3 days jumped into help answer, maybe I am not alone in not understanding…



  • I just want to copy (Bookmarked) and paste the translated lines instead… thanks



  • Caveat: I have never intentionally used the Bookmarks feature or the “Paste To (Replace) Bookmarked Lines” command before… but I think it does what you want:

    using the original data:

    Gregory I
    Gregory II
    Gregory III
    Gregory IV
    William IV
    Victoria
    Edward VII
    Gregory V
    Edward VIII
    Gregory VI
    Elizabeth
    
    1. Search > Mark ...
      • Find What : Gregory\s+,
      • Bookmark Line,
      • Regular Expression
    2. Copy the text “George Nth” from this line
    3. Search > Bookmark > Paste To (Replace) Bookmarked Lines

    The data changes to:

    George Nth
    George Nth
    George Nth
    George Nth
    William IV
    Victoria
    Edward VII
    George Nth
    Edward VIII
    George Nth
    Elizabeth
    

    But I would think just using the search/replace dialog would be easier: Search > Replace

    • Find What : Gregory\x20+\w+,
    • Replace With : George Nth
    • Regular Expression (checked)
    • . matches newline (unchecked)
    • Replace All

    … but maybe there was a portion of your requirements that you didn’t include, that requires you bookmark multiple lines through multiple confusing matches before you do one solid replace.

    Notice, both of these replace all the originally matched data – either the bookmarked lines, or the matched text – with the George Nth: if you really want to replace each bookmarked line with something different, neither of these strategies will work for you. (Your use of the plural in “translated lines” makes me think you want something different for each line)

    It might be a good idea for you to more clearly define what you’re trying to achieve, with better example texts, and showing both “before” and “after” conditions… Embedding the text, so we can copy your actual text, is helpful. This FAQ shows some ways to embed text, and to embed the image so that it shows up in the post, rather than requiring us to click to another site.



  • Hello, @cacarasa-parada, @@peterjones, @scott-sumner and All,

    The last Peter’s post, speaking about the command Search > Bookmark > Paste To (Replace) Bookmarked Lines helped me to think of a true advantage of this command. Indeed, let’s suppose we would like to search a great amount of text and replace it with, a great amount of text, too !

    As you probably know, the Find what: and Replace with: zones cannot contain more than 2046 characters


    Regarding the Find what: field, you can, generally, consider any reasonable amount of text, while using regular expressions, by two means :

    • Using the generic regexes (?s-i)Beginning mark.+?Ending Mark Included or (?s-i)Beginning mark.+?(?=Ending Mark Excluded)

    For instance, in the N++ license.txt file, using the Regular expression search mode, the regex (?s-i)TERMS AND CONDITIONS.+?(?=NO WARRANTY) will select all the TERMS AND CONDITIONS paragraph, with its 11 points !

    • Using the generic regex (?s-i)(\QMark\E).+?\1\R, where Mark represents any odd string

    For instance, in the text, below, the part, which will be deleted or replaced, is delimited by the two specific strings ##**## and is matched with the regex (?s-i)(\Q##**##\E).+?\1\R

    Text
    ...
    ...
    ##**##
    ...
    ...
    Text
    ...
    ...
    Text
    ...
    ...
    Text
    ...
    ...
    ##**##
    ...
    ...
    

    Well, but regarding the Replace with: field, we cannot go the same way :-((. So, when the Replace area, contains more than 2046 characters :

    • First, place the replaced text, whatever its size, in the clipboard

    • Open the Search > Mark... command and tick the Bookmark line option

    • Search for your text, either using the regexes above or typing your simple text in the Find what:, in normal search mode

    • Finally, use the Search > Bookmark > Paste to (Replace) Bookmarked Lines

    Et voilà !

    Remark :

    Of course, we, just, can copy some static text in the clipboard and you cannot benefit, for instance, of the \# syntax, which allow us to rewrite the group #, in replacement. But, all in all , it’s a nice work-around ;-))

    Best Regards,

    guy038



  • @guy038 said:

    …the command…“Paste To (Replace) Bookmarked Lines” helped me to think of a true advantage of this command. Indeed, let’s suppose we would like to search a great amount of text and replace it with, a great amount of text…

    When Marking (with bookmarking hits enabled) finds a match that spans lines, it will only bookmark the FIRST line of the match, so this technique may not allow full replacement of “a great amount of text” searched for.



  • @Scott-Sumner said:

    @guy038 said:

    …the command…“Paste To (Replace) Bookmarked Lines” helped me to think of a true advantage of this command. Indeed, let’s suppose we would like to search a great amount of text and replace it with, a great amount of text…

    When Marking (with bookmarking hits enabled) finds a match that spans lines, it will only bookmark the FIRST line of the match, so this technique may not allow full replacement of “a great amount of text” searched for.

    Yes, this is the problem…

    •<Text>Text to replace 1</Text>
    <Answer1ID/>
    <Answer1Label/>
    </Dialog>
    <Dialog>
    •<Text>Text to replace 2</Text>
    <Answer1ID/>
    <Answer1Label/>
    •<Text>Text to replace 3</Text>
    <Answer1ID/>
    <Answer1Label/>

    Result:

    <Text>Text to replace 1</Text>
    <Text>Text to replace 2</Text>
    <Text>Text to replace 3</Text>
    <Answer1ID/>
    <Answer1Label/>
    </Dialog>
    <Dialog>
    <Answer1ID/>
    <Answer1Label/>
    <Answer1ID/>
    <Answer1Label/>



  • Hello, @cacarasa-parada, @@peterjones, @scott-sumner and All,

    Arrrrgh, sorry, I’m really confused ! I confess that, when elaborating my previous post, I just verified that my regexes were correct, but, without even doing a mark test :-(( I would, certainly, have noticed that well-known fact !

    However, the search regexes, of my previous post, are still reliable when a great amount of text must be simply replaced by the contents of the Replace area :-))

    On the other hand, if your regex identifies some specific lines in the scanned file(s), the Search > Bookmark > Paste to (Replace) Bookmarked Lines command allow you to replace each of those specific lines with the clipboard contents, which may have a consequent size !

    Now, even if the Mark feature would have marked all the lines, matched in a Multi-lines search, the Search > Bookmark > Paste to (Replace) Bookmarked Lines command would have been useless, as every line marked would have been replaced with the clipboard contents ! Not the expected result, isn’t it !!


    But I’ve got an easy solution !! Don’t you see ?..

    Well, regarding the different areas of text, whatever their reasonable size, which will be replaced, each, by the clipboard contents :

    • Insert a line, with a Start Mark, before these areas of text

    • Insert a line, with a Stop Mark after these areas of text

    • Now, perform the following global replacement :

    SEARCH (?s)^\QStart Mark\E.+?(?=^\QStop Mark\E)

    REPLACE Leave EMPTY

    => After replacement, the area(s) of text is/are deleted and it just remains one/several line(s) Stop Mark, which will be replaced by the clipboard contents. Now, everything is clear :

    • First, put the replaced text, whatever its size, in the clipboard

    • Open the Mark panel

    • Enter the simple search regex \QStop Mark\E

    • Tick the Bookmark line option and, may be, the Purge for each search option

    • Click on the Mark button

    • Select the Search > Bookmark > Paste to (Replace) Bookmarked Lines command

    => Every line Strop Mark will be replaced with the clipboard contents ;-))

    You are done !


    Remarks :

    • If your marks do not contain any special regex character, you can omit the \Q and \E escape sequences

    • Your marks can, also, be any simple character, assuming that your text does not contain this character at column 1. For instance, if your Start Mark and Stop Mark are, respectively, the # and the @ symbols, just use the regex S/R :

    SEARCH (?s)^#.+?(?=^@)

    REPLACE Leave EMPTY

    Cheers,

    guy038



  • Yes, this works really well. I need to replace many large blocks of text of variable size in a large xml file. This solution works well for me.


Log in to reply