Community
    • Login

    Translate only part of an xml text from one language to another?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 1.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tonio Mr.BamboloT
      Tonio Mr.Bambolo
      last edited by

      Hello everyone
      I am new here.
      I state that I understand little about construction and codes, but by following some guide I can gradually understand (at least the little that is needed to solve my little things).
      In summary … I have been trying for a few days to modify an xml text file (actually it would be a translation file for a program I use) since Italian is not present (and not being good in English) I started thinking about perform a translation of the file yourself. The problem is that we are talking about 9k lines and after 3 hours of copy, translate and paste I have lost a good part of my low IQ. Is there a way to make the time a little easier?
      I also tried to have 2 files now now, post example:

      Original complete line:
      <message name = “point could not be projected”> el punto no se ha podido proyectar </message>

      First file section :
      <message name=" point could not be projected">

      Second file section (translate):
      il punto non poteva essere proiettato

      But I don’t find a way (if it exists) to recompile the lines with the translated text together

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Tonio Mr.Bambolo
        last edited by

        @Tonio-Mr-Bambolo ,

        I’m not 100% sure what you’re trying to ask.

        But if you are trying to translate a lot of strings in a file, you might want to follow the advice in this recent discussion. To do so, you would need to have the PythonScript plugin, and then edit the translation table in the script, and then run it on your code. (See also the FAQ on how to use PythonScript solutions)

        But if I have misunderstood your question, sorry. Maybe someone else will be able to reply in a way that’s meaningful to your question.

        Tonio Mr.BamboloT 1 Reply Last reply Reply Quote 0
        • Tonio Mr.BamboloT
          Tonio Mr.Bambolo @PeterJones
          last edited by

          @PeterJones

          Thanks Peter for your input.
          Unfortunately, as mentioned, I am not very familiar with codes and languages. I can hardly follow some tutorials and not always succeed.
          However I try to attach a small screen, where I try to make people understand (in my ignorance) maybe better.
          In summary from the original file, through the find and replace guides I was able to separate the texts, with the presumption of being able to put everything back together with the translated text.translate txt.jpg

          Tonio Mr.BamboloT 1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            Hello, @tonio-mr-bambolo, @peterjones and All,

            OK ! So, let’s start with two INPUT files :

            • The first file contains all the English translations :
            <message name=" point could not be projected">
            <message name=" polnt is out of tolerance">
            <message name=" points are out of tolerance">
            <message name=" points could not be projected">
            <message name=" result is out of tolerance">
            <message name=" results are out of tolerance">
            
            • The second file contains all the Italian translations
            il punto non poteva essere proiettato</message>
            il punto è fuori tolleranza</message>
            i punto sono fuori tolleranza</message>
            non é stato possibile proiettare i punti</message>
            il risultato è fuori tolleranza</message>
            i risultato sono fuori tolleranza</message>
            

            And you expect this OUTPUT file :

            <message name=" point could not be projected">il punto non poteva essere proiettato</message>
            <message name=" polnt is out of tolerance">il punto è fuori tolleranza</message>
            <message name=" points are out of tolerance">i punto sono fuori tolleranza</message>
            <message name=" points could not be projected">non é stato possibile proiettare i punti</message>
            <message name=" result is out of tolerance">il risultato è fuori tolleranza</message>
            <message name=" results are out of tolerance">i risultato sono fuori tolleranza</message>
            

            In this case, we can simply use the native N++ Column mode, with the help of the BetterMultiSelection plugin, to achieve this goal !

            However, if all your message name= lines are part of a larger XML file, you should, probably, follow the @peterjones advice and use a Python script

            Now, I tested my method with two files of 10,000 records and everything went fine !

            IMPORTANT : Of course, I suppose that your two INPUT files have, exactly, the same number of lines !


            Follow carefully this road map :

            • If the BetterMultiSelection plugin is not installed, in your N++ configuration :

              • Select the Plugins > Plugin Admin... option

              • In the first Available tab, select the BetterMultiSelection plugin

              • Click on the Install button

            • Move to the beginning of the first line of your Italian translations file

            • Select the Edit > Begin/End select N++ option

            • Now, move to the end of the last line of your Italian translations file

            • Hold down the Alt key and click on the mouse left button ( IMPORTANT )

            • Select, again, the Edit > Begin/End select N++ option

            Note : A partial column mode selection should occur

            • Click simultaneously, on the Shift and the End keys

            Note : The 10,000 lines are completely selected. This action may take some seconds !

            • Copy all these lines in the clipboard ( Ctrl + C )

            • Move to the end of the first line of the English translations file

            • Add some space characters ( I would say a minimum of 20 )

            • Paste the contents of the clipboard ( Ctrl + V )

            Note : This action may be long enough, depending of your configuation ( ~ 45s with an old laptop )

            • Now, open the Replace dialog ( Ctrl + H )

              • Untick all box options

              • SEARCH >\x20+

              • REPLACE >

              • Tick the Wrap around box option

              • Select the Regular expression search mode

              • Click on Replace All button

            • Hit the Esc key to close the dialog

            • Save your file ( Ctrl + S )

            Here you are !

            Best Regards,

            guy038

            Tonio Mr.BamboloT 1 Reply Last reply Reply Quote 0
            • Tonio Mr.BamboloT
              Tonio Mr.Bambolo @Tonio Mr.Bambolo
              last edited by

              Hello to you @guy038
              Many thanks also for your contribution and for the time you dedicate to me.
              Yes, the intention is to have a final file with the Italian translation.
              As already mentioned, I catapulted into something much more demanding than my little knowledge, but with guides, tutorials, examples, etc., with the notepad ++ (known 1 month ago) just to find a solution, a little something I managed to do.
              I have also read all the discussion addressed by the kind @Peter, but I believe that he is not up to face all that procedure (especially not even knowing the terminologies and functionalities)
              While as you have listed the instructions, with these I think I can try, in fact I will do it as soon as I return home this weekend.
              For now, thank you both for their support
              and as soon as I have tried it, I will inform you if it was successful or I gave up (most likely in my opinion) :)

              Thanks again

              Tonio

              1 Reply Last reply Reply Quote 0
              • Tonio Mr.BamboloT
                Tonio Mr.Bambolo @guy038
                last edited by

                Hello @guy038

                Thanks to your scheme to follow after 3 attempts (but only because I did not understand some terms well) I was able to reassemble the localization file.
                Now the menu is in Italian, even if some terms are translated (cupola instead Cappello :)) but in any case everything is finally working.
                The only regret is that I have received a great deal of breath on this comunity
                known through research and use of the program, But I will never be able to reciprocate the help received towards anyone, as I hardly know the first basic commands :(

                Anyway, thank you very much again

                sincere greetings

                Tonio

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors