Home » Can Google Translate translate a language content source code file from Chinese to Spanish?

Can Google Translate translate a language content source code file from Chinese to Spanish?

Solutons:


You need to separate the text you want to translate from the code. Google Translate can’t do that for you. It simply tries to translate all of the text given to it.

(How to put your application together so that it’s easier to translate the text of it into different languages is beyond the scope of this site.)

In the box on the left type the web address or drag and drop the address on to the page.

I just did it from English to Chinese for two different websites.

Here is the working code.

<!-- Translate flag start -->
                <div id="translateFlags">
                    <ul class="translation-links">
                      <a class="japanese" data-lang="Japanese"><img alt="Japanese" title="Japanese" src="https://webapps.stackexchange.com/questions/45462/images/flags/Ja_flag.png"></a>
                      <a class="english" data-lang="English"><img alt="English" title="English" src="images/flags/En_flag.png"></a>
                      <a class="tagalog" data-lang="Filipino"><img alt="Tagalog" title="Tagalog" src="images/flags/tl_flag.png"></a>
                      <a class="chinese" data-lang="Chinese (Traditional)"><img alt="Chinese" title="Chinese" src="images/flags/zh-TW_flag.png"></a>
                      <a class="korean" data-lang="Korean"><img alt="Korean" title="Korean" src="images/flags/ko_flag.png"></a>
                    </ul>
                </div>
            <!-- Translate design and connection -->
                    <style type="text/css">
                     .goog-te-banner-frame.skiptranslate{display:none!important;}body{top:0px!important;}

                     .translation-links {
                         right:0px;
                         top:3px;
                         }
                     .translation-links img {
                        filter:alpha(opacity=100);
                        -moz-opacity: 1.0;
                        opacity: 1.0;
                        border:0;
                        cursor: pointer;
                        margin-right:8px;
                        height:24px;
                        width:24px;
                        }
                     .translation-links img:hover {
                        filter:alpha(opacity=30);
                        -moz-opacity: 0.30;
                        opacity: 0.30;
                        }
                     </style>



                <div id="google_translate_element" style="display:none;"></div>
                <script type="text/javascript">
                  function googleTranslateElementInit() {
                    new google.translate.TranslateElement({pageLanguage: 'ja', autoDisplay: false},     'google_translate_element'); //remove the layout
                  }
                </script>

                <script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
                <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

                <script type="text/javascript" src="translate-it.js"></script>
                <script type="text/javascript">
                    TranslateIt.init();

function triggerHtmlEvent(element, eventName)
        {
            var event;
                if(document.createEvent) {
                    event = document.createEvent('HTMLEvents');
                    event.initEvent(eventName, true, true);
                    element.dispatchEvent(event);
        }
            else {
                event = document.createEventObject();
                event.eventType = eventName;
                element.fireEvent('on' + event.eventType, event);
                }
        }


                        // Flag click handler
                                       var jq = $.noConflict();
                                 jq('.translation-links a').click(function(e)
                                {
                                    e.preventDefault();
                                    var lang = jq(this).data('lang');
                                    jq('#google_translate_element select option').each(function(){
                                    if(jq(this).text().indexOf(lang) > -1) {
                                        jq(this).parent().val(jq(this).val());
                                        var container = document.getElementById('google_translate_element');
                                        var select = container.getElementsByTagName('select')[0];
                                        triggerHtmlEvent(select, 'change');
                                    }
                                    });
                                });

                </script>

Related Solutions

Difference between .bashrc and .bash_profile

Traditionally, when you log into a Unix system, the system would start one program for you. That program is a shell, i.e., a program designed to start other programs. It's a command line shell: you start another program by typing its name. The default shell, a...

Custom query with Castle ActiveRecord

In this case what you want is HqlBasedQuery. Your query will be a projection, so what you'll get back will be an ArrayList of tuples containing the results (the content of each element of the ArrayList will depend on the query, but for more than one value will...

What is the “You have new mail” message in Linux/UNIX?

Where is this mail? It's likely to be in the spool file: /var/mail/$USER or /var/spool/mail/$USER are the most common locations on Linux and BSD. (Other locations are possible – check if $MAIL is set – but by default, the system only informs you about...

How can I find the implementations of Linux kernel system calls?

System calls aren't handled like regular function calls. It takes special code to make the transition from user space to kernel space, basically a bit of inline assembly code injected into your program at the call site. The kernel side code that "catches" the...

Is a composite index also good for queries on the first field?

It certainly is. We discussed that in great detail under this related question: Working of indexes in PostgreSQL Space is allocated in multiples of MAXALIGN, which is typically 8 bytes on a 64-bit OS or (much less common) 4 bytes on a 32-bit OS. If you are not...

Explaining computational complexity theory

Hoooo, doctoral comp flashback. Okay, here goes. We start with the idea of a decision problem, a problem for which an algorithm can always answer "yes" or "no." We also need the idea of two models of computer (Turing machine, really): deterministic and...

Building a multi-level menu for umbraco

First off, no need pass the a parent parameter around. The context will transport this information. Here is the XSL stylesheet that should solve your problem: <!-- update this variable on how deep your menu should be --> <xsl:variable...

How to generate a random string?

My favorite way to do it is by using /dev/urandom together with tr to delete unwanted characters. For instance, to get only digits and letters: tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '' Alternatively, to include more characters from the OWASP...

How to copy a file from a remote server to a local machine?

The syntax for scp is: If you are on the computer from which you want to send file to a remote computer: scp /file/to/send username@remote:/where/to/put Here the remote can be a FQDN or an IP address. On the other hand if you are on the computer wanting to...

What is the difference between curl and wget?

The main differences are: wget's major strong side compared to curl is its ability to download recursively. wget is command line only. There's no lib or anything, but curl's features are powered by libcurl. curl supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP,...

Using ‘sed’ to find and replace [duplicate]

sed is the stream editor, in that you can use | (pipe) to send standard streams (STDIN and STDOUT specifically) through sed and alter them programmatically on the fly, making it a handy tool in the Unix philosophy tradition; but can edit files directly, too,...

How do I loop through only directories in bash?

You can specify a slash at the end to match only directories: for d in */ ; do echo "$d" done If you want to exclude symlinks, use a test to continue the loop if the current entry is a link. You need to remove the trailing slash from the name in order for -L to...

How to clear journalctl

The self maintenance method is to vacuum the logs by size or time. Retain only the past two days: journalctl --vacuum-time=2d Retain only the past 500 MB: journalctl --vacuum-size=500M man journalctl for more information. You don't typically clear the journal...

How can I run a command which will survive terminal close?

One of the following 2 should work: $ nohup redshift & or $ redshift & $ disown See the following for a bit more information on how this works: man nohup help disown Difference between nohup, disown and & (be sure to read the comments too) If your...

Get exit status of process that’s piped to another

bash and zsh have an array variable that holds the exit status of each element (command) of the last pipeline executed by the shell. If you are using bash, the array is called PIPESTATUS (case matters!) and the array indicies start at zero: $ false | true $...

Execute vs Read bit. How do directory permissions in Linux work?

When applying permissions to directories on Linux, the permission bits have different meanings than on regular files. The read bit (r) allows the affected user to list the files within the directory The write bit (w) allows the affected user to create, rename,...