How to Setup App Domain on SharePoint Server 2016

To setup and configure APP Domain On SharePoint Server use below steps.

Open DNS Manager on Server

Find DNS and Open it

Select Forward Lookup Zone

Right Click on Forward Lookup Zone and Click on New Zone

It will start New Zone Wizard

Click on Next

Select Primary Zone

Click On Next

Select Second Option running all DNS server in this domain option

Click Next

Enter Zone Name

Click Next

Select Dynamic Update option Allow Only Secure Update

Click Next

Finish New Wizard.

Click on Finish

It will created newly assigned Forward Lookup Zone: sharepointapps.com

Right Click on sharepointapps.com and click on New Alias (CNAME)

Add New Resource Record

Here Add Alias Name “*” and set Fully Qualified Domain Name (FQDN) by browse file selection and select existing server (same as parent folder) option.

Click OK

Now Lookup Forward Zone is configured here.

Next Step is to Configure SharePoint Service: App Management Service Application

Navigate to SharePoint Central Administration

Click on Application Management -> Manage Service Applications

Create App Management Service

Click New and Select App Management Service

It will create App Management Service as shown in image

Once Application is created run below command to setup

Run the SharePoint 2016 Management Shell as an administrator

Start the SPAdminV4 and SPTimerV4 service applications


net start SPAdminV4
net start SPTimerV4

Also Set the domain used to host apps to the new zone created above


Set-SPAppDomain "sharepointapps.com"

Start the AppManagementServiceInstance and SPSubscriptionSettingsServiceInstance service instances:



Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance





Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"}


Create the SharePoint Subscription Service:

Note that I have used my server “SPS2012” here for SPManagedAccount you can use your own server.


$account = Get-SPManagedAccount "SPS2012"
$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
$appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
$appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName SettingsServiceDB
$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $appSubSvc
$appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName AppServiceDB
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc


Set the name for the site subscription:



Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false


Here App Domain Service for SharePoint is configured successfully.

Now you can use App Service for your developer site or any other site collection.

How to Allow JSON File Format on SharePoint 2016 on Premise

While working with SharePoint Framework Web Part I found that it requires JSON file to publish or add on CDN File address location on SharePoint Server.

SharePoint 2016 or any other on premises version by default block JSON file type. There are few other file types which are also blocked on SharePoint Server.

You may get its detail information on Microsoft Site.

https://support.office.com/en-us/article/Types-of-files-that-cannot-be-added-to-a-list-or-library-30BE234D-E551-4C2A-8DE8-F8546FFBF5B3#ID0EAABAAA=2016

To allow blocked file type on SharePoint Server follow below steps.

Navigate to: SharePoint Central Administration

Click on Manage Web Application

Select your desired site on which you want to allow JSON File.

From Ribbon Select or Click on Blocked File Types.

It will open Blocked File Types Modal Dialog Box.

Remove JSON extension from that list and press OK button.

After performing above steps, Now you can upload JSON file on SharePoint Server 2016.

How to remove NodeJS from Windows

Follow below steps to remove NodeJS from your PC/Windows.

Uninstall nodejs from Control Panel->Programs ->Uninstall a Program

Clear all temporary files from below locations:

• C:\Program Files (x86)\Nodejs
• C:\Program Files\Nodejs
• C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
• C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
• C:\Users\{User}\.npmrc (and possibly check for that without the . prefix too)
• C:\Users\{User}\AppData\Local\Temp\npm-*

Also remove if there is any other reference for node.js is available by running command


where node

If you found any other reference than remove it from that location.

Restart your PC once above operation or task is completed.

For more detail Reference URL: https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows

How to render separate HTML file with SPFX WebPart

SPFX WebParts gives us facility to write HTML content in Render() method. Many times if HTML file is large or for our own convenience we want or needs  to create separate HTML file.

To create HTML file we need to create .ts file with HTML content.To use created file we need to add its reference to WebPart file. Web Part file will render its HTML content in browser.

I have created SPFX Solution: SPDesignTest and added webpart SpCustomDesignSpfxWebPart

To add separate html file I created MyCustomHTML.ts file  and added content as shown in below image.

 

Once HTML file is ready we can access this file in SpCustomDesignSpfxWebPart.ts file by adding its references.

Added reference


/* Reference of MyCustomHTML HTML Content File  */
import objMyCustomHTML from './MyCustomHTML';

/* Load External Bootstrap CSS Reference */
import { SPComponentLoader } from '@microsoft/sp-loader';
SPComponentLoader.loadCss('https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css');

We need to provide its reference to SpCustomDesignSpfxWebPart.ts using variable as shown in below code


public render(): void {
    /* Load HTML From MyCustomHTML.ts file by using its variable templateHTML */
    this.domElement.innerHTML = objMyCustomHTML.templateHTML;
  }

Final SpCustomDesignSpfxWebPart.ts will look as per below image

Now when we run our SPFX Solution using gulp serve we are able to see HTMLas shown in below image

SPFX WebPart TS File Code :

MyCustomHTML.ts


import { escape } from '@microsoft/sp-lodash-subset';
import styles from './SpCustomDesignSpfxWebPart.module.scss';

export default class sample {

	public static templateHTML: string = 
	`
		<div class="container">
		<h2>Custom Form</h2>
		<p>Custom Form in SPFX using Bootstrap 4</p>
		<form>
		<div class="form-group">
			<label for="inputdefault">Name</label>
			<input class="form-control" id="inputdefault" type="text">
		</div>
		<div class="form-group">
			<label for="sel1">Country</label>
			<select class="form-control" id="sel1">
				<option>-Select-</option>
				<option>2</option>
				<option>3</option>
				<option>4</option>
			</select>
		</div>
		<div class="form-group">
			<button type="submit" class="btn btn-default">Submit</button>
		</div>
		</form>
	</div>

	`
	}


SpCustomDesignSpfxWebPart.ts

import { Version } from '@microsoft/sp-core-library';
import {
  BaseClientSideWebPart,
  IPropertyPaneConfiguration,
  PropertyPaneTextField
} from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';

import styles from './SpCustomDesignSpfxWebPart.module.scss';
import * as strings from 'SpCustomDesignSpfxWebPartStrings';

export interface ISpCustomDesignSpfxWebPartProps {
  description: string;
}

/* Reference of MyCustomHTML HTML Content File  */
import objMyCustomHTML from './MyCustomHTML';

/* Load External Bootstrap CSS Reference */
import { SPComponentLoader } from '@microsoft/sp-loader';
SPComponentLoader.loadCss('https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css');

export default class SpCustomDesignSpfxWebPart extends BaseClientSideWebPart<ISpCustomDesignSpfxWebPartProps> {

  public render(): void {
    /* Load HTML From MyCustomHTML.ts file by using its variable templateHTML */
    this.domElement.innerHTML = objMyCustomHTML.templateHTML;
  }

  protected get dataVersion(): Version {
    return Version.parse('1.0');
  }

  protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
    return {
      pages: [
        {
          header: {
            description: strings.PropertyPaneDescription
          },
          groups: [
            {
              groupName: strings.BasicGroupName,
              groupFields: [
                PropertyPaneTextField('description', {
                  label: strings.DescriptionFieldLabel
                })
              ]
            }
          ]
        }
      ]
    };
  }
}


Deploy SharePoint Framework -SPFX WebPart with CDN

While working with SPFX solution I found that we need CDN address for script and other configuration files to make SPFX web part run independently on SharePoint Site.

We can create CDN on SharePoint Site using PowerShell Scripts. Below scripts includes steps to create CDN on SharePoint Site as well as Deployment of SPFX using CDN.

Steps to Create CDN [Content Delivery Networks] Location On SharePoint Site:

Use SharePoint Online Management PowerShell to run commands or get CDN details for SharePoint Online Site.

I have created Document Library “CustomCDNFiles” which will work as CDN address for files


##Login to SharePoint Online Site 
##Make sute you select admin site . Note that url with admin site contains " -admin "
Connect-SPOService -Url https://nileshspsolutions-admin.sharepoint.com -Credential nilesh@nileshspsolutions.onmicrosoft.com

##Get your current tenant configuration
Get-SPOTenant | fl *cdn*

##Create Private CDN 
Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/Intranet/CustomCDNFiles

##Get Private CDN Value 
Get-SPOTenantCdnOrigins -CdnType Private

For demo purpose I have created Private CDN. You may also create Public CDN using below comands


##Login to SharePoint Online Site 
Connect-SPOService -Url https://nileshspsolutions-admin.sharepoint.com -Credential nilesh@nileshspsolutions.onmicrosoft.com

##Create Public CDN 
Add-SPOTenantCdnOrigin -CdnType Public  -OriginUrl sites/Intranet/CustomCDNFiles

##Get Private CDN Value 
Get-SPOTenantCdnOrigins -CdnType Public 

Above commands will set CDN location on SharePoint Site Location : https://nileshspsolutions.sharepoint.com/sites/Intranet/CustomCDNFiles

I will use this library to store files as CDN address files.

Now Next Task is to create SPFX WebPart. I have created SPFX Webpart and able to run this webpart using gulp serve command. To tun this webpart on SharePoint Site we need to also provices its configuration files on CDN so that it can access it.

Navigate to Config => write-manifests.json File in your SPFX WebPart Solution

Update “cdnBasePath” value using created CDN Value

Also note the location of deploy files from config => copy-assets.json

Here path deployCdnPath is the location where our SPFX files which needs to be migrtates avaiablei after deployment commands.

Above steps include configuration and deploypath location.Next turn is for actual deployment of SPFX

As we are deploying SPFX on Produciton or SharePoint Site we need to use below commnads to Ship SPFX.

SPFX Deployment Commands

gulp bundle --ship 

gulp bundle –ship : This executes a release build of your project by using a dynamic label as the host URL for your assets. This URL is automatically updated based on your tenant CDN settings.

gulp package-solution --ship

package-solution –ship :. This creates an updated sp-design-test.sppkg package on the sharepoint/solution folder.

After solution ship commnad we need to transfer configration fille from deploypath which is “temp/deploy”.

Open your solution folder and Navigate to “temp/deploy” location

Copy all files from deploy Folder to CDN Library . In my case https://nileshspsolutions.sharepoint.com/sites/Intranet/CustomCDNFiles/Forms/AllItems.aspx

Copied to Library

Next Navigate to SharePoint => solution Fodder Where actual SPFX WebPart Package file

Upload sp-design-test.sppkg to your App Catalog and add it into your website

After Upload and added to Page SPFX will run without any dependency to gulp serve or local files.

Please note that I have added HTML design in my SPFX Webpart which is shown in an Image. In your case it may be normal SPFX webpart.

C# Thread.Sleep Method With Console Foreground Text Color

We can change Console Text Color using Console.ForegroundColor propety.

Below code give an idea and usage of System.Thread in application.

 
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Application Execution Process Start");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Thread Process Start On " + DateTime.Now.ToString("ddMMyyyy  hh:mm:ss"));

            for (int i = 1; i < 6; i++)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("********************* Thread Sleep Start **********************");
                System.Threading.Thread.Sleep(5000);
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Sleeping for Item " + i.ToString() + " Thread is Exexuing on Inteval of 5 Seconds " + DateTime.Now.ToString("ddMMyyyy  hh:mm:ss"));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("********************* Thread Sleep End ************************");
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Thread Process End On " + DateTime.Now.ToString("ddMMyyyy  hh:mm:ss"));

            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Application Execution Process End");

            Console.Read();
        }
    }
}

Output:

How to Create File On Same Folder For Azure Web Application

Many times we need to create file of folder in web application to store log or other file related information.

The application which is hosted on Azure like Web Jobs or Application has to use different syntax to create file or folder in same or another directory.

Use below code to upload file or folder on Azure Web Application

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFiles
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("File Write Operation Start");

            /*Folder Name Which needs to be Crated on Azure */
            string FolderName = "MyapplicationLogs";

            /*File Name : Here For Demo Purpose to create multiple file I have added FileName in For Loop */
            string FileName;

            //File Content Which needs to be Added in text File
            string strLogText = "Log Information Found on " + DateTime.Now;

            //AZURE Application Root Folder Location + Folder Name Combination 
            //Here  Environment.GetEnvironmentVariable("HOME") gives is Azure Web Application Local Path
            //For e.g. Actial Path for File Creation on Azure will be : D:\home\site\wwwroot\DemoLogs\1Log.txt
            //where D:\home\site\wwwroot is Path for Azure Web Application
            string strFolderName = Environment.GetEnvironmentVariable("HOME") + @"\site\wwwroot\" + FolderName;

            //If the directory doesn't exist, create it.
            if (!Directory.Exists(strFolderName))
            {
                Directory.CreateDirectory(strFolderName);
            }

            for (int i=0;i<10;i++)
            {
                FileName = i + "Log.txt";

                string strLogFilePath = strFolderName.Trim() + @"\"+ FileName;

                //Once Directory Exists Create or Writre File 
                using (StreamWriter writer = new StreamWriter(strLogFilePath, true))
                {
                    writer.WriteLine(strLogText);
                }

                Console.WriteLine("File Created On Location " + strLogFilePath);
            }
            
            Console.WriteLine("File Write Operation End");
        }
    }
}

Azure WebJob To Create Azure File Share and File

Scenario: Client needs to upload files on daily basis as timer job to particular location (here Azure File Share). File contains auto generated name and individual content for each file. Below code includes example to create and upload file on Azure File Share and also Creation and configuration of Azure WebJob  to achieve requirement.

Steps :

  1. Create Console Application
  2. Configure Azure File Share Location
  3. Create or Configure Azure WebJob
  4. Deployment Of Console Application as Web Job
  5. Run Web Job and outcome of the application

Create New Project using Visual Studio

Select Console Application

Give your desired project name and location

It will create Console Application

Next Step is to add Azure Cloud Reference Files which is required to call Azure Objects in Code

Right Click on Project and Select Manage NuGet Packages

Installed Packages as shown in below image

Once above packages installed in application, you can see References in Solution Explorer as below

Add below code which Creates Azure File Object and Upload File on mentioned location

using Microsoft.WindowsAzure.Storage;
using System;
using System.Configuration;
using System.IO;
using System.Text;

namespace AzureFilesApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string strConnectionSting = ConfigurationManager.ConnectionStrings["AzureStorageAccount"].ConnectionString;

            Console.WriteLine(@"Connecting to Azure Storage Account");

            CloudStorageAccount sa = CloudStorageAccount.Parse(strConnectionSting);

            Console.WriteLine(@"Connected To Azure Storage Account");

            Console.WriteLine(@"Cheking Cloud Storage File Location");
            
            //Create Azure File Share   
            //this wull create File Service 'myfilesonazure' on Azure
            var share = sa.CreateCloudFileClient().GetShareReference("myfilesonazure");
            share.CreateIfNotExists();

            Console.WriteLine(@"Cloud Location Found On Azure");
            Console.WriteLine(@"Preparing Content For File");

            //Create Dyamicn File Name and File Content. 
            //Dynamic Content form Database or other Service will be availalbe here 
            string TempFileName = DateTime.Now.Second.ToString() + ".html";
            string content = @"<!DOCTYPE html><html><body><h2>HTML Forms</h2><form action='/action_page.php'>  First name:<br>  <input type='text' name='firstname' value='Nilesh'>  <br>  Last name:<br><input type='text' name='lastname' value='Rathod'><br><br>  <input type='submit' value='Submit'></form></body></html>";

            Console.WriteLine(@"File Content Completed");

            Console.WriteLine(@"Adding File On Cloud Location");

            //Create File in Root Folder and Upload its Content
            var rootDir = share.GetRootDirectoryReference();            
            var fileToCreate = rootDir.GetFileReference(TempFileName);
            fileToCreate.UploadText(content);

            Console.WriteLine(@"File Successfully Uploaded On Cloud Location");

        }

    }
}


Here console application is ready .Note that ‘AzureStorageAccount’ variable is connection string which is used in App.Config file which is connection string to your Azure Application

Code For App.Config File is as below

You can get your connection string from Azure Application

Navigate to Your Application and Select Access Key. It will display Connection String in another panel.

Once Console Application is ready you can run it and check its functionality to make sure that it is working with Azure File Share and provided Azure configuration.

If it works fine then next task is to schedule this console application as timer job or Web Job.

Meaning this Console Application needs to call on specific interval to generate file.
In this demo we are going to see 2 different scenarios to upload or publish solution on Azure.
1. Using Publishing Profile from Visual Studio
2. Manual Configuration of Web Job

Using Publishing Profile from Visual Studio

Using Visual Studio we can publish our console app as WebJob. It requires Publishing Profile of Azure to be downloaded and add into Visual Studio Publish Option.

To download Publishing Profile from Azure -> Navigate to your application and click on Get publish profile as shown in below Image.

Once you click on Get publish profile it will download Azure PublishSettings profile for Visual Studio which helps us to deploy application.

Right Click on Project and Select Publish As Azure WebJob and import downloaded profile to Visual Studio.

Import profile will automatically fetch all required information for Azure and Visual Studio and it will publish application.

Import the profile and click on Next it will display web Deploy Information.

Now Visual Studio is going to publish application on Azure. You can see its information in Visual Studio Output Configuration.

Once application is deployed on Azure we can see it from Azure WebJobs

Select that WebJob and Click on Run

It will execute WebJob. You can also check its Status from Status Column of the webjob.

Click on WebJob and You can get more detail information for the service

Click on WebJob Name you can get WebJob Run Details

Once WebJob is completed we can see generated file on Azure File Share.
Navigate to Azure File Share

Click on myfilesonazure File Share
You can see generated file on Azure File Share as below

Now we will see another method to add file on Azure
Manual Publishing from Visual Studio

Navigate to AzureFilesApp\AzureFilesApp\bin\Release
Select All Files from release folder and create Zip File of all files.

Navigate to WebJobs Click on Add. It will open popup as shown below.

Provide Name of Webjobs.In File Upload you need to select ZIP file which we created from release folder. Select WebJob Type . For Scheduled Trigger you need to provide CRON Expression.
For example below syntax is used for 2 min WebJob Time. Hence WebJob will trigger on every 2min

0 */2 * * * *

You can also Map your Azure File Share to your Local PC by running below script.

net use I: \\eradarsacronjob.file.core.windows.net\myfile
sonazure /u:AZURE\mycronjob 7BX9SSHn5HK8urK9KqfBP1sOsEDWyb7wBN3zJu6TFYE1v2
EMedCYlKwzs+MyuZdPZtamI71TxlKp/bIkCmDflg==

Mapped Folder will be available in your PC as shown below Image

From Mapped Folder you can easily upload or delete file to Azure File Share.

SharePoint Custom Form Language Translation with Multilingual Site

You may use below steps to achieve language translation for custom form which is used in SharePoint multilingual site.

Create List named as: Translations


Above list contains information of translation for different language. I have used language pack Hindi for
Language Code: 1081 for SharePoint Site.

Columns detail for Translation list:
Title: Label code text. You can compare text by Title column to assign value +
TextToDisplay : English Language Text
TextToDisplay2: Hindi Or Other Language Text

Assign Language Translation Value to form control as shown in below code

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.min.css">
    <link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/css/fabric.components.min.css">
    <script type="text/javascript" src="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-js/1.4.0/js/fabric.min.js"></script>
    <title>Responsive Test</title>
</head>

<body>
    <script type="text/javascript">
        $(document).ready(function () {
            LaunchResponsivePage();
            if (_spPageContextInfo.currentLanguage == 1033) {
                alert("User Selected Language :English == Language Code" + _spPageContextInfo.currentLanguage);
            } else {
                alert("User Selected Language : Hindi == Language Code" + _spPageContextInfo.currentLanguage);
            }
            /********************************GEt Value from Translation List and Set Value to Controls Code Start ****************************************/
            var listName = "Translations";
            var url = _spPageContextInfo.webAbsoluteUrl;
            var condition = "$select=Title,TextToDisplay,TextToDisplay2'";
            getListItems(listName, url, condition, function (data) {
                var items = data.d.results;
                for (var i = 0; i < items.length; i++) {
                        
                    	if (_spPageContextInfo.currentLanguage == 1033) 
						{						
							if (items[i].Title == "Name")	{ $('#lname').html(items[i].TextToDisplay);}
							if (items[i].Title == "City")	{ $('#lcity').html(items[i].TextToDisplay);}			 
							if (items[i].Title == "Choose a programming language")	{ $('#lchooseprogram').html(items[i].TextToDisplay);}			 
							if (items[i].Title == "Send me promotional emails from Microsoft")	{ $('#lpromotional').html(items[i].TextToDisplay);}			 
							if (items[i].Title == "Male")	{ $('#lmale').html(items[i].TextToDisplay);}			 
							if (items[i].Title == "Female")	{ $('#lfemale').html(items[i].TextToDisplay);}			 
						}
						else 
						{					
							if (items[i].Title == "Name")	{ $('#lname').html(items[i].TextToDisplay2);}
							if (items[i].Title == "City")	{ $('#lcity').html(items[i].TextToDisplay2);}			 
							if (items[i].Title == "Choose a programming language")	{ $('#lchooseprogram').html(items[i].TextToDisplay2);}			 
							if (items[i].Title == "Send me promotional emails from Microsoft")	{ $('#lpromotional').html(items[i].TextToDisplay2);}			 
							if (items[i].Title == "Male")	{ $('#lmale').html(items[i].TextToDisplay2);}			 
							if (items[i].Title == "Female")	{ $('#lfemale').html(items[i].TextToDisplay2);}			 
						}			

                }
            }, function (data) {
                alert("Ooops, an error occured. Please try again");
            });
            /********************************GEt Value from Translation List and Set Value to Controls Code End ****************************************/
        });
    </script>
    <div id="ResponsiveTestDiv">
        <div class="ms-Grid">
            <div class="ms-Grid-row">
                <div class="ms-Grid-col ms-u-sm12">
                    <div class="ms-fontSize-xl"> SharePoint Language Translation Form </div>
                </div>
            </div>
            <div class="ms-Grid-row">
                <div class="ms-Grid-col ms-u-sm12">
                    <div class="ms-TextField">
                        <label id="lname" class="ms-Label is-required">Name</label>
                        <input id="txtName" class="ms-TextField-field is-required" type="text" value="" placeholder=""> </div>
                </div>
            </div>
            <div class="ms-Grid-row">
                <div class="ms-Grid-col ms-u-sm12">
                    <div class="ms-TextField">
                        <label id="lcity" class="ms-Label">City</label>
                        <input id="txtCity" class="ms-TextField-field" type="text" value="" placeholder=""> </div>
                </div>
            </div>
            <div class="ms-Grid-row">
                <div class="ms-Grid-col ms-u-sm12">
                    <div class="ms-Dropdown" tabindex="0">
                        <label class="ms-Label" id="lchooseprogram">Choose a programming language</label>
                        <i class="ms-Dropdown-caretDown ms-Icon ms-Icon--ChevronDown"></i>
                        <select id="dropdownProg" class="ms-Dropdown-select">
                            <option>Choose a programming language</option>
                            <option>Javascript</option>
                            <option>C#</option>
                            <option>F#</option>
                            <option>Python</option>
                            <option>Other</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="ms-ChoiceFieldGroup" id="choicefieldgroup" role="radiogroup">
                <div class="ms-ChoiceFieldGroup-title">
                    <label class="ms-Label is-required" id="lgender">Gender</label>
                </div>
                <ul class="ms-ChoiceFieldGroup-list">
                    <li class="ms-RadioButton">
                        <input tabindex="-1" type="radio" class="ms-RadioButton-input">
                        <label role="radio" class="ms-RadioButton-field" tabindex="0" aria-checked="false" name="choicefieldgroup">
                            <span class="ms-Label">Option 1</span>
                        </label>
                    </li>
                    <li class="ms-RadioButton">
                        <input tabindex="-1" type="radio" class="ms-RadioButton-input">
                        <label role="radio" class="ms-RadioButton-field" tabindex="0" aria-checked="false" name="choicefieldgroup">
                            <span class="ms-Label">Option 2</span>
                        </label>
                    </li>
                </ul>
            </div>
            <div class="ms-CheckBox">
                <input tabindex="-1" type="checkbox" class="ms-CheckBox-input">
                <label role="checkbox" class="ms-CheckBox-field" tabindex="0" name="checkboxa">
                    <span class="ms-Label" id="lpromotional">Send me promotional emails from Microsoft</span>
                </label>
            </div>
            <div class="ms-Grid-row">
                <div class="ms-Grid-col ms-u-sm6">
                    <button type="button" id="buttonSave" class="ms-Button ms-Button--primary">
                        <span class="ms-Button-label">Save</span>
                    </button>
                    <button id="buttonCancel" type="button" class="ms-Button">
                        <span class="ms-Button-label">Cancel</span>
                    </button>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    function LaunchResponsivePage() {
        MakeResponsive();
        InitializeComponents();
        AddEventHandlers();
    }
    // READ operation  
    // listName: The name of the list you want to get items from  
    // siteurl: The url of the site that the list is in.  
    // success: The function to execute if the call is sucesfull  
    // failure: The function to execute if the call fails  
    function getListItems(listName, siteurl, condition, success, failure) {
        $.ajax({
            url: siteurl + "/_api/web/lists/getbytitle('" + listName + "')/items?" + condition,
            method: "GET",
            async: false,
            headers: {
                "Accept": "application/json; odata=verbose"
            },
            success: function (data) {
                success(data);
            },
            error: function (data) {
                failure(data);
            }
        });
    }
    function MakeResponsive() {
        $("#s4-ribbonrow").hide(); //hide the ribbon row
        $("#s4-workspace").children().hide(); //hide all elements in workspace
        var div = $("#ResponsiveTestDiv"); //move the div to make it visible
        $("#s4-workspace").append(div); //add the div after s4-workspace
    }

    function InitializeComponents() {
        var TextFieldElements = document.querySelectorAll(".ms-TextField");
        for (var i = 0; i < TextFieldElements.length; i++) {
            new fabric['TextField'](TextFieldElements[i]);
        }
        var ChoiceFieldGroupElements = document.querySelectorAll(".ms-ChoiceFieldGroup");
        for (var i = 0; i < ChoiceFieldGroupElements.length; i++) {
            new fabric['ChoiceFieldGroup'](ChoiceFieldGroupElements[i]);
        }
        var CheckBoxElements = document.querySelectorAll(".ms-CheckBox");
        for (var i = 0; i < CheckBoxElements.length; i++) {
            new fabric['CheckBox'](CheckBoxElements[i]);
        }
        var DropdownHTMLElements = document.querySelectorAll('.ms-Dropdown');
        for (var i = 0; i < DropdownHTMLElements.length; ++i) {
            var Dropdown = new fabric['Dropdown'](DropdownHTMLElements[i]);
        }
    }

    function AddEventHandlers() {
        $("#buttonSave").click(function () {
            var output = "Hello " + $("#txtName").val();
            alert(output);
            return false;
        });
        $("#buttonCancel").click(function () {
            alert("Cancelled");
            return false
        });
    }
</script>

</html>

Once we implement above code to form it will appear as below for Hindi and English language site.

Form in Hindi Language Site

Form in English Language Site