Thursday, 1 June 2017

translation using npm google-translate-api

I have used the google-translate-api npm package for the localization of the web page that is madeup with reactjs and nodejs.

But in here ,the translation is done by the given string only.As the main usage is to localize the whole page into several languages, I need to go through one by one of the texts in the web page.

But frankly, i don't know a better way to do it without slowing down the web page. Here are sample code lines that I need to translate.

module.exports.surveyJSON = {
clearInvisibleValues: true,
completeText: "Submit Assessment",
completedHtml: "<h1><strong>Processing</strong> your answers...</h1><br /><br /><br /><br /><br /><br /><br /><br />",
pages: [
    {
        name: "preQual",
        questions: [
            {
                type: "dropdown",
                choices: [
                    {
                        value: "managerial",
                        text:"Managerial e.g. middle management"
                    },
                    {
                        value: "strategic",
                        text: "Strategic e.g. executive position"
                    },
                    {
                        value: "operational",
                        text: "Operational e.g. frontline, backoffice, etc."
                    }
                ],
                isRequired: true,
                name: "companyRole",
                title: "What level is your role within your organization?"
            },
            {
                type: "checkbox",
                name: "taxonomyPersonalData",
                title: "Which of these types of information does your organization process?",
                choices: [
                    {
                        value: "personalCharacteristics",
                        text: "Personal Characteristics"
                    },
                    {
                        value: "personalFinancialData",
                        text: "Personal Financial Data"
                    },
                    {
                        value: "dataCreatedByPeople",
                        text: "Data created by people (Content)"
                    },
                    {
                        value: "identifierData",
                        text: "Identifier Data"
                    },
                    {
                        value: "location",
                        text: "Location"
                    },
                    {
                        value: "healthMedical",
                        text: "Health & Medical"
                    },
                    {
                        value: "relationships",
                        text: "Relationships"
                    },
                    {
                        value: "legal",
                        text: "Legal"
                    },
                    {
                        value: "education",
                        text: "Education"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "personalCharacteristicsOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'personalCharacteristics' ",
                title: "Personal Characteristics. Which of these sub-types of information does your organization process?",
                choices: [
                    {
                        value: "contactDetails",
                        text: "Contact Details"
                    },
                    {
                        value: "personalTemporalData",
                        text: "Personal Temporal Data"
                    },
                    {
                        value: "demographicDetails",
                        text: "Demographic Details"
                    },
                    {
                        value: "sensitiveDemographicDetails",
                        text: "Sensitive Demographic Details"
                    },
                    {
                        value: "employmentRelated",
                        text: "Employment Related"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "personalFinancialDataOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'personalFinancialData'",
                title: "Personal Financial Data. Which of these sub-types of information does your organization process?",
                choices: [
                    {
                        value: "financialTransactionsAndPayments",
                        text: "Financial Transactions and Payments"
                    },
                    {
                        value: "creditHistory",
                        text: "Credit History"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "dataCreatedByPeopleOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'dataCreatedByPeople'",
                title: "Data Created By People. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "contentCreatedByDataSubject",
                        text: "Content Created by Data Subject"
                    },
                    {
                        value: "contentFeaturingDataSubject",
                        text: "Content Featuring Data Subject"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "identifierDataOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'identifierData'",
                title: "Identifier Data. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "onlineIdentifiers",
                        text: "Online Identifiers"
                    },
                    {
                        value: "biometricIdentifiers",
                        text: "Biometric Identifiers"
                    },
                    {
                        value: "genetic",
                        text: "Genetic"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "locationOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'location'",
                title: "Location. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "geographicalEntity",
                        text: "Geographical Entity"
                    },
                    {
                        value: "placeOfInterest",
                        text: "Place of Interest"
                    },
                    {
                        value: "coordinate",
                        text: "Co-ordinate"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "healthMedicalOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'healthMedical'",
                title: "Health & Medical. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "physicalHealth",
                        text: "Physical Health"
                    },
                    {
                        value: "mentalHealth",
                        text: "Mental Health"
                    },
                    {
                        value: "employmentRelatedHealth",
                        text: "Employment Related"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "relationshipsOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'relationships'",
                title: "Relationships. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "familyRelationships",
                        text: "Family Relationships"
                    },
                    {
                        value: "socialRelationships",
                        text: "Social Relationships"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "legalOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'legal'",
                title: "Legal. Which of these sub-types of information does your organization process? ",
                choices: [
                    {
                        value: "legalStatus",
                        text: "Legal Status"
                    },
                    {
                        value: "criminalHistory",
                        text: "Criminal History"
                    },
                    {
                        value: "legalProceedings",
                        text: "Legal Proceedings"
                    },
                    {
                        value: "employmentRelatedLegal",
                        text: "Employment Related"
                    }
                ]
            },
            {
                type: "checkbox",
                name: "educationOptions",
                visible: false,
                visibleIf: "{taxonomyPersonalData} contains 'education'",
                title: "Education. Which of these sub-types of information does your organiation process? ",
                choices: [
                    {
                        value: "educationAttainment",
                        text: "Education Attainment"
                    },
                    {
                        value: "educationAbility",
                        text: "Education Ability"
                    }
                ]
            }
        ]
    }],
showPageNumbers: true,
showProgressBar: "",
};

Please help me with this.Thanks in advance.



via Kalanka

No comments:

Post a Comment