working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,413 snippets matching: translate

    public by marksimon232 modified Jun 10, 2014  252575  1  6  0

    translate messages with html tags - Code snippets for symfony 1.x

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-open.org/committees/xliff/documents/xliff.dtd">
    <xliff version="1.0">
        <file original="global" source-language="en" datatype="plaintext" date="2009-08-12T12:32:00Z">
            <header/>
            <body>
                ...
                <trans-unit>
                    <source>from %from_date%<br/>to %to_date%</source>
                    <target>de %from_date%<br/>até %to_date%</target>
                </trans-unit>
            </body>
        </file>
    </xliff>
    
    

    public by Geometry modified Aug 7, 2016  697  0  5  0

    Translate: Translates the given <see cref="IdxDataType"/> to a .NET <see cref="Type"/>.

    Translates the given to a .NET . The type to be translated. A .NET that represents the .
    /// <summary>
    ///   Translates the given <see cref="IdxDataType"/> to a .NET <see cref="Type"/>.
    /// </summary>
    /// 
    /// <param name="type">The type to be translated.</param>
    /// 
    /// <returns>
    ///   A .NET <see cref="Type"/> that represents the <see cref="IdxDataType"/>.
    /// </returns>
    /// 
    public static Type Translate(IdxDataType type)
    {
        switch (type)
        {
            case IdxDataType.UnsignedByte:
                return typeof(byte);
            case IdxDataType.SignedByte:
                return typeof(sbyte);
            case IdxDataType.Short:
                return typeof(short);
            case IdxDataType.Integer:
                return typeof(int);
            case IdxDataType.Float:
                return typeof(float);
            case IdxDataType.Double:
                return typeof(double);
        }
    
        throw new ArgumentOutOfRangeException("type");
    }

    public by yourfriendcaspian modified Sep 2, 2017  379  0  3  0

    Install Mysql with Python and Django Debian/Derivatives - Translated

    Install Mysql with Python and Django Debian/Derivatives - Translated: mysql_python_on_debian.txt
    #Install Mysql with Python and Django Debian/Derivatives 
    
    #To install we need to have some dependencies in the system for now we will show on
    #Debian and Derivatives.
    
    #But first install updates and MySQL
    
    ```
    $ sudo apt-get update
    $ sudo apt-get upgrade
    ```	
    
    # ** NOTE: ** 
    #Each System has its commands for updating, if your machine is not derived from Debian ** look for them **
    
    ##Install MySQL
    
    ```
    $ sudo apt-get install mysql-server mysql-client
    Passwd for 'root' user: <password>
    ```
    
    #At the end we execute this command to give more security to our BD
    
    ```
    $ mysql_secure_installation
    ```
    
    #Check carefully the changes that will be made, the first question is the passwd for root,
    #IF you want to keep or change it, and continue with other security questions.
    
    ##Create a database and a user for the DB
    
    #Now we will create the DB that will be connected to DJango and a User with Passwd to access it.
    #There are two ways to do this:
    
    ```
    echo "CREATE DATABASE <DATABASENAME>;" | mysql -u root -p
    echo "CREATE USER '<DATABASEUSER>'@'localhost' IDENTIFIED BY '<PASSWORD>';" | mysql -u root -p
    echo "GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@'localhost';" | mysql -u root -p
    echo "FLUSH PRIVILEGES;" | mysql -u root -p
    ```
    
    #So they should put their passwd of mysql in each line or
    #they can also do it of the following way
    
    ```
    $ mysql -u root -p
    ```
    
    #Enter your passwd and then do the following.
    
    ```
    CREATE DATABASE <DATABASENAME>;
    CREATE USER '<DATABASEUSER>'@localhost IDENTIFIED BY '<PASSWORD>';
    GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@localhost;
    FLUSH PRIVILEGES;
    exit
    ```
    
    #We Check Dependencies
    #There are only a few dependencies but you have to be sure
    
    ```
    $ sudo apt-get install libmysqlclient-dev python-dev
    ```
    
    #So far it's all just proceed to install pip in our virtual environment or globally
    
    ```
    $ sudo -H pip install mysql-python
    ```
    
    #As you can see now you can create DB and Users for each Django Project
    
    

    public by cghersi modified Jul 30, 2012  8835  31  7  0

    MySQL SELECT statement from blob to string

    SELECT statement to translate a blob field into a readable string
    CREATE TABLE tbl (myBlob longblob);
    
    INSERT INTO tbl VALUES (0x1234);
    
    SELECT 	HEX(myBlob) AS PrintableBlob
    FROM	tbl;

    public by lbottaro modified Feb 26, 2014  1993  0  7  1

    Simple CORBA IDL interface

    This code shows an example of a IDL interface to be used in a simple Java Corba application. The IDL interface defines the contract between the client and server parts of your application, specifying what operations and attributes are available. Since OMG IDL is purely declarative language and programming-language independent, a mapping to J
    module HelloApp
    {
      interface Hello
      {
        string sayHello();
      };
    }; 
       

    public by msdn modified Jan 12, 2015  1132  0  6  0

    TranslateString: Uses the TranslatorContainer to translate inputString from sourceLanguage to targetLanguage.

    Uses the TranslatorContainer to translate inputString from sourceLanguage to targetLanguage. The TranslatorContainer to use The string to translate The Language Code to use in interpreting the input string. The Language Code to translate the input string to. The translated string, or null if no translation results were found.
    using System;
    using System.Linq;
    using System.Net;
    using Microsoft;
    using System.Text;
    
    /// <summary>
    /// Uses the TranslatorContainer to translate inputString from sourceLanguage
    /// to targetLanguage.
    /// </summary>
    /// <param name="tc">The TranslatorContainer to use</param>
    /// <param name="inputString">The string to translate</param>
    /// <param name="sourceLanguage">The Language Code to use in interpreting the input string.</param>
    /// <param name="targetLanguage">The Language Code to translate the input string to.</param>
    /// <returns>The translated string, or null if no translation results were found.</returns>
    private static Translation TranslateString(TranslatorContainer tc, string inputString, DetectedLanguage sourceLanguage, Language targetLanguage)
    {
        // Generate the query
        var translationQuery = tc.Translate(inputString, targetLanguage.Code, sourceLanguage.Code);
    
        // Call the query and get the results as a List
        var translationResults = translationQuery.Execute().ToList();
    
        // Verify there was a result
        if (translationResults.Count() <= 0)
        {
            return null;
        }
    
        // In case there were multiple results, pick the first one
        var translationResult = translationResults.First();
    
        return translationResult;
    }

    public by msdn modified Jan 10, 2015  1430  2  8  0

    Translate

    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Text;
    using System.Xaml;
    using System.Xml;
    using System.Xml.Linq;
    using Microsoft.Activities.Design.ExpressionTranslation;
    using Microsoft.Workflow.Client;
    
    public static XElement Translate(string xamlFile)
    {
        string translatedWorkflowString = null;
    
        using (XamlReader xamlReader = new XamlXmlReader(xamlFile))
        //using (XamlReader xamlReader = new XamlXmlReader(xamlFile)) // end of workaround
        {
            TranslationResults result = ExpressionTranslator.Translate(xamlReader);
            if (result.Errors.Count == 0)
            {
                StringBuilder sb = new StringBuilder();
                using (XmlWriter xmlWriter = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }))
                {
                    using (XamlXmlWriter writer = new XamlXmlWriter(xmlWriter, result.Output.SchemaContext))
                    {
                        XamlServices.Transform(result.Output, writer);
                    }
                }
                translatedWorkflowString = sb.ToString();
            }
            else
            {
                throw new InvalidOperationException("Translation errors");
            }
        }
    
        return XElement.Parse(translatedWorkflowString);
    }

    public by msdn modified Jan 12, 2015  753  7  5  0

    AddSyncByte: submit a sync job to translate array of bytes the input file will be converted to array of bytes and send to translation

    submit a sync job to translate array of bytes the input file will be converted to array of bytes and send to translation target langauge input file location (not on SharePoint) output file location (not on SharePoint) file extension of the input file
    using System;
    using System.Collections.ObjectModel;
    using System.Collections.Generic;
    using System.Globalization;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.Office.TranslationServices;
    using Microsoft.Office.TranslationServices.Parsing;
    using System.Management.Automation.Runspaces;
    using System.Threading;
    using System.IO;
    using System.Data.SqlClient;
    using System.Data;
    using System.Management.Automation;
    using System.Text;
    
    /// <summary>
    /// submit a sync job to translate array of bytes
    /// the input file will be converted to array of bytes and send to translation
    /// </summary>
    /// <param name="culture">target langauge</param>
    /// <param name="input">input file location (not on SharePoint)</param>
    /// <param name="output">output file location (not on SharePoint)</param>
    /// <param name="fileFormat">file extension of the input file</param>
    static void AddSyncByte(string culture, string input, string output, string fileFormat)
    {
        SyncTranslator job = createSyncTranslationJob(culture);
        Byte[] inputByte;
        Byte[] outputByte;
        inputByte = File.ReadAllBytes(input);
        outputByte = null;
        TranslationItemInfo itemInfo = job.Translate(inputByte, out outputByte, fileFormat);
        Console.WriteLine("Targetlang: {0}", job.TargetLanguage.Name);
        Console.WriteLine("OutputSaveBehavior: {0}", job.OutputSaveBehavior.ToString());
        PrintItemInfo(itemInfo);
        Console.WriteLine("Writing to output file");
        FileStream outputStream = File.Open(output, FileMode.Create);
        MemoryStream memoryStream = new MemoryStream(outputByte);
        memoryStream.WriteTo(outputStream);
        outputStream.Flush();
        outputStream.Close();        
    }

    public by msdn modified Jan 12, 2015  1204  0  6  0

    ConvertToDataServiceProject: Translate a <see cref="RCE.Infrastructure.Models.Project"/> into a <see cref="Project"/>.

    Translate a into a . The being translated. A .
    /// <summary>
    /// Constant used for the Title Uri.
    /// </summary>
    private const string Titles = "Titles";
    /// <summary>
    /// Constant used for Track Uri(Visual/Audio).
    /// </summary>
    private const string Tracks = "Tracks";
    
    /// <summary>
    /// Translate a <see cref="RCE.Infrastructure.Models.Project"/> into a <see cref="Project"/>.
    /// </summary>
    /// <param name="project">The <see cref="RCE.Infrastructure.Models.Project"/>being translated.</param>
    /// <returns>A <see cref="Project"/>.</returns>
    public static Project ConvertToDataServiceProject(RCE.Infrastructure.Models.Project project)
    {
        CreateIds(project);
    
        Project dataProject = null;
    
        if (project != null)
        {
            dataProject = new Project
                              {
                                  Id = project.ProviderUri,
                                  Title = project.Name,
                                  Creator = project.Creator,
                                  Created = project.Created,
                                  Modified = DateTime.Now,
                                  ModifiedBy = project.ModifiedBy,
                                  MediaBin = ConvertToDataServiceMediaBin(project.MediaBin),
                                  Resolution = project.Resolution,
                                  Duration = project.Duration,
                                  AutoSaveInterval = project.AutoSaveInterval,
                                  StartTimeCode = project.StartTimeCode.TotalSeconds,
                                  SmpteFrameRate = project.SmpteFrameRate.ToString(),
                                  RippleMode = project.RippleMode,
                                  ProjectThumbnail = project.ProjectThumbnail,
                                  Comments = new CommentCollection(),
                                  Sequences = new SequenceCollection(),
                                  Titles = new TitleCollection(),
                                  Metadata = project.Metadata,
                              };
    
            List<Comment> comments = ConvertToDataServiceComments(project.Comments);
    
            comments.ForEach(comment => dataProject.Comments.Add(comment));
    
            foreach (var timeline in project.Timelines)
            {
                var sequence = new RCE.Services.Contracts.Sequence
                                   {
                                       Id = timeline.Id,
                                       Name = timeline.Name,
                                       SequenceThumbnail = timeline.EncodedThumbnail
                                   };
                dataProject.Sequences.Add(sequence);
                List<Track> tracks = ConvertToDataServiceTracks(timeline.Tracks, dataProject.Comments);
                tracks.ForEach(track => sequence.Tracks.Add(track));
                timeline.AdOpportunities.ForEach(ao => sequence.AdOpportunities.Add(ao));
                timeline.Markers.ForEach(m => sequence.MarkerCollection.Add(m));
                timeline.CommentElements.ForEach(c => sequence.CommentsCollection.Add(ConvertToDataServiceComment(c)));
            }
        }
    
        return dataProject;
    }

    public by msdn modified Jan 12, 2015  1204  0  6  0

    ConvertToMediaBin: Translate a <see cref="Container"/> into a <see cref="RCE.Infrastructure.Models.MediaBin"/>.

    Translate a into a . The being translated. A .
    /// <summary>
    /// Constant used for the folder Container Uri.
    /// </summary>
    private const string Containers = "Containers";
    
    /// <summary>
    /// Translate a <see cref="Container"/> into a <see cref="RCE.Infrastructure.Models.MediaBin"/>.
    /// </summary>
    /// <param name="mediaBinContainer">The <see cref="Container"/>being translated.</param>
    /// <returns>A <see cref="RCE.Infrastructure.Models.MediaBin"/>.</returns>
    public static RCE.Infrastructure.Models.MediaBin ConvertToMediaBin(Container mediaBinContainer)
    {
        RCE.Infrastructure.Models.MediaBin mediaBin = new RCE.Infrastructure.Models.MediaBin();
    
        if (mediaBinContainer != null)
        {
            mediaBin.ProviderUri = mediaBinContainer.Id;
            mediaBin.Created = mediaBinContainer.Created;
            mediaBin.Creator = mediaBinContainer.Creator;
            mediaBin.Modified = mediaBinContainer.Modified;
            mediaBin.ModifiedBy = mediaBinContainer.ModifiedBy;
    
            // mediaBin.Title = mediaBinContainer.Title;
            // mediaBin.Description = mediaBinContainer.Description;
            if (mediaBinContainer.Items != null)
            {
                foreach (Item item in mediaBinContainer.Items)
                {
                    if (item != null)
                    {
                        var subClipItem = item as SubClipItem;
                        Asset asset;
                                
                        if (subClipItem != null)
                        {
                            asset = ConvertToVideoAssetInOut(subClipItem);
                        }
                        else
                        {
                            asset = ConvertToAsset(item);
                        }
    
                        if (asset != null)
                        {
                            mediaBin.Assets.Add(asset);
                        }
                    }
                }
            }
    
            if (mediaBinContainer.Containers != null)
            {
                foreach (Container container in mediaBinContainer.Containers)
                {
                    FolderAsset folderAsset = ConvertToFolderAsset(container);
                    IList<Asset> assets = ConvertToAssets(container);
    
                    foreach (Asset asset in assets)
                    {
                        folderAsset.Assets.Add(asset);
                    }
    
                    mediaBin.Assets.Add(folderAsset);
                }
            }
        }
    
        return mediaBin;
    }
    • Public Snippets
    • Channels Snippets